lint: fix 22 gosec G710 open-redirect findings in internal/handlers/app.go #176
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 23
gosecfindingson
main; 22 of them areG710: Open redirect via taint analysis, allin
internal/handlers/app.go(lines 289, 374, 400, 424, 429, 802, 835,889, 899, 1034, 1062, 1075, 1091, 1120, 1148, 1169, 1215, 1277, 1290,
1326, 1334, 1348). The remaining
G703finding is tracked in its ownissue.
Every site has the same shape:
http.Redirectwith a URL built bystring concatenation from
application.ID, which taint analysisconsiders request-derived, e.g.:
App IDs are ULIDs. Remediation: add one small helper (e.g.
redirectToApp(w, r, appID, query string)) that validates the ID is awell-formed ULID (or applies
url.PathEscape) before building therelative URL, then convert all 22 sites to use it. This both satisfies
the taint analysis and makes the invariant explicit. Do not use
//nolint— fix the code, per the README commit requirements.Definition of done:
make lint(golangci-lint ≥ 2.12) reports zeroG710findings//nolintdirectives addedmake testpasses; existing handlertests still green)
make fmtrun before commit;TODO.mdupdated per the repo workflowmainStarting this now on branch
fix-gosec-g710, stacked onfix-noctx-lint(PR #183) so the lint-count progression and theTODO.mdrotation stay serial; the PR should merge after #183.Definition of done for the PR:
internal/handlersthat validates the app IDbefore building the redirect target; all 22
G710sites convertedto it
make lint(golangci-lint 2.12.2): zeroG710findings; totaldrops 47 → 25 (remaining: 1
gosecG703 → #177, 24goconst→#178)
//nolintdirectives; redirect behavior unchanged;make testgreen
make fmtrun;TODO.mdNext Step rotated to #177Done in PR #186 (branch
fix-gosec-g710, commitb580dbb, stacked onPR #183): all 22
G710findings resolved via aredirectToApphelper (
ulid.ParseStrict+ re-serialize +url.PathEscape),make linttotal 47 → 25,make testandmake fmt-checkgreen.Awaiting independent review (labeled needs-review); merge after #183.
Definition of done verified met on
main(7a34fc9) — the fix landedvia #187 rather than PR #186, which is now closed as superseded:
G710sites ininternal/handlers/app.gonow go through aredirectToApphelper that builds"/apps/" + url.PathEscape(appID) + suffix— a real sanitizationproducing an always-relative application URL (
url.PathEscapeisone of the two remediations this issue accepts)
//nolintor#nosecdirectives added for these sitesmake lint(pinned golangci-lint v2.12.2, canonical config): 0findings, so zero
G710make checkgreen in a clean worktree ofmain(tests with racedetector, lint,
fmt-check); redirect behavior unchanged, handlertests green
Closing.