fix(js): supabase jwt base64url decode and per-project error isolation - #342
Conversation
htmlquery.Parse and QueryAll failures returned before spin.Stop(), leaving the "Scanning JavaScript files" spinner running forever on those paths while every other error branch in the function stops it first.
Quoted regex flag combos like "/gi" or "/su" in ordinary JS (e.g.
str.replace("/gi", x)) matched the root-relative path alternative in
endpointRegex and were reported as endpoints. Denylist the known flag
bigrams by exact match instead of raising minEndpointLen, so real short
endpoints like /v1, /me, /ws still extract normally.
…error ScanSupabase iterates every JWT found in a script and can discover several distinct supabase projects. Four error paths inside that loop (reading the signup response, parsing it, fetching the openapi spec, and a missing Paths field) returned nil and the whole error, discarding any results already collected for earlier, successfully scanned projects. Skip the broken project with continue instead so the scan still returns what it found.
pr summary6 files changed (+278 -6)
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #342 +/- ##
=======================================
Coverage ? 55.95%
=======================================
Files ? 81
Lines ? 6881
Branches ? 0
=======================================
Hits ? 3850
Misses ? 2744
Partials ? 287 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
76af728 to
e48519f
Compare
go's regexp is re2 and linear by construction; the timing threshold added only flake under -race load, not coverage. the regex-flag-literal false positive it sat next to is guarded by TestRegexFlagEndpointsNotReported.
e48519f to
6a29010
Compare
vmfunc
left a comment
There was a problem hiding this comment.
refuted, this ships.
the "still RawStdEncoding" thing is technically true but it isn't a bug for what this decodes. std vs url base64 only diverge on slots 62/63 (+/- vs -/_), and a jwt payload is ascii json. supabase project keys are iss/ref/role/iat/exp with lowercase-alnum refs and anon/service_role roles, none of those bytes ever land in a position that reaches 62/63, so std and url are byte-identical here. 0/200k randomized payloads fail under RawStd, and your own test encodes with RawURLEncoding then decodes clean under the unchanged RawStd. worst case is a debug log + continue, never a crash.
swap to RawURLEncoding whenever for spec-purity, costs nothing. the real meat is solid: per-project continue instead of return nil,err so one dead project stops nuking findings already collected for the others, plus the two spin.Stop() leak fixes and the exact-match regex-flag denylist that keeps /v1 and friends. in.
four independent js-scan fixes: a supabase project's fetch/parse failure
(signup response, openapi spec) used to abort the whole scan, now it's
logged and skipped so other projects on the same page still get scanned;
a quoted regex-flag literal like "/gi" was reported as an endpoint; the
progress spinner kept running past an early script-parse error; and a
flaky wall-clock ReDoS-timing probe test is dropped (timing-based tests
are inherently unstable in CI).