lab(lab9): Trivy + ZAP + securityHeaders middleware#1397
Open
GrandAdmiralBee wants to merge 4 commits into
Open
lab(lab9): Trivy + ZAP + securityHeaders middleware#1397GrandAdmiralBee wants to merge 4 commits into
GrandAdmiralBee wants to merge 4 commits into
Conversation
Signed-off-by: GrandAdmiralBee <karim.abdulkin@gmail.com>
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.
Goal
Lab 9 submission β Trivy scans (image/fs/config/SBOM) with per-finding triage, plus OWASP ZAP baseline with a security-headers middleware fix landed in code, guarded by a table-driven test.
Changes
app/middleware.goβ newsecurityHeaders(next http.Handler) http.Handlermiddleware. SetsX-Content-Type-Options: nosniff,X-Frame-Options: DENY,Content-Security-Policy: default-src 'none'(safe strict because API returns only JSON), andReferrer-Policy: no-referreron every response.app/handlers.goβRoutes()signature changes from*http.ServeMuxtohttp.Handler; returnssecurityHeaders(mux)so headers land on all routes including future ones and error paths.app/middleware_test.goβ new table-driven test asserts the four headers are present on/health,/notes,/notes/{id}, and/metrics. Fails immediately ifsecurityHeaders(mux)is dropped fromRoutes().submissions/lab9.mdβ full submission: four Trivy scan output heads, HIGH/CRITICAL triage table with disposition per unique CVE + Vagrant private-key false-positive, SBOM head + component count, ZAP triage + before/after run consoles, code diff, design questions aβg, pitfalls (rootless podman UID mapping, ZAP spider seed URL, addon-update hangs, Trivy config subcommand flag differences).submissions/lab9/trivy/β raw scan outputs + CycloneDX SBOM.submissions/lab9/zap/β baseline HTML + JSON + console before and after the fix.Testing
go vet ./...clean;go test -race -count=1 ./...passes with the new middleware test.X-Content-Type-Optionsmissing on/notes).FAIL-NEW: 0 WARN-NEW: 0 PASS: 58. The previously-firing rule now PASSes.curl -sSI http://127.0.0.1:8080/notesshows all four headers set.Skipped
Checklist