Skip to content

fix(ci): unblock image job on private-repo SARIF upload - #11

Merged
kphunter merged 2 commits into
mainfrom
devin/1776735092-fix-sarif-upload-permission
Apr 21, 2026
Merged

fix(ci): unblock image job on private-repo SARIF upload#11
kphunter merged 2 commits into
mainfrom
devin/1776735092-fix-sarif-upload-permission

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The post-merge main build of #10 (commit db7fcb5) successfully built, pushed, and Cosign-signed ghcr.io/bcit-tlu/haproxy-operator/haproxy-operator:0.2.1-head.db7fcb5, but the final github/codeql-action/upload-sarif@v4 step failed with:

Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run

Because the image job failed, the downstream helm-publish job (needs: [image, versions]) was skipped, so the chart was not published and the first-ever haproxy-operator/charts/haproxy-operator GHCR package still doesn't exist.

Root cause: on private repos, codeql-action/upload-sarif fetches the calling workflow run's metadata from /actions/runs/{run_id} which requires actions: read. Public repos (hriv, tech-ops-docs) don't hit this path because that endpoint is anonymous for public repos — which is why their post-merge unified-versioning builds both published cleanly.

Two-part fix:

  1. Add actions: read to the workflow-level permissions: block so the required metadata fetch actually works.
  2. Mark the upload step continue-on-error: true so a transient telemetry-upload failure never cascades into blocking chart publication of an already-built, already-signed image. The Security tab upload is a diagnostic sidecar — publish-gate is already defended by the MODE guards on build/push/sign, which are the artifact-correctness path.

Review & Testing Checklist for Human

  • After merging, watch the post-merge main CI run — expect image + helm-publish both green, and the first unified chart artifact 0.2.1-head.<sha> (+ head moving tag) to land at ghcr.io/bcit-tlu/haproxy-operator/charts/haproxy-operator.
  • Verify Trivy SARIF results still appear in GitHub Security → Code scanning alerts (confirms actions: read did what we expect).
  • After this lands, open the flux-fleet follow-up to flip apps/haproxy-operator/base/ocirepository.yaml from ref.tag: latest to ref.tag: head (noted as pending in the Apr 2026 strict-D adoption).

Notes

Not propagating this fix to hriv or tech-ops-docs — they're both public and their post-merge unified builds already succeeded (hriv 0.6.0-head.40b2888, tech-ops-docs 0.2.1-head.28e2ad8), so there's no evidence the private-repo code path is exercised there. Adding actions: read to those preemptively would be harmless but violates minimum-scope; happy to propagate if you'd prefer symmetric permissions across the three repos.

Link to Devin session: https://app.devin.ai/sessions/a5e23b4cc3a34f4caa54267af3c1ccc4
Requested by: @kphunter


Open in Devin Review

The post-merge main build of PR #10 successfully built, pushed, and
Cosign-signed ghcr.io/bcit-tlu/haproxy-operator/haproxy-operator:0.2.1-head.db7fcb5,
but the codeql-action/upload-sarif@v4 step failed with
'Resource not accessible by integration' on the workflow-runs GET.

On private repos, upload-sarif needs 'actions: read' to read the
calling workflow's run metadata; public repos (hriv, tech-ops-docs)
don't hit this path because the metadata endpoint is anonymous.

Two-part fix:
1. Add 'actions: read' to the workflow permissions block so the
   required metadata fetch actually works.
2. Mark the upload step 'continue-on-error: true' so a transient
   telemetry-upload failure never cascades into blocking chart
   publication of an already-built, already-signed image.

This mirrors the intent of the existing guards — publish artifacts
stay gated on MODE + successful build+sign; SARIF-to-Security-tab is
a diagnostic sidecar.

Co-Authored-By: kyle_hunter@bcit.ca <kyle_hunter@bcit.ca>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Comment thread .github/workflows/ci.yaml Outdated
- name: Upload scan results to GitHub Security
if: needs.versions.outputs.mode == 'head' || needs.versions.outputs.mode == 'release'
uses: github/codeql-action/upload-sarif@v4
continue-on-error: true # Non-critical: don't block chart publish on telemetry upload

@devin-ai-integration devin-ai-integration Bot Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: continue-on-error silently swallows all upload-sarif failures

Adding continue-on-error: true at line 255 means that any failure of the SARIF upload — including persistent misconfiguration (wrong permissions, bad SARIF format, etc.) — will be reduced to a workflow warning rather than a failure. The follow-up step at line 260-263 does emit a ::warning, which is good, but warnings are easy to miss in GitHub Actions UI. If the SARIF upload is broken for an extended period (e.g., a permissions regression), the team may not notice that vulnerability scan results are silently not reaching the Security tab. Consider whether a periodic audit or a separate alerting mechanism is warranted.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — the review correctly points out that continue-on-error: true is too broad as written. Addressed in a1830cd:

  • Added an id: upload-sarif handle on the codeql-action step.
  • Added a follow-up step guarded by if: steps.upload-sarif.outcome == 'failure' that emits a ::warning:: annotation.

Net effect: a failed SARIF upload still doesn't block the pipeline (preserves the original unblock intent), but it now surfaces as a yellow warning annotation in the workflow summary instead of silently disappearing. This covers the regression scenarios you enumerated (malformed SARIF, removed security-events: write, CodeQL breaking changes) — each would show up as a visible warning on the run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that a persistent warning can get buried if nobody watches the runs — but I think that's a monitoring/alerting concern separate from this workflow change, not something to block the PR on. Concretely:

  • The GitHub Security tab itself is the primary signal: if it stops gaining new scan timestamps, that's the canonical "alert". Anyone looking at https://github.com/bcit-tlu/haproxy-operator/security/code-scanning will see stale data immediately.
  • The right place for an "extended-period SARIF upload broken" alarm is a Vault/Grafana-style cross-repo audit (e.g. a scheduled workflow that lists repos + checks last CodeQL analysis date), not inside each per-repo pipeline.
  • The ::warning:: annotation plus the image job going green is the correct local contract: publish artifacts are decoupled from telemetry upload, but telemetry failures are not invisible on the run that produced them.

Happy to file a follow-up issue to track the cross-repo audit idea if that's useful, but not going to add it inline here.

Addresses Devin Review feedback on PR #11.

'continue-on-error: true' on upload-sarif correctly unblocks chart
publish when the upload fails, but it silently swallows ALL upload
failures — including genuine regressions (malformed SARIF, removed
'security-events: write', breaking CodeQL action changes). The
security scan results would silently disappear from the GitHub
Security tab with no signal in the workflow summary.

Add a follow-up step that emits a '::warning::' annotation when the
preceding step's outcome is 'failure'. This surfaces the failure in
the Actions UI (yellow warning icon + annotation in the summary)
without gating the pipeline, preserving the original intent that the
image+chart artifacts ship even if telemetry upload glitches.

Co-Authored-By: kyle_hunter@bcit.ca <kyle_hunter@bcit.ca>
@kphunter
kphunter merged commit 8e40960 into main Apr 21, 2026
6 checks passed
@devin-ai-integration devin-ai-integration Bot mentioned this pull request Apr 21, 2026
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