Skip to content

fix(tech-detect): detect Supabase from a supabase-js signature plus a quoted project URL #1379 - #1380

Closed
nc9 wants to merge 4 commits into
mainfrom
fix/supabase-bundle-detect-1379
Closed

nc9 wants to merge 4 commits into
mainfrom
fix/supabase-bundle-detect-1379

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1379.

Tech detection missed Supabase in real bundles in three ways. All three are covered:

  • Library signature plus a quoted project URL. A new script-content detector option, also, makes a bundle match only when the same script body also matches a second pattern. Supabase uses it: a quoted <20-char ref>.supabase.co URL anywhere (in a variable, no key beside it) counts when the bundle carries supabase-js's own strings: the Node.js deprecation notice linking github.com/orgs/supabase/discussions/<n> or the sb-${...}-auth-token storage key. Both patterns are linear (no nested quantifiers), and (?!your) and the repeated-char guard still reject placeholders.
  • sb_secret_ keys are accepted by the existing URL-plus-key pair pattern, like sb_publishable_ and eyJ.
  • Bundle sampling. The URL and the signature are located by their own hints (.supabase.co", .supabase.co', the discussions link, -auth-token), so they are pulled into the sampled windows of a big bundle under the default 64 KB bundle_bytes. A hit inside a short string that opened before the window (the deprecation notice is a 230-char string) now keeps the whole string instead of being skipped. Sampling now tests each hint hit's window against the patterns of the detectors that use that hint and keeps it only if one matches, deduping identical windows: a placeholder URL, a non-key pair or a repeated literal can no longer use up the sample, so a hit that can match (the supported pair pattern, or the signature plus URL) is always kept (bounded by 512 scans per hint and the existing byte budget). Hints with no detector pattern keep the old cap of 48; the byte caps are unchanged. This is the root cause of the issue's 209 KB miss: earlier .supabase.co mentions used up the 24 kept hits before the real URL. Pinned by tests with 200 identical and 60 distinct earlier placeholder URLs, and 300 earlier URL-and-non-key pairs, in the synthetic file and in the real-build file (the app module sits between two filler modules, not in the head or tail); 3 of them fail on the previous sampler.

Notes: also needs inCode: true (enforced by the type), and its second pattern also matches inside strings and comments, so a docs bundle that quotes both the discussions link and a 20-char ref URL would match. CHANGELOG bullet is under Unreleased; it will conflict with #1381's at the same line (whoever merges second rebases).

Tests (packages/audit-engine/tests/tech-supabase-signature-1379.test.ts, 12): synthetic minified-shape fixtures, no real hosts or keys (key shapes assembled at run time). URL in a variable plus notice; storage-key signature; URL at 400 KB+ of a 1 MB bundle under default limits; notice and URL both far past the head; sb_secret_, sb_publishable_ and JWT keys; negatives (library strings only, URL only, docs link and placeholders); Base44 unlessAny still holds. 5 of them fail on main. Existing tech-detect (221) and 1254 bundle tests pass. Gates: tsgo in tech-detect and audit-engine, oxlint, make validate.

Docs: docs/cloud/technologies.mdx. CHANGELOG under Unreleased / Fixed. Skill: no change needed.

nik

Real-build tests: tech-supabase-real-build-1379.test.ts (7) builds the real supabase-js (devDependency @supabase/supabase-js 2.118.0 in audit-engine, so bun.lock moves) with Bun.build --minify at test time, around synthetic refs and keys: URL in a variable, sb_secret_ pair, URL past 256 KB of a ~1 MB bundle, URL after 40 earlier placeholder URLs, and negatives (library with no URL, library with a placeholder). 4 fail on main. The >24-earlier-hits cap miss is pinned in the synthetic file (fails at the old cap).

@supabase/supabase-js 2.118.0 is a devDependency of the private packages/audit-engine only (never imported by shipped code); the bun.lock change is that package and its 7 dependencies, nothing else. detect-secrets-hook is clean on bun.lock and the new files.

nc9 added 2 commits October 31, 2026 08:07
… quoted project URL; accept sb_secret_ keys #1379

Signed-off-by: Nik Cubrilovic <[email protected]>
…CHANGELOG under Unreleased #1379

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added 2 commits October 31, 2026 08:14
…118.0 build, built at test time #1379

Signed-off-by: Nik Cubrilovic <[email protected]>
…an match a detector, dedupes repeats, drops ones that cannot #1379

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.146 as 114cafcd 396c8b93 a244399d c76ca88f via #1383. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.146. Closing this original.

nik

@nc9 nc9 closed this Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tech detection misses Supabase in real bundles: URL in a variable, sb_secret_ keys, matches past the bundle byte budget

1 participant