Skip to content

refactor: read WH014 workflows through the canonical model - #1182

Merged
hyperpolymath merged 2 commits into
mainfrom
codex/wh014-workflow-model-20261116
Nov 16, 2026
Merged

hyperpolymath merged 2 commits into
mainfrom
codex/wh014-workflow-model-20261116

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

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 run as a script. Read these through Hypatia.Workflow instead, 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.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 168d7120-ce15-40b1-a4d8-5f5a63f256bf
Commits

Reviewing files that changed from the base of the PR and between ea7b9f6 and c52e464.

Files selected for processing: 4

  • CHANGELOG.adoc
  • lib/rules/workflow_hardening.ex
  • test/wh014_workflow_model_test.exs
  • test/workflow_hardening_test.exs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T10:28:45.898359Z c52e464 New commits
🔒 Security Review ✅ Completed 2026-11-16T10:32:04.860146Z c52e464 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 6f3f16f into main Nov 16, 2026
99 checks passed
@hyperpolymath
hyperpolymath deleted the codex/wh014-workflow-model-20261116 branch November 16, 2026 10:47
hyperpolymath added a commit that referenced this pull request Nov 16, 2026
)

## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants