lint: fix gosec G703 path traversal finding in deploy log download handler #177
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Surveyed 2026-08-07: golangci-lint 2.12.2 reports one
G703: Path traversal via taint analysisfinding atinternal/handlers/app.go:629—http.ServeFilecalled with alogPathderived from request data:Remediation: before serving, canonicalize the path
(
filepath.Clean, resolving against the configured data directory)and verify containment — the resolved path must be inside the deploy
log directory (e.g.
filepath.Relresult must not start with..).Return 404 on violation. Do not use
//nolint.Definition of done:
make lint(golangci-lint ≥ 2.12) reports zeroG703findings(e.g. an id containing
..) and asserts it is rejectedmake testpasses)make fmtrun before commit;TODO.mdupdated per the repo workflowmainStill open — the finding was silenced, not fixed
Re-verified against
main@7a34fc9on 2026-09-03. PR #187 listsgosec (23)among its fixes and its description says thehttp.ServeFilecall was "annotated like the adjacentos.Stat". That is exactly the outcome this issue ruled out.Current state of
internal/handlers/app.go:The definition of done above explicitly says
Do not use //nolintand requires a containment check plus a traversal test. None of that landed:filepath.Clean/filepath.Relcontainment check against the configured deploy-log directory..)make lintreports zeroG703findings only because the annotations suppress the linter, so the first DoD bullet is satisfied vacuously. The justification comment ("internal path, not user input") is also the claim that actually needs proving in code —logPathis derived from a request-supplied id, which is precisely why gosec flagged it.Keeping this open. The remediation is unchanged from the description: canonicalize and verify containment, return 404 on violation, add the traversal test, and remove both
#nosec G703annotations so the linter is genuinely satisfied.