Skip to content

feat(export): add gitlab-sast and gitlab-secret-detection findings formats - #202

Merged
vsn411 merged 1 commit into
secfoo-com:mainfrom
Labu1:repodestek/issue-110
Nov 26, 2026
Merged

vsn411 merged 1 commit into
secfoo-com:mainfrom
Labu1:repodestek/issue-110

Conversation

@Labu1

@Labu1 Labu1 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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.md could only keep findings as a file to download. This PR adds GitLab's own report formats to secfoo findings export:

  • --format gitlab-sast: a GitLab SAST report (schema v15) built from sast findings.
  • --format gitlab-secret-detection: a Secret Detection report built from secret-scanning findings. location.commit.sha is the scanned commit when current_ref looks like a SHA, otherwise GitLab's 0000000 placeholder. The secret value (evidence) is never copied.

The serializer is in src/secfoo/report/gitlab.py and follows the report/sarif.py pattern: a pure function with no I/O.

  • Each vulnerability gets a stable UUID5 built from project, skill and secfoo fingerprint.
  • Its first identifier is the secfoo fingerprint. GitLab uses the first identifier to tell findings apart, so two findings with the same CWE are not merged. The CWE identifiers come next, with MITRE links.
  • Severity maps to Critical/High/Medium/Low/Info, and anything else to Unknown.
  • The location is the finding's first site (file, start_line, end_line).
  • name and solution are cut to the schema's length limits.
  • Findings from other skills are left out, with a note on stderr. SCA has no matching GitLab report, because GitLab's dependency-scanning format needs dependency files that secfoo doesn't record.

examples/ci/gitlab-ci.yml and the GitLab section of docs/CI.md now export both reports and attach them under artifacts: reports: sast: / secret_detection:. The SARIF and JSONL exports are still kept as artifacts. docs/REFERENCE.md documents the new formats.

Tests: tests/test_report/test_gitlab.py checks both report types against schema fixtures in tests/fixtures/, and a CLI test in tests/test_cli_memory.py covers the new --format values, the skill split and --no-locations.

Please note:

  • The schema fixtures were not downloaded. They are my transcription of the required fields, enums, patterns and length limits of GitLab's published security-report-schemas v15.0.7 (sast-report-format.json and secret-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.
  • I have not run this in a real GitLab pipeline, so there is no merge-request widget screenshot yet.
  • This PR does not add the CircleCI example, the platform matrix, or the run dates and versions for the Bitbucket, Azure and Jenkins examples. The issue requires every example to have actually run on its platform, so those are better done in separate PRs by someone who can run them.

Testing

Ran pytest in a clean Linux container: the 4 remaining failure(s) also occur on the base branch without this change; no new failures are introduced.

  • pytest tests passes
  • ruff check . passes
  • Added/updated tests for the behavior change

This PR was prepared with AI assistance (Claude) and reviewed by me before submitting.

…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.
@Labu1
Labu1 requested a review from vsn411 as a code owner November 26, 2026 17:16
@vsn411
vsn411 merged commit 4fb374c into secfoo-com:main Nov 26, 2026
15 checks passed
@github-actions

Copy link
Copy Markdown

Leaderboard update

Labu1 now has 12 points (rank #7). 13 more to reach Bronze.

Full leaderboard

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.

Every CI system: GitLab native SAST report, plus verified Bitbucket, Azure Pipelines, Jenkins and CircleCI examples

2 participants