@sema-agent/primitives 7.67.3 → 7.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -21
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/redaction-marks.d.ts +49 -0
- package/dist/redaction-marks.js +40 -0
- package/dist/secret-scan.d.ts +69 -52
- package/dist/secret-scan.js +210 -98
- package/dist/secret-vocabulary.d.ts +39 -5
- package/dist/secret-vocabulary.js +28 -21
- package/package.json +2 -2
|
@@ -18,13 +18,15 @@
|
|
|
18
18
|
*
|
|
19
19
|
* A family's strict, wide, fragment and env forms live on the SAME row, and every text the strict form matches the wide
|
|
20
20
|
* form matches too (machine-judged over the fixture file by `scripts/verify-credential-vocabulary.mjs`): the two faces may
|
|
21
|
-
* differ in floors, never in vocabulary. Detection is shared
|
|
22
|
-
* value stands beside (a keyword ahead of `=`, a URL parameter) are one
|
|
21
|
+
* differ in floors, never in vocabulary. Detection is shared, and so is the mark a hit writes: each row names its member
|
|
22
|
+
* of the marks table (`mark`). The credential NAMES a value stands beside (a keyword ahead of `=`, a URL parameter) are one
|
|
23
|
+
* list too ({@link CredentialVocabulary.names}).
|
|
23
24
|
*
|
|
24
|
-
* The table holds no layer's policy: which form a reader reads, how a text is read first
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* The table holds no layer's policy: which form a reader reads, how a text is read first and whether a URL's username is
|
|
26
|
+
* kept are the caller's, passed in whole (`SecretScanPolicy` in secret-scan.ts). No value imports by design: the gate reads
|
|
27
|
+
* this module alone (the one import is a type, erased when it is compiled).
|
|
27
28
|
*/
|
|
29
|
+
import type { RedactionMarkName } from "./redaction-marks.js";
|
|
28
30
|
/** How sure a detection is. */
|
|
29
31
|
export type RedactionConfidence = "high" | "medium" | "low";
|
|
30
32
|
/** Which rule table a finding names as its minter. A closed set: a report's entries can only have been written by
|
|
@@ -39,6 +41,12 @@ export interface ValueFamilyRow<Id extends string = CredentialFamilyId> {
|
|
|
39
41
|
readonly kind: string;
|
|
40
42
|
readonly source: RedactionSource;
|
|
41
43
|
readonly confidence: RedactionConfidence;
|
|
44
|
+
/** The mark a hit of this row writes, by its name in the marks table (redaction-marks.ts): `bare` where the text around the
|
|
45
|
+
* value says what it is (a kept label or name, a scheme word, a kept webhook head), else the kind the row reads by shape —
|
|
46
|
+
* the vendor's own word (`gh-token`, `aws-key`, `slack-token`, `private-key`) or `key`; the URL userinfo row names
|
|
47
|
+
* `userinfo`, the mark of a userinfo withheld whole (one whose username is kept writes `bare`). The fragment grade writes
|
|
48
|
+
* the name's `:partial` member. Required: a row names its mark, nothing infers it. */
|
|
49
|
+
readonly mark: Exclude<RedactionMarkName, `${string}:partial`>;
|
|
42
50
|
/** The wide form (egress), global. A capture group 1, when the form has one, is a label kept verbatim ahead of the
|
|
43
51
|
* marker (`AccountKey=`, `api_key=`). */
|
|
44
52
|
readonly match: RegExp;
|
|
@@ -166,6 +174,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
166
174
|
readonly kind: "prefixed-token";
|
|
167
175
|
readonly source: "arg-summary";
|
|
168
176
|
readonly confidence: "high";
|
|
177
|
+
readonly mark: "gh-token";
|
|
169
178
|
readonly pass: "vendor-prefixed";
|
|
170
179
|
readonly match: RegExp;
|
|
171
180
|
readonly strict: RegExp;
|
|
@@ -176,6 +185,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
176
185
|
readonly kind: "prefixed-token";
|
|
177
186
|
readonly source: "arg-summary";
|
|
178
187
|
readonly confidence: "high";
|
|
188
|
+
readonly mark: "gh-token";
|
|
179
189
|
readonly pass: "vendor-prefixed";
|
|
180
190
|
readonly match: RegExp;
|
|
181
191
|
readonly strict: RegExp;
|
|
@@ -186,6 +196,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
186
196
|
readonly kind: "prefixed-token";
|
|
187
197
|
readonly source: "arg-summary";
|
|
188
198
|
readonly confidence: "high";
|
|
199
|
+
readonly mark: "key";
|
|
189
200
|
readonly pass: "vendor-prefixed";
|
|
190
201
|
readonly match: RegExp;
|
|
191
202
|
readonly strict: RegExp;
|
|
@@ -196,6 +207,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
196
207
|
readonly kind: "prefixed-token";
|
|
197
208
|
readonly source: "arg-summary";
|
|
198
209
|
readonly confidence: "high";
|
|
210
|
+
readonly mark: "key";
|
|
199
211
|
readonly pass: "vendor-prefixed";
|
|
200
212
|
readonly match: RegExp;
|
|
201
213
|
readonly strict: RegExp;
|
|
@@ -205,6 +217,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
205
217
|
readonly kind: "prefixed-token";
|
|
206
218
|
readonly source: "arg-summary";
|
|
207
219
|
readonly confidence: "high";
|
|
220
|
+
readonly mark: "key";
|
|
208
221
|
readonly pass: "vendor-prefixed";
|
|
209
222
|
readonly match: RegExp;
|
|
210
223
|
readonly envValueHead: RegExp;
|
|
@@ -213,6 +226,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
213
226
|
readonly kind: "prefixed-token";
|
|
214
227
|
readonly source: "arg-summary";
|
|
215
228
|
readonly confidence: "high";
|
|
229
|
+
readonly mark: "key";
|
|
216
230
|
readonly pass: "vendor-prefixed";
|
|
217
231
|
readonly match: RegExp;
|
|
218
232
|
readonly strict: RegExp;
|
|
@@ -223,6 +237,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
223
237
|
readonly kind: "prefixed-token";
|
|
224
238
|
readonly source: "arg-summary";
|
|
225
239
|
readonly confidence: "high";
|
|
240
|
+
readonly mark: "key";
|
|
226
241
|
readonly pass: "vendor-prefixed";
|
|
227
242
|
readonly match: RegExp;
|
|
228
243
|
readonly envValueHead: RegExp;
|
|
@@ -231,6 +246,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
231
246
|
readonly kind: "prefixed-token";
|
|
232
247
|
readonly source: "arg-summary";
|
|
233
248
|
readonly confidence: "high";
|
|
249
|
+
readonly mark: "key";
|
|
234
250
|
readonly pass: "vendor-prefixed";
|
|
235
251
|
readonly match: RegExp;
|
|
236
252
|
readonly envValueHead: RegExp;
|
|
@@ -239,6 +255,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
239
255
|
readonly kind: "prefixed-token";
|
|
240
256
|
readonly source: "arg-summary";
|
|
241
257
|
readonly confidence: "high";
|
|
258
|
+
readonly mark: "key";
|
|
242
259
|
readonly pass: "vendor-prefixed";
|
|
243
260
|
readonly match: RegExp;
|
|
244
261
|
readonly strict: RegExp;
|
|
@@ -248,6 +265,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
248
265
|
readonly kind: "prefixed-token";
|
|
249
266
|
readonly source: "arg-summary";
|
|
250
267
|
readonly confidence: "high";
|
|
268
|
+
readonly mark: "key";
|
|
251
269
|
readonly match: RegExp;
|
|
252
270
|
readonly strict: RegExp;
|
|
253
271
|
}, {
|
|
@@ -255,6 +273,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
255
273
|
readonly kind: "prefixed-token";
|
|
256
274
|
readonly source: "arg-summary";
|
|
257
275
|
readonly confidence: "high";
|
|
276
|
+
readonly mark: "slack-token";
|
|
258
277
|
readonly match: RegExp;
|
|
259
278
|
readonly strict: RegExp;
|
|
260
279
|
readonly fragment: RegExp;
|
|
@@ -264,6 +283,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
264
283
|
readonly kind: "prefixed-token";
|
|
265
284
|
readonly source: "arg-summary";
|
|
266
285
|
readonly confidence: "high";
|
|
286
|
+
readonly mark: "slack-token";
|
|
267
287
|
readonly match: RegExp;
|
|
268
288
|
readonly strict: RegExp;
|
|
269
289
|
readonly fragment: RegExp;
|
|
@@ -272,6 +292,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
272
292
|
readonly kind: "prefixed-token";
|
|
273
293
|
readonly source: "arg-summary";
|
|
274
294
|
readonly confidence: "high";
|
|
295
|
+
readonly mark: "aws-key";
|
|
275
296
|
readonly match: RegExp;
|
|
276
297
|
readonly strict: RegExp;
|
|
277
298
|
readonly fragment: RegExp;
|
|
@@ -281,6 +302,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
281
302
|
readonly kind: "prefixed-token";
|
|
282
303
|
readonly source: "arg-summary";
|
|
283
304
|
readonly confidence: "high";
|
|
305
|
+
readonly mark: "key";
|
|
284
306
|
readonly match: RegExp;
|
|
285
307
|
readonly strict: RegExp;
|
|
286
308
|
}, {
|
|
@@ -288,6 +310,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
288
310
|
readonly kind: "jwt";
|
|
289
311
|
readonly source: "arg-summary";
|
|
290
312
|
readonly confidence: "high";
|
|
313
|
+
readonly mark: "key";
|
|
291
314
|
readonly match: RegExp;
|
|
292
315
|
readonly strict: RegExp;
|
|
293
316
|
readonly envValueHead: RegExp;
|
|
@@ -296,6 +319,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
296
319
|
readonly kind: "private-key-block";
|
|
297
320
|
readonly source: "arg-summary";
|
|
298
321
|
readonly confidence: "high";
|
|
322
|
+
readonly mark: "private-key";
|
|
299
323
|
readonly match: RegExp;
|
|
300
324
|
readonly strict: RegExp;
|
|
301
325
|
readonly envValue: RegExp;
|
|
@@ -304,6 +328,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
304
328
|
readonly kind: "bearer-token";
|
|
305
329
|
readonly source: "arg-summary";
|
|
306
330
|
readonly confidence: "high";
|
|
331
|
+
readonly mark: "bare";
|
|
307
332
|
readonly match: RegExp;
|
|
308
333
|
readonly strict: RegExp;
|
|
309
334
|
readonly envValue: RegExp;
|
|
@@ -312,6 +337,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
312
337
|
readonly kind: "authorization-header";
|
|
313
338
|
readonly source: "arg-summary";
|
|
314
339
|
readonly confidence: "high";
|
|
340
|
+
readonly mark: "bare";
|
|
315
341
|
readonly match: RegExp;
|
|
316
342
|
readonly envValue: RegExp;
|
|
317
343
|
}, {
|
|
@@ -319,12 +345,14 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
319
345
|
readonly kind: "scheme-credential";
|
|
320
346
|
readonly source: "arg-summary";
|
|
321
347
|
readonly confidence: "high";
|
|
348
|
+
readonly mark: "bare";
|
|
322
349
|
readonly match: RegExp;
|
|
323
350
|
}, {
|
|
324
351
|
readonly id: "token-scheme";
|
|
325
352
|
readonly kind: "scheme-credential";
|
|
326
353
|
readonly source: "arg-summary";
|
|
327
354
|
readonly confidence: "high";
|
|
355
|
+
readonly mark: "bare";
|
|
328
356
|
readonly match: RegExp;
|
|
329
357
|
readonly envValue: RegExp;
|
|
330
358
|
}, {
|
|
@@ -332,6 +360,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
332
360
|
readonly kind: "prefixed-token";
|
|
333
361
|
readonly source: "arg-summary";
|
|
334
362
|
readonly confidence: "high";
|
|
363
|
+
readonly mark: "bare";
|
|
335
364
|
readonly match: RegExp;
|
|
336
365
|
readonly strict: RegExp;
|
|
337
366
|
}, {
|
|
@@ -339,6 +368,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
339
368
|
readonly kind: "keyword-value";
|
|
340
369
|
readonly source: "arg-summary";
|
|
341
370
|
readonly confidence: "medium";
|
|
371
|
+
readonly mark: "bare";
|
|
342
372
|
readonly match: RegExp;
|
|
343
373
|
readonly envValue: RegExp;
|
|
344
374
|
}, {
|
|
@@ -346,6 +376,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
346
376
|
readonly kind: "keyword-value";
|
|
347
377
|
readonly source: "arg-summary";
|
|
348
378
|
readonly confidence: "high";
|
|
379
|
+
readonly mark: "bare";
|
|
349
380
|
readonly match: RegExp;
|
|
350
381
|
readonly envValue: RegExp;
|
|
351
382
|
}, {
|
|
@@ -353,12 +384,14 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
353
384
|
readonly kind: "url-credentials";
|
|
354
385
|
readonly source: "untrusted-egress";
|
|
355
386
|
readonly confidence: "medium";
|
|
387
|
+
readonly mark: "userinfo";
|
|
356
388
|
readonly match: RegExp;
|
|
357
389
|
}, {
|
|
358
390
|
readonly id: "webhook-url";
|
|
359
391
|
readonly kind: "webhook-url";
|
|
360
392
|
readonly source: "untrusted-egress";
|
|
361
393
|
readonly confidence: "high";
|
|
394
|
+
readonly mark: "bare";
|
|
362
395
|
readonly match: RegExp;
|
|
363
396
|
readonly envValue: RegExp;
|
|
364
397
|
}, {
|
|
@@ -366,6 +399,7 @@ declare const VALUE_FAMILY_ROWS: readonly [{
|
|
|
366
399
|
readonly kind: "signed-url-param";
|
|
367
400
|
readonly source: "untrusted-egress";
|
|
368
401
|
readonly confidence: "high";
|
|
402
|
+
readonly mark: "bare";
|
|
369
403
|
readonly match: RegExp;
|
|
370
404
|
}];
|
|
371
405
|
/** A value family's id: the closed set of the vocabulary's rows, so a table keyed by family is checked against it. */
|
|
@@ -27,7 +27,8 @@ const URL_USERINFO_SOURCE = String.raw `[^/\s"]*` + repeated(String.raw `"(?!${A
|
|
|
27
27
|
const USERINFO_WORD_START = String.raw `(?<![^\s"])`;
|
|
28
28
|
const USERINFO_FRONT = String.raw `${URI_SCHEME_SOURCE}:\/\/|(?<!${SCHEME_CHAR})(?:https?|wss?|ftp):\/?(?!\/)|${USERINFO_WORD_START}\/\/`;
|
|
29
29
|
const FRONTLESS_HOST = String.raw `(?:\[[0-9A-Fa-f:.]+\]|[^\s/@:"'\`]+)(?::[0-9]{1,5}(?![0-9A-Za-z_])|\/)`;
|
|
30
|
-
const
|
|
30
|
+
const FRONTLESS_PASSWORD_START = String.raw `(?=[^\\/"']|${[`"`, `'`].map((q) => String.raw `${q}[^${q}"\s/]*${q}@(?=${FRONTLESS_HOST})`).join("|")})`;
|
|
31
|
+
const FRONTLESS_USERINFO = String.raw `(?!(?:mailto|sips?|xmpp|im|acct):)[^\s/@:"]+:${FRONTLESS_PASSWORD_START}${URL_USERINFO_SOURCE}(?<=[^:]@)(?=${FRONTLESS_HOST})`;
|
|
31
32
|
const VALUE_RUN_END = `(?:(?<!\\\\)|(?!\\\\{0,${ESCAPE_DEPTH}}["']))`;
|
|
32
33
|
const GLUED_RUN = `${VALUE_CHAR}*${VALUE_RUN_END}`;
|
|
33
34
|
const pairedValue = (open, close) => `${open}(?!${AFTER_CLOSING_QUOTE})[^\\n]{0,${QUOTED_VALUE_MAX}}?${close}`;
|
|
@@ -131,26 +132,27 @@ const STRUCTURED_KEY_NAME = (() => {
|
|
|
131
132
|
const WEBHOOK_HEAD = String.raw `https:\/\/(?:hooks\.slack\.com\/(?:services|workflows|triggers)\/|(?:ptb\.|canary\.)?discord(?:app)?\.com\/api\/webhooks\/\d+\/|[\w.-]+\.webhook\.office\.com\/webhookb2\/)`;
|
|
132
133
|
const WEBHOOK_PATH = atLeast(String.raw `[\w\/@.~-]`, 16);
|
|
133
134
|
const VALUE_FAMILY_ROWS = [
|
|
134
|
-
{ id: "github-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: unheaded(`gh[opsur][-_]${VENDOR_BODY}`), strict: new RegExp(String.raw `(?:ghp|gho|ghu|ghs|ghr)_${atLeast("[A-Za-z0-9]", 36)}\b`), fragment: headed(residue("(?:ghp|gho|ghu|ghs|ghr)_", "[A-Za-z0-9]", 8)), envValueHead: /gh[opusr]_/ },
|
|
135
|
-
{ id: "github-fine-grained-pat", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: unheaded(`github_pat[-_]${VENDOR_BODY}`), strict: new RegExp(String.raw `github_pat_${atLeast("[A-Za-z0-9_]", 60)}\b`), fragment: new RegExp(`github_pat_${atLeast("[A-Za-z0-9_]", 8)}`, "g"), envValueHead: /github_pat_/ },
|
|
136
|
-
{ id: "openai-api-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`sk-${VENDOR_BODY}`), strict: new RegExp(String.raw `\bsk-(?:ant-(?:api03-)?|proj-)?${atLeast("[A-Za-z0-9_]", 20)}\b`), fragment: headed(residue("sk-", "[A-Za-z0-9_-]", 6)), envValueHead: /sk-/ },
|
|
137
|
-
{ id: "stripe-secret-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`(?:sk_|rk[-_])${VENDOR_BODY}`), strict: new RegExp(String.raw `\b[sr]k_(?:live|test|org)_${atLeast("[A-Za-z0-9]", 24)}\b`), fragment: headed(residue("(?:sk|rk)_(?:live|test|org)_", "[A-Za-z0-9_-]", 8)) },
|
|
138
|
-
{ id: "stripe-publishable-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`pk[-_]${VENDOR_BODY}`), envValueHead: /pk-/ },
|
|
139
|
-
{ id: "gitlab-pat", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: unheaded(`${GITLAB_HEAD}${atLeast("[A-Za-z0-9_-]", 20)}`), strict: new RegExp(String.raw `${GITLAB_HEAD}(?=[A-Za-z0-9_]*[0-9])${atLeast("[A-Za-z0-9_]", 20)}\b`), fragment: headed(residue(GITLAB_HEAD, "[A-Za-z0-9_-]", 8)), envValueHead: /glpat-/ },
|
|
140
|
-
{ id: "npm-access-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`npm_${atLeast("[A-Za-z0-9]", 36)}`), envValueHead: /npm_/ },
|
|
141
|
-
{ id: "google-oauth-access-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(String.raw `ya29\.${atLeast("[A-Za-z0-9_.-]", 20)}`), envValueHead: /ya29\./ },
|
|
142
|
-
{ id: "pypi-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`pypi-${atLeast("[A-Za-z0-9_-]", 85)}`), strict: new RegExp(String.raw `\bpypi-(?=[A-Za-z0-9_-]*[0-9])${atLeast("[A-Za-z0-9_-]", 85)}`), fragment: headed(residue("pypi-", "[A-Za-z0-9_-]", 8)) },
|
|
143
|
-
{ id: "google-api-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed(`AIza${atLeast("[A-Za-z0-9_-]", 20)}`), strict: /\bAIza[0-9A-Za-z_-]{35}\b/ },
|
|
144
|
-
{ id: "slack-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed(`xox[baprse]-${atLeast("[A-Za-z0-9_-]", 10)}`), strict: new RegExp(String.raw `\bxox[baprse]-${repeated("(?:[A-Za-z0-9]+-)", 1, 3)}${atLeast("[A-Za-z0-9]", 16)}\b`), fragment: headed(residue("xox[baprse]-", "[A-Za-z0-9-]", 4)), envValueHead: /xox[abpr]-/ },
|
|
145
|
-
{ id: "slack-app-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed(String.raw `xapp-\d-${atLeast("[A-Za-z0-9_-]", 20)}`), strict: new RegExp(String.raw `\bxapp-\d-(?=[A-Za-z0-9-]{20})${repeated("(?:[A-Za-z0-9]+-)", 1, 3)}(?=[A-Za-z0-9]*[0-9])${atLeast("[A-Za-z0-9]", 16)}\b`), fragment: headed(residue(String.raw `xapp-\d-`, "[A-Za-z0-9-]", 4)) },
|
|
146
|
-
{ id: "aws-access-key-id", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed(`(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)${atLeast("[0-9A-Z]", 12)}`), strict: /AKIA[0-9A-Z]{16}\b/, fragment: headed(`(?:${residue("AKIA", "[0-9A-Z]", 6)}|${residue("ASIA", "[0-9A-Z]", 8)})`), envValueHead: /AKIA/ },
|
|
147
|
-
{ id: "huggingface-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed(`hf_${atLeast("[A-Za-z0-9]", 20)}`), strict: new RegExp(String.raw `\bhf_(?=[A-Za-z0-9]*[0-9])${atLeast("[A-Za-z0-9]", 20)}\b`) },
|
|
148
|
-
{ id: "jwt", kind: "jwt", source: "arg-summary", confidence: "high", match: headed(`eyJ${atLeast("[A-Za-z0-9._-]", 20)}`), strict: new RegExp(String.raw `\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.${atLeast("[A-Za-z0-9_-]", 16)}\b`), envValueHead: /eyJ/ },
|
|
135
|
+
{ id: "github-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "gh-token", pass: "vendor-prefixed", match: unheaded(`gh[opsur][-_]${VENDOR_BODY}`), strict: new RegExp(String.raw `(?:ghp|gho|ghu|ghs|ghr)_${atLeast("[A-Za-z0-9]", 36)}\b`), fragment: headed(residue("(?:ghp|gho|ghu|ghs|ghr)_", "[A-Za-z0-9]", 8)), envValueHead: /gh[opusr]_/ },
|
|
136
|
+
{ id: "github-fine-grained-pat", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "gh-token", pass: "vendor-prefixed", match: unheaded(`github_pat[-_]${VENDOR_BODY}`), strict: new RegExp(String.raw `github_pat_${atLeast("[A-Za-z0-9_]", 60)}\b`), fragment: new RegExp(`github_pat_${atLeast("[A-Za-z0-9_]", 8)}`, "g"), envValueHead: /github_pat_/ },
|
|
137
|
+
{ id: "openai-api-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: headed(`sk-${VENDOR_BODY}`), strict: new RegExp(String.raw `\bsk-(?:ant-(?:api03-)?|proj-)?${atLeast("[A-Za-z0-9_]", 20)}\b`), fragment: headed(residue("sk-", "[A-Za-z0-9_-]", 6)), envValueHead: /sk-/ },
|
|
138
|
+
{ id: "stripe-secret-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: headed(`(?:sk_|rk[-_])${VENDOR_BODY}`), strict: new RegExp(String.raw `\b[sr]k_(?:live|test|org)_${atLeast("[A-Za-z0-9]", 24)}\b`), fragment: headed(residue("(?:sk|rk)_(?:live|test|org)_", "[A-Za-z0-9_-]", 8)) },
|
|
139
|
+
{ id: "stripe-publishable-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: headed(`pk[-_]${VENDOR_BODY}`), envValueHead: /pk-/ },
|
|
140
|
+
{ id: "gitlab-pat", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: unheaded(`${GITLAB_HEAD}${atLeast("[A-Za-z0-9_-]", 20)}`), strict: new RegExp(String.raw `${GITLAB_HEAD}(?=[A-Za-z0-9_]*[0-9])${atLeast("[A-Za-z0-9_]", 20)}\b`), fragment: headed(residue(GITLAB_HEAD, "[A-Za-z0-9_-]", 8)), envValueHead: /glpat-/ },
|
|
141
|
+
{ id: "npm-access-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: headed(`npm_${atLeast("[A-Za-z0-9]", 36)}`), envValueHead: /npm_/ },
|
|
142
|
+
{ id: "google-oauth-access-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: headed(String.raw `ya29\.${atLeast("[A-Za-z0-9_.-]", 20)}`), envValueHead: /ya29\./ },
|
|
143
|
+
{ id: "pypi-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", pass: "vendor-prefixed", match: headed(`pypi-${atLeast("[A-Za-z0-9_-]", 85)}`), strict: new RegExp(String.raw `\bpypi-(?=[A-Za-z0-9_-]*[0-9])${atLeast("[A-Za-z0-9_-]", 85)}`), fragment: headed(residue("pypi-", "[A-Za-z0-9_-]", 8)) },
|
|
144
|
+
{ id: "google-api-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", match: headed(`AIza${atLeast("[A-Za-z0-9_-]", 20)}`), strict: /\bAIza[0-9A-Za-z_-]{35}\b/ },
|
|
145
|
+
{ id: "slack-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "slack-token", match: headed(`xox[baprse]-${atLeast("[A-Za-z0-9_-]", 10)}`), strict: new RegExp(String.raw `\bxox[baprse]-${repeated("(?:[A-Za-z0-9]+-)", 1, 3)}${atLeast("[A-Za-z0-9]", 16)}\b`), fragment: headed(residue("xox[baprse]-", "[A-Za-z0-9-]", 4)), envValueHead: /xox[abpr]-/ },
|
|
146
|
+
{ id: "slack-app-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "slack-token", match: headed(String.raw `xapp-\d-${atLeast("[A-Za-z0-9_-]", 20)}`), strict: new RegExp(String.raw `\bxapp-\d-(?=[A-Za-z0-9-]{20})${repeated("(?:[A-Za-z0-9]+-)", 1, 3)}(?=[A-Za-z0-9]*[0-9])${atLeast("[A-Za-z0-9]", 16)}\b`), fragment: headed(residue(String.raw `xapp-\d-`, "[A-Za-z0-9-]", 4)) },
|
|
147
|
+
{ id: "aws-access-key-id", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "aws-key", match: headed(`(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)${atLeast("[0-9A-Z]", 12)}`), strict: /AKIA[0-9A-Z]{16}\b/, fragment: headed(`(?:${residue("AKIA", "[0-9A-Z]", 6)}|${residue("ASIA", "[0-9A-Z]", 8)})`), envValueHead: /AKIA/ },
|
|
148
|
+
{ id: "huggingface-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "key", match: headed(`hf_${atLeast("[A-Za-z0-9]", 20)}`), strict: new RegExp(String.raw `\bhf_(?=[A-Za-z0-9]*[0-9])${atLeast("[A-Za-z0-9]", 20)}\b`) },
|
|
149
|
+
{ id: "jwt", kind: "jwt", source: "arg-summary", confidence: "high", mark: "key", match: headed(`eyJ${atLeast("[A-Za-z0-9._-]", 20)}`), strict: new RegExp(String.raw `\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.${atLeast("[A-Za-z0-9_-]", 16)}\b`), envValueHead: /eyJ/ },
|
|
149
150
|
{
|
|
150
151
|
id: "private-key",
|
|
151
152
|
kind: "private-key-block",
|
|
152
153
|
source: "arg-summary",
|
|
153
154
|
confidence: "high",
|
|
155
|
+
mark: "private-key",
|
|
154
156
|
match: new RegExp(`${PEM_HEAD}[\\s\\S]*?(?:${PEM_FOOT}|$)|` +
|
|
155
157
|
String.raw `---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----[\s\S]*?(?:---- END SSH2 ENCRYPTED PRIVATE KEY ----|$)|PuTTY-User-Key-File-\d+:[\s\S]*?(?:Private-MAC:[ \t]*[0-9A-Fa-f]+|$)|Private-Lines:[ \t]*\d+(?:\r?\n[A-Za-z0-9+/=]+(?=\r?\n|$))+`, "g"),
|
|
156
158
|
strict: new RegExp(PEM_HEAD),
|
|
@@ -161,6 +163,7 @@ const VALUE_FAMILY_ROWS = [
|
|
|
161
163
|
kind: "bearer-token",
|
|
162
164
|
source: "arg-summary",
|
|
163
165
|
confidence: "high",
|
|
166
|
+
mark: "bare",
|
|
164
167
|
match: new RegExp(`()(?:${WORD_START}${BEARER_WORD}${SCHEME_SEPARATOR}+|${GLUED_LEFT}${BEARER_WORD}${SCHEME_GLUE_GATE})${atLeast(TOKEN68_CHAR, CREDENTIAL_MIN_CHARS)}=*(?:${BEARER_TAIL})?`, "g"),
|
|
165
168
|
strict: new RegExp(String.raw `\bAuthorization:\s*Bearer\s+(?=[A-Za-z0-9._~+/-]*[0-9])${atLeast("[A-Za-z0-9._~+/-]", 20)}=*`),
|
|
166
169
|
envValue: new RegExp(String.raw `\b(?:Bearer|Basic)\s+(?=[A-Za-z._~+\/=-]*[0-9]|${repeated(String.raw `(?:[A-Za-z0-9._~+\/=-]*?[a-z][A-Z](?![a-z]))`, 2, 2)}|[A-Za-z0-9.-]*[_~+\/=])${atLeast(String.raw `[A-Za-z0-9._~+\/=-]`, CREDENTIAL_MIN_CHARS)}`),
|
|
@@ -170,38 +173,42 @@ const VALUE_FAMILY_ROWS = [
|
|
|
170
173
|
kind: "authorization-header",
|
|
171
174
|
source: "arg-summary",
|
|
172
175
|
confidence: "high",
|
|
176
|
+
mark: "bare",
|
|
173
177
|
match: headed(String.raw `(authorization(?:\\{0,${ESCAPE_DEPTH}}["'])?[ \t]*[=:][ \t]*(?:\\{0,${ESCAPE_DEPTH}}["'])?)${HEADER_VALUE}`, "gi"),
|
|
174
178
|
envValue: new RegExp(String.raw `\bauthorization\s*[:=]\s*["']?[a-z][a-z0-9_-]*\s+${atLeast(String.raw `[A-Za-z0-9._~+\/=-]`, CREDENTIAL_MIN_CHARS)}`, "i"),
|
|
175
179
|
},
|
|
176
|
-
{ id: "basic-credential", kind: "scheme-credential", source: "arg-summary", confidence: "high", match: new RegExp(`(?:${WORD_START}${BASIC_WORD}${SCHEME_SEPARATOR}+|${GLUED_LEFT}${BASIC_WORD}${SCHEME_GLUE_GATE})(?=[A-Za-z+/]*[0-9]|${repeated("(?:[A-Za-z0-9+/]*?[a-z][A-Z](?![a-z]))", 2, 2)}|[A-Za-z0-9]*[+/=]|${BASE64_COLON})${atLeast("[A-Za-z0-9+/]", CREDENTIAL_MIN_CHARS)}={0,2}`, "g") },
|
|
180
|
+
{ id: "basic-credential", kind: "scheme-credential", source: "arg-summary", confidence: "high", mark: "bare", match: new RegExp(`(?:${WORD_START}${BASIC_WORD}${SCHEME_SEPARATOR}+|${GLUED_LEFT}${BASIC_WORD}${SCHEME_GLUE_GATE})(?=[A-Za-z+/]*[0-9]|${repeated("(?:[A-Za-z0-9+/]*?[a-z][A-Z](?![a-z]))", 2, 2)}|[A-Za-z0-9]*[+/=]|${BASE64_COLON})${atLeast("[A-Za-z0-9+/]", CREDENTIAL_MIN_CHARS)}={0,2}`, "g") },
|
|
177
181
|
{
|
|
178
182
|
id: "token-scheme",
|
|
179
183
|
kind: "scheme-credential",
|
|
180
184
|
source: "arg-summary",
|
|
181
185
|
confidence: "high",
|
|
186
|
+
mark: "bare",
|
|
182
187
|
match: headed(String.raw `()(?:[Tt]oken|TOKEN)\s+(?=[A-Za-z0-9_~+=-]*[0-9])(?=(${atLeast("[A-Za-z0-9_~+=-]", 20)}))\2(?![\/.])`),
|
|
183
188
|
envValue: new RegExp(String.raw `\b(?:[Tt]oken|TOKEN)\s+(?=[A-Za-z0-9_~+=-]*[0-9])(?=[A-Za-z0-9_~+=-]*[A-Z])(?=(${atLeast("[A-Za-z0-9_~+=-]", 20)}))\1(?![\/.])`),
|
|
184
189
|
},
|
|
185
|
-
{ id: "azure-storage-account-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: new RegExp(`(${AZURE_FIELD})${AZURE_BODY}`, "g"), strict: new RegExp(`${AZURE_FIELD}${AZURE_BODY}`) },
|
|
190
|
+
{ id: "azure-storage-account-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", mark: "bare", match: new RegExp(`(${AZURE_FIELD})${AZURE_BODY}`, "g"), strict: new RegExp(`${AZURE_FIELD}${AZURE_BODY}`) },
|
|
186
191
|
{
|
|
187
192
|
id: "keyword-value",
|
|
188
193
|
kind: "keyword-value",
|
|
189
194
|
source: "arg-summary",
|
|
190
195
|
confidence: "medium",
|
|
196
|
+
mark: "bare",
|
|
191
197
|
match: new RegExp(`${KEYWORD_LABEL}(?:${KEYWORD_VALUE})`, "g"),
|
|
192
198
|
envValue: new RegExp(String.raw `(?:(?:^|[;&?#,{]|\/:)\s*|\s)["']?(?!-*jobserver-auth\s*[=:])${STRUCTURED_KEY_NAME}["']?\s*[=:]\s*["']?(?!(?:${FLAG_WORDS.join("|")})(?:$|[;&,\s"']))[^;&,\s"']+`, "i"),
|
|
193
199
|
},
|
|
194
|
-
{ id: "sonar-login", kind: "keyword-value", source: "arg-summary", confidence: "high", match: new RegExp(String.raw `(${KEY_QUOTE}sonar\.login${KEY_QUOTE}\s*[:=]\s*${KEY_QUOTE})${atLeast(String.raw `[^\s"',}]`, CREDENTIAL_MIN_CHARS)}${VALUE_RUN_END}`, "g"), envValue: new RegExp(String.raw `["']?sonar\.login["']?\s*[:=]\s*["']?${atLeast(String.raw `[^\s"',}]`, CREDENTIAL_MIN_CHARS)}`) },
|
|
195
|
-
{ id: "url-userinfo", kind: "url-credentials", source: "untrusted-egress", confidence: "medium", match: new RegExp(String.raw `(${USERINFO_FRONT}|${USERINFO_WORD_START})((?<=[:/])${URL_USERINFO_SOURCE}|${USERINFO_WORD_START}${FRONTLESS_USERINFO})`, "gi") },
|
|
200
|
+
{ id: "sonar-login", kind: "keyword-value", source: "arg-summary", confidence: "high", mark: "bare", match: new RegExp(String.raw `(${KEY_QUOTE}sonar\.login${KEY_QUOTE}\s*[:=]\s*${KEY_QUOTE})${atLeast(String.raw `[^\s"',}]`, CREDENTIAL_MIN_CHARS)}${VALUE_RUN_END}`, "g"), envValue: new RegExp(String.raw `["']?sonar\.login["']?\s*[:=]\s*["']?${atLeast(String.raw `[^\s"',}]`, CREDENTIAL_MIN_CHARS)}`) },
|
|
201
|
+
{ id: "url-userinfo", kind: "url-credentials", source: "untrusted-egress", confidence: "medium", mark: "userinfo", match: new RegExp(String.raw `(${USERINFO_FRONT}|${USERINFO_WORD_START})((?<=[:/])${URL_USERINFO_SOURCE}|${USERINFO_WORD_START}${FRONTLESS_USERINFO})`, "gi") },
|
|
196
202
|
{
|
|
197
203
|
id: "webhook-url",
|
|
198
204
|
kind: "webhook-url",
|
|
199
205
|
source: "untrusted-egress",
|
|
200
206
|
confidence: "high",
|
|
207
|
+
mark: "bare",
|
|
201
208
|
match: new RegExp(`(${WEBHOOK_HEAD})${WEBHOOK_PATH}`, "gi"),
|
|
202
209
|
envValue: new RegExp(`${WEBHOOK_HEAD}${WEBHOOK_PATH}`, "i"),
|
|
203
210
|
},
|
|
204
|
-
{ id: "signed-url-param", kind: "signed-url-param", source: "untrusted-egress", confidence: "high", match: new RegExp(String.raw `([?&#](?:${namesAt("url-param").map(literally).join("|")})=)[^&\s"'#]+${VALUE_RUN_END}`, "gi") },
|
|
211
|
+
{ id: "signed-url-param", kind: "signed-url-param", source: "untrusted-egress", confidence: "high", mark: "bare", match: new RegExp(String.raw `([?&#](?:${namesAt("url-param").map(literally).join("|")})=)[^&\s"'#]+${VALUE_RUN_END}`, "gi") },
|
|
205
212
|
];
|
|
206
213
|
export const CREDENTIAL_VOCABULARY = {
|
|
207
214
|
values: VALUE_FAMILY_ROWS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/primitives",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.68.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared low-level definitions of the sema engine, importable by any layer: the credential reference (closed set of kinds, one reader) and the secret-shape detection definition (one table, its matcher and its renderer, no layer's policy). Zero dependencies.",
|
|
6
6
|
"type": "module",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --emitDeclarationOnly --removeComments false"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "d1b75e444fcc96b605fb95122839fdf072afa855"
|
|
35
35
|
}
|