Skip to content

Scan the image with Trivy and the live site with ZAP; fix what ZAP found - #36

Merged
MCCProgrammer merged 2 commits into
mainfrom
feat/security-scans
Oct 28, 2026
Merged

MCCProgrammer merged 2 commits into
mainfrom
feat/security-scans

Conversation

@MCCProgrammer

Copy link
Copy Markdown
Owner

What

  • Trivy in the image job. The image is built into the runner first and scanned before anything is published.
    • HIGH and CRITICAL findings are printed in the log, and from main they are uploaded to code scanning as SARIF.
    • The build fails only on a CRITICAL vulnerability that has a fix and is in one of the app's libraries.
  • SBOM: a CycloneDX SBOM is kept as an artifact of the run. The push from main attaches BuildKit's SBOM and a provenance attestation (provenance: mode=max).
  • OWASP ZAP baseline (zap.yml): runs every Thursday, or by hand, against the live site. It is passive and only reads pages. .zap/rules.tsv decides which findings fail the run, which are warnings and which are ignored.
  • Fixes for what ZAP's first scan found:
    • Swagger UI's bundled DOMPurify 3.4.13 has known vulnerabilities. org.webjars:swagger-ui is pinned to 5.33.2, which bundles DOMPurify 3.4.16, until springdoc brings it. springdoc.swagger-ui.version takes the same version from the pom, otherwise /swagger-ui/index.html returns 404.
    • No Permissions-Policy header was set. Caddy now sends one for camera, microphone, geolocation, payment, USB and browsing topics.
  • Docs: ADR 0020, and the README.

Checks

  • Trivy, run locally as in CI on this branch's image: the gate passes, there are 0 HIGH or CRITICAL findings, and the SBOM has 241 components (swagger-ui 5.33.2 among them).
  • ZAP against the app: the first run against production found the two issues above. Against this branch running locally, the vulnerable-library check passes and nothing fails. Swagger UI loads the API (checked with a screenshot).
  • Caddy: caddy validate accepts the Caddyfile.
  • Workflows: actionlint passes.
  • Tests: ./mvnw verify passes.

Trivy reports HIGH and CRITICAL findings in the image and fails the build only on a
fixable critical one in a library the app brings; the image from main carries an SBOM
and a provenance attestation. A weekly OWASP ZAP baseline reads the live site. Its first
run found a DOMPurify with known vulnerabilities in Swagger UI (now 5.33.2, DOMPurify
3.4.16) and no Permissions-Policy header (Caddy sets it now).
…it writable by all

SonarQube Cloud (githubactions:S2612) flagged the chmod a+rwX.
@sonarqubecloud

Copy link
Copy Markdown

@MCCProgrammer
MCCProgrammer merged commit ad62237 into main Oct 28, 2026
10 checks passed
@MCCProgrammer
MCCProgrammer deleted the feat/security-scans branch October 28, 2026 19:38
MCCProgrammer added a commit that referenced this pull request Oct 28, 2026
Both sides added a property and a managed dependency in the same places of pom.xml
(the pinned Swagger UI from #36, the Spring Modulith BOM here); kept both.
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