fix: resolve all 22 gosec G710 open-redirect findings (closes #176) #186
Reference in New Issue
Block a user
Delete Branch "fix-gosec-g710"
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?
Second lint batch toward a green
make checkunder currentgolangci-lint (issue #176).
Stacked on PR #183 (
fix-noctx-lint): this branch contains thatPR's commit and should merge after it. Once #183 merges, this diff
reduces to the single G710 commit (
b580dbb).What changed
redirectToApphelper ininternal/handlers/app.go: parsesthe app ID with
ulid.ParseStrict(404 on failure), re-serializesit, and applies
url.PathEscapebefore building the/apps/<id>redirect target — no request-derived string can reach
http.Redirectunvalidated (url.PathEscapeis also what gosec'staint analysis recognizes as the sanitizer)
http.Redirectsites converted to the helper,including the multiline ones in
HandleAppDeploy,HandleCancelDeploy, andHandleVolumeAddHandleAppCreateconvertedtoo, for consistency (app IDs there come from
CreateApp, not theURL)
uppercase ULIDs (
ulid.MustNew(...).String()), soparse → re-serialize → escape is the identity on every valid ID
//nolintdirectives addedTODO.mdrotated: Next Step is now the G703 path traversal (#177)Lint counts (golangci-lint 2.12.2)
gosecG710gosecG703goconstmake testpasses (race detector on, all handler redirect testsgreen),
make fmtrun,make fmt-checkclean.Note: while verifying I found the shared golangci-lint cache can
report stale findings from a different checkout with
../../../path prefixes;
golangci-lint cache cleanbefore the final runconfirmed the counts above are ground truth.
@clawbot please fix this one too
Manager note (independent verification, not authored by this PR's implementer):
This PR is superseded by #187 (commit
7a34fc9, merged tomain2026-08-07 22:21), which fixes issue #176 with the same approach: a
redirectToApphelper ininternal/handlers/app.gothrough whichall 22 flagged
http.Redirectsites now go.I verified
main's fix is a real sanitization, not a suppression:"/apps/" + url.PathEscape(appID) + suffix, sothe target is always a relative application URL —
url.PathEscapeis one of the two remediations issue #176 explicitly accepts
//nolintor#nosecdirectives were added for these sitesmainin a clean worktree with the pinnedtoolchain (golangci-lint v2.12.2,
maketargets only):make checkgreen — tests pass, lint reports 0 issues (zeroG710),fmt-checkcleanA rebase of
fix-gosec-g710ontomainreduces to a single cosmeticresidue: this PR additionally converted the unflagged raw redirect in
HandleAppCreate(internal/handlers/app.goline 143 onmain,"/apps/"+createdApp.ID— ID comes fromCreateApp, not therequest, so gosec does not flag it). That consistency tweak is not
part of #176's definition of done and does not justify its own PR;
noting it here in case the owner wants it folded into future work in
that file.
Closing as superseded; issue #176's definition of done is met by
mainand is being closed with reference to #187. Branchfix-gosec-g710is left on the remote untouched.Pull request closed