Repository navigation
feat(export): add gitlab-sast and gitlab-secret-detection findings formats - #202
Merged
Merged
Conversation
…rmats GitLab's merge-request security widget and Vulnerability Report do not read SARIF, so the GitLab CI example could only keep findings as a plain artifact. `secfoo findings export` now writes GitLab's own report JSON (schema v15): --format gitlab-sast for SAST findings and --format gitlab-secret-detection for secret-scanning findings. The serializer is a pure function in secfoo.report.gitlab, like the SARIF one. Each vulnerability gets a stable UUID derived from its project and secfoo fingerprint, the fingerprint as primary identifier (so findings sharing a CWE stay separate), its CWEs, a mapped severity and its first location. Secret Detection reports carry the scanned commit (or GitLab's 0000000 placeholder) and never the secret value. Findings from other skills are left out with a note on stderr. The GitLab example and docs now attach both reports under `artifacts: reports:`. Fixes secfoo-com#110.
3 tasks
Leaderboard update
Labu1 now has 12 points (rank #7). 13 more to reach Bronze. |
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.
Fixes #110
What does this change, and why?
GitLab's merge-request security widget and Vulnerability Report don't read SARIF, so the GitLab job in
docs/CI.mdcould only keep findings as a file to download. This PR adds GitLab's own report formats tosecfoo findings export:--format gitlab-sast: a GitLab SAST report (schema v15) built fromsastfindings.--format gitlab-secret-detection: a Secret Detection report built fromsecret-scanningfindings.location.commit.shais the scanned commit whencurrent_reflooks like a SHA, otherwise GitLab's0000000placeholder. The secret value (evidence) is never copied.The serializer is in
src/secfoo/report/gitlab.pyand follows thereport/sarif.pypattern: a pure function with no I/O.file,start_line,end_line).nameandsolutionare cut to the schema's length limits.examples/ci/gitlab-ci.ymland the GitLab section ofdocs/CI.mdnow export both reports and attach them underartifacts: reports: sast:/secret_detection:. The SARIF and JSONL exports are still kept as artifacts.docs/REFERENCE.mddocuments the new formats.Tests:
tests/test_report/test_gitlab.pychecks both report types against schema fixtures intests/fixtures/, and a CLI test intests/test_cli_memory.pycovers the new--formatvalues, the skill split and--no-locations.Please note:
sast-report-format.jsonandsecret-detection-report-format.json), and the source is linked in each file's$comment. They are not verbatim copies, so please replace them with the published files if you prefer.Testing
Ran
pytestin a clean Linux container: the 4 remaining failure(s) also occur on the base branch without this change; no new failures are introduced.pytest testspassesruff check .passesThis PR was prepared with AI assistance (Claude) and reviewed by me before submitting.