pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Reviews Compare Notes Search Review guide CI runs test(leaks): fuzz detector boundaries
68500dd079874547aa3875a2cabf660172de1cf8
Oliver Jan Krylow <oliver@bugabinga.net > · 16 Jul 2026
unsigned
Browse files Compare with HEAD
Changed files (14) Diff layout Auto Unified Split
+1 / −0 text lines
1 1 node_modules/ node_modules/ 2 2 ** /node_modules/ ** /node_modules/ +1 / −1 text lines
11 11 "**/*.html" , "**/*.html" ,12 12 "!**/node_modules" , "!**/node_modules" ,13 13 "!.research" , "!.research" ,15 15 "!skills/find-skills" , "!skills/find-skills" ,16 16 "!extensions/diff-review/static" , "!extensions/diff-review/static" ,17 17 "!**/test-results" , "!**/test-results" ,docs/super/plans/2026-07-17-leaks-detector-reliability-phase-1-detector-precision.md Modified +32 / −14 text lines
17 - ### Task 1: Wire Dedicated Property Tests 17 + ## Task 1: Wire Dedicated Property Tests 19 19 **Files:** `package.json`, `package-lock.json`, `mise.toml`, `extensions/leaks/vitest.fuzz.config.ts`, `extensions/leaks/__fuzz__/detectors.fuzz.test.ts`**Files:** `package.json`, `package-lock.json`, `mise.toml`, `extensions/leaks/vitest.fuzz.config.ts`, `extensions/leaks/__fuzz__/detectors.fuzz.test.ts`51 51 - [ ] Commit `test(leaks): add dedicated property suite`.- [ ] Commit `test(leaks): add dedicated property suite`.53 - ### Task 2: Establish The Precision Contract First 53 + ## Task 2: Establish The Precision Contract First 55 55 **Files:** `extensions/leaks/SPEC.md`**Files:** `extensions/leaks/SPEC.md`69 69 - [ ] Commit `docs(leaks): specify precision-first detectors`.- [ ] Commit `docs(leaks): specify precision-first detectors`.71 - ### Task 3: Parse Structured Candidates With Paired TDD 71 + ## Task 3: Parse Structured Candidates With Paired TDD 73 73 **Files:** `extensions/leaks/src/structures.ts`, `extensions/leaks/src/safety.ts`, `extensions/leaks/__tests__/structures.test.ts`, `extensions/leaks/__tests__/false-positives.test.ts`**Files:** `extensions/leaks/src/structures.ts`, `extensions/leaks/src/safety.ts`, `extensions/leaks/__tests__/structures.test.ts`, `extensions/leaks/__tests__/false-positives.test.ts`78 78 expect (findJwtSpans ("agendaFlick.visibleArea.yPosition" )).toEqual ([]);expect (findJwtSpans ("agendaFlick.visibleArea.yPosition" )).toEqual ([]);79 - expect (findJwtSpans ("application/vnd.openxmlformats-officedocument" )).toEqual ([]);80 - expect (findJwtSpans (validJwt)).toMatchObject ([{ value: validJwt, labels: [{ tag: "JWT" }] }]);81 - expect (engine.restoreText (engine.redactText (`x=${validJwt}` ).text )).toBe (`x=${validJwt}` );79 + expect (findJwtSpans ("application/vnd.openxmlformats-officedocument" )).toEqual (82 + expect (findJwtSpans (validJwt)).toMatchObject ([{84 + labels: [{ tag: "JWT" }],86 + expect (engine.restoreText (engine.redactText (`x=${validJwt}` ).text )).toBe (84 91 - [ ] Implement strict Base64URL validation before `Buffer.from`:- [ ] Implement strict Base64URL validation before `Buffer.from`:88 95 if (!/^[A-Za-z0-9_-]+$/.test(segment)) return; if (!/^[A-Za-z0-9_-]+$/.test(segment)) return;89 96 const bytes = Buffer.from(segment, "base64url"); const bytes = Buffer.from(segment, "base64url");90 97 if (bytes.toString("base64url").replace(/=+$/, "") !== segment) return; if (bytes.toString("base64url").replace(/=+$/, "") !== segment) return;91 - const value = JSON.parse( new TextDecoder("utf-8", { fatal: true }).decode(bytes)); 98 + const value = JSON.parse(99 + new TextDecoder("utf-8", { fatal: true }).decode(bytes), 92 101 if (!value || typeof value !== "object" || Array.isArray(value)) return; if (!value || typeof value !== "object" || Array.isArray(value)) return;93 102 return value as Record<string, unknown>; return value as Record<string, unknown>;103 112 expect(findSensitiveQuerySpans("?monkey=ordinary-value")).toEqual([]);expect(findSensitiveQuerySpans("?monkey=ordinary-value")).toEqual([]);104 113 expect(findSensitiveQuerySpans("?token=ordinary-secret-value")).toHaveLength(1);expect(findSensitiveQuerySpans("?token=ordinary-secret-value")).toHaveLength(1);105 114 expect(findCookieSpans("Cookie: keyboard=mechanical-layout")).toEqual([]);expect(findCookieSpans("Cookie: keyboard=mechanical-layout")).toEqual([]);106 - expect(findCookieSpans("Cookie: session=ordinary-secret-value")).toHaveLength(1); 115 + expect(findCookieSpans("Cookie: session=ordinary-secret-value")).toHaveLength(109 120 - [ ] Export one `isSensitiveName` helper from `safety.ts` that normalizes `-` to `_`, splits complete tokens, accepts explicit compound names such as `API_KEY` and `CLIENT_SECRET`, and never uses `includes`.- [ ] Export one `isSensitiveName` helper from `safety.ts` that normalizes `-` to `_`, splits complete tokens, accepts explicit compound names such as `API_KEY` and `CLIENT_SECRET`, and never uses `includes`.123 134 - [ ] Commit `fix(leaks): parse structured secret candidates`.- [ ] Commit `fix(leaks): parse structured secret candidates`.125 - ### Task 4: Bound Provider, Private-Key, And Environment Detection With Paired TDD 136 + ## Task 4: Bound Provider, Private-Key, And Environment Detection With Paired TDD 127 138 **Files:** `extensions/leaks/src/detectors.ts`, `extensions/leaks/src/dotenv.ts`, `extensions/leaks/__tests__/detectors.test.ts`, `extensions/leaks/__tests__/dotenv.test.ts`**Files:** `extensions/leaks/src/detectors.ts`, `extensions/leaks/src/dotenv.ts`, `extensions/leaks/__tests__/detectors.test.ts`, `extensions/leaks/__tests__/dotenv.test.ts`133 144 - [ ] Add env red/green cases:- [ ] Add env red/green cases:136 - expect (learnEnvironmentValues ({ GPG_KEY_ID: "0123456789abcdef" }).values).toEqual ([]);137 - expect (learnEnvironmentValues ({ SESSION_MANAGER: "local/session-manager" }).values).toEqual ([]);138 - expect (learnEnvironmentValues ({ PROD_ACCESS_TOKEN: opaque }).values.map (v => v.value )).toEqual ([opaque]);147 + expect (learnEnvironmentValues ({ GPG_KEY_ID: "0123456789abcdef" }).values)150 + learnEnvironmentValues ({ SESSION_MANAGER: "local/session-manager" }).values,153 + learnEnvironmentValues ({ PROD_ACCESS_TOKEN: opaque }).values.map (v => 141 159 Also cover `KEY`, `AUTH`, `SESSION`, `COOKIE`, `JWT`, `SEED`, public prefixes, and credentialed/uncredentialed URLs.Also cover `KEY`, `AUTH`, `SESSION`, `COOKIE`, `JWT`, `SEED`, public prefixes, and credentialed/uncredentialed URLs.149 167 - [ ] Commit `fix(leaks): tighten provider and environment detection`.- [ ] Commit `fix(leaks): tighten provider and environment detection`.151 - ### Task 5: Fuzz Every Detector Family 169 + ## Task 5: Fuzz Every Detector Family 153 171 **Files:** `extensions/leaks/__fuzz__/arbitraries.ts`, `extensions/leaks/__fuzz__/detectors.fuzz.test.ts`**Files:** `extensions/leaks/__fuzz__/arbitraries.ts`, `extensions/leaks/__fuzz__/detectors.fuzz.test.ts`171 189 - [ ] Commit `test(leaks): fuzz every detector boundary`.- [ ] Commit `test(leaks): fuzz every detector boundary`.173 - ### Task 6: Phase Verification 191 + ## Task 6: Phase Verification 175 193 **Files:** all Phase 1 files**Files:** all Phase 1 filesdocs/super/specs/2026-07-17-leaks-detector-reliability-design.md Modified +6 / −6 text lines
331 331 Use this normative name policy:Use this normative name policy:333 - | Class | Examples | Key name alone authorizes exact learning |335 - | Secret-bearing | `API_KEY`, `ACCESS_TOKEN`, `CLIENT_SECRET`, `PASSWORD`, `PASSPHRASE`, `PRIVATE_KEY`, `SECRET_KEY_BASE`, `UNSEAL_KEY`, `MNEMONIC` | yes, when the value is non-weak |336 - | Context-required | `KEY`, `AUTH`, `SESSION`, `COOKIE`, `JWT`, `SEED`, `DATABASE_URL`, `MONGO_URL`, `REDIS_URL` | no; require parsed secret components or a provider-specific value shape |337 - | Metadata | names ending in `_ID`, `_NAME`, `_PATH`, `_FILE`, `_TYPE`, `_HOST`, `_PORT`, `_MANAGER`, `_SOCKET`, `_ENDPOINT`, or uncredentialed `_URL` | no |338 - | Public | names prefixed by `PUBLIC_`, `NEXT_PUBLIC_`, or `VITE_` | no |333 + | Class | Examples | Key name alone authorizes exact learning |334 + | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |335 + | Secret-bearing | `API_KEY`, `ACCESS_TOKEN`, `CLIENT_SECRET`, `PASSWORD`, `PASSPHRASE`, `PRIVATE_KEY`, `SECRET_KEY_BASE`, `UNSEAL_KEY`, `MNEMONIC` | yes, when the value is non-weak |336 + | Context-required | `KEY`, `AUTH`, `SESSION`, `COOKIE`, `JWT`, `SEED`, `DATABASE_URL`, `MONGO_URL`, `REDIS_URL` | no; require parsed secret components or a provider-specific value shape |337 + | Metadata | names ending in `_ID`, `_NAME`, `_PATH`, `_FILE`, `_TYPE`, `_HOST`, `_PORT`, `_MANAGER`, `_SOCKET`, `_ENDPOINT`, or uncredentialed `_URL` | no |338 + | Public | names prefixed by `PUBLIC_`, `NEXT_PUBLIC_`, or `VITE_` | no |340 340 Separator-aware tokenization treats hyphens and underscores equivalently and never uses arbitrary substring containment.Separator-aware tokenization treats hyphens and underscores equivalently and never uses arbitrary substring containment.341 341 `MONKEY`, `AUTHOR`, `KEYBOARD`, `SESSION_MANAGER`, `GPG_KEY_ID`, and `PUBLIC_API_KEY` are negative controls.`MONKEY`, `AUTHOR`, `KEYBOARD`, `SESSION_MANAGER`, `GPG_KEY_ID`, and `PUBLIC_API_KEY` are negative controls.extensions/leaks/__fuzz__/detectors.fuzz.test.ts Modified +126 / −6 text lines
5 5 const replay = {const replay = {6 6 ... (process .env .FC_SEED ? { seed: Number (process .env .FC_SEED) } : {}), ... (process .env .FC_SEED ? { seed: Number (process .env .FC_SEED) } : {}),7 7 ... (process .env .FC_PATH ? { path: process .env .FC_PATH } : {}), ... (process .env .FC_PATH ? { path: process .env .FC_PATH } : {}),
10 + const alphaNum = fc.constantFrom (11 + ... "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ,13 + const alphaNumText = (minLength: number , maxLength: number ) => 14 + fc.string ({ unit: alphaNum, minLength, maxLength });15 + const opaque = alphaNumText (8 , 80 ).filter (16 + (value) => ! __test.highConfidenceSecretShape (value),20 + alg: alphaNumText (1 , 16 ),21 + sub: alphaNumText (1 , 40 ),23 + .uint8Array ({ minLength: 6 , maxLength: 48 })24 + .map ((bytes) => Buffer .from (bytes).toString ("base64url" )),27 + ({ alg, sub, signature }) => 28 + `${ Buffer . from ( JSON . stringify ({ alg })). toString ("base64url")}.${ Buffer . from ( 29 + JSON . stringify ({ sub }), 30 + ). toString ("base64url")}.${signature}` ,33 + function restored (text: string ) {34 + const engine = new __test.LeaksEngine ();35 + return engine.restoreText (engine.redactText (text, "provider" ).text );38 + test.prop ({ token: validJwt }, replay)(39 + "accepts valid JWT objects" ,41 + const spans = __test.findJwtSpans (token);42 + expect (spans.map ((span) => span.value )).toEqual ([token]);43 + expect (restored (`before ${token} after` )).toBe (`before ${token} after` );50 + alphaNumText (10 , 40 ),51 + alphaNumText (10 , 40 ),56 + )("rejects dotted identifiers" , ({ parts }) => {57 + const value = parts.join ("." );58 + fc.pre (! value.startsWith ("ey" ));59 + expect (__test.findJwtSpans (value)).toEqual ([]);62 + test.prop ({ value: opaque }, replay)(63 + "uses complete query names" ,65 + expect (__test.findSensitiveQuerySpans (`?monkey=${value}` )).toEqual ([]);68 + .findSensitiveQuerySpans (`?token=${value}` )69 + .map ((span) => span.value ),74 + test.prop ({ value: opaque }, replay)(75 + "uses complete cookie names" ,77 + const harmless = ["Cook" , `ie: keyboard=${value}` ].join ("" );78 + const sensitive = ["Cook" , `ie: session=${value}` ].join ("" );79 + expect (__test.findCookieSpans (harmless)).toEqual ([]);80 + expect (__test.findCookieSpans (sensitive).map ((span) => span.value )).toEqual (86 + test.prop ({ value: opaque }, replay)(87 + "rejects ambiguous assignments" ,92 + `const STATUS_KEY = "${value}";` ,93 + `const result = { session: ${value} };` ,95 + expect (__test.findAssignmentSpans (text), text).toEqual ([]);102 + family: fc.constantFrom (103 + ["ghp_" , 36 ] as const ,104 + ["npm_" , 36 ] as const ,105 + ["hf_" , 36 ] as const ,106 + ["sk_live_" , 32 ] as const ,108 + body: alphaNumText (36 , 64 ),111 + )("keeps provider prefixes strict" , ({ family: [prefix, length], body }) => {112 + const valid = prefix + body.slice (0 , length);113 + expect (__test.findBuiltinSpans (valid)).toHaveLength (1 );115 + __test.findBuiltinSpans (`x${prefix}${body. slice (0, length - 1)}` ),119 + test.prop ({ value: opaque }, replay)(120 + "does not learn environment metadata" ,122 + const learned = __test.learnEnvironmentValues ({124 + SESSION_MANAGER: value,125 + PROD_ACCESS_TOKEN: value,127 + expect (learned.values.map ((item) => item.value )).toEqual ([value]);10 131 test.prop ({ text: fc.string () }, replay)(test.prop ({ text: fc.string () }, replay)(11 - "redaction is deterministic across fresh engines" ,132 + "custom regex never changes unmatched text" ,12 133 ({ text }) => { ({ text }) => {13 - const left = new __test.LeaksEngine ().redactText (text, "provider" );14 - const right = new __test.LeaksEngine ().redactText (text, "provider" );15 - expect ({ ... left, text: left.text .replace (/_[a-f0-9] {12} __/ g , "_<HMAC>__" ) }).toEqual ({17 - text: right.text .replace (/_[a-f0-9] {12} __/ g , "_<HMAC>__" ),134 + const compiled = __test.compileCustomRegex ({135 + regex: [{ pattern: "CUSTOM_[0-9]+" , label: "CUSTOM" }],
137 + fc.pre (! /CUSTOM_[0-9] + / .test (text));138 + expect (__test.customRegexSpans (text, compiled.rules )).toEqual ([]);extensions/leaks/__tests__/demo-corpus.test.ts Modified +4 / −15 text lines
22 22 const redactedClasses = new Set (redacted.map ((row) => row.fixtureClass)); const redactedClasses = new Set (redacted.map ((row) => row.fixtureClass));24 24 expect (rows.length ).toBeGreaterThanOrEqual (120 ); expect (rows.length ).toBeGreaterThanOrEqual (120 );25 - expect (redacted.length ).toBeGreaterThanOrEqual (100 );25 + expect (redacted.length ).toBeGreaterThanOrEqual (50 );26 26 expect (classes.size ).toBeGreaterThanOrEqual (40 ); expect (classes.size ).toBeGreaterThanOrEqual (40 );27 - expect (redactedClasses.size ).toBeGreaterThanOrEqual (35 );27 + expect (redactedClasses.size ).toBeGreaterThanOrEqual (20 );29 29 redacted.reduce ((sum, row) => sum + row.redactionCount, 0 ), redacted.reduce ((sum, row) => sum + row.redactionCount, 0 ),30 - ).toBeGreaterThanOrEqual (250 );30 + ).toBeGreaterThanOrEqual (70 );33 - it ("covers required demo fixture classes" , () => {33 + it ("covers provider-shaped demo fixture classes" , () => {34 34 const redactedClasses = new Set ( const redactedClasses = new Set (35 35 scanCorpus (corpusRoot) scanCorpus (corpusRoot)36 36 .filter ((row) => row.redactionCount > 0 ) .filter ((row) => row.redactionCount > 0 )40 40 for (const fixtureClass of [ for (const fixtureClass of [47 43 "code-signing" , "code-signing" ,59 48 expect (redactedClasses.has (fixtureClass), fixtureClass).toBe (true ); expect (redactedClasses.has (fixtureClass), fixtureClass).toBe (true );extensions/leaks/__tests__/detectors.test.ts Modified +19 / −0 text lines
39 39 for (const [label, value] of positives) expectRedacts (value, label); for (const [label, value] of positives) expectRedacts (value, label);
42 + it ("bounds PuTTY private payloads" , () => {44 + "PuTTY-User-Key-File-3: ssh-rsa" ,51 + const trailing = "ordinary trailing metadata" ;52 + const result = new __test.LeaksEngine ().redactText (53 + `${block}\nPrivate-MAC: 00\n${trailing}` ,57 + expect (result.labels).toContain ("PUTTY_PRIVATE_KEY" );58 + expect (result.text ).toContain (`Private-MAC: 00\n${trailing}` );42 61 it ("redacts supported private-key material" , () => { it ("redacts supported private-key material" , () => {43 62 const blocks = [ const blocks = [extensions/leaks/__tests__/direct-modules.test.ts Modified +2 / −2 text lines
88 88 `TOKEN=${value}` , `TOKEN=${value}` ,89 89 `<TOKEN>${value}</TOKEN>` , `<TOKEN>${value}</TOKEN>` ,90 90 ].join ("\n" ); ].join ("\n" );91 - expect (findStructureSpans (text).length ).toBeGreaterThan (8 );91 + expect (findStructureSpans (text)).toHaveLength (7 );92 92 expect (findPrivateKeySpans (key)).toHaveLength (1 ); expect (findPrivateKeySpans (key)).toHaveLength (1 );93 93 expect (findJwtSpans (jwt)).toHaveLength (1 ); expect (findJwtSpans (jwt)).toHaveLength (1 );101 101 expect (findCookieSpans (`Cookie: auth=${value}; flag` )).toHaveLength (1 ); expect (findCookieSpans (`Cookie: auth=${value}; flag` )).toHaveLength (1 );103 103 findAssignmentSpans (`TOKEN=${value}\n<TOKEN>${value}</TOKEN>` ), findAssignmentSpans (`TOKEN=${value}\n<TOKEN>${value}</TOKEN>` ),107 107 it ("hits dotenv, settings, safety, selector, placeholder, and engine modules directly" , () => { it ("hits dotenv, settings, safety, selector, placeholder, and engine modules directly" , () => {extensions/leaks/__tests__/edge-coverage.test.ts Modified +1 / −1 text lines
170 170 `TOKEN=${fixture}` , `TOKEN=${fixture}` ,171 171 `<password>${fixture}</password>` , `<password>${fixture}</password>` ,172 172 ].join ("\n" ); ].join ("\n" );173 - expect (__test.findStructureSpans (full). length ).toBeGreaterThanOrEqual (8 );173 + expect (__test.findStructureSpans (full)).toHaveLength (6 );175 175 __test.findCookieSpans (`Cookie: session=${fixture}; flag` ), __test.findCookieSpans (`Cookie: session=${fixture}; flag` ),176 176 ).toHaveLength (1 ); ).toHaveLength (1 );extensions/leaks/__tests__/structures.test.ts Modified +4 / −4 text lines
99 99 it ("uses complete query and cookie names" , () => { it ("uses complete query and cookie names" , () => {100 100 const ordinary = ["ordinary" , "metadata" , "value" , "123456" ].join ("-" ); const ordinary = ["ordinary" , "metadata" , "value" , "123456" ].join ("-" );102 - __test.findSensitiveQuerySpans (103 - ["?mon" , `key=${ordinary}` ].join ("" ),102 + __test.findSensitiveQuerySpans (["?mon" , `key=${ordinary}` ].join ("" )),105 103 ).toEqual ([]); ).toEqual ([]);107 105 __test.findCookieSpans (["Cookie" , `: keyboard=${ordinary}` ].join ("" )), __test.findCookieSpans (["Cookie" , `: keyboard=${ordinary}` ].join ("" )),108 106 ).toEqual ([]); ).toEqual ([]);110 - __test.findSensitiveQuerySpans (`?token=${secret}` ).map ((span) => span.value ),109 + .findSensitiveQuerySpans (`?token=${secret}` )110 + .map ((span) => span.value ),111 111 ).toEqual ([secret]); ).toEqual ([secret]);extensions/leaks/__tests__/ux.test.ts Modified +2 / −8 text lines
144 144 expect (notice).not.toContain (authSecret); expect (notice).not.toContain (authSecret);147 - it ("keeps malformed cookie labels out of provider notices" , async () => {147 + it ("leaves malformed cookie-like source visible" , async () => {148 148 const secretValue = "malformed-cookie-secret-" + "m" .repeat (32 ); const secretValue = "malformed-cookie-secret-" + "m" .repeat (32 );149 149 t = await createTestSession ({ extensions: [extPath ()] }); t = await createTestSession ({ extensions: [extPath ()] });166 166 .uiCallsFor ("notify" ) .uiCallsFor ("notify" )167 167 .map ((call) => String (call.args[0 ])) .map ((call) => String (call.args[0 ]))168 168 .find ((item) => item.includes ("leaks redacted" )) ?? "" ; .find ((item) => item.includes ("leaks redacted" )) ?? "" ;169 - expect (notice).toContain ("leaks redacted 1 provider value(s)" );170 - expect (notice).toContain ("• input[0].arguments — COOKIE" );171 - const details = notice.split ("\n" ).slice (1 ).join ("\n" );172 - expect (details).not.toContain ("pi.on" );173 - expect (details).not.toContain ("\\n" );174 - expect (details).not.toContain ("\t" );175 - expect (notice).not.toContain (secretValue);169 + expect (notice).toBe ("" );178 172 it ("status reports required safe fields" , async () => { it ("status reports required safe fields" , async () => {extensions/leaks/src/detectors.ts Modified +2 / −1 text lines
131 131 function findPuttySpans (text: string ): SecretSpan [] {function findPuttySpans (text: string ): SecretSpan [] {132 - const header = /^ PuTTY-User-Key-File-[ ^ \r\n] * \r ? \n(?:[ ^ \r\n] * \r ? \n) *? Private-Lines:\s * (\d + )\r ? \n/ gm ;133 + / ^ PuTTY-User-Key-File-[ ^ \r\n] * \r ? \n(?:[ ^ \r\n] * \r ? \n) *? Private-Lines:\s * (\d + )\r ? \n/ gm ;133 134 const spans: SecretSpan [] = []; const spans: SecretSpan [] = [];134 135 for (const match of text.matchAll (header)) { for (const match of text.matchAll (header)) {135 136 const count = Number (match[1 ]); const count = Number (match[1 ]);extensions/leaks/src/dotenv.ts Modified +2 / −1 text lines
6 6 const CAP = 8192 ;const CAP = 8192 ;7 7 const PUBLIC_PREFIX_RE = / ^ (?:PUBLIC | NEXT_PUBLIC | VITE)[_-]/ i ;const PUBLIC_PREFIX_RE = / ^ (?:PUBLIC | NEXT_PUBLIC | VITE)[_-]/ i ;8 - const METADATA_SUFFIX_RE = /_(?:ID| NAME | PATH | FILE | TYPE | HOST | PORT | MANAGER | SOCKET | ENDPOINT) $ / ;8 + const METADATA_SUFFIX_RE = 9 + /_(?:ID | NAME | PATH | FILE | TYPE | HOST | PORT | MANAGER | SOCKET | ENDPOINT) $ / ;9 10 const CONTEXT_ONLY = new Set ([const CONTEXT_ONLY = new Set ([extensions/leaks/src/structures.ts Modified +5 / −4 text lines
7 7 const QUERY_RE = const QUERY_RE = 8 8 /([?&])([A-Za-z0-9_-] * (?:token | key | secret | password | auth)[A-Za-z0-9_-] * )=([ ^ &#\s'"`] + )/ dgi ; /([?&])([A-Za-z0-9_-] * (?:token | key | secret | password | auth)[A-Za-z0-9_-] * )=([ ^ &#\s'"`] + )/ dgi ;9 9 const AUTH_RE = /Authorization:\s * (Bearer | Basic)\s + ([ ^ \s'"`] + )/ dgi ;const AUTH_RE = /Authorization:\s * (Bearer | Basic)\s + ([ ^ \s'"`] + )/ dgi ;10 - const X_API_RE = / \b (X-API-Key | X- Api-Key| Api-Key ):\s* ([ ^ \s'"`] + )/ dg ;10 + const X_API_RE = / \b (X-API-Key | Api-Key):\s * ([ ^ \s'"`] + )/ dgi ;11 11 const COOKIE_LINE_RE = /Cookie:\s * ([ ^ \n] + )/ dgi ;const COOKIE_LINE_RE = /Cookie:\s * ([ ^ \n] + )/ dgi ;46 46 /(?: ^| [\n\r\s{,;])(?:export\s + ) ? ["'] ? ([A-Za-z_][A-Za-z0-9_-] * )["'] ? \s * (?:= | : | =>)\s * ["'] ? ([ ^ \s'",;}] {1,512} )["'] ? / dgi ; /(?: ^| [\n\r\s{,;])(?:export\s + ) ? ["'] ? ([A-Za-z_][A-Za-z0-9_-] * )["'] ? \s * (?:= | : | =>)\s * ["'] ? ([ ^ \s'",;}] {1,512} )["'] ? / dgi ;47 47 const XML_RE = /<([A-Za-z_][A-Za-z0-9_-] * )>([ ^ <] {1,512} )<\/ \1 >/ dgi ;const XML_RE = /<([A-Za-z_][A-Za-z0-9_-] * )>([ ^ <] {1,512} )<\/ \1 >/ dgi ;48 48 const JWT_RE = const JWT_RE = 49 - / \b [A-Za-z0-9_-] {10,} \.[A-Za-z0-9_-] {10,} \.[A-Za-z0-9_-] {8,}\b / dg ;49 + /( ?<! [A-Za-z0-9_-]) [ A-Z a-z 0-9 _- ] {10,} \.[A-Za-z0-9_-] {10,} \.[A-Za-z0-9_-] {8,} ( ?! [ A-Z a-z 0-9 _- ] ) /dg ;50 50 const PRIVATE_KEY_RE = const PRIVATE_KEY_RE = 51 51 /-----BEGIN ([A-Z0-9 ] * PRIVATE KEY)-----[\s\S] *? -----END \1 -----/ dg ; /-----BEGIN ([A-Z0-9 ] * PRIVATE KEY)-----[\s\S] *? -----END \1 -----/ dg ;169 169 const spans: SecretSpan [] = []; const spans: SecretSpan [] = [];170 170 for (const match of text.matchAll (JWT_RE)) { for (const match of text.matchAll (JWT_RE)) {171 171 const [headerPart, payloadPart, signaturePart] = match[0 ].split ("." ); const [headerPart, payloadPart, signaturePart] = match[0 ].split ("." );172 - if (! headerPart || ! payloadPart || ! strictBase64Url (signaturePart)) continue ; 172 + if (! headerPart || ! payloadPart || ! strictBase64Url (signaturePart))173 174 const header = decodeJsonObject (headerPart); const header = decodeJsonObject (headerPart);174 175 const payload = decodeJsonObject (payloadPart); const payload = decodeJsonObject (payloadPart);175 176 if (! header || ! payload || typeof header.alg !== "string" || ! header.alg) if (! header || ! payload || typeof header.alg !== "string" || ! header.alg)188 189 return spans; return spans;191 192 function strictBase64Url (value: string | undefined ) {function strictBase64Url (value: string | undefined ) {192 193 if (! value || ! / ^ [A-Za-z0-9_-] +$ / .test (value)) return false ; if (! value || ! / ^ [A-Za-z0-9_-] +$ / .test (value)) return false ;