Skip to content

ci: add DockSec container scan with SARIF upload - #5689

Closed
advaitpatel wants to merge 2 commits into
cilium:mainfrom
advaitpatel:ci/docksec-sarif-scan
Closed

advaitpatel wants to merge 2 commits into
cilium:mainfrom
advaitpatel:ci/docksec-sarif-scan

Conversation

@advaitpatel

@advaitpatel advaitpatel commented Sep 21, 2026 •

Copy link
Copy Markdown

Fixes

Description

Adds a GitHub Actions workflow that scans the Dockerfile with
DockSec and uploads the results to code
scanning as SARIF, so container findings are annotated inline on pull requests.

DockSec is an OWASP Lab Project (MIT). It wraps Hadolint and Trivy and reports
Dockerfile misconfigurations and image CVEs through a single SARIF upload.

Why this repository: DockSec scores the current Dockerfile at 37.5/100,
the lowest of the repositories I checked, across 15 findings:

DL3008 warning  line 15  Pin versions in apt-get install
DL3018 warning  line 35  Pin versions in apk add
DL3003 warning  line 35  Use WORKDIR to switch to a directory
DL4006 / SC2086 across several RUN lines

The unpinned apt-get and apk add on lines 15 and 35 are the substantive ones
for a security-focused project: an unpinned package install means two builds of
the same commit can produce different binaries.

The base images are already SHA-pinned, which keeps the image-layer CVE surface
low, so most of the value here is the Dockerfile layer plus the weekly re-scan
that catches newly disclosed CVEs without a code change.

Scope notes:

  • Runs scan_only, so no API key and no AI calls: fully local to the runner.
  • Does not gate merges. No fail_on, so the job reports and never fails a build.
  • Scans the Dockerfile only, so the workflow does not pull or scan a built image.
    Adding image: to the same step enables that later if you want it.
  • All three actions are pinned to a commit SHA; security-events: write is
    scoped to the single job that needs it.

Changelog


Disclosure, per https://github.com/cilium/community/blob/main/AI-POLICY.md: I
used an AI assistant (Claude) to draft this PR description and to generate the
workflow file from DockSec's documented Action inputs. I ran the scan results
quoted above myself, validated the workflow with actionlint, and verified the
SARIF output against the published DockSec container before opening this. I
understand the change and take responsibility for it.

Disclosure of interest: I am the project lead for DockSec, the tool this
workflow adds. Happy to close this if it is not a fit - no hard feelings.

Scans the Dockerfile with DockSec and uploads the results to code scanning
as SARIF, so container findings are annotated on pull requests.

Runs scan-only, so no API key is required and no gate is added to the build.
All actions are pinned to a commit SHA.

Signed-off-by: Advait Patel <advaitpa93@gmail.com>
@advaitpatel
advaitpatel requested a review from a team as a code owner September 21, 2026 07:03

@mtardy mtardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey, I don't think we particularly want a new workflow to run your tool in the CI, on the other hand, if you want to propose fixes for the things it detected (when running locally) and they make sense we'll be happy to review them. Thanks.

…IF upload

The path filter matched nested Dockerfile/Containerfile variants but the scan
itself only ever reads the root Dockerfile, so a change to a nested file would
trigger a green run that scanned nothing relevant - worse than no scan, since
it reads as coverage that isn't there. Narrowed the trigger to match what is
actually scanned.

checkout now sets persist-credentials: false; nothing after it needs the token
in git config, and the next step runs third-party actions.

The SARIF upload no longer runs unconditionally on fork pull requests. GITHUB_TOKEN
is read-only there, so security-events: write cannot apply and the upload would
fail every time - turning a routine fork contribution into a red required check.
It now runs on push, on same-repo PRs, and on schedule, and is skipped on fork PRs.

Thanks to a reviewer on an earlier PR for catching all three.

Signed-off-by: Advait Patel <advaitpa93@gmail.com>
@netlify

netlify Bot commented Sep 21, 2026

Copy link
Copy Markdown

✅ Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit f1fa6fd
🔍 Latest deploy log https://app.netlify.com/projects/tetragon/deploys/6ab16394277c3e00089e95e1
😎 Deploy Preview https://deploy-preview-5689--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@advaitpatel

Copy link
Copy Markdown
Author

Understood, thanks for the quick answer. Closing this rather than leaving it open against your wishes.

If it's useful: the DockSec scan found 15 Dockerfile findings when I ran it locally, the largest cluster being 20 instances of DL3020 (using ADD where COPY would do - none of the file's ADD instructions pull a remote URL or extract an archive, so COPY covers the same job with less capability than needed). Happy to open a separate PR fixing just that pattern if it's useful, with no workflow attached - your call, no worries either way if not.

@advaitpatel

Copy link
Copy Markdown
Author

Closing per the maintainer's note above - not something they want in CI right now.

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