|
| 1 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +# Hypatia Scorecard Rules — CI/CD security posture checks |
| 3 | +# |
| 4 | +# These rules teach Hypatia to monitor and enforce OpenSSF Scorecard |
| 5 | +# compliance across the BoJ server and any repo that includes them. |
| 6 | +# |
| 7 | +# Rule severity aligns with Scorecard alert levels. |
| 8 | + |
| 9 | +rules: |
| 10 | + # --- HIGH severity (Scorecard High) --- |
| 11 | + |
| 12 | + branch-protection: |
| 13 | + severity: high |
| 14 | + description: "Main branch must require PR reviews and dismiss stale approvals" |
| 15 | + checks: |
| 16 | + - required_approving_review_count >= 1 |
| 17 | + - dismiss_stale_reviews == true |
| 18 | + - require_code_owner_reviews == true |
| 19 | + - enforce_admins == true |
| 20 | + remediation: | |
| 21 | + gh api repos/{owner}/{repo}/branches/main/protection/required_pull_request_reviews \ |
| 22 | + -X PATCH --input - <<< '{"required_approving_review_count":1,"require_code_owner_reviews":true,"dismiss_stale_reviews":true}' |
| 23 | +
|
| 24 | + code-review: |
| 25 | + severity: high |
| 26 | + description: "All changes to main must go through reviewed pull requests" |
| 27 | + checks: |
| 28 | + - no_direct_pushes_to_main |
| 29 | + - all_merged_prs_have_approvals |
| 30 | + remediation: "Enable branch protection with required reviews (see branch-protection rule)" |
| 31 | + |
| 32 | + maintained: |
| 33 | + severity: high |
| 34 | + description: "Repository must show recent activity (commits within 90 days)" |
| 35 | + checks: |
| 36 | + - last_commit_age_days <= 90 |
| 37 | + - open_issues_responded_within_days <= 14 |
| 38 | + remediation: "Ensure regular commits and issue triage" |
| 39 | + |
| 40 | + # --- MEDIUM severity --- |
| 41 | + |
| 42 | + fuzzing: |
| 43 | + severity: medium |
| 44 | + description: "Repository must have fuzz testing (ClusterFuzzLite, OSS-Fuzz, or custom)" |
| 45 | + checks: |
| 46 | + - workflow_exists: fuzz.yml |
| 47 | + - fuzz_targets_exist: true |
| 48 | + remediation: "Add .github/workflows/fuzz.yml with fuzz test targets" |
| 49 | + |
| 50 | + pinned-dependencies: |
| 51 | + severity: medium |
| 52 | + description: "All GitHub Actions must use SHA-pinned references, not tag refs" |
| 53 | + checks: |
| 54 | + - no_tag_refs_in_workflows |
| 55 | + pattern: 'uses:\s+[\w-]+/[\w-]+@v\d' |
| 56 | + remediation: "Replace @v* tags with @SHA pins. Use: gh api repos/{owner}/{action}/git/refs/tags/{tag} to get SHA" |
| 57 | + |
| 58 | + # --- LOW severity --- |
| 59 | + |
| 60 | + cii-best-practices: |
| 61 | + severity: low |
| 62 | + description: "Repository should be registered at bestpractices.coreinfrastructure.org" |
| 63 | + checks: |
| 64 | + - badge_url_in_readme: true |
| 65 | + remediation: "Register at https://www.bestpractices.dev/en and add badge to README" |
| 66 | + |
| 67 | + security-policy: |
| 68 | + severity: medium |
| 69 | + description: "SECURITY.md must exist (root, .github/, or docs/)" |
| 70 | + checks: |
| 71 | + - file_exists_any: |
| 72 | + - SECURITY.md |
| 73 | + - .github/SECURITY.md |
| 74 | + - docs/SECURITY.md |
| 75 | + remediation: "Add SECURITY.md with vulnerability reporting instructions" |
| 76 | + |
| 77 | + # --- Workflow-specific rules --- |
| 78 | + |
| 79 | + action-sha-pinning: |
| 80 | + severity: high |
| 81 | + description: "Every 'uses:' line in workflows must reference a full 40-char SHA" |
| 82 | + scan_paths: |
| 83 | + - .github/workflows/*.yml |
| 84 | + pattern: 'uses:\s+[\w-]+/[\w-]+@(?![0-9a-f]{40})' |
| 85 | + exclude_pattern: 'uses:\s+\./|uses:\s+docker://' |
| 86 | + remediation: "Pin to SHA: uses: owner/action@FULL_SHA # vX.Y.Z" |
| 87 | + |
| 88 | + workflow-permissions: |
| 89 | + severity: high |
| 90 | + description: "Every workflow must declare top-level 'permissions:' (prefer read-all)" |
| 91 | + scan_paths: |
| 92 | + - .github/workflows/*.yml |
| 93 | + checks: |
| 94 | + - top_level_permissions_declared |
| 95 | + remediation: "Add 'permissions: read-all' at workflow level, then grant per-job" |
| 96 | + |
| 97 | + spdx-headers: |
| 98 | + severity: low |
| 99 | + description: "Every workflow must have an SPDX license header" |
| 100 | + scan_paths: |
| 101 | + - .github/workflows/*.yml |
| 102 | + pattern: '^# SPDX-License-Identifier:' |
| 103 | + remediation: "Add '# SPDX-License-Identifier: PMPL-1.0-or-later' as first line" |
0 commit comments