ci: add DockSec container scan with SARIF upload - #1789
Open
advaitpatel wants to merge 4 commits into
Open
advaitpatel wants to merge 4 commits into
advaitpatel wants to merge 4 commits into
Conversation
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>
…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>
This repository has no Containerfile, so the trigger path was dead weight - worse than harmless, since a repo that DOES add one later would get a green scan run that never actually reads it (dockerfile: is a fixed string pointing at Dockerfile). Caught by CodeRabbit on the OpenCRE PR; same bug class as the earlier persist-credentials/fork-SARIF fixes, just the half that survived that pass because I hadn't checked whether the repo actually had one. Signed-off-by: Advait Patel <advaitpa93@gmail.com>
Author
|
Hi @EnriqueL8 can I please get your review here? Happy to share more about the tool if needed. Thanks! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Adds a GitHub Actions workflow that scans the
DockerfilewithDockSec 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
Dockerfileat 42.5/100across 17 findings, and four of them are Hadolint errors rather than style advice:
ADDis the one worth a look: unlikeCOPYit auto-extracts archives andaccepts remote URLs, so it is a wider surface than those four lines need.
SC2261 on line 17 is a correctness bug rather than a security one - competing
stdout redirections mean one silently wins.
No issue is linked. This is a small CI-only addition, but I am happy to open an
issue first and let you confirm the approach if that is the process you prefer.
Fixes #
Types of changes
Please make sure to follow these points
actionlint).Other Information
Scope notes:
scan_only, so no API key and no AI calls: fully local to the runner.fail_on, so the job reports and never fails a build.image:to the same step enables that later if you want it.
Disclosure: I used an AI assistant (Claude) to draft this description and generate
the workflow file from DockSec's documented Action inputs. The scan results quoted
above are from runs I did myself; the workflow passes
actionlintand I verified itsSARIF output against the published DockSec container before opening this.
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 either way.