Skip to content

fix(ci): generate the SBOM before the blocking vulnix gate - #1343

Merged
c-vigo merged 2 commits into
release/1.6.0from
bugfix/1342-sbom-on-red-gate
Aug 4, 2026
Merged

c-vigo merged 2 commits into
release/1.6.0from
bugfix/1342-sbom-on-red-gate

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

The nightly scan's SBOM steps ran after the blocking vulnix-gate with no
if: condition, so a red gate ended the job before they executed. The artifact
— uploaded with if: always() precisely because "a red vulnix-gate is exactly
when the findings are needed" — therefore carried its CycloneDX SBOM and Trivy
defence-in-depth view only on green runs, and was stripped on red ones.

Targets release/1.6.0, not dev: the branch was cut minutes before this
was filed and no RC has been tagged yet, so the fix rides 1.6.0 rather than
waiting a train. dev picks it up via the release-merge PR.

Closes #1342

Type of Change

  • fix -- Bug fix
  • ci -- CI/CD pipeline changes

Changes Made

  • .github/workflows/security-scan.yml: the three evidence steps (Build the Nix image for SBOM generation, Generate Nix image SBOM (CycloneDX),
    Trivy SBOM-mode scan) move above Gate on unexcepted HIGH/CRITICAL vulnix findings. The gate is now the last checking step; only the always() upload
    and summary and the failure()-conditioned tracking-issue step follow it.
    The gate itself is byte-for-byte unchanged apart from a comment noting why it
    is deliberately last.
  • tests/test_workflow_sbom_ordering.py (new): four YAML-shape assertions —
    the SBOM producers precede the gate; nothing after the gate is unconditioned;
    the gate stays blocking (no continue-on-error, no if:); the upload keeps
    always().

Ordering was chosen over if: !cancelled() on the SBOM steps so the gate
remains the job's final, unambiguous verdict. The cost is that the image build
now runs before the gate on every run — but nix build .#devkitImage is largely
cache-warm after devkitImageEnv was built earlier in the same job.

Changelog Entry

Added to the frozen ## [1.6.0] - TBD section (this ships in 1.6.0, so it does
not belong under ## Unreleased):

### Fixed

- **The nightly scan keeps its SBOM when the vulnix gate goes red** ([#1342](https://github.com/vig-os/devkit/issues/1342))
  - `security-scan.yml` generated the CycloneDX SBOM and ran the Trivy
    defence-in-depth view *after* the blocking `vulnix-gate` step, with no `if:`
    condition, so a red gate ended the job before they ran. The uploaded
    artifact was complete on green runs and stripped on red ones — the inverse
    of what triage needs (17 kB on the red 2026-08-03 dev run vs ~466 kB on the
    green 2026-07-30 one).
  - The SBOM steps now run before the gate, which stays last, blocking and
    unchanged — so it remains the job's verdict and the tracking-issue
    automation that keys on its outcome is unaffected.

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

TDD, red-first. The test committed first (ace02b53) against the unmodified
workflow:

FAILED test_sbom_steps_precede_the_blocking_gate
FAILED test_nothing_unconditioned_follows_the_gate
2 failed, 2 passed

The two that passed are the guards that already held (gate blocking, upload
always()) — they are regression cover, not new behavior.

Re-verified after the fix by stashing only the workflow change, so the final
test file is proven red against the original workflow and green against the
fixed one:

$ git stash push .github/workflows/security-scan.yml && pytest   # 2 failed, 2 passed
$ git stash pop && pytest -v                                     # 4 passed

Regression cover: pytest -k workflow → 130 passed, 529 deselected.

Hooks: just precommit (full suite, all files) green, exit 0, tree
unmodified by the run.

Correction made mid-implementation

The first version of test_nothing_unconditioned_follows_the_gate asserted that
every step after the gate carries always(). That was over-specified and failed
against the correct workflow: Open a tracking issue when the vulnix gate fails
deliberately runs on failure() && steps.vulnix-gate.outcome == 'failure'. The
assertion now requires an explicit if: on anything following the gate, which
is the invariant that actually prevents #1342 — an unconditioned step silently
inherits the gate's outcome.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have updated CHANGELOG.md (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

Additional Notes

Not a regression from anything in 1.6.0 — the ordering has been there since the
SBOM steps were added, and it only bites on a red gate, which was rare until the
libssh2 batch turned the nightly red on 2026-07-31 (#1322 / #1323).

The fix cannot be proven end-to-end without a genuinely red gate, which dev
no longer has after #1327 and #1328. The YAML-shape tests are the durable proof;
the next real red-gate run is the live confirmation.

Refs: #1342

c-vigo added 2 commits August 4, 2026 11:29
The nightly scan uploads its artifact with `if: always()` because a red gate is
exactly when the findings are needed, but the image build and CycloneDX SBOM
steps sat after the blocking gate unconditioned, so a red gate ended the job
before they ran — the artifact was complete only on green runs.

Assert the SBOM producers precede the gate, that nothing unconditional follows
it, and (already true) that the gate stays blocking and the upload stays
always(). RED: 2 failed, 2 passed.

Refs: #1342
The CycloneDX SBOM and Trivy defence-in-depth steps carried no `if:` and sat
after the blocking gate, so a red gate ended the job first and the artifact —
uploaded with `if: always()` precisely because a red gate is when the evidence
is needed — lost its SBOM on exactly those runs (17 kB on the red 2026-08-03 dev
run vs ~466 kB on the green 2026-07-30 one).

Move the SBOM steps above the gate rather than conditioning them, so the gate
stays last, blocking and unconditioned: it remains the job's verdict and the
tracking-issue automation keyed on `vulnix-gate.outcome` is untouched.

Also relax the follow-the-gate assertion from `always()` to "states an explicit
condition" — the tracking-issue step legitimately runs on `failure()`, and the
invariant that matters is that no step after the gate is unconditioned.

Refs: #1342
@c-vigo
c-vigo merged commit 3253bfa into release/1.6.0 Aug 4, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1342-sbom-on-red-gate branch August 4, 2026 10:44
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