Repository navigation
refactor: read WH014 workflows through the canonical model - #1182
Conversation
|
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 48 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: ✅ CompletedThis 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. |
|
) ## Summary WH013 now reads `Hypatia.Workflow`, as RE001 and RE002 (#1036) and WH014 (#1182) already do. With that, nothing reads `Hypatia.WorkflowYaml`, the line reader the hardening rules shared, so it is deleted. This is the WH013 half of the work that followed #1036. #1182 landed WH014 separately, and this change keeps #1182's WH014 code as it is. ## Changes - **A grant is a `permissions:` value.** `permissions: {contents: write}`, the form WH013's own fix text recommends, now counts as a grant. A `run:` script that writes `contents: write` into a file no longer does. - **Writes, masks and credentials are read from values and keys, not lines.** - A YAML comment naming `git push` is not a write. - A `GH_TOKEN:` line that a script writes into a file is not the job's credential. - A workflow-level `env:` written after `jobs:` is inherited. - **Flow-style jobs are judged per job.** The line reader couldn't split `jobs: { … }`, so it treated the whole file as one body. - **An unreadable workflow is reported, not guessed at.** It gets a `:warn` finding at the error line if it names a write, and is skipped otherwise. - **The line-based rules are unchanged.** `ResearchExtensions.flow_to_block/1` moves back into that module unchanged, so RE003, RE005 and the WorkflowAudit toolchain check, which still read lines, keep their findings and fixer line numbers. - **CLAUDE.md file count.** The `lib/` count is re-measured at 171 (main tracks 172, and this deletes one). ## Testing Run locally under the repo's pinned toolchain, Elixir 1.19.4 on OTP 27.3.4.19, built here because the container had 1.14/OTP 25: - **Format and warnings:** `mix format --check-formatted` passes across the repo, and the changed modules compile with no warnings (CI uses `--warnings-as-errors`). - **Tests:** 34 test files touching the workflow rules pass. Only `workflow_hardening_test.exs` differs from main: 118 tests instead of 104, all passing. - Seven of the eight new WH013 tests fail on main. The eighth guards against a new false positive. - Six WH014 tests carried over from the earlier rebuild pass on #1182's WH014. - **Findings differential:** I compared main (6f3f16f) with this change, running WorkflowAudit, WorkflowHardening and ResearchExtensions. - Every rule gives the same findings on six repository snapshots (hypatia, standards, kyq, rsr-template-repo, choreographic-types, mathesis). - WH013 doesn't fire on those trees, so I repeated the comparison on perturbed copies that make it fire (12 WH013 findings), again with identical results. - **Not run locally:** `mix deps.get`. This environment's network policy blocks hex.pm, so tests ran through `elixirc` builds. CI runs the real Mix lanes. ## Notes - #1179 (open) also edits `lib/rules/research_extensions.ex`, but in different regions: RE001 endpoint code there, the line-reader section here. Whichever merges second may need a trivial rebase. - RE003, RE005 and the toolchain check still read lines. Moving them onto the model remains under #971. --- _Generated by [Claude Code](https://claude.ai/code/session_01J4QvDithtn5Xk5MbSPm4Px)_ Co-authored-by: Claude <[email protected]>



WH014 reconstructed jobs, steps, inputs and run scalars with its own YAML text readers. It missed flow mappings, quoted keys and aliases, and could interpret a step environment key named
runas a script. Read these throughHypatia.Workflowinstead, including parsed workflow/job defaults and decoded/folded run values. Remove the superseded helpers; retain the existing bounded shell tokenizer and literal-path analysis.Findings identify the first affected job's source line, including an alias use site. A KYAML error produces a located warning explicitly marked as incomplete analysis instead of an empty result. One existing working-directory fixture now puts a colon-bearing shell command in a literal scalar so it is valid YAML; its expected result is unchanged.
Validation: eight targeted controls yield seven failures against the old implementation and all pass after migration. Together with unchanged workflow-hardening and model tests: 122 passed on local Elixir 1.19.4 / OTP 28.3. Before/after WH014 scans were identical (zero findings) on Hypatia b93f061, standards 305743d271bac04cf271a792b703a6379e29588b and Echidna 478b7519c559b55b610a31df3b4813833f0e2bd9. Formatting and diff checks pass; hosted OTP 27 validation is required.
Part of #971. Other workflow-hardening rules, WorkflowAudit and PinSites still require migration; no baseline expiry is extended. The bounded analysis does not establish scan completion, and an absent WH014 finding is not a safety verdict.