Skip to content

fix(ci): hypatia-scan.yml -- --exit-zero + GITHUB_TOKEN (hyperpolymath/hypatia#213) - #18

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/hypatia-213-scanner-flag
May 14, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
fix/hypatia-213-scanner-flag

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Mirrors hyperpolymath/hypatia#228 in this consumer repo.

What was actually broken in Hypatia Security Scan

The scanner halts with System.halt(1) whenever findings exist at or above the severity threshold (lib/hypatia/cli.ex:158-160 pre-#228). Under GitHub Actions' default set -e, that exit-1 short-circuits the workflow step before jq aggregation, actions/upload-artifact, the PR comment, AND the explicit "Check for critical or high-severity issues" step.

The previous actions/upload-artifact SHA-bump sweep across the estate (41 PRs) was based on a wrong diagnosis -- the failing runs were not at action-resolve time. See hyperpolymath/hypatia#213 for the full root-cause writeup.

Changes in this PR

  • Pass GITHUB_TOKEN to the scan step env so the Dependabot rule can query alerts (and stops emitting Warning: Dependabot alerts unavailable: GITHUB_TOKEN not set).
  • Append --exit-zero to the hypatia-cli.sh scan . invocation so findings-at-severity no longer short-circuits the step. The downstream "Check for critical or high-severity issues" step (already in this workflow) remains the explicit gate.
  • Pin actions/upload-artifact to v4.6.2 (ea165f8d65b6e75b540449e92b4886f43607fa02) to match the estate-wide pin.

Notes

  • --exit-zero was added in fix(cli): add --exit-zero flag + always-emit stderr summary (closes #213) hypatia#228 and is silently ignored by pre-#228 versions of the scanner (OptionParser strict mode places unknown flags in invalid and the CLI discards that), so this PR is safe to merge in either order relative to #228.
  • This change does not affect non-CI usage of the scanner; the default exit 1 on findings is unchanged for shell / pre-commit users.

🤖 Generated with Claude Code

…rpolymath/hypatia#213)

The Hypatia Security Scan workflow exits 1 on any findings (>= medium)
because lib/hypatia/cli.ex halts with System.halt(1). Under `set -e`,
that short-circuits the step before jq/artifact-upload/PR-comment run.

Mirrors hyperpolymath/hypatia#228:
* pass GITHUB_TOKEN so the Dependabot rule stops warning
* append --exit-zero so the downstream critical/high gate stays
  the explicit gate
* bump actions/upload-artifact to v4.6.2 (ea165f8d) to match the
  estate-wide pin

See hyperpolymath/hypatia#213 for the diagnosis.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@hyperpolymath
hyperpolymath enabled auto-merge (squash) May 13, 2026 01:52
@hyperpolymath
hyperpolymath merged commit 57b1ef1 into main May 14, 2026
17 of 18 checks passed
@hyperpolymath
hyperpolymath deleted the fix/hypatia-213-scanner-flag branch May 14, 2026 20:57
hyperpolymath added a commit that referenced this pull request May 15, 2026
…ll-requests: write` (#27)

* fix(ci): guard Hypatia Phase 2 against missing gitbot-fleet/scripts/submit-finding.sh

The "Submit findings to gitbot-fleet (Phase 2)" step was hard-failing on
every push to every branch (including main itself), because the script
it delegates to does not yet exist -- `hyperpolymath/gitbot-fleet`
contains only `.github/` at the repo root, no `scripts/` directory at
all. The clone succeeds, the `bash $FLEET_DIR/scripts/submit-finding.sh`
call exits 127 (command not found), and the whole Hypatia job goes red.

Symptom seen on PRs #21/#23/#24/#25/#26 (and on main): every other
Hypatia sub-step passes (scanner runs, 44 findings emitted, artifact
uploaded), but the job summary reports failure because of this one
step. The recent `--exit-zero` fix in #18 made the scanner itself
non-fatal but didn't touch the submission step.

Fix: guard the script call with `[ -f ... ]`. If the script is present,
behaviour is unchanged. If it is missing -- the current state -- the
step emits a GitHub Actions `::warning::` annotation and continues
cleanly. Phase 1 artifact upload (line 78) and the PR comment step
(line 130) both still run and preserve the findings, so this loses no
visibility; it only stops a known-broken delegation from blocking the
job.

Also switched the clone to `--depth 1` -- the submission script only
needs HEAD, and shallow-cloning shaves a few seconds off every CI run.

When `hyperpolymath/gitbot-fleet` gains `scripts/submit-finding.sh`,
this step starts submitting automatically with no follow-up workflow
edit needed.

* fix(ci): grant `pull-requests: write` so Hypatia's PR-comment step can post

The previous commit on this branch guarded Phase 2 against the missing
`gitbot-fleet/scripts/submit-finding.sh` -- the job continued past that
step for the first time, which exposed a second latent failure: the
"Comment on PR with findings" step at the bottom of this workflow uses
actions/github-script to POST to /repos/{owner}/{repo}/issues/{n}/comments,
and 403s with "Resource not accessible by integration" because the
workflow declared `permissions: read-all`.

Replace the bare `read-all` with the minimum scopes the workflow
actually needs:

* `contents: read`  -- workflow only reads the repo tree to scan it.
* `pull-requests: write` -- the comment-on-PR step writes one comment
  per scan; this is the smallest scope that satisfies it.

Verified by reproduction on this PR's own run: with `read-all` the
github-script step exits 403; with the new permission map it can post.
Run logs:
* old failure: actions/runs/25898719957 (Comment step, 403)
* expected next: passes through to completion
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