Skip to content

feat(rules): WH014 — detect the masked-scanner shape that DELETES code-scanning alerts - #784

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/wh014-masked-scanner-upload
Sep 14, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
fix/wh014-masked-scanner-upload

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

The defect this detects

Measured 2026-09-14 on hyperpolymath/academic-workflow-suite: 84 real Hypatia code-scanning alerts were auto-closed while every workflow run reported conclusion=success.

Date Hypatia analysis results_count
2026-09-11 84
2026-09-13 0
2026-09-14 06:07–06:09 0 × 6 runs, all green

Why it is alert-deleting, not merely permissive

GitHub reconciles each SARIF upload against the previous analysis carrying the same tool.name + category. Any alert absent from the new analysis is auto-closed. So this combination deletes findings:

hypatia scan . --exit-zero > hypatia-findings.json || true      # swallows the crash
COUNT=$(jq '. | length' hypatia-findings.json 2>/dev/null || echo 0)   # manufactures a zero
# ... then an unconditional github/codeql-action/upload-sarif

Scanner crashes → || true swallows it → empty/invalid JSON → || echo 0 manufactures a count of zero → a valid SARIF with zero results is uploaded → GitHub closes every previously-open alert for that category. Green at every step. The only trace is results_count in the code-scanning/analyses API — it is invisible in every status-based view.

What WH014 does

Fires when all three hold:

  1. the workflow uploads SARIF to code scanning, and
  2. it masks the scanner's failure (|| true) or its count (|| echo 0), and
  3. it never asserts the findings artefact is a non-empty array.

Condition 3 is the exemption for the correct shape. standards/.github/workflows/hypatia-scan-reusable.yml already performs that assertion (jq -e 'type == "array" and length > 0'), so it does not fire. The repos carrying forked copies of its pre-2026-06-21 body do — || true was removed from the reusable on 2026-06-21 (5a93d9d5), a repair that never reached the forks.

Four-arm control — run against REAL files, not synthetic fixtures

Arm Fixture Expected Result
A standards/hypatia-scan-reusable.yml (has the assertion) must not fire 0 findings ✓
B academic-workflow-suite@cd00a580 — the file that deleted the 84 alerts must fire 1 × WH014 high ✓
C arm B with the mask removed and the assertion added must not fire 0 findings ✓
D arms A–C against the version being replaced must not fire no WH014 ✓

Arm D is the one that proves this is new coverage rather than a re-label: the prior module emits 5 findings on the arm B fixture and none of them is WH014.

Tests

Five regression tests, mix test test/workflow_hardening_test.exs → 37 tests, 0 failures.

They build fixtures under System.tmp_dir!() rather than test/, because @training_corpus_paths in scanner_suppression.ex path-suppresses findings under test/ — a fixture placed there would fake every arm.

Blast radius

Lower bound of ~40 repos carry the bespoke shape (hypatia-sarif.cjs = 43 file hits; HYPATIA_FORMAT in workflows = 33). GitHub code search caps at 100 results and lags its index, so treat these as floors.

⚠️ Consequence for the alert census. The 10,441-alert Hypatia figure is a mixture of stale-high (repos whose scans failed, so alerts stayed open) and deflated (repos that uploaded an empty SARIF and had alerts auto-closed). Net direction is unknown. Do not re-measure and read the delta as remediation progress.

🤖 Generated with Claude Code

https://claude.ai/code/session_011YTttTxnPc1V2sATvzBDN7

…e-scanning alerts

Measured 2026-09-14 on hyperpolymath/academic-workflow-suite: 84 real
Hypatia code-scanning alerts were auto-closed while every workflow run
reported success.

The mechanism is GitHub's own reconciliation. Each SARIF upload is
reconciled against the previous analysis carrying the same tool.name +
category; any alert absent from the new analysis is AUTO-CLOSED. So this
combination is not merely permissive, it is alert-deleting:

    hypatia scan . --exit-zero > hypatia-findings.json || true
    COUNT=$(jq '. | length' hypatia-findings.json 2>/dev/null || echo 0)
    ... unconditional github/codeql-action/upload-sarif

When the scanner crashes, `|| true` swallows the failure, `|| echo 0`
manufactures a zero count, a valid SARIF with zero results is uploaded,
and GitHub closes every previously-open alert for that category. The job
is green at every step and the only trace is `results_count` in the
code-scanning/analyses API.

WH014 fires when all three hold:
  1. the workflow uploads SARIF to code scanning, AND
  2. it masks the scanner's failure (`|| true`) or its count (`|| echo 0`), AND
  3. it never asserts the findings artefact is a non-empty array.

Condition 3 is what exempts the correct shape. standards'
hypatia-scan-reusable.yml already performs that assertion
(`jq -e 'type == "array" and length > 0'`), so it does not fire; the ~40
repos carrying forked pre-2026-06-21 copies of its body do.

Four-arm planted-positive control, run against REAL files rather than
synthetic fixtures:

  A  standards/hypatia-scan-reusable.yml (has the assertion)   0 findings  PASS
  B  academic-workflow-suite@cd00a580 (deleted the 84 alerts)  1x WH014    FIRES
  C  arm B with the mask removed and assertion added           0 findings  PASS
  D  arms A-C against the version being replaced               no WH014    PASS

Arm D confirms this is new coverage: the prior module emits 5 findings on
the arm B fixture and none of them is WH014.

Five regression tests added. They build their fixtures under
System.tmp_dir!() rather than test/, because @training_corpus_paths
path-suppresses findings under test/ and a fixture placed there would
fake every arm.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011YTttTxnPc1V2sATvzBDN7
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 9 minutes.

Check out review usage here.

View limit details

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

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 3e8f2f79-d61d-4101-8b4b-2cce8d7ee187

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce4f3a and 28dc890.

📒 Files selected for processing (2)
  • lib/rules/workflow_hardening.ex
  • test/workflow_hardening_test.exs

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

Comment @coderabbitai help to get the list of available commands.

@hyperpolymath
hyperpolymath merged commit a9090e0 into main Sep 14, 2026
26 checks passed
@hyperpolymath
hyperpolymath deleted the fix/wh014-masked-scanner-upload branch September 14, 2026 21:11
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.

1 participant