Repository navigation
feat(rules): ResearchExtensions (RE001-RE010) — 10 rules from Snyk/StepSecurity/Endor/academic literature - #325
Merged
Conversation
…epSecurity/Endor/academic literature New Hypatia.Rules.ResearchExtensions module captures GitHub Actions workflow defects sourced from commercial CI/CD security tools (Snyk, StepSecurity, Endor Labs, Datadog CI Visibility) and recent academic literature. Complementary to WorkflowHardening (OSS actionlint/zizmor cluster, PR #321) and BaselineHealth (drift, PR #320). Rule inventory: | ID | Detects | Severity | Provenance | |---|---|---|---| | RE001 | Workflow with secrets access lacks step-security/harden-runner | warn | StepSecurity | | RE002 | Harden-Runner in egress-policy: audit on protected-branch workflow | high | StepSecurity | | RE003 | actions/cache key interpolates github.head_ref / PR title | high | Snyk dataflow | | RE004 | Container action pinned by tag, not digest | warn | Snyk container scan | | RE005 | Test step swallows non-zero exit | warn | Datadog CI | | RE006 | Composite action calls third-party uses: it doesn't SHA-pin | warn | Endor R-END-05 | | RE007 | Top-level env: contains secrets reference | warn | Endor R-END-01 | | RE008 | Bot identity check via spoofable github.actor | critical | zizmor + Koishybayev 2022 | | RE009 | fromJSON(secrets.X) bypasses runner-side redaction | critical | zizmor unredacted-secrets | | RE010 | workflow_run consumes artifacts without provenance verification | warn | EuroS&P 2023 | Module + tests mirror WorkflowHardening shape: scan/2 facade returning %{findings, total, by_severity, dispatch}; helpers workflow_files/1, composite_action_files/1, line_number_for_offset/2, group_by_severity/1, dispatch_recommendations/1. All findings routed to :sustainabot at confidence calibrated by severity (critical -> 0.92, high -> 0.85, warn -> 0.75, info -> 0.60). Pure-local file scans; no GitHub API. Test file: test/research_extensions_test.exs -- 27 tests covering positive + negative cases per rule plus three scan/1 facade tests. Module size: ~900 lines. No refactor to existing modules.
🔍 Hypatia Security ScanFindings: 103 issues detected
View findings[
{
"reason": "Docker reference in Nickel config -- Podman/Containerfile highly preferred (Docker permitted) (1 occurrences, CWE-1104)",
"type": "ncl_docker_not_podman",
"file": "/home/runner/work/hypatia/hypatia/.machine_readable/svc/k9/hypatia-metadata.k9.ncl",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/batch.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/batch.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/scan.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/scan.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/fleet.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/output.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/build.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (3 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/fixer/src/main.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (5 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/fixer/src/scanner.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
🔍 Hypatia Security ScanFindings: 104 issues detected
View findings[
{
"reason": "Docker reference in Nickel config -- Podman/Containerfile highly preferred (Docker permitted) (1 occurrences, CWE-1104)",
"type": "ncl_docker_not_podman",
"file": "/home/runner/work/hypatia/hypatia/.machine_readable/svc/k9/hypatia-metadata.k9.ncl",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/batch.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/batch.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/scan.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/scan.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/fleet.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/src/output.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (2 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/cli/build.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap() without prior check -- DoS via panic (3 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/hypatia/hypatia/fixer/src/main.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (5 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/fixer/src/scanner.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
🔍 Hypatia Security ScanFindings: 105 issues detected
View findings[
{
"reason": "expect() in hot path (2 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/batch.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/scan.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (1 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/scan.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (2 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/cli/src/commands/fleet.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (2 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/cli/src/output.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (2 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/cli/build.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (2 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/fixer/src/main.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "expect() in hot path (1 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/hypatia/hypatia/integration/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "low"
},
{
"reason": "1 untracked file(s) -- review and add or .gitignore",
"type": "GS001",
"file": ".",
"action": "review",
"rule_module": "git_state",
"severity": "low"
},
{
"reason": "Repository has 3 non-main remote branch(es). Policy: single main branch only.",
"type": "GS007",
"file": ".",
"action": "delete_remote_branches",
"rule_module": "git_state",
"severity": "medium"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
hyperpolymath
added a commit
that referenced
this pull request
May 26, 2026
## Summary Adds delegates on \`Hypatia.Rules\` for the rule families landed in PRs #320, #321, #322, #323. The new modules were independently usable but invisible from the top-level facade; this PR closes that gap. ## New facade surface | Function | Delegates to | Rules | |---|---|---| | \`scan_baseline_health/2\` | \`BaselineHealth.scan\` (existing; docstring updated for BH007) | BH001-BH007 | | \`scan_workflow_hardening/2\` | \`WorkflowHardening.scan\` | WH001-WH012 | | \`scan_supply_chain/2\` | \`SupplyChain.scan\` | SC001-SC011 | | \`scan_branch_protection/2\` | \`BranchProtection.scan\` (API-backed; takes \`owner, repo\`) | BP001-BP007 | | \`scan_all_estate_policies/2\` | — runs all four families and merges results | 34 rules total | ## Why combined-scan helper Callers (\`pattern_analyzer\`, \`triangle_router\`, \`fleet_dispatcher\`) already treat \`Hypatia.Rules\` as the entrypoint. Without these delegates the new modules are reachable only via fully-qualified names, which works but inverts the facade pattern adopted in #316. ## RE001-RE010 (PR #325) not included PR #325 (ResearchExtensions) is still OPEN at the time of this PR. Adding its alias here would break compilation on \`main\` for the window between this PR landing and #325 landing. A follow-up commit will wire \`ResearchExtensions\` once #325 merges — tracked inline at the alias block as a \`# wired in follow-up\` comment. ## Test plan - Existing 18-test \`BaselineHealth\` suite still passes (untouched). - Module compile-checks pass for the four families + facade. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
hyperpolymath
added a commit
that referenced
this pull request
Sep 10, 2026
…#763) RE001-RE010 merged in PR #325 on 2026-05-26 with 27 passing tests and no caller anywhere in lib/. rules.ex:32 still carried # alias Hypatia.Rules.ResearchExtensions # wired in follow-up after PR #325 merges and rules.ex:690 a matching "delegate added in follow-up once PR #325 lands on main". That precondition was met 105 days ago. Ten working security rules had never run against a repository. This is the connection, not new rules. Four wiring points: rules.ex:31 uncomment the alias rules.ex:706 @doc + defdelegate scan_research_extensions/2 rules.ex:729 add to scan_all_estate_policies/2's parts list cli.ex:48 :research_extensions in @all_rule_modules, plus a normalization branch in collect_findings/2 Only the cli.ex path executes today: scan_all_estate_policies/2 has no caller in lib/ or test/, and its four sibling families (BaselineHealth, WorkflowHardening, SupplyChain, BranchProtection) appear nowhere in cli.ex. Adding RE to the facade alone would have reproduced the exact defect this commit fixes. Both surfaces are wired. Two seam defects had to be fixed or the wiring would have been cosmetic. 1. The :warn tier was discarded after the rules ran. Six of the ten RE rules emit `severity: :warn`. "warn" was absent from cli.ex's @severity_order, so `Map.get(@severity_order, "warn", 5)` gave it rank 5, and the filter `rank <= threshold` at the default `--severity medium` (3) dropped every one of them. Measured on this repository: 22 of 23 findings are warn-tier, so 96% of the new output would have evaporated one function after being computed. "warn" is now ranked with medium, and SARIF maps it to the "warning" level rather than the "note" catch-all. This also un-drops workflow_audit's one warn finding, which had the same fate. 2. :line was dropped at the normalization seam. RE004, RE005 and RE008 compute real line numbers but nest them under `:detail`, so a plain `Map.get(f, :line)` returns nil and SARIF falls back to startLine 1. The branch reads `get_in(f, [:detail, :line]) || Map.get(f, :line)`, which tolerates the seven rules that carry no line at all. Gates, all re-run after rebasing onto 0e91342: mix compile --force rc=0, 0 warnings tree-wide, 0 attributable to cli.ex, sarif.ex or rules/rules.ex mix test research_extensions_test 27 tests, 0 failures (unchanged) mix test (new wiring test) 8 tests, 0 failures mix test (full) 1481 tests, 1 failure, 242 excluded The single failure is ActionsLockTest:277 "parses the repository's authoritative generated lockfile", which arrived with #741. Controlled: a clean detached checkout of origin/main 0e91342 without this commit runs that file at 13 tests, 1 failure - identical. Pre-existing, and untouched by this branch, which changes no file under lib/rules/actions_lock.ex. End-to-end against this repository at default severity: ./hypatia scan . --rules research_extensions --format json 23 findings, rule_module: research_extensions on all 23 RE001 x13, RE004 x4, RE005 x5, RE008 x1 severity: 22 warn, 1 critical 10 carry a real line; SARIF startLines span 11 distinct values to 701 That the module filter holds is itself the proof of @all_rule_modules membership: parse_rules/1 silently falls back to every rule when a name does not resolve, so a mis-wired atom would have returned all modules. The critical finding is real: RE008 flags .github/workflows/dependabot-automerge.yml:56 gating on `github.actor == 'dependabot[bot]'`, which an attacker controls on pull_request_target from a fork. C1/C2 triage, since two RE rules touch pinning. RE004 concerns docker:// image tags and sha256 digests, outside actions.lock's remit entirely. RE006 advises replacing an unpinned nested `uses:` inside a composite action's action.yml with a 40-char SHA - the same shape of advice rejected from Codacy under C1. It is wired because composite action.yml files are not covered by actions.lock, and because it is advisory only: severity :warn gives it dispatch confidence 0.75, below the 0.80 propose-PR threshold, so it can alert but never open a pinning PR. RE006 did not fire on this repository. Expect RE001 to fire broadly across the estate - it flags any workflow touching secrets.* without step-security/harden-runner. Also adds `research_extensions` to both `--rules` help listings in cli.ex. The parser fails open - an unrecognised rule name filters to an empty list and silently runs *every* rule - so an undocumented module is not merely a docs gap: a user guessing the name gets a full scan and no error. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New module
Hypatia.Rules.ResearchExtensionscaptures GitHub Actions workflow defects sourced from commercial CI/CD security tools (Snyk, StepSecurity, Endor Labs, Datadog CI Visibility) and recent academic literature. Complementary toWorkflowHardening(open-source actionlint/zizmor cluster, PR #321) andBaselineHealth(drift, PR #320).10 rules, all pure-local YAML scans on
<repo>/.github/workflows/*.ymlplus repo-walk for compositeaction.ymlfiles.Rule inventory
secrets.*but does not installstep-security/harden-runner:warnegress-policy: auditon a protected-branch trigger (no actual containment):highactions/cachekey interpolatesgithub.head_ref/ PR title / PR body — cache poisoning vector:highdocker://image:tagorcontainer: image:tagpinned by tag, not by@sha256:<digest>:warncontinue-on-error: trueor|| true:warnaction.yml(using: composite) calls a third-partyuses:that isn't SHA-pinned (nested-pinning gap):warnenv:block contains\${{ secrets.* }}— exposes secret to every step:warnif: github.actor == 'dependabot[bot]'— spoofable bot identity onpull_request_targetfrom a fork:criticalbot-conditions+ Koishybayev et al. (USENIX Security 2022)\${{ fromJSON(secrets.X) }}— parsed fields bypass runner-side log redaction:criticalunredacted-secretsworkflow_runtrigger downloads artifacts withoutrun-idconstraint or provenance verification:warnTests
mix test test/research_extensions_test.exscovers 27 tests:continue-on-error: trueand\|\| true; RE010 has two clean-state paths:run-idconstraint andgh attestation verify).scan/1facade exercised on a clean workflow, an empty repo, and a multi-finding repo (asserting all dispatch routes to:sustainabotat severity-calibrated confidence).Design
.github/workflows/*.yml/*.yamlonly (mirrorsWorkflowHardening/BaselineHealthBH004).action.ymlfiles — composite actions can live anywhere.WorkflowHardening.:sustainabot(advisory — fixes vary by defect class). Confidence calibrated by severity: critical 0.92, high 0.85, warn 0.75, info 0.60.Module size
lib/rules/research_extensions.ex— ~900 lines.test/research_extensions_test.exs— ~400 lines.No refactor to existing modules.
🤖 Generated with Claude Code