Repository navigation
Rule registry: add the plain type names findings carry (A5, second pass) - #1082
Conversation
The A5 registry had the coded ids (WF013, SD001, ...) but not the plain `type` names that most findings emit: `code_safety/js_exec_sync`, `content_patterns/http_in_docs`, `workflow_audit/missing_workflow`. SARIF ruleIds, .hypatia-baseline.json and .hypatia-ignore key on those, so a deviation against them did not resolve. The generator now also reads, from the code that cli.ex normalises: - code_safety: `id: :name` entries with a `pattern:` (95) - content_patterns: entries of @blocked_patterns with `applies_to:` (11) - honest_completion, green_web, root_hygiene, workflow_audit: `type: :name` atoms (workflow_audit also `rule: "name"` strings) - scorecard: the 20 check categories - seven fixed names, each guarded by the literal in the code that emits it (missing_requirement, banned_language_file, no_workflows_dir, inflated_completion, deprecated_api, secret_detected, SF001) A name that already has a row is skipped, so nothing existing changes: 234 to 429 rules, 195 added, none changed or removed. Tests: every rule_module/type pair of this repo's .hypatia-baseline.json and the 17 pairs A5 counts in the standards baseline resolve, with a negative control. Nine baseline names (inbox_automation IA001-IA007, workflow_audit inbox_steward_*) are in no code under lib/; the test lists them as stale and checks that claim against lib/. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7ZmHbN98VWzhw9EshkN
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
CI failed "Rule registry ... is stale" on #1082 although the deed matched locally. The CI runner's awk is gawk, this sandbox's is mawk. The script passed the block-start pattern '^ @blocked_patterns \[' through `-v`: mawk keeps the backslash, gawk turns `\[` into `[`, an invalid regex, and the awk dies inside a process substitution with no error in the script. All 11 content_patterns rows vanished from CI's generation, so the check saw a stale deed. - The pattern is now '^ @blocked_patterns [[]' (no backslash). Run under gawk 5.2.1 and mawk 1.3.4, the output is byte-identical to the committed deed, with no stderr. - tests/rules-praxis-test.sh now runs the generator under every awk it finds (gawk, mawk, original-awk) and requires the committed bytes and an empty stderr. With the bug put back, it fails under gawk and passes under mawk, which is the CI situation. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7ZmHbN98VWzhw9EshkN
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98f3c76c70
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { echo "gen-rules-praxis: cli.ex no longer defaults content_patterns severity to medium; update the generator" >&2; exit 1; } | ||
| while IFS=$'\037' read -r name sev txt; do | ||
| emit_name content_patterns "$name" "${sev:-medium}" "$txt" | ||
| done < <(entries lib/rules/cicd_rules.ex 'applies_to:' '^ @blocked_patterns \[') |
There was a problem hiding this comment.
Escape the block-start regex across awk -v
In the repository's GNU awk environment, bash tests/rules-praxis-test.sh fails here with escape sequence '\[' treated as plain '[' followed by fatal: invalid regexp ... /^ @blocked_patterns [/, because -v consumes the backslash before bstart is used as a regex. The extractor therefore emits none of the 11 content-pattern rows; --check reports the committed deed as stale, while normal generation can silently succeed with those rows removed because the process-substitution failure is not propagated. Pass a pattern whose literal bracket survives -v, or avoid a dynamic regex for this marker.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, and already fixed in 7ccdfb5, which this review predates (it reviewed 98f3c76). The pattern now passes no backslash through -v ([[]). The test also runs the generator under every awk it finds (gawk and mawk) and requires the committed bytes and an empty error output. A second fix, 5208b60, removed three head -1 pipes that printed Broken pipe when the runner ignores SIGPIPE.
Generated by Claude Code
| :status active) | ||
| ;; defaulted: text class excusable-at scope-form | ||
| (rule-def | ||
| :id "hypatia/workflow_audit/always_after_cancel" |
There was a problem hiding this comment.
Honor rule_id module overrides when registering types
When WF029 emits always_after_cancel, lib/rules/workflow_audit.ex:4551-4552 supplies rule_id: "hypatia/ci_failure_triage/always_after_cancel", and the normalizer in lib/hypatia/cli.ex:571-574 explicitly replaces both the module and type from that value. Consequently this newly registered workflow_audit/always_after_cancel ID is never emitted (the correct ci_failure_triage row already exists), so the registry now canonizes a nonexistent rule; the type-name extraction should account for A5 rule_id overrides rather than always assigning the source module.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in the next commit. WF029 declares rule_id: "hypatia/ci_failure_triage/always_after_cancel", and cli.ex moves both module and type to that value, so workflow_audit/always_after_cancel is never emitted. The generator now skips a name that a rule_id override moves to another module, and the row is dropped. The ci_failure_triage row is the real one. The row came from this unmerged PR, so no merged id is deleted. A test checks that the name is registered under ci_failure_triage only.
Generated by Claude Code
| # Fixed names, each proved by a literal in the code that emits it. | ||
| while IFS=$'\t' read -r mod name f lit text; do | ||
| grep -qF -- "$lit" "$f" || { echo "gen-rules-praxis: $f no longer has '$lit' ($mod/$name)" >&2; exit 1; } | ||
| emit_name "$mod" "$name" "" "$text" |
There was a problem hiding this comment.
Propagate metadata for fixed-name rows
Every entry in the fixed-name table is emitted with an empty severity and without an advisory argument, even when the guarded emitting code states those fields. As a result, missing_requirement, no_workflows_dir, and inflated_completion lose their hard-coded high severity, banned_language_file loses its current critical severity, and structured_format/SF001 is registered as a severity-less gate despite its finding declaring severity: "medium", advisory: true in lib/rules/structured_format.ex:33-34. Pass or extract the fixed rows' metadata so the registry does not change their stated gate semantics.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in the next commit. The fixed names now carry the metadata the code states: missing_requirement, no_workflows_dir and inflated_completion are high; banned_language_file is critical (all three banned extensions are); deprecated_api is high; secret_detected is critical; SF001 is medium and :class advisory, as its finding declares. Each value is proved by the code: beside the emitting literal, or in the named file. The generator refuses to run if a proof goes away. A test checks SF001 and banned_language_file.
Generated by Claude Code
| emit_name content_patterns "$name" "${sev:-medium}" "$txt" | ||
| done < <(entries lib/rules/cicd_rules.ex 'applies_to:' '^ @blocked_patterns \[') | ||
|
|
||
| for m in honest_completion green_web root_hygiene workflow_audit; do |
There was a problem hiding this comment.
Register plain names from every emitting module
This module list is not exhaustive for CLI-emitted types: run_opt_in(:audit_prevention) normalizes f.rule and can emit 15 lowercase names such as audit_prevention/parser_input_limits (lib/hypatia/cli.ex:1254-1261), workflow hardening can emit workflow_hardening/invalid_actions_lock (lib/hypatia/cli.ex:802-807), and the implementation-inside-canon evaluator emits the hard-coded type implementation_inside_canon/HYP-S009. None of those IDs exists in the generated deed, so SARIF, baselines, and deviations for those actual scan findings still cannot resolve despite this pass; extraction and its coverage test need to include every normalizer rather than only these four modules.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Two of the three are real and fixed in the next commit: workflow_hardening/invalid_actions_lock and implementation_inside_canon/HYP-S009 are now registered. The third is not a gap. For audit_prevention the finding sets rule: record.id (AP001 to AP015) and type: record.rule (parser_input_limits and the other lowercase names), and cli.ex:1254-1261 emits type: f.rule, which is record.id. So the emitted names are the AP codes, which the registry already had, and the lowercase names are never emitted. I also added a test that every literal rule_module/type pair in cli.ex and the rule files is in the registry, with a control that names a missing pair.
Generated by Claude Code
The awk-portability test added in 7ccdfb5 failed in CI under both gawk and mawk, printing "sed: couldn't flush stdout: Broken pipe". The registry bytes were right; the stderr was not empty. Cause: three `| head -1` pipes. head exits after one line, and a writer upstream then hits a closed pipe. With SIGPIPE at its default the writer dies silently (my machine). A step on the CI runner starts with SIGPIPE ignored, so the writer prints "Broken pipe" instead. Run that way here the generator printed 110 such messages. - The three `head -1` become `sed -n 1p`, which reads all its input. With SIGPIPE ignored the generator prints nothing, and its output is unchanged. - The portability test now runs the generator with SIGPIPE ignored, so the failure shows on a dev machine. With one `head -1` put back, it fails under both awks with the same message as CI; with the fix it passes. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7ZmHbN98VWzhw9EshkN
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
…errides Review findings on #1082, checked against the code: - The fixed names were registered with no severity and as gates. The code states: missing_requirement, no_workflows_dir, inflated_completion high; banned_language_file critical (all three banned extensions); deprecated_api high; secret_detected critical; SF001 medium and advisory. Each is now read from a table whose severity is proved by the code (beside the emitting literal, or in the named file); the generator refuses to run if a proof goes away. - Two emitted names were missing: workflow_hardening/invalid_actions_lock and implementation_inside_canon/HYP-S009. - workflow_audit/always_after_cancel is never emitted: WF029 declares rule_id hypatia/ci_failure_triage/always_after_cancel and cli.ex moves it there. A name moved off a module by a rule_id override is no longer registered under the source module. The row is dropped (this PR is unmerged, so no merged id is deleted). - Not changed, on the evidence: audit_prevention emits f.rule, which is record.id (AP001..AP015), not the lowercase record.rule. Those rows were already right. 430 rules (one net row added, six rows gain a severity, one becomes advisory). New tests: every literal rule_module/type pair in cli.ex and the rule files is in the registry (with a control that names the missing pair); the override name is under its real module only; the fixed rows carry the stated metadata. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7ZmHbN98VWzhw9EshkN
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
…ASE-043 main gained WF031 (#1076) and ci_failure_triage/github_state_unreadable (#1077). Their own regenerations merged into this branch's deed cleanly, but WF031's plain type name (workflow_audit/gitleaks_full_history_on_pr) is a row this PR adds, so the deed was stale and the "Rule registry" check would fail. Regenerated with scripts/gen-rules-praxis.sh: 433 rules, one row added, none changed or removed, no duplicate id. The tests pass under gawk and mawk. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7ZmHbN98VWzhw9EshkN
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5cf03bd70
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| # Scorecard: one type per check category. | ||
| for name in $({ grep -ohE 'category: "[A-Za-z]+"' lib/scorecard_ingestor.ex | sed 's/.*: "//; s/"$//'; } | sort -u); do | ||
| emit_name scorecard "$name" "" "OpenSSF Scorecard check category $name." |
There was a problem hiding this comment.
Propagate Scorecard severities into generated rows
Pass each check's declared risk instead of an empty severity here. make_pattern/4 turns the @scorecard_checks risk into the runtime finding severity, so local findings such as scorecard/TokenPermissions are high and scorecard/DependencyPinning is medium, but every newly generated Scorecard rule-def omits :severity; registry consumers therefore lose the severity that the emitted finding actually carries.
Useful? React with 👍 / 👎.
| for m in honest_completion green_web root_hygiene; do | ||
| emit_found "$m" "$(atoms lib/rules/$m.ex)" |
There was a problem hiding this comment.
Preserve aggregate root-hygiene severities
Handle root_hygiene separately rather than relying on near() at the type: site. These findings copy severity through rule.severity or req.severity, while the literals live in @banned_root_files, @stale_patterns, and the required-file table, so the generated banned, stale, and missing rows all omit :severity; for example, a missing license and several banned-root findings are critical, and this generator otherwise records the highest declared severity for multi-severity rule IDs.
Useful? React with 👍 / 👎.
| for m in honest_completion green_web root_hygiene; do | ||
| emit_found "$m" "$(atoms lib/rules/$m.ex)" | ||
| done | ||
| emit_found workflow_audit "$(atoms lib/rules/workflow_audit.ex)" "$(strs lib/rules/workflow_audit.ex)" |
There was a problem hiding this comment.
Preserve the missing-workflow severity
Teach this extraction path about severity_for_workflow/1 rather than leaving workflow_audit/missing_workflow severity-less. The finding stores severity: severity_for_workflow(wf), whose static cases range up to critical for a missing hypatia-scan.yml, but near() only recognizes one-line severity helpers and therefore emits no :severity for this newly registered type; this loses the highest declared severity that the generator deliberately preserves for other multi-severity rules.
Useful? React with 👍 / 👎.



What
Follow-up to #1070. The A5 registry had the coded ids (
WF013,SD001,PA001) but not the plaintypenames that most findings carry, for examplecode_safety/js_exec_syncandworkflow_audit/missing_workflow. SARIF ruleIds,.hypatia-baseline.jsonand.hypatia-ignorekey on those names. A deviation against them did not resolve.This PR adds them. It is additive: 236 to 433 rules (main's current count), 197 added, none changed, none removed. No rule code changes and no emitted id changes.
workflow_auditis the reason the coded ids were not enough.cli.exemitsMap.get(f, :type) || Map.get(f, :rule), so a finding that carries both (for exampleWF013andnpermissions_typo) is emitted under the type. Both names are now registered. A finding that declares arule_idof the formhypatia/<module>/<name>is emitted under that module (WF029 isci_failure_triage/always_after_cancel), so the generator does not register that name under the source module.Where each name comes from
The generator reads the code that
lib/hypatia/cli.exturns intotype:code_safetyid: :nameentries with apattern:incode_safety.excontent_patterns@blocked_patternsentries withapplies_to:incicd_rules.exworkflow_audittype: :nameatoms andrule: "name"stringshonest_completiontype: :nameatomsgreen_webtype: :nameatomsroot_hygienetype: :nameatomsscorecardcategory:of each of the 20 checksworkflow_hardeningrule: "invalid_actions_lock"cicd_rules/missing_requirement,cicd_rules/banned_language_file,migration_rules/deprecated_api,security_errors/secret_detected,structured_format/SF001,implementation_inside_canon/HYP-S009(plusno_workflows_dirandinflated_completion, counted above)Each fixed name is proved by a literal in the code that emits it, and so is the severity the code states for it (beside the literal, or in the named file). The generator refuses to run if a proof goes away. A name that already has a row is skipped.
audit_preventionneeds no new rows: its finding setsrule: record.id(AP001toAP015), andcli.exemits that, not the lowercaserecord.rule.Tests
tests/rules-praxis-test.sh: 23 passed, 0 failed, under both gawk and mawk. The checks that matter here:rule_module/typepair in this repo's.hypatia-baseline.jsonplus the 17 pairs A5 counts in the standards baseline. A planted control shows a missing pair is caught.rule_module/typepair incli.exand the rule files is in the registry, with a control that names the missing pair.\[in an awk-vvalue, andhead -1pipes); this test now catches both on a dev machine.lib/mentions them:inbox_automation/IA001toIA007andworkflow_audit/inbox_steward_intake_missingandinbox_steward_missing. The test lists them as stale and checks that claim againstlib/. For the owner: those baseline entries suppress nothing in this tree and could be removed, or the rules that emitted them are on another branch.deed_lint.js(standardsbfdb066) accepts the deed.scripts/check-readme-claims.shpasses.Defaulted fields, for owner review
Every defaulted row carries a
;; defaulted:comment. Of the 197 new rows::excusable-at repoand:scope-form exact-paths: all 197 (A5 G3 and 4.1 defaults).:class gate: 193.:class advisory: 4, because the code says so (structured_format/SF001,known_broken_reusable_revision,reusable_call_to_moved_repository,sha_pinned_toolchain_without_input).:textis a placeholder ("<id> in lib/rules/<module>.ex.") on 62 rows, because the code gives no one-line text:workflow_audit42,green_web8,honest_completion8,root_hygiene3,workflow_hardening1. The other 135 texts come from adescription:orreason:in the code.:severityis omitted on 24 rows where the code states none: the 20scorecardrows (the level comes from the scan),root_hygiene3 andworkflow_audit1. Content patterns state none, so they take themediumdefault thatcli.exstates.Two judgement points for the owner:
green_webconfirmations.green_hosting_confirmed,green_badge_present,green_registry_confirmedanddomain_green_check_neededare severityinfoand read like confirmations, not violations. I left them:class gate, because the code does not say "advisory". The owner may want them advisory.root_hygiene. The names are generic (banned,missing,stale) because that is what the code emits.What this does not cover
cli.expair tests are where a gap would show.Next
Whichever PR merges next and adds a type to one of these files must run
scripts/gen-rules-praxis.shand commit the deed, or the "Rule registry" step fails as stale. I told the Extended Hypatia session before opening this. This PR already had to be regenerated once aftermaingained WF031 andgithub_state_unreadable.🤖 Generated with Claude Code
https://claude.ai/code/session_0136P7ZmHbN98VWzhw9EshkN