@akasecurity/ai-tc-codex 0.9.16 → 0.9.17-beta.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/.codex-plugin/plugin.json +1 -1
- package/package.json +5 -5
- package/scripts/apply-suppressions.js +678 -1252
- package/scripts/backfill.js +879 -1267
- package/scripts/content-retention.js +761 -2073
- package/scripts/filescan.js +1105 -473
- package/scripts/firstrun.js +1215 -1690
- package/scripts/history-sync.js +750 -2106
- package/scripts/intro.js +123 -2189
- package/scripts/onboard.js +2755 -1185
- package/scripts/post-tool-use.js +1302 -1696
- package/scripts/pre-tool-use.js +903 -1295
- package/scripts/query.js +1215 -1690
- package/scripts/reconcile.js +835 -1277
- package/scripts/remediate.js +920 -1317
- package/scripts/scan-worker.js +97 -13
- package/scripts/session-start.js +1819 -816
- package/scripts/start-light.js +127 -1360
- package/scripts/stop.js +271 -1112
- package/scripts/sync.js +1657 -1005
- package/scripts/user-prompt-submit.js +1042 -1404
package/scripts/onboard.js
CHANGED
|
@@ -1,885 +1,8 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
try {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
} catch (e) {
|
|
11
|
-
throw mod = 0, e;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
2
|
var __export = (target, all) => {
|
|
15
3
|
for (var name in all)
|
|
16
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
5
|
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
-
mod
|
|
33
|
-
));
|
|
34
|
-
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
|
|
36
|
-
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
|
|
38
|
-
"use strict";
|
|
39
|
-
function makeArray(subject) {
|
|
40
|
-
return Array.isArray(subject) ? subject : [subject];
|
|
41
|
-
}
|
|
42
|
-
var UNDEFINED = void 0;
|
|
43
|
-
var EMPTY = "";
|
|
44
|
-
var SPACE = " ";
|
|
45
|
-
var ESCAPE = "\\";
|
|
46
|
-
var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
47
|
-
var REGEX_TEST_BLANK_LINE = /^\uFEFF? *$/;
|
|
48
|
-
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
49
|
-
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
50
|
-
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
51
|
-
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
52
|
-
var DOUBLE_SLASH = "//";
|
|
53
|
-
var SLASH_CODE = 47;
|
|
54
|
-
var DOT_CODE = 46;
|
|
55
|
-
var SLASH2 = "/";
|
|
56
|
-
var TMP_KEY_IGNORE = "node-ignore";
|
|
57
|
-
if (typeof Symbol !== "undefined") {
|
|
58
|
-
TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
|
|
59
|
-
}
|
|
60
|
-
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
61
|
-
var define = (object2, key, value) => {
|
|
62
|
-
Object.defineProperty(object2, key, { value });
|
|
63
|
-
return value;
|
|
64
|
-
};
|
|
65
|
-
var RETURN_FALSE = () => false;
|
|
66
|
-
var cleanRangeBackSlash = (slashes) => {
|
|
67
|
-
const { length } = slashes;
|
|
68
|
-
return slashes.slice(0, length - length % 2);
|
|
69
|
-
};
|
|
70
|
-
var POSIX_CLASSES = {
|
|
71
|
-
alnum: "0-9A-Za-z",
|
|
72
|
-
alpha: "A-Za-z",
|
|
73
|
-
blank: " \\t",
|
|
74
|
-
cntrl: "\\x00-\\x1f\\x7f",
|
|
75
|
-
digit: "0-9",
|
|
76
|
-
graph: "!-.0-~",
|
|
77
|
-
lower: "a-z",
|
|
78
|
-
print: " -.0-~",
|
|
79
|
-
punct: "!-.:-@\\[-`{-~",
|
|
80
|
-
// git's `sane-ctype.h` classifies \v and \f as control, not space,
|
|
81
|
-
// unlike C's `isspace`
|
|
82
|
-
space: " \\t\\n\\r",
|
|
83
|
-
upper: "A-Z",
|
|
84
|
-
xdigit: "0-9A-Fa-f"
|
|
85
|
-
};
|
|
86
|
-
var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
|
|
87
|
-
var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
|
|
88
|
-
var NON_SLASH = "(?!\\/)";
|
|
89
|
-
var classSource = (negated, body) => {
|
|
90
|
-
if (negated) {
|
|
91
|
-
return `[^\\/${body}]`;
|
|
92
|
-
}
|
|
93
|
-
const source = `[${body}]`;
|
|
94
|
-
return new RegExp(source).test("/") ? NON_SLASH + source : source;
|
|
95
|
-
};
|
|
96
|
-
var scanBracket = (pattern, start) => {
|
|
97
|
-
const { length } = pattern;
|
|
98
|
-
let index = start + 1;
|
|
99
|
-
let negated = EMPTY;
|
|
100
|
-
const lead = pattern[index];
|
|
101
|
-
if (lead === "!" || lead === "^") {
|
|
102
|
-
negated = "^";
|
|
103
|
-
index++;
|
|
104
|
-
}
|
|
105
|
-
let body = EMPTY;
|
|
106
|
-
let prev = EMPTY;
|
|
107
|
-
for (; ; ) {
|
|
108
|
-
const char = pattern[index];
|
|
109
|
-
if (char === UNDEFINED) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
if (char === ESCAPE) {
|
|
113
|
-
const escaped = pattern[index + 1];
|
|
114
|
-
if (escaped === UNDEFINED) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
body += escapeMember(escaped);
|
|
118
|
-
prev = escaped;
|
|
119
|
-
index++;
|
|
120
|
-
} else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
|
|
121
|
-
index++;
|
|
122
|
-
let to = pattern[index];
|
|
123
|
-
if (to === ESCAPE) {
|
|
124
|
-
to = pattern[index += 1];
|
|
125
|
-
}
|
|
126
|
-
if (prev <= to) {
|
|
127
|
-
body += `-${escapeMember(to)}`;
|
|
128
|
-
}
|
|
129
|
-
prev = EMPTY;
|
|
130
|
-
} else if (char === "[" && pattern[index + 1] === ":") {
|
|
131
|
-
const nameStart = index + 2;
|
|
132
|
-
let end = nameStart;
|
|
133
|
-
while (end < length && pattern[end] !== "]") {
|
|
134
|
-
end++;
|
|
135
|
-
}
|
|
136
|
-
if (end === length) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
if (end > nameStart && pattern[end - 1] === ":") {
|
|
140
|
-
const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
|
|
141
|
-
if (expanded === UNDEFINED) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
body += expanded;
|
|
145
|
-
prev = EMPTY;
|
|
146
|
-
index = end;
|
|
147
|
-
} else {
|
|
148
|
-
body += escapeMember("[");
|
|
149
|
-
prev = "[";
|
|
150
|
-
index = nameStart - 2;
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
body += escapeMember(char);
|
|
154
|
-
prev = char;
|
|
155
|
-
}
|
|
156
|
-
index++;
|
|
157
|
-
if (pattern[index] === "]") {
|
|
158
|
-
return {
|
|
159
|
-
end: index,
|
|
160
|
-
source: classSource(negated, body)
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
var NEVER_MATCH = "[]";
|
|
166
|
-
var PLACEHOLDER = "\0";
|
|
167
|
-
var REGEX_RESTORE_PLACEHOLDER = new RegExp(
|
|
168
|
-
`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
|
|
169
|
-
"g"
|
|
170
|
-
);
|
|
171
|
-
var TRAILING_WILDCARD = "\uE000";
|
|
172
|
-
var TRAILING_DOUBLESTAR = "\uE001";
|
|
173
|
-
var extractBrackets = (pattern) => {
|
|
174
|
-
const sources = [];
|
|
175
|
-
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
176
|
-
const { length } = pattern;
|
|
177
|
-
let out = EMPTY;
|
|
178
|
-
let index = 0;
|
|
179
|
-
while (index < length) {
|
|
180
|
-
const char = pattern[index];
|
|
181
|
-
if (char === ESCAPE) {
|
|
182
|
-
const escaped = pattern[index + 1];
|
|
183
|
-
if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
|
|
184
|
-
out += pattern.slice(index, index + 2);
|
|
185
|
-
} else {
|
|
186
|
-
out += hold(
|
|
187
|
-
REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
index += 2;
|
|
191
|
-
} else if (char === PLACEHOLDER) {
|
|
192
|
-
out += hold(`[${PLACEHOLDER}]`);
|
|
193
|
-
index++;
|
|
194
|
-
} else if (char === "[") {
|
|
195
|
-
const scanned = scanBracket(pattern, index);
|
|
196
|
-
if (scanned === null) {
|
|
197
|
-
out += hold(NEVER_MATCH);
|
|
198
|
-
index = length;
|
|
199
|
-
} else {
|
|
200
|
-
out += hold(scanned.source);
|
|
201
|
-
index = scanned.end + 1;
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
out += char;
|
|
205
|
-
index++;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
source: out,
|
|
210
|
-
sources
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
var DIRECT = null;
|
|
214
|
-
var REGEX_INNER_SLASH = /\/(?!$)/;
|
|
215
|
-
var REPLACERS = [
|
|
216
|
-
[
|
|
217
|
-
// Remove BOM
|
|
218
|
-
// TODO:
|
|
219
|
-
// Other similar zero-width characters?
|
|
220
|
-
/^\uFEFF/,
|
|
221
|
-
() => EMPTY,
|
|
222
|
-
"\uFEFF"
|
|
223
|
-
],
|
|
224
|
-
[
|
|
225
|
-
// A trailing line terminator, left on when a whole file's contents are
|
|
226
|
-
// added as one pattern rather than split into lines. git never sees one
|
|
227
|
-
// -- it reads a `.gitignore` line by line -- so it is not part of the
|
|
228
|
-
// pattern and is dropped here, apart from the trailing-space trimming,
|
|
229
|
-
// which follows git in touching spaces and nothing else.
|
|
230
|
-
/[\r\n]+$/,
|
|
231
|
-
() => EMPTY
|
|
232
|
-
],
|
|
233
|
-
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
234
|
-
[
|
|
235
|
-
// Only spaces, never tabs or other whitespace: git trims a trailing run
|
|
236
|
-
// of `' '` and nothing else (dir.c, `trim_trailing_spaces`, a single
|
|
237
|
-
// `case ' '`), so a pattern ending in a tab keeps it as a literal.
|
|
238
|
-
// (a\ ) -> (a )
|
|
239
|
-
// (a ) -> (a)
|
|
240
|
-
// (a ) -> (a)
|
|
241
|
-
// (a \ ) -> (a )
|
|
242
|
-
/((?:\\\\)*?)(\\? +)$/,
|
|
243
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
244
|
-
],
|
|
245
|
-
// Replace (\ ) with ' '
|
|
246
|
-
// Only a space: an escaped tab or other whitespace is already a literal by
|
|
247
|
-
// the time it reaches here, and a bare tab must be left as one, not turned
|
|
248
|
-
// into a space.
|
|
249
|
-
// (\ ) -> ' '
|
|
250
|
-
// (\\ ) -> '\\ '
|
|
251
|
-
// (\\\ ) -> '\\ '
|
|
252
|
-
[
|
|
253
|
-
/(\\+?) /g,
|
|
254
|
-
(_, m1) => {
|
|
255
|
-
const { length } = m1;
|
|
256
|
-
return m1.slice(0, length - length % 2) + SPACE;
|
|
257
|
-
}
|
|
258
|
-
],
|
|
259
|
-
// Escape metacharacters
|
|
260
|
-
// which is written down by users but means special for regular expressions.
|
|
261
|
-
// > There are 12 characters with special meanings:
|
|
262
|
-
// > - the backslash \,
|
|
263
|
-
// > - the caret ^,
|
|
264
|
-
// > - the dollar sign $,
|
|
265
|
-
// > - the period or dot .,
|
|
266
|
-
// > - the vertical bar or pipe symbol |,
|
|
267
|
-
// > - the question mark ?,
|
|
268
|
-
// > - the asterisk or star *,
|
|
269
|
-
// > - the plus sign +,
|
|
270
|
-
// > - the opening parenthesis (,
|
|
271
|
-
// > - the closing parenthesis ),
|
|
272
|
-
// > - and the opening square bracket [,
|
|
273
|
-
// > - the opening curly brace {,
|
|
274
|
-
// > These special characters are often called "metacharacters".
|
|
275
|
-
[
|
|
276
|
-
/[\\$.|*+(){^]/g,
|
|
277
|
-
(match) => `\\${match}`
|
|
278
|
-
],
|
|
279
|
-
[
|
|
280
|
-
// > a question mark (?) matches a single character
|
|
281
|
-
/(?!\\)\?/g,
|
|
282
|
-
() => "[^/]",
|
|
283
|
-
"?"
|
|
284
|
-
],
|
|
285
|
-
// leading slash
|
|
286
|
-
[
|
|
287
|
-
// > A leading slash matches the beginning of the pathname.
|
|
288
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
289
|
-
// A leading slash matches the beginning of the pathname
|
|
290
|
-
/^\//,
|
|
291
|
-
() => "^",
|
|
292
|
-
SLASH2
|
|
293
|
-
],
|
|
294
|
-
// replace special metacharacter slash after the leading slash
|
|
295
|
-
[
|
|
296
|
-
/\//g,
|
|
297
|
-
() => "\\/",
|
|
298
|
-
SLASH2
|
|
299
|
-
],
|
|
300
|
-
[
|
|
301
|
-
// > A leading "**" followed by a slash means match in all directories.
|
|
302
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
303
|
-
// > the same as pattern "foo".
|
|
304
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
305
|
-
// > under directory "foo".
|
|
306
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
307
|
-
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
308
|
-
// '**/foo' <-> 'foo'
|
|
309
|
-
() => "^(?:.*\\/)?",
|
|
310
|
-
"*"
|
|
311
|
-
],
|
|
312
|
-
// starting
|
|
313
|
-
[
|
|
314
|
-
// there will be no leading '/'
|
|
315
|
-
// (which has been replaced by section "leading slash")
|
|
316
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
317
|
-
DIRECT,
|
|
318
|
-
(source, pattern) => {
|
|
319
|
-
if (!source || source[0] === "^") {
|
|
320
|
-
return source;
|
|
321
|
-
}
|
|
322
|
-
const anchor2 = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
|
|
323
|
-
return anchor2 + source;
|
|
324
|
-
}
|
|
325
|
-
],
|
|
326
|
-
// two globstars
|
|
327
|
-
[
|
|
328
|
-
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
329
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
330
|
-
// Zero, one or several directories
|
|
331
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
332
|
-
// Check if it is not the last `'/**'`
|
|
333
|
-
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
334
|
-
"*"
|
|
335
|
-
],
|
|
336
|
-
// normal intermediate wildcards
|
|
337
|
-
[
|
|
338
|
-
// Never replace escaped '*'
|
|
339
|
-
// ignore rule '\*' will match the path '*'
|
|
340
|
-
// 'abc.*/' -> go
|
|
341
|
-
// 'abc.*' -> skip this rule,
|
|
342
|
-
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
343
|
-
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
344
|
-
// '*.js' matches '.js'
|
|
345
|
-
// '*.js' doesn't match 'abc'
|
|
346
|
-
(_, p1, p2) => {
|
|
347
|
-
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
348
|
-
return p1 + unescaped;
|
|
349
|
-
},
|
|
350
|
-
"*"
|
|
351
|
-
],
|
|
352
|
-
// trailing wildcard, held apart from a literal star
|
|
353
|
-
[
|
|
354
|
-
// The step above leaves a trailing `*` alone, so a single `\*` is all that
|
|
355
|
-
// can be left at the end here. Whether it is a wildcard or a literal
|
|
356
|
-
// turns on the backslashes the user put in front of it: the escaper has
|
|
357
|
-
// since doubled every one, so what stands here is those `2N` doubled
|
|
358
|
-
// backslashes and then the star's own escape. An even number of the
|
|
359
|
-
// original `N` leaves the star unescaped -- a wildcard -- and an odd
|
|
360
|
-
// number escapes it -- a literal. This runs while the two are still
|
|
361
|
-
// distinct, before the unescape steps below collapse the literal onto
|
|
362
|
-
// the very `\*` a wildcard leaves behind.
|
|
363
|
-
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
364
|
-
(match, p1, p2) => (
|
|
365
|
-
// `p2` holds the doubled user backslashes; half of them is `N`.
|
|
366
|
-
p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
|
|
367
|
-
),
|
|
368
|
-
"*"
|
|
369
|
-
],
|
|
370
|
-
[
|
|
371
|
-
// unescape, revert step 3 except for back slash
|
|
372
|
-
// For example, if a user escape a '\\*',
|
|
373
|
-
// after step 3, the result will be '\\\\\\*'
|
|
374
|
-
/\\\\\\(?=[$.|*+(){^])/g,
|
|
375
|
-
() => ESCAPE,
|
|
376
|
-
ESCAPE + ESCAPE
|
|
377
|
-
],
|
|
378
|
-
[
|
|
379
|
-
// '\\\\' -> '\\'
|
|
380
|
-
/\\\\/g,
|
|
381
|
-
() => ESCAPE,
|
|
382
|
-
ESCAPE + ESCAPE
|
|
383
|
-
],
|
|
384
|
-
[
|
|
385
|
-
// Every real bracket expression -- POSIX classes included -- has already
|
|
386
|
-
// been held aside by `extractBrackets`, so the only `[` left in the
|
|
387
|
-
// pattern is an escaped, literal one.
|
|
388
|
-
// `\` is escaped by step 3
|
|
389
|
-
/\\\[([^\]/]*?)(\\*)($|\])/g,
|
|
390
|
-
// '\\[bar]' -> '\\\\[bar\\]'
|
|
391
|
-
(match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
|
|
392
|
-
"["
|
|
393
|
-
],
|
|
394
|
-
// ending
|
|
395
|
-
[
|
|
396
|
-
// 'js' will not match 'js.'
|
|
397
|
-
// 'ab' will not match 'abc'
|
|
398
|
-
DIRECT,
|
|
399
|
-
// WTF!
|
|
400
|
-
// https://git-scm.com/docs/gitignore
|
|
401
|
-
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
402
|
-
// which re-fixes #24, #38
|
|
403
|
-
// > If there is a separator at the end of the pattern then the pattern
|
|
404
|
-
// > will only match directories, otherwise the pattern can match both
|
|
405
|
-
// > files and directories.
|
|
406
|
-
// 'js*' will not match 'a.js'
|
|
407
|
-
// 'js/' will not match 'a.js'
|
|
408
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
409
|
-
(source) => {
|
|
410
|
-
const last = source[source.length - 1];
|
|
411
|
-
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
412
|
-
return source;
|
|
413
|
-
}
|
|
414
|
-
return last === SLASH2 ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
415
|
-
}
|
|
416
|
-
]
|
|
417
|
-
];
|
|
418
|
-
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
|
|
419
|
-
var MODE_IGNORE = "regex";
|
|
420
|
-
var MODE_CHECK_IGNORE = "checkRegex";
|
|
421
|
-
var UNDERSCORE = "_";
|
|
422
|
-
var replaceTrailingWildcard = (_, p1) => {
|
|
423
|
-
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
424
|
-
return `${prefix}(?=$|\\/$)`;
|
|
425
|
-
};
|
|
426
|
-
var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
427
|
-
var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
|
|
428
|
-
var WILDCARD = "[^\\/]*";
|
|
429
|
-
var separatorAfter = (run, at) => {
|
|
430
|
-
let separator = EMPTY;
|
|
431
|
-
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
432
|
-
separator += run[index].single;
|
|
433
|
-
}
|
|
434
|
-
return separator;
|
|
435
|
-
};
|
|
436
|
-
var pinWildcards = (source) => {
|
|
437
|
-
if (source.indexOf(WILDCARD) < 0) {
|
|
438
|
-
return source;
|
|
439
|
-
}
|
|
440
|
-
const tokens = [];
|
|
441
|
-
const { length } = source;
|
|
442
|
-
let index = 0;
|
|
443
|
-
while (index < length) {
|
|
444
|
-
const char = source[index];
|
|
445
|
-
if (source.startsWith(WILDCARD, index)) {
|
|
446
|
-
tokens.push({ wildcard: true });
|
|
447
|
-
index += WILDCARD.length;
|
|
448
|
-
} else if (char === "[") {
|
|
449
|
-
let end = index + 1;
|
|
450
|
-
if (source[end] === "^") {
|
|
451
|
-
end++;
|
|
452
|
-
}
|
|
453
|
-
if (source[end] === "]") {
|
|
454
|
-
end++;
|
|
455
|
-
}
|
|
456
|
-
while (end < length && source[end] !== "]") {
|
|
457
|
-
end += source[end] === ESCAPE ? 2 : 1;
|
|
458
|
-
}
|
|
459
|
-
end++;
|
|
460
|
-
tokens.push({ single: source.slice(index, end) });
|
|
461
|
-
index = end;
|
|
462
|
-
} else if (char === ESCAPE) {
|
|
463
|
-
tokens.push({ single: source.slice(index, index + 2) });
|
|
464
|
-
index += 2;
|
|
465
|
-
} else if (char === "(") {
|
|
466
|
-
let depth = 0;
|
|
467
|
-
let end = index;
|
|
468
|
-
do {
|
|
469
|
-
if (source[end] === ESCAPE) {
|
|
470
|
-
end++;
|
|
471
|
-
} else if (source[end] === "(") {
|
|
472
|
-
depth++;
|
|
473
|
-
} else if (source[end] === ")") {
|
|
474
|
-
depth--;
|
|
475
|
-
}
|
|
476
|
-
end++;
|
|
477
|
-
} while (end < length && depth > 0);
|
|
478
|
-
if ("*+?".indexOf(source[end]) >= 0) {
|
|
479
|
-
end++;
|
|
480
|
-
}
|
|
481
|
-
tokens.push({ boundary: source.slice(index, end) });
|
|
482
|
-
index = end;
|
|
483
|
-
} else if (char === "^" || char === "$") {
|
|
484
|
-
tokens.push({ boundary: char });
|
|
485
|
-
index++;
|
|
486
|
-
} else {
|
|
487
|
-
tokens.push({ single: char });
|
|
488
|
-
index++;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
let out = EMPTY;
|
|
492
|
-
let run = [];
|
|
493
|
-
const flush = () => {
|
|
494
|
-
let lastWildcard;
|
|
495
|
-
run.forEach((token, at) => {
|
|
496
|
-
if (token.wildcard) {
|
|
497
|
-
lastWildcard = at;
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
run.forEach((token, at) => {
|
|
501
|
-
if (!token.wildcard) {
|
|
502
|
-
out += token.single;
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
506
|
-
});
|
|
507
|
-
run = [];
|
|
508
|
-
};
|
|
509
|
-
tokens.forEach((token) => {
|
|
510
|
-
if (token.boundary === void 0) {
|
|
511
|
-
run.push(token);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
flush();
|
|
515
|
-
out += token.boundary;
|
|
516
|
-
});
|
|
517
|
-
flush();
|
|
518
|
-
return out;
|
|
519
|
-
};
|
|
520
|
-
var makeRegexPrefix = (pattern) => {
|
|
521
|
-
const { source, sources } = extractBrackets(pattern);
|
|
522
|
-
const replaced = REPLACERS.reduce(
|
|
523
|
-
// A pass whose matcher finds nothing hands back the very string it was
|
|
524
|
-
// given, so asking first costs a search and saves a rewrite. Ten of the
|
|
525
|
-
// fifteen passes never fire for a typical .gitignore line, and between
|
|
526
|
-
// them they were 45% of this chain.
|
|
527
|
-
(prev, [matcher, replacer, required2]) => {
|
|
528
|
-
if (matcher === DIRECT) {
|
|
529
|
-
return replacer(prev, pattern);
|
|
530
|
-
}
|
|
531
|
-
if (required2 !== UNDEFINED && prev.indexOf(required2) < 0) {
|
|
532
|
-
return prev;
|
|
533
|
-
}
|
|
534
|
-
return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
|
|
535
|
-
},
|
|
536
|
-
source
|
|
537
|
-
);
|
|
538
|
-
return sources.length ? replaced.replace(
|
|
539
|
-
REGEX_RESTORE_PLACEHOLDER,
|
|
540
|
-
(match, index) => sources[index]
|
|
541
|
-
) : replaced;
|
|
542
|
-
};
|
|
543
|
-
var checkSourceOf = (body, prefix) => {
|
|
544
|
-
if (body[body.length - 1] === SLASH2) {
|
|
545
|
-
prefix = makeRegexPrefix(body.slice(0, -1));
|
|
546
|
-
}
|
|
547
|
-
const head = prefix.slice(0, -1);
|
|
548
|
-
const last = prefix[prefix.length - 1];
|
|
549
|
-
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
|
|
550
|
-
};
|
|
551
|
-
var matchesBasename = (body) => {
|
|
552
|
-
const index = body.indexOf(SLASH2);
|
|
553
|
-
return index < 0 || index === body.length - 1;
|
|
554
|
-
};
|
|
555
|
-
var basenameOf = (path) => {
|
|
556
|
-
const end = path.length - 1;
|
|
557
|
-
const index = path.lastIndexOf(
|
|
558
|
-
SLASH2,
|
|
559
|
-
path[end] === SLASH2 ? end - 1 : end
|
|
560
|
-
);
|
|
561
|
-
return index < 0 ? path : path.slice(index + 1);
|
|
562
|
-
};
|
|
563
|
-
var parentOf = (path) => {
|
|
564
|
-
if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
|
|
565
|
-
const slices = path.split(SLASH2).filter(Boolean);
|
|
566
|
-
slices.pop();
|
|
567
|
-
return slices.length ? slices.join(SLASH2) + SLASH2 : EMPTY;
|
|
568
|
-
}
|
|
569
|
-
const end = path.length - 1;
|
|
570
|
-
const cut = path.lastIndexOf(
|
|
571
|
-
SLASH2,
|
|
572
|
-
path.charCodeAt(end) === SLASH_CODE ? end - 1 : end
|
|
573
|
-
);
|
|
574
|
-
return cut < 0 ? EMPTY : path.slice(0, cut + 1);
|
|
575
|
-
};
|
|
576
|
-
var isString = (subject) => typeof subject === "string";
|
|
577
|
-
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
578
|
-
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
579
|
-
var IgnoreRule = class {
|
|
580
|
-
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
581
|
-
this.pattern = pattern;
|
|
582
|
-
this.mark = mark;
|
|
583
|
-
this.negative = negative;
|
|
584
|
-
define(this, "body", body);
|
|
585
|
-
define(this, "ignoreCase", ignoreCase);
|
|
586
|
-
define(this, "regexPrefix", prefix);
|
|
587
|
-
}
|
|
588
|
-
// Worked out on first use and kept behind an own property, the way `regex`
|
|
589
|
-
// caches itself in `_regex`. Deciding it in the constructor instead would
|
|
590
|
-
// add a fourth `defineProperty` to every rule ever built, which cost 4% of
|
|
591
|
-
// every compile -- including the compiles of rules that are never matched
|
|
592
|
-
// against anything.
|
|
593
|
-
get _basenameOnly() {
|
|
594
|
-
return define(this, "_basenameOnly", matchesBasename(this.body));
|
|
595
|
-
}
|
|
596
|
-
get regex() {
|
|
597
|
-
const key = UNDERSCORE + MODE_IGNORE;
|
|
598
|
-
if (this[key]) {
|
|
599
|
-
return this[key];
|
|
600
|
-
}
|
|
601
|
-
return this._make(MODE_IGNORE, key);
|
|
602
|
-
}
|
|
603
|
-
get checkRegex() {
|
|
604
|
-
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
605
|
-
if (this[key]) {
|
|
606
|
-
return this[key];
|
|
607
|
-
}
|
|
608
|
-
return this._make(MODE_CHECK_IGNORE, key);
|
|
609
|
-
}
|
|
610
|
-
_make(mode, key) {
|
|
611
|
-
const str2 = pinWildcards(
|
|
612
|
-
mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
|
|
613
|
-
);
|
|
614
|
-
const regex = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
615
|
-
return define(this, key, regex);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
var createRule = ({
|
|
619
|
-
pattern,
|
|
620
|
-
mark
|
|
621
|
-
}, ignoreCase) => {
|
|
622
|
-
let negative = false;
|
|
623
|
-
let body = pattern;
|
|
624
|
-
if (body.indexOf("!") === 0) {
|
|
625
|
-
negative = true;
|
|
626
|
-
body = body.substr(1);
|
|
627
|
-
}
|
|
628
|
-
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
629
|
-
const regexPrefix = makeRegexPrefix(body);
|
|
630
|
-
return new IgnoreRule(
|
|
631
|
-
pattern,
|
|
632
|
-
mark,
|
|
633
|
-
body,
|
|
634
|
-
ignoreCase,
|
|
635
|
-
negative,
|
|
636
|
-
regexPrefix
|
|
637
|
-
);
|
|
638
|
-
};
|
|
639
|
-
var RuleManager = class {
|
|
640
|
-
constructor(ignoreCase) {
|
|
641
|
-
this._ignoreCase = ignoreCase;
|
|
642
|
-
this._rules = [];
|
|
643
|
-
this._basenameCount = 0;
|
|
644
|
-
}
|
|
645
|
-
_add(pattern) {
|
|
646
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
647
|
-
this._rules = this._rules.concat(pattern._rules._rules);
|
|
648
|
-
this._basenameCount += pattern._rules._basenameCount;
|
|
649
|
-
this._added = true;
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
if (isString(pattern)) {
|
|
653
|
-
pattern = {
|
|
654
|
-
pattern
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
if (checkPattern(pattern.pattern)) {
|
|
658
|
-
const rule = createRule(pattern, this._ignoreCase);
|
|
659
|
-
this._added = true;
|
|
660
|
-
this._rules.push(rule);
|
|
661
|
-
if (matchesBasename(rule.body)) {
|
|
662
|
-
this._basenameCount++;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
// @param {Array<string> | string | Ignore} pattern
|
|
667
|
-
add(pattern) {
|
|
668
|
-
this._added = false;
|
|
669
|
-
makeArray(
|
|
670
|
-
isString(pattern) ? splitPattern(pattern) : pattern
|
|
671
|
-
).forEach(this._add, this);
|
|
672
|
-
if (this._added) {
|
|
673
|
-
this._literalRules = UNDEFINED;
|
|
674
|
-
}
|
|
675
|
-
return this._added;
|
|
676
|
-
}
|
|
677
|
-
// Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
|
|
678
|
-
// ending in a wildcard can match it (see `checkSourceOf`), so the rest
|
|
679
|
-
// are left out once, rather than tested or compiled for every path.
|
|
680
|
-
testLiteral(path) {
|
|
681
|
-
const rules = this._literalRules || (this._literalRules = this._rules.filter(
|
|
682
|
-
({ body }) => body[body.length - (body[body.length - 1] === SLASH2 ? 2 : 1)] === "*"
|
|
683
|
-
));
|
|
684
|
-
let ignored = false;
|
|
685
|
-
let unignored = false;
|
|
686
|
-
let matchedRule;
|
|
687
|
-
for (let index = rules.length - 1; index >= 0; index--) {
|
|
688
|
-
const rule = rules[index];
|
|
689
|
-
if (rule.checkRegex.test(path)) {
|
|
690
|
-
ignored = !rule.negative;
|
|
691
|
-
unignored = rule.negative;
|
|
692
|
-
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
const ret = {
|
|
697
|
-
ignored,
|
|
698
|
-
unignored
|
|
699
|
-
};
|
|
700
|
-
if (matchedRule) {
|
|
701
|
-
ret.rule = matchedRule;
|
|
702
|
-
}
|
|
703
|
-
return ret;
|
|
704
|
-
}
|
|
705
|
-
// Test one single path without recursively checking parent directories
|
|
706
|
-
//
|
|
707
|
-
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
708
|
-
// setting `checkUnignored` to `false` could reduce additional
|
|
709
|
-
// path matching.
|
|
710
|
-
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
711
|
-
// @returns {TestResult} true if a file is ignored
|
|
712
|
-
test(path, checkUnignored, mode) {
|
|
713
|
-
let ignored = false;
|
|
714
|
-
let unignored = false;
|
|
715
|
-
let matchedRule;
|
|
716
|
-
const rules = this._rules;
|
|
717
|
-
const { length } = rules;
|
|
718
|
-
const shortcut = this._basenameCount * 2 >= length;
|
|
719
|
-
const basename7 = shortcut ? basenameOf(path) : path;
|
|
720
|
-
for (let index = 0; index < length; index++) {
|
|
721
|
-
const rule = rules[index];
|
|
722
|
-
const { negative } = rule;
|
|
723
|
-
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
724
|
-
if (!skip && rule[mode].test(
|
|
725
|
-
shortcut && rule._basenameOnly ? basename7 : path
|
|
726
|
-
)) {
|
|
727
|
-
ignored = !negative;
|
|
728
|
-
unignored = negative;
|
|
729
|
-
matchedRule = negative ? UNDEFINED : rule;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
const ret = {
|
|
733
|
-
ignored,
|
|
734
|
-
unignored
|
|
735
|
-
};
|
|
736
|
-
if (matchedRule) {
|
|
737
|
-
ret.rule = matchedRule;
|
|
738
|
-
}
|
|
739
|
-
return ret;
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
var throwError = (message, Ctor) => {
|
|
743
|
-
throw new Ctor(message);
|
|
744
|
-
};
|
|
745
|
-
var checkPath = (path, originalPath, doThrow) => {
|
|
746
|
-
if (!isString(path)) {
|
|
747
|
-
return doThrow(
|
|
748
|
-
`path must be a string, but got \`${originalPath}\``,
|
|
749
|
-
TypeError
|
|
750
|
-
);
|
|
751
|
-
}
|
|
752
|
-
if (!path) {
|
|
753
|
-
return doThrow(`path must not be empty`, TypeError);
|
|
754
|
-
}
|
|
755
|
-
if (checkPath.isNotRelative(path)) {
|
|
756
|
-
const r = "`path.relative()`d";
|
|
757
|
-
return doThrow(
|
|
758
|
-
`path should be a ${r} string, but got "${originalPath}"`,
|
|
759
|
-
RangeError
|
|
760
|
-
);
|
|
761
|
-
}
|
|
762
|
-
return true;
|
|
763
|
-
};
|
|
764
|
-
var isNotRelative = (path) => {
|
|
765
|
-
const first = path.charCodeAt(0);
|
|
766
|
-
if (first === SLASH_CODE) {
|
|
767
|
-
return true;
|
|
768
|
-
}
|
|
769
|
-
if (first !== DOT_CODE) {
|
|
770
|
-
return false;
|
|
771
|
-
}
|
|
772
|
-
if (path.length === 1) {
|
|
773
|
-
return true;
|
|
774
|
-
}
|
|
775
|
-
const second = path.charCodeAt(1);
|
|
776
|
-
if (second === SLASH_CODE) {
|
|
777
|
-
return true;
|
|
778
|
-
}
|
|
779
|
-
if (second !== DOT_CODE) {
|
|
780
|
-
return false;
|
|
781
|
-
}
|
|
782
|
-
return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
|
|
783
|
-
};
|
|
784
|
-
checkPath.isNotRelative = isNotRelative;
|
|
785
|
-
checkPath.convert = (p) => p;
|
|
786
|
-
var Ignore = class {
|
|
787
|
-
constructor({
|
|
788
|
-
ignorecase = true,
|
|
789
|
-
ignoreCase = ignorecase,
|
|
790
|
-
allowRelativePaths = false
|
|
791
|
-
} = {}) {
|
|
792
|
-
define(this, KEY_IGNORE, true);
|
|
793
|
-
this._rules = new RuleManager(ignoreCase);
|
|
794
|
-
this._strictPathCheck = !allowRelativePaths;
|
|
795
|
-
this._initCache();
|
|
796
|
-
}
|
|
797
|
-
_initCache() {
|
|
798
|
-
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
799
|
-
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
800
|
-
}
|
|
801
|
-
add(pattern) {
|
|
802
|
-
if (this._rules.add(pattern)) {
|
|
803
|
-
this._initCache();
|
|
804
|
-
}
|
|
805
|
-
return this;
|
|
806
|
-
}
|
|
807
|
-
// legacy
|
|
808
|
-
addPattern(pattern) {
|
|
809
|
-
return this.add(pattern);
|
|
810
|
-
}
|
|
811
|
-
// @returns {TestResult}
|
|
812
|
-
_test(originalPath, cache, checkUnignored) {
|
|
813
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
814
|
-
checkPath(
|
|
815
|
-
path,
|
|
816
|
-
originalPath,
|
|
817
|
-
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
818
|
-
);
|
|
819
|
-
return this._t(path, cache, checkUnignored);
|
|
820
|
-
}
|
|
821
|
-
checkIgnore(path) {
|
|
822
|
-
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
823
|
-
return this.test(path);
|
|
824
|
-
}
|
|
825
|
-
const dir = this._t(path, this._testCache, true);
|
|
826
|
-
if (dir.ignored) {
|
|
827
|
-
return dir;
|
|
828
|
-
}
|
|
829
|
-
const literal2 = this._rules.testLiteral(path);
|
|
830
|
-
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
831
|
-
}
|
|
832
|
-
_t(path, cache, checkUnignored) {
|
|
833
|
-
if (path in cache) {
|
|
834
|
-
return cache[path];
|
|
835
|
-
}
|
|
836
|
-
const parentPath = parentOf(path);
|
|
837
|
-
const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
|
|
838
|
-
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
839
|
-
}
|
|
840
|
-
ignores(path) {
|
|
841
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
842
|
-
}
|
|
843
|
-
createFilter() {
|
|
844
|
-
return (path) => !this.ignores(path);
|
|
845
|
-
}
|
|
846
|
-
filter(paths) {
|
|
847
|
-
return makeArray(paths).filter(this.createFilter());
|
|
848
|
-
}
|
|
849
|
-
// @returns {TestResult}
|
|
850
|
-
test(path) {
|
|
851
|
-
return this._test(path, this._testCache, true);
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
var factory = (options) => new Ignore(options);
|
|
855
|
-
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
856
|
-
var setupWindows = () => {
|
|
857
|
-
const makePosix = (str2) => /^\\\\\?\\/.test(str2) || /["<>|\u0000-\u001F]+/u.test(str2) ? str2 : str2.replace(/\\/g, "/");
|
|
858
|
-
checkPath.convert = makePosix;
|
|
859
|
-
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
860
|
-
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
861
|
-
};
|
|
862
|
-
if (
|
|
863
|
-
// Detect `process` so that it can run in browsers.
|
|
864
|
-
typeof process !== "undefined" && process.platform === "win32"
|
|
865
|
-
) {
|
|
866
|
-
setupWindows();
|
|
867
|
-
}
|
|
868
|
-
module.exports = factory;
|
|
869
|
-
factory.default = factory;
|
|
870
|
-
module.exports.isPathValid = isPathValid;
|
|
871
|
-
define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// ../../packages/persistence/src/attached-derived.ts
|
|
876
|
-
import { rmSync } from "fs";
|
|
877
|
-
import { join } from "path";
|
|
878
|
-
var POLICY_CACHE_FILENAME = "policy-cache.json";
|
|
879
|
-
|
|
880
|
-
// ../../packages/persistence/src/control-plane-credential.ts
|
|
881
|
-
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
|
|
882
|
-
import { join as join2 } from "path";
|
|
883
6
|
|
|
884
7
|
// ../../packages/schema/src/drizzle/deferred-migrations.ts
|
|
885
8
|
var DEFERRED_MIGRATION_TAGS = [
|
|
@@ -3864,9 +2987,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
|
|
|
3864
2987
|
function stripTabAndNewline(value) {
|
|
3865
2988
|
return value.replace(asciiTabOrNewline, "");
|
|
3866
2989
|
}
|
|
3867
|
-
function urlHostnameOk(url2,
|
|
3868
|
-
|
|
3869
|
-
return
|
|
2990
|
+
function urlHostnameOk(url2, hostname4) {
|
|
2991
|
+
hostname4.lastIndex = 0;
|
|
2992
|
+
return hostname4.test(url2.hostname);
|
|
3870
2993
|
}
|
|
3871
2994
|
function urlProtocolOk(url2, protocol) {
|
|
3872
2995
|
protocol.lastIndex = 0;
|
|
@@ -20786,13 +19909,16 @@ function serviceTierMultiplier(tier) {
|
|
|
20786
19909
|
if (tier === void 0) return 1;
|
|
20787
19910
|
return SERVICE_TIER_MULTIPLIERS.get(tier) ?? 1;
|
|
20788
19911
|
}
|
|
19912
|
+
function promptTokensOf(usage) {
|
|
19913
|
+
return usage.promptTokens ?? (usage.inputTokens ?? 0) + (usage.cacheReadTokens ?? 0) + (usage.cacheWrite1hTokens ?? 0) + (usage.cacheWrite5mTokens ?? 0);
|
|
19914
|
+
}
|
|
20789
19915
|
function costOf(price, usage) {
|
|
20790
19916
|
const metered = [
|
|
20791
19917
|
[usage.cacheWrite1hTokens ?? 0, price.cacheWrite1h],
|
|
20792
19918
|
[usage.cacheWrite5mTokens ?? 0, price.cacheWrite5m],
|
|
20793
19919
|
[usage.cacheReadTokens ?? 0, price.cacheRead]
|
|
20794
19920
|
];
|
|
20795
|
-
const band = price.longContext !== null && (usage
|
|
19921
|
+
const band = price.longContext !== null && promptTokensOf(usage) > price.longContext.thresholdInputTokens ? price.longContext : null;
|
|
20796
19922
|
if (band !== null && (band.input === null || band.output === null)) return null;
|
|
20797
19923
|
const inputRate = band?.input ?? price.input;
|
|
20798
19924
|
const outputRate = band?.output ?? price.output;
|
|
@@ -20865,8 +19991,8 @@ var PLATFORM_HOSTING = /* @__PURE__ */ new Map([
|
|
|
20865
19991
|
["ollama", "local"],
|
|
20866
19992
|
["local", "local"]
|
|
20867
19993
|
]);
|
|
20868
|
-
function hostingFor(
|
|
20869
|
-
return PLATFORM_HOSTING.get(
|
|
19994
|
+
function hostingFor(platform) {
|
|
19995
|
+
return PLATFORM_HOSTING.get(platform) ?? "api";
|
|
20870
19996
|
}
|
|
20871
19997
|
var FIRST_PARTY = /* @__PURE__ */ new Map([
|
|
20872
19998
|
["anthropic", "anthropic"],
|
|
@@ -20880,8 +20006,8 @@ var FIRST_PARTY = /* @__PURE__ */ new Map([
|
|
|
20880
20006
|
function firstPartyPlatformFor(vendor2) {
|
|
20881
20007
|
return FIRST_PARTY.get(vendor2) ?? null;
|
|
20882
20008
|
}
|
|
20883
|
-
function isFirstParty(vendor2,
|
|
20884
|
-
return FIRST_PARTY.get(vendor2) ===
|
|
20009
|
+
function isFirstParty(vendor2, platform) {
|
|
20010
|
+
return FIRST_PARTY.get(vendor2) === platform;
|
|
20885
20011
|
}
|
|
20886
20012
|
var PLATFORM_NAMESPACES = Object.freeze([
|
|
20887
20013
|
"anthropic",
|
|
@@ -20942,14 +20068,14 @@ var ModelVendorBuilder = class {
|
|
|
20942
20068
|
);
|
|
20943
20069
|
}
|
|
20944
20070
|
for (const ref of spec.on ?? []) {
|
|
20945
|
-
const { platform
|
|
20946
|
-
const firstParty = isFirstParty(this.vendor,
|
|
20947
|
-
const hosting = hostingFor(
|
|
20071
|
+
const { platform, price, retention, region } = normalizeRef(ref);
|
|
20072
|
+
const firstParty = isFirstParty(this.vendor, platform);
|
|
20073
|
+
const hosting = hostingFor(platform);
|
|
20948
20074
|
const isSelfHosted = hosting === "local";
|
|
20949
20075
|
platforms.set(
|
|
20950
|
-
|
|
20076
|
+
platform,
|
|
20951
20077
|
Object.freeze({
|
|
20952
|
-
platform
|
|
20078
|
+
platform,
|
|
20953
20079
|
hosting,
|
|
20954
20080
|
firstParty,
|
|
20955
20081
|
price: price ?? (isSelfHosted ? ZERO_PRICE : firstParty ? spec.price ?? null : null),
|
|
@@ -21002,35 +20128,35 @@ var GATEWAY_VENDOR_SLASH_RE = /^[a-z0-9][\w.-]*\//iu;
|
|
|
21002
20128
|
var BEDROCK_VERSION_RE = /-v\d+:\d+$/u;
|
|
21003
20129
|
var BEDROCK_REVISION_RE = /:\d+$/u;
|
|
21004
20130
|
var VERTEX_VERSION_RE = /@[\w-]+$/u;
|
|
21005
|
-
var DATED_SUFFIX_RE =
|
|
20131
|
+
var DATED_SUFFIX_RE = /-(?:\d{8}|\d{4}-\d{2}-\d{2})$/u;
|
|
21006
20132
|
function stripPlatformDecorations(model) {
|
|
21007
20133
|
let id = model.trim();
|
|
21008
|
-
let
|
|
20134
|
+
let platform = null;
|
|
21009
20135
|
if (GEO_PREFIX_RE.test(id)) {
|
|
21010
20136
|
id = id.replace(GEO_PREFIX_RE, "");
|
|
21011
|
-
|
|
20137
|
+
platform = "bedrock";
|
|
21012
20138
|
}
|
|
21013
20139
|
if (NAMESPACE_DOT_RE.test(id)) {
|
|
21014
20140
|
id = id.replace(NAMESPACE_DOT_RE, "");
|
|
21015
|
-
|
|
20141
|
+
platform ??= "bedrock";
|
|
21016
20142
|
}
|
|
21017
20143
|
if (BEDROCK_VERSION_RE.test(id)) {
|
|
21018
20144
|
id = id.replace(BEDROCK_VERSION_RE, "");
|
|
21019
|
-
|
|
20145
|
+
platform ??= "bedrock";
|
|
21020
20146
|
} else if (BEDROCK_REVISION_RE.test(id)) {
|
|
21021
20147
|
id = id.replace(BEDROCK_REVISION_RE, "");
|
|
21022
|
-
|
|
20148
|
+
platform ??= "bedrock";
|
|
21023
20149
|
}
|
|
21024
20150
|
if (VERTEX_VERSION_RE.test(id)) {
|
|
21025
20151
|
id = id.replace(VERTEX_VERSION_RE, "");
|
|
21026
|
-
|
|
20152
|
+
platform ??= "vertex";
|
|
21027
20153
|
}
|
|
21028
20154
|
if (NAMESPACE_SLASH_RE.test(id)) {
|
|
21029
20155
|
id = id.replace(NAMESPACE_SLASH_RE, "");
|
|
21030
20156
|
} else if (GATEWAY_VENDOR_SLASH_RE.test(id)) {
|
|
21031
20157
|
id = id.replace(GATEWAY_VENDOR_SLASH_RE, "");
|
|
21032
20158
|
}
|
|
21033
|
-
return { id, platform
|
|
20159
|
+
return { id, platform };
|
|
21034
20160
|
}
|
|
21035
20161
|
function buildModelIndex(entries) {
|
|
21036
20162
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -21047,19 +20173,19 @@ function resolveModel(raw, index) {
|
|
|
21047
20173
|
if (exact !== void 0) {
|
|
21048
20174
|
return { entry: exact, canonicalId: raw, platform: null, raw };
|
|
21049
20175
|
}
|
|
21050
|
-
const { id, platform
|
|
20176
|
+
const { id, platform } = stripPlatformDecorations(raw);
|
|
21051
20177
|
const stripped = index.byId.get(id);
|
|
21052
20178
|
if (stripped !== void 0) {
|
|
21053
|
-
return { entry: stripped, canonicalId: id, platform
|
|
20179
|
+
return { entry: stripped, canonicalId: id, platform, raw };
|
|
21054
20180
|
}
|
|
21055
20181
|
if (DATED_SUFFIX_RE.test(id)) {
|
|
21056
20182
|
const undated = id.replace(DATED_SUFFIX_RE, "");
|
|
21057
20183
|
const byDate = index.byId.get(undated);
|
|
21058
20184
|
if (byDate !== void 0) {
|
|
21059
|
-
return { entry: byDate, canonicalId: undated, platform
|
|
20185
|
+
return { entry: byDate, canonicalId: undated, platform, raw };
|
|
21060
20186
|
}
|
|
21061
20187
|
}
|
|
21062
|
-
return { entry: null, canonicalId: raw, platform
|
|
20188
|
+
return { entry: null, canonicalId: raw, platform, raw };
|
|
21063
20189
|
}
|
|
21064
20190
|
|
|
21065
20191
|
// ../../packages/schema/src/model/catalog.ts
|
|
@@ -21152,7 +20278,7 @@ anthropic.model("claude-haiku-4-5", {
|
|
|
21152
20278
|
name: "Claude Haiku 4.5",
|
|
21153
20279
|
ctx: 2e5,
|
|
21154
20280
|
maxOut: 64e3,
|
|
21155
|
-
// Reviewed: fast/cheap tier,
|
|
20281
|
+
// Reviewed: fast/cheap general-purpose tier, not a reasoning or code model.
|
|
21156
20282
|
capability: null,
|
|
21157
20283
|
price: anthropicPrice(1, 5, 0.1),
|
|
21158
20284
|
// The vendor documents `claude-haiku-4-5-20251001` as the versioned id and
|
|
@@ -21283,6 +20409,11 @@ openai.model("gpt-4o", {
|
|
|
21283
20409
|
price: tokenPrice(2.5, 10, { cacheRead: 1.25 }),
|
|
21284
20410
|
on: [...OPENAI_RESELLERS]
|
|
21285
20411
|
});
|
|
20412
|
+
openai.model("gpt-4o-2024-05-13", {
|
|
20413
|
+
name: "GPT-4o (2024-05-13)",
|
|
20414
|
+
price: tokenPrice(5, 15),
|
|
20415
|
+
on: [...OPENAI_RESELLERS]
|
|
20416
|
+
});
|
|
21286
20417
|
openai.model("gpt-4o-mini", {
|
|
21287
20418
|
name: "GPT-4o mini",
|
|
21288
20419
|
price: tokenPrice(0.15, 0.6, { cacheRead: 0.075 }),
|
|
@@ -21302,6 +20433,24 @@ openai.model("o3", {
|
|
|
21302
20433
|
price: tokenPrice(2, 8, { cacheRead: 0.5 }),
|
|
21303
20434
|
on: [...OPENAI_RESELLERS]
|
|
21304
20435
|
});
|
|
20436
|
+
openai.model("text-embedding-3-small", {
|
|
20437
|
+
name: "text-embedding-3-small",
|
|
20438
|
+
capability: "embedding",
|
|
20439
|
+
price: tokenPrice(0.02, 0),
|
|
20440
|
+
on: [...OPENAI_RESELLERS]
|
|
20441
|
+
});
|
|
20442
|
+
openai.model("text-embedding-3-large", {
|
|
20443
|
+
name: "text-embedding-3-large",
|
|
20444
|
+
capability: "embedding",
|
|
20445
|
+
price: tokenPrice(0.13, 0),
|
|
20446
|
+
on: [...OPENAI_RESELLERS]
|
|
20447
|
+
});
|
|
20448
|
+
openai.model("text-embedding-ada-002", {
|
|
20449
|
+
name: "text-embedding-ada-002",
|
|
20450
|
+
capability: "embedding",
|
|
20451
|
+
price: tokenPrice(0.1, 0),
|
|
20452
|
+
on: [...OPENAI_RESELLERS]
|
|
20453
|
+
});
|
|
21305
20454
|
openai.model("gpt-oss-120b", {
|
|
21306
20455
|
name: "GPT-OSS 120B",
|
|
21307
20456
|
openWeights: true,
|
|
@@ -21588,10 +20737,21 @@ var MODEL_ENTRIES = Object.freeze([
|
|
|
21588
20737
|
...alibaba.models(),
|
|
21589
20738
|
...amazon.models()
|
|
21590
20739
|
]);
|
|
20740
|
+
var LONG_CONTEXT_THRESHOLDS = Object.freeze(
|
|
20741
|
+
[
|
|
20742
|
+
...new Set(
|
|
20743
|
+
MODEL_ENTRIES.flatMap(
|
|
20744
|
+
(entry) => [...entry.platforms.values()].flatMap(
|
|
20745
|
+
(offering) => offering.price?.longContext ? [offering.price.longContext.thresholdInputTokens] : []
|
|
20746
|
+
)
|
|
20747
|
+
)
|
|
20748
|
+
)
|
|
20749
|
+
].sort((a, b) => a - b)
|
|
20750
|
+
);
|
|
21591
20751
|
var MODEL_INDEX = buildModelIndex(MODEL_ENTRIES);
|
|
21592
20752
|
|
|
21593
20753
|
// ../../packages/schema/src/model/governance.ts
|
|
21594
|
-
var ModelCapability = external_exports.enum(["reasoning", "code"]);
|
|
20754
|
+
var ModelCapability = external_exports.enum(["reasoning", "code", "embedding"]);
|
|
21595
20755
|
var DataRetention = external_exports.enum([
|
|
21596
20756
|
"zero_retention",
|
|
21597
20757
|
"no_storage",
|
|
@@ -21687,16 +20847,16 @@ function platformForProvider(provider) {
|
|
|
21687
20847
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
21688
20848
|
}
|
|
21689
20849
|
function isLocalProvider(provider) {
|
|
21690
|
-
const
|
|
21691
|
-
return
|
|
20850
|
+
const platform = platformForProvider(provider);
|
|
20851
|
+
return platform !== null && hostingFor(platform) === "local";
|
|
21692
20852
|
}
|
|
21693
20853
|
function priceFor(provider, model) {
|
|
21694
20854
|
if (isLocalProvider(provider)) return ZERO_PRICE;
|
|
21695
20855
|
const resolved = resolveModel(model, MODEL_INDEX);
|
|
21696
20856
|
if (resolved.entry === null) return null;
|
|
21697
|
-
const
|
|
21698
|
-
if (
|
|
21699
|
-
return resolved.entry.platforms.get(
|
|
20857
|
+
const platform = resolved.platform ?? platformForProvider(provider);
|
|
20858
|
+
if (platform === null) return null;
|
|
20859
|
+
return resolved.entry.platforms.get(platform)?.price ?? null;
|
|
21700
20860
|
}
|
|
21701
20861
|
var defaultCostModel = {
|
|
21702
20862
|
normalizeModelId(provider, model) {
|
|
@@ -21722,7 +20882,7 @@ var COMPACT = new Intl.NumberFormat("en-US", {
|
|
|
21722
20882
|
|
|
21723
20883
|
// ../../packages/schema/src/token/token-report.ts
|
|
21724
20884
|
var num = (value) => value ?? 0;
|
|
21725
|
-
function costUsageOf(a) {
|
|
20885
|
+
function costUsageOf(a, promptTokens) {
|
|
21726
20886
|
const usage = {
|
|
21727
20887
|
inputTokens: num(a.input_tokens),
|
|
21728
20888
|
outputTokens: num(a.output_tokens),
|
|
@@ -21732,11 +20892,12 @@ function costUsageOf(a) {
|
|
|
21732
20892
|
webSearchRequests: num(a.web_search_requests)
|
|
21733
20893
|
};
|
|
21734
20894
|
if (a.service_tier !== void 0) usage.serviceTier = a.service_tier;
|
|
20895
|
+
if (promptTokens !== void 0) usage.promptTokens = promptTokens;
|
|
21735
20896
|
return usage;
|
|
21736
20897
|
}
|
|
21737
20898
|
function buildTokenReports(leaves, costModel) {
|
|
21738
20899
|
const bySession = /* @__PURE__ */ new Map();
|
|
21739
|
-
for (const { sessionId, attributes } of leaves) {
|
|
20900
|
+
for (const { sessionId, attributes, promptTokens } of leaves) {
|
|
21740
20901
|
const provider = attributes.provider ?? "unknown";
|
|
21741
20902
|
const model = attributes.model ?? "unknown";
|
|
21742
20903
|
const key = `${provider} ${model}`;
|
|
@@ -21755,7 +20916,8 @@ function buildTokenReports(leaves, costModel) {
|
|
|
21755
20916
|
cacheCreation: 0,
|
|
21756
20917
|
cacheRead: 0,
|
|
21757
20918
|
costUsd: 0,
|
|
21758
|
-
priced: false
|
|
20919
|
+
priced: false,
|
|
20920
|
+
partial: false
|
|
21759
20921
|
};
|
|
21760
20922
|
rollups.set(key, acc);
|
|
21761
20923
|
}
|
|
@@ -21763,8 +20925,14 @@ function buildTokenReports(leaves, costModel) {
|
|
|
21763
20925
|
acc.output += num(attributes.output_tokens);
|
|
21764
20926
|
acc.cacheCreation += num(attributes.cache_creation_input_tokens);
|
|
21765
20927
|
acc.cacheRead += num(attributes.cache_read_input_tokens);
|
|
21766
|
-
const leafCost = costModel.costFor({
|
|
21767
|
-
|
|
20928
|
+
const leafCost = costModel.costFor({
|
|
20929
|
+
provider,
|
|
20930
|
+
model,
|
|
20931
|
+
usage: costUsageOf(attributes, promptTokens)
|
|
20932
|
+
});
|
|
20933
|
+
if (leafCost === null) {
|
|
20934
|
+
acc.partial = true;
|
|
20935
|
+
} else {
|
|
21768
20936
|
acc.costUsd += leafCost;
|
|
21769
20937
|
acc.priced = true;
|
|
21770
20938
|
}
|
|
@@ -21780,9 +20948,8 @@ function buildTokenReports(leaves, costModel) {
|
|
|
21780
20948
|
const rollupTotal = acc.input + acc.output + acc.cacheCreation + acc.cacheRead;
|
|
21781
20949
|
totalTokens += rollupTotal;
|
|
21782
20950
|
const estimatedCostUsd = acc.priced ? acc.costUsd : null;
|
|
21783
|
-
if (
|
|
21784
|
-
|
|
21785
|
-
} else {
|
|
20951
|
+
if (acc.partial) anyUnpriced = true;
|
|
20952
|
+
if (estimatedCostUsd !== null) {
|
|
21786
20953
|
anyPriced = true;
|
|
21787
20954
|
costUsd += estimatedCostUsd;
|
|
21788
20955
|
}
|
|
@@ -21805,7 +20972,7 @@ function buildTokenReports(leaves, costModel) {
|
|
|
21805
20972
|
totalTokens,
|
|
21806
20973
|
// Σ of the PRICED rollups; null when none had a known price.
|
|
21807
20974
|
estimatedCostUsd: anyPriced ? costUsd : null,
|
|
21808
|
-
// Any
|
|
20975
|
+
// Any call priced to null means the total understates real spend.
|
|
21809
20976
|
costIsPartial: anyUnpriced
|
|
21810
20977
|
});
|
|
21811
20978
|
}
|
|
@@ -22684,8 +21851,9 @@ var SessionTokenReport = external_exports.object({
|
|
|
22684
21851
|
totalTokens: external_exports.number().int().nonnegative(),
|
|
22685
21852
|
// Σ of the PRICED rollups only; null when no rollup had a known price.
|
|
22686
21853
|
estimatedCostUsd: external_exports.number().nullable(),
|
|
22687
|
-
// True whenever any
|
|
22688
|
-
//
|
|
21854
|
+
// True whenever any call priced to null (an unknown provider/model, or a call
|
|
21855
|
+
// over a long-context threshold whose rate is unpublished), so the total
|
|
21856
|
+
// understates real spend — the UI renders `≥ $X` instead of a falsely
|
|
22689
21857
|
// precise figure rather than silently dropping the unpriced calls.
|
|
22690
21858
|
costIsPartial: external_exports.boolean()
|
|
22691
21859
|
});
|
|
@@ -23534,7 +22702,15 @@ var StorePostureSnapshot = external_exports.object({
|
|
|
23534
22702
|
policyCounts: StorePosturePolicyCounts,
|
|
23535
22703
|
// OPTIONAL, not nullable: a reporter that predates this member keeps
|
|
23536
22704
|
// getting its 200 without a payload change.
|
|
23537
|
-
plugin: StorePosturePlugin.optional()
|
|
22705
|
+
plugin: StorePosturePlugin.optional(),
|
|
22706
|
+
// OPTIONAL, and sent only by a scoped attachment, always as `scoped`. A
|
|
22707
|
+
// machine attachment omits it, so its body is byte for byte the one it
|
|
22708
|
+
// sent before this member existed. Absent therefore means machine-wide OR
|
|
22709
|
+
// a reporter older than this member, never "scoped". Both values parse, so
|
|
22710
|
+
// a sender that one day spells `machine` breaks no receiver; any other
|
|
22711
|
+
// value fails the whole snapshot, which is why the reporter sends a
|
|
22712
|
+
// constant and never the raw mode.
|
|
22713
|
+
attachmentMode: AttachmentMode.optional()
|
|
23538
22714
|
}).meta({ id: "StorePostureSnapshot" });
|
|
23539
22715
|
var CAPTURE_VERSION_PREFIX = "capture/";
|
|
23540
22716
|
var RecordAuditEventRequest = AuditEventInput.extend({
|
|
@@ -23981,7 +23157,7 @@ var Rule = external_exports.strictObject({
|
|
|
23981
23157
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23982
23158
|
requiresNearby: RequiresNearby.optional(),
|
|
23983
23159
|
examples: external_exports.array(external_exports.string()).optional(),
|
|
23984
|
-
// Whether the matched text is itself sensitive
|
|
23160
|
+
// Whether the matched text is itself sensitive (see RuleEvidence).
|
|
23985
23161
|
evidence: RuleEvidence.optional()
|
|
23986
23162
|
}).meta({ id: "Rule" });
|
|
23987
23163
|
var Author = external_exports.object({
|
|
@@ -24073,7 +23249,13 @@ var DetectionRule = external_exports.object({
|
|
|
24073
23249
|
// Representative matching strings the rule author shipped with the rule. The
|
|
24074
23250
|
// cheapest honest answer to "show me what this rule catches" — every bundled
|
|
24075
23251
|
// rule has them, and they are already in the stored snapshot.
|
|
24076
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
23252
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
23253
|
+
// The rule's DECLARED evidence, as stored. Absent defers to the engine's
|
|
23254
|
+
// classification (ruleEvidence in @akasecurity/detections): a bundled
|
|
23255
|
+
// code-flaw rule reads as 'code' and anything else as 'value', and a rule
|
|
23256
|
+
// in a value category (secret/pii/financial/phi) is always 'value',
|
|
23257
|
+
// whatever it declares.
|
|
23258
|
+
evidence: RuleEvidence.optional()
|
|
24077
23259
|
}).meta({ id: "DetectionRule" });
|
|
24078
23260
|
var DetectionUpdate = external_exports.object({
|
|
24079
23261
|
available: external_exports.boolean(),
|
|
@@ -24141,8 +23323,10 @@ var ImportDetectionRequest = external_exports.object({
|
|
|
24141
23323
|
}).meta({ id: "ImportDetectionRequest" });
|
|
24142
23324
|
|
|
24143
23325
|
// ../../packages/schema/src/zod/detection-build.ts
|
|
24144
|
-
function optional2(key,
|
|
24145
|
-
if (raw === void 0
|
|
23326
|
+
function optional2(key, raw, parse4) {
|
|
23327
|
+
if (raw === void 0) return {};
|
|
23328
|
+
const parsed = parse4(raw);
|
|
23329
|
+
if (!parsed.success || parsed.data === void 0) return {};
|
|
24146
23330
|
return { [key]: parsed.data };
|
|
24147
23331
|
}
|
|
24148
23332
|
function isStringArray(value) {
|
|
@@ -24177,10 +23361,12 @@ function rowToDetectionDetail(row, findingsLast30d, update) {
|
|
|
24177
23361
|
category: r.category,
|
|
24178
23362
|
severity: r.severity,
|
|
24179
23363
|
matcher: parsed.data,
|
|
24180
|
-
//
|
|
24181
|
-
//
|
|
24182
|
-
//
|
|
24183
|
-
//
|
|
23364
|
+
// `appliesTo`, `postValidators` and `requiresNearby` are the rest of what
|
|
23365
|
+
// decides whether this rule fires. Carried so a consumer re-running the
|
|
23366
|
+
// rule (a preview, a tester) evaluates what the engine evaluates rather
|
|
23367
|
+
// than a matcher stripped of its guards — half the bundled catalog
|
|
23368
|
+
// carries at least one of these. `examples` and `evidence` describe the
|
|
23369
|
+
// rule and never gate a match.
|
|
24184
23370
|
//
|
|
24185
23371
|
// Enrichment is deliberately per-field and best-effort, NOT a whole-rule
|
|
24186
23372
|
// `Rule.safeParse`. Two reasons: `Rule` is a strict object pinned to
|
|
@@ -24190,18 +23376,19 @@ function rowToDetectionDetail(row, findingsLast30d, update) {
|
|
|
24190
23376
|
// test should stay exactly what it was, namely a renderable matcher. A
|
|
24191
23377
|
// field that fails validation is omitted, which reads as "not set" and is
|
|
24192
23378
|
// the same thing the consumer saw before this change.
|
|
24193
|
-
...optional2("appliesTo",
|
|
23379
|
+
...optional2("appliesTo", r.appliesTo, (v) => AppliesTo.safeParse(v)),
|
|
24194
23380
|
...optional2(
|
|
24195
23381
|
"postValidators",
|
|
24196
|
-
|
|
24197
|
-
|
|
23382
|
+
r.postValidators,
|
|
23383
|
+
(v) => PostValidatorRef.array().safeParse(v)
|
|
24198
23384
|
),
|
|
24199
|
-
...optional2("requiresNearby",
|
|
23385
|
+
...optional2("requiresNearby", r.requiresNearby, (v) => RequiresNearby.safeParse(v)),
|
|
24200
23386
|
...optional2(
|
|
24201
23387
|
"examples",
|
|
24202
|
-
|
|
24203
|
-
|
|
24204
|
-
)
|
|
23388
|
+
r.examples,
|
|
23389
|
+
(v) => isStringArray(v) ? { success: true, data: v } : { success: false }
|
|
23390
|
+
),
|
|
23391
|
+
...optional2("evidence", r.evidence, (v) => RuleEvidence.safeParse(v))
|
|
24205
23392
|
}
|
|
24206
23393
|
];
|
|
24207
23394
|
});
|
|
@@ -24894,11 +24081,14 @@ var PolicyBundle = external_exports.object({
|
|
|
24894
24081
|
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
24895
24082
|
// Model ids (the raw `model` string a harness reports, e.g.
|
|
24896
24083
|
// `claude-opus-4-1`) the tenant has PROHIBITED. The plugin refuses to switch
|
|
24897
|
-
// a session onto one (PreModelSwitch)
|
|
24898
|
-
//
|
|
24899
|
-
//
|
|
24900
|
-
//
|
|
24901
|
-
//
|
|
24084
|
+
// a session onto one (PreModelSwitch), refuses a turn that would run on one
|
|
24085
|
+
// (UserPromptSubmit) and refuses a subagent spawn onto one (PreToolUse),
|
|
24086
|
+
// wherever the organization governs the event: everywhere on a
|
|
24087
|
+
// machine-wide attachment, and only in enrolled repositories on a scoped
|
|
24088
|
+
// one (the plugin runtime's `governanceApplies`).
|
|
24089
|
+
// Optional so an older backend — and an older on-disk cache — still
|
|
24090
|
+
// parses; consumers read `?? []`, which is the unenforced behaviour that
|
|
24091
|
+
// predates this field and the safe direction to default.
|
|
24902
24092
|
//
|
|
24903
24093
|
// Ids, not display names: the governance decision is keyed on the exact
|
|
24904
24094
|
// string the harness reports (`model_status_override.versionId` in the
|
|
@@ -25281,6 +24471,8 @@ var AttachmentScopeEntry = external_exports.object({
|
|
|
25281
24471
|
});
|
|
25282
24472
|
var AttachmentScope = external_exports.object({
|
|
25283
24473
|
endpoint: external_exports.string().min(1),
|
|
24474
|
+
tenantName: PluginWhoami.shape.tenantName.optional(),
|
|
24475
|
+
userEmail: PluginWhoami.shape.userEmail.optional(),
|
|
25284
24476
|
entries: external_exports.array(AttachmentScopeEntry)
|
|
25285
24477
|
});
|
|
25286
24478
|
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
@@ -25614,6 +24806,27 @@ var ManagedSettings = external_exports.object({
|
|
|
25614
24806
|
}).meta({ id: "ManagedSettings" });
|
|
25615
24807
|
var NO_MANAGED_CONTEXT = { present: false, lockedFields: [] };
|
|
25616
24808
|
|
|
24809
|
+
// ../../packages/schema/src/zod/mod-policy-snapshot.ts
|
|
24810
|
+
var MOD_POLICY_SNAPSHOT_VERSION = 1;
|
|
24811
|
+
var MOD_POLICY_SNAPSHOT_MAX_BYTES = 4 * 1024 * 1024;
|
|
24812
|
+
var ModPolicySnapshot = external_exports.object({
|
|
24813
|
+
version: external_exports.literal(MOD_POLICY_SNAPSHOT_VERSION),
|
|
24814
|
+
generatedAt: external_exports.iso.datetime(),
|
|
24815
|
+
// The complete effective ruleset, as the hook's runtime scans with it: the
|
|
24816
|
+
// user's enabled installed packs (user-modified and custom packs included).
|
|
24817
|
+
// Absent means the store holds no authoritative snapshot, and the reader
|
|
24818
|
+
// scans with the packs it ships — the hook's own fallback.
|
|
24819
|
+
rules: external_exports.array(Rule).optional(),
|
|
24820
|
+
// Rule-targeted actions (first enabled policy per rule wins).
|
|
24821
|
+
ruleActions: external_exports.record(external_exports.string(), ActionTaken),
|
|
24822
|
+
// The resolved action per detection category.
|
|
24823
|
+
categoryActions: external_exports.record(external_exports.string(), ActionTaken),
|
|
24824
|
+
// Rules with an active exception grant. Honouring a grant means matching a
|
|
24825
|
+
// keyed fingerprint of the value and consuming a use, which only the hook can
|
|
24826
|
+
// do, so the mod leaves a finding of one of these rules for the hook to decide.
|
|
24827
|
+
exceptionRuleIds: external_exports.array(external_exports.string())
|
|
24828
|
+
}).meta({ id: "ModPolicySnapshot" });
|
|
24829
|
+
|
|
25617
24830
|
// ../../packages/schema/src/zod/project-files.ts
|
|
25618
24831
|
var ProjectFileInput = external_exports.object({
|
|
25619
24832
|
path: external_exports.string().min(1),
|
|
@@ -25934,7 +25147,16 @@ var AttachInput = external_exports.object({
|
|
|
25934
25147
|
// 200 matches the tenantName bound beside it in control-plane.ts; nothing
|
|
25935
25148
|
// renders a longer one usefully.
|
|
25936
25149
|
label: printable(200).optional(),
|
|
25937
|
-
accessKey: external_exports.string()
|
|
25150
|
+
accessKey: external_exports.string(),
|
|
25151
|
+
// How much of this machine the attachment is for: everything, or only the
|
|
25152
|
+
// repositories its user enrolls. Optional, so an input without it still
|
|
25153
|
+
// parses; what an absent mode means is for whatever reads it to decide, not
|
|
25154
|
+
// this shape. This member validates the VALUE rather than leaving that to the
|
|
25155
|
+
// call site, a deliberate exception to this module's shape-only rule: a shape
|
|
25156
|
+
// rejection names the field, so a value that is not a mode is refused as a bad
|
|
25157
|
+
// `mode` rather than stripped or passed on. The dashboard's attach action reads
|
|
25158
|
+
// it as the mode to attach in.
|
|
25159
|
+
mode: AttachmentMode.optional()
|
|
25938
25160
|
});
|
|
25939
25161
|
|
|
25940
25162
|
// ../../packages/schema/src/zod/triage.ts
|
|
@@ -26220,6 +25442,15 @@ function fromCaptureStatusAttributes(bag) {
|
|
|
26220
25442
|
return parsedStatus.success ? parsedStatus.data : null;
|
|
26221
25443
|
}
|
|
26222
25444
|
|
|
25445
|
+
// ../../packages/persistence/src/attached-derived.ts
|
|
25446
|
+
import { rmSync } from "fs";
|
|
25447
|
+
import { join } from "path";
|
|
25448
|
+
var POLICY_CACHE_FILENAME = "policy-cache.json";
|
|
25449
|
+
|
|
25450
|
+
// ../../packages/persistence/src/control-plane-credential.ts
|
|
25451
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync2, readFileSync, rmSync as rmSync3, statSync } from "fs";
|
|
25452
|
+
import { join as join2 } from "path";
|
|
25453
|
+
|
|
26223
25454
|
// ../../packages/persistence/src/paths.ts
|
|
26224
25455
|
import {
|
|
26225
25456
|
chmodSync,
|
|
@@ -26290,7 +25521,7 @@ function writeOwnerOnlyFileSync(file2, data) {
|
|
|
26290
25521
|
|
|
26291
25522
|
// ../../packages/persistence/src/database.ts
|
|
26292
25523
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
26293
|
-
import { dirname as dirname2, join as
|
|
25524
|
+
import { dirname as dirname2, join as join8, sep } from "path";
|
|
26294
25525
|
import { DatabaseSync } from "node:sqlite";
|
|
26295
25526
|
|
|
26296
25527
|
// ../../packages/persistence/src/ids.ts
|
|
@@ -26323,6 +25554,7 @@ function captureId(sessionId, contentHash, filePath = null) {
|
|
|
26323
25554
|
canonicalIdentity(["capture", sessionId ?? NO_SESSION, contentHash, filePath ?? NO_PATH])
|
|
26324
25555
|
);
|
|
26325
25556
|
}
|
|
25557
|
+
var DOT = ".".charCodeAt(0);
|
|
26326
25558
|
|
|
26327
25559
|
// ../../packages/persistence/src/internal/snapshot.ts
|
|
26328
25560
|
import { randomUUID } from "crypto";
|
|
@@ -26650,6 +25882,25 @@ function scopeKeysParam(scopeKeys) {
|
|
|
26650
25882
|
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
26651
25883
|
FROM audit_events AS session_root
|
|
26652
25884
|
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
25885
|
+
var COUNTED_IN_SCOPE = `
|
|
25886
|
+
AND ${inScope("scope_key")}
|
|
25887
|
+
AND (event_type IN (${CAPTURE_TYPE_LIST}) OR ${inScope(ROOT_SCOPE_KEY)})`;
|
|
25888
|
+
var DRAIN_TOTALS = `SELECT
|
|
25889
|
+
SUM(CASE WHEN synced_at IS NULL AND started_at < :before THEN 1 ELSE 0 END) AS pending,
|
|
25890
|
+
SUM(CASE WHEN synced_at > 0 THEN 1 ELSE 0 END) AS sent,
|
|
25891
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
25892
|
+
AND (sync_failure IS NULL OR sync_failure = 'payload_invalid')
|
|
25893
|
+
THEN 1 ELSE 0 END) AS skipped,
|
|
25894
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
25895
|
+
AND sync_failure = 'deployment_refused' THEN 1 ELSE 0 END) AS refused,
|
|
25896
|
+
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
25897
|
+
AND sync_failure = 'detached_undelivered' THEN 1 ELSE 0 END) AS detached
|
|
25898
|
+
FROM audit_events
|
|
25899
|
+
WHERE event_type IN (${TYPE_LIST})`;
|
|
25900
|
+
var CAPTURE_SKIPS = `SELECT COUNT(*) AS skipped
|
|
25901
|
+
FROM audit_events
|
|
25902
|
+
WHERE synced_at = ${String(SKIPPED)}
|
|
25903
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})`;
|
|
26653
25904
|
var ROW_COLUMNS = `id,
|
|
26654
25905
|
parent_id AS parentId,
|
|
26655
25906
|
root_session_id AS rootSessionId,
|
|
@@ -26725,7 +25976,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
26725
25976
|
);
|
|
26726
25977
|
this.scopedCaptureRowsStmt = db.prepare(
|
|
26727
25978
|
`SELECT ${ROW_COLUMNS}
|
|
26728
|
-
FROM audit_events
|
|
25979
|
+
FROM audit_events INDEXED BY idx_audit_scope_owed
|
|
26729
25980
|
WHERE synced_at IS NULL
|
|
26730
25981
|
AND sync_claimed_at IS NULL
|
|
26731
25982
|
AND outbox_owed = 1
|
|
@@ -26778,40 +26029,28 @@ var SqliteHistorySyncRepository = class {
|
|
|
26778
26029
|
);
|
|
26779
26030
|
this.partitionStmt = db.prepare(`SELECT${PARTITION_BUCKETS}
|
|
26780
26031
|
FROM audit_events${COUNTED_SCOPE}`);
|
|
26032
|
+
this.scopedPartitionStmt = db.prepare(`SELECT${PARTITION_BUCKETS}
|
|
26033
|
+
FROM audit_events${COUNTED_SCOPE}${COUNTED_IN_SCOPE}`);
|
|
26781
26034
|
this.partitionByKindStmt = db.prepare(
|
|
26782
26035
|
`SELECT event_type AS kind,${PARTITION_BUCKETS}
|
|
26783
26036
|
FROM audit_events INDEXED BY idx_audit_events_sync${COUNTED_SCOPE}
|
|
26784
26037
|
GROUP BY event_type`
|
|
26785
26038
|
);
|
|
26786
|
-
this.
|
|
26787
|
-
`SELECT
|
|
26788
|
-
|
|
26789
|
-
|
|
26790
|
-
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
26791
|
-
AND (sync_failure IS NULL OR sync_failure = 'payload_invalid')
|
|
26792
|
-
THEN 1 ELSE 0 END) AS skipped,
|
|
26793
|
-
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
26794
|
-
AND sync_failure = 'deployment_refused' THEN 1 ELSE 0 END) AS refused,
|
|
26795
|
-
SUM(CASE WHEN synced_at = ${String(SKIPPED)}
|
|
26796
|
-
AND sync_failure = 'detached_undelivered' THEN 1 ELSE 0 END) AS detached
|
|
26797
|
-
FROM audit_events
|
|
26798
|
-
WHERE event_type IN (${TYPE_LIST})`
|
|
26039
|
+
this.scopedPartitionByKindStmt = db.prepare(
|
|
26040
|
+
`SELECT event_type AS kind,${PARTITION_BUCKETS}
|
|
26041
|
+
FROM audit_events INDEXED BY idx_audit_events_sync${COUNTED_SCOPE}${COUNTED_IN_SCOPE}
|
|
26042
|
+
GROUP BY event_type`
|
|
26799
26043
|
);
|
|
26800
|
-
this.
|
|
26801
|
-
|
|
26802
|
-
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
|
|
26809
|
-
|
|
26810
|
-
// frees.
|
|
26811
|
-
`SELECT COUNT(*) AS skipped
|
|
26812
|
-
FROM audit_events
|
|
26813
|
-
WHERE synced_at = ${String(SKIPPED)}
|
|
26814
|
-
AND event_type IN (${CAPTURE_TYPE_LIST})`
|
|
26044
|
+
this.countsStmt = db.prepare(DRAIN_TOTALS);
|
|
26045
|
+
this.scopedCountsStmt = db.prepare(
|
|
26046
|
+
`${DRAIN_TOTALS}
|
|
26047
|
+
AND ${inScope("scope_key")}
|
|
26048
|
+
AND ${inScope(ROOT_SCOPE_KEY)}`
|
|
26049
|
+
);
|
|
26050
|
+
this.captureSkipCountStmt = db.prepare(CAPTURE_SKIPS);
|
|
26051
|
+
this.scopedCaptureSkipCountStmt = db.prepare(
|
|
26052
|
+
`${CAPTURE_SKIPS}
|
|
26053
|
+
AND ${inScope("scope_key")}`
|
|
26815
26054
|
);
|
|
26816
26055
|
this.fingerprintStmt = db.prepare(
|
|
26817
26056
|
`SELECT endpoint_fingerprint AS fingerprint, backlog_before AS backlogBefore
|
|
@@ -26925,6 +26164,10 @@ var SqliteHistorySyncRepository = class {
|
|
|
26925
26164
|
scopedCaptureRowsStmt;
|
|
26926
26165
|
scopedCaptureBacklogOwedStmt;
|
|
26927
26166
|
markScopeCapturesOwedStmt;
|
|
26167
|
+
scopedPartitionStmt;
|
|
26168
|
+
scopedPartitionByKindStmt;
|
|
26169
|
+
scopedCountsStmt;
|
|
26170
|
+
scopedCaptureSkipCountStmt;
|
|
26928
26171
|
/**
|
|
26929
26172
|
* The masked detections recorded against one tool call.
|
|
26930
26173
|
*
|
|
@@ -27146,7 +26389,29 @@ var SqliteHistorySyncRepository = class {
|
|
|
27146
26389
|
* in" — and a machine that has never attached has no boundary to pass, so
|
|
27147
26390
|
* requiring one would force a caller to invent one and report the whole store
|
|
27148
26391
|
* as queued.
|
|
26392
|
+
*
|
|
26393
|
+
* `scopeKeys` is a scoped attachment's filter: every bucket then counts only
|
|
26394
|
+
* the rows that pass the drain's reachability rule for that scope
|
|
26395
|
+
* (COUNTED_IN_SCOPE, which also names the one kind of row it counts that the
|
|
26396
|
+
* drain never offers), so a personal repository's rows are in none of them.
|
|
26397
|
+
* Omitted, this runs the machine statement, unchanged; an empty list counts
|
|
26398
|
+
* nothing.
|
|
27149
26399
|
*/
|
|
26400
|
+
partition(scopeKeys) {
|
|
26401
|
+
const row = getRow(
|
|
26402
|
+
scopeKeys === void 0 ? this.partitionStmt : this.scopedPartitionStmt,
|
|
26403
|
+
scopeKeys === void 0 ? {} : { scopeKeys: scopeKeysParam(scopeKeys) }
|
|
26404
|
+
);
|
|
26405
|
+
return {
|
|
26406
|
+
queued: row?.queued ?? 0,
|
|
26407
|
+
inProgress: row?.inProgress ?? 0,
|
|
26408
|
+
synced: row?.synced ?? 0,
|
|
26409
|
+
failed: row?.failed ?? 0,
|
|
26410
|
+
refused: row?.refused ?? 0,
|
|
26411
|
+
detached: row?.detached ?? 0,
|
|
26412
|
+
total: row?.total ?? 0
|
|
26413
|
+
};
|
|
26414
|
+
}
|
|
27150
26415
|
/**
|
|
27151
26416
|
* The same partition, one row per kind that a lane carries.
|
|
27152
26417
|
*
|
|
@@ -27156,11 +26421,14 @@ var SqliteHistorySyncRepository = class {
|
|
|
27156
26421
|
* rendering a fixed list of kinds must therefore treat a missing one as "no
|
|
27157
26422
|
* rows", never as "zero sent"; the two look identical in a bar and mean
|
|
27158
26423
|
* different things.
|
|
26424
|
+
*
|
|
26425
|
+
* `scopeKeys` scopes it with the clause `partition` uses, so the per-kind rows
|
|
26426
|
+
* still sum to the scoped aggregate. An empty list returns no rows.
|
|
27159
26427
|
*/
|
|
27160
|
-
partitionByKind() {
|
|
26428
|
+
partitionByKind(scopeKeys) {
|
|
27161
26429
|
return allRows(
|
|
27162
|
-
this.partitionByKindStmt,
|
|
27163
|
-
{}
|
|
26430
|
+
scopeKeys === void 0 ? this.partitionByKindStmt : this.scopedPartitionByKindStmt,
|
|
26431
|
+
scopeKeys === void 0 ? {} : { scopeKeys: scopeKeysParam(scopeKeys) }
|
|
27164
26432
|
).map((row) => ({
|
|
27165
26433
|
kind: row.kind,
|
|
27166
26434
|
queued: row.queued ?? 0,
|
|
@@ -27172,22 +26440,25 @@ var SqliteHistorySyncRepository = class {
|
|
|
27172
26440
|
total: row.total ?? 0
|
|
27173
26441
|
}));
|
|
27174
26442
|
}
|
|
27175
|
-
|
|
27176
|
-
|
|
27177
|
-
|
|
27178
|
-
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27190
|
-
|
|
26443
|
+
/**
|
|
26444
|
+
* The drain's totals. `pending` counts only what is inside the backlog; sent
|
|
26445
|
+
* and skipped are totals.
|
|
26446
|
+
*
|
|
26447
|
+
* `scopeKeys` is a scoped attachment's filter, and it scopes every figure,
|
|
26448
|
+
* `capturesSkipped` included: a structural row is counted only when its own
|
|
26449
|
+
* key and its session root's key are among them, a capture when its own key
|
|
26450
|
+
* is. So `pending` is exactly what pendingSessions and pendingRows page out
|
|
26451
|
+
* under the same keys and boundary. Omitted, this runs the machine
|
|
26452
|
+
* statements, unchanged; an empty list counts nothing.
|
|
26453
|
+
*/
|
|
26454
|
+
counts(before, scopeKeys) {
|
|
26455
|
+
const row = getRow(
|
|
26456
|
+
scopeKeys === void 0 ? this.countsStmt : this.scopedCountsStmt,
|
|
26457
|
+
scopeKeys === void 0 ? { before } : { before, scopeKeys: scopeKeysParam(scopeKeys) }
|
|
26458
|
+
);
|
|
26459
|
+
const captures = scopeKeys === void 0 ? getRow(this.captureSkipCountStmt) : getRow(this.scopedCaptureSkipCountStmt, {
|
|
26460
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26461
|
+
});
|
|
27191
26462
|
return {
|
|
27192
26463
|
pending: row?.pending ?? 0,
|
|
27193
26464
|
sent: row?.sent ?? 0,
|
|
@@ -27439,6 +26710,7 @@ function applyMigrations(db, file2, options = {}) {
|
|
|
27439
26710
|
}
|
|
27440
26711
|
ensureSyncedAtColumn(db, "audit_events");
|
|
27441
26712
|
ensureScopeKeyColumn(db);
|
|
26713
|
+
ensureScopeOwedIndex(db);
|
|
27442
26714
|
ensureScanLedgerTable(db);
|
|
27443
26715
|
ensureHistorySyncTable(db);
|
|
27444
26716
|
ensureBlockedDetectionsTable(db);
|
|
@@ -27879,14 +27151,48 @@ function ensureScopeKeyColumn(db) {
|
|
|
27879
27151
|
function hasScopeKeyColumn(db) {
|
|
27880
27152
|
return columnNames(db, "audit_events", { includeGenerated: true }).includes("scope_key");
|
|
27881
27153
|
}
|
|
27154
|
+
var SCOPE_OWED_INDEX_DDL = "CREATE INDEX IF NOT EXISTS idx_audit_scope_owed ON audit_events (scope_key, event_type, started_at) WHERE outbox_owed = 1 AND synced_at IS NULL";
|
|
27155
|
+
function ensureScopeOwedIndex(db) {
|
|
27156
|
+
if (!schemaObjectExists(db, "table", "audit_events")) return;
|
|
27157
|
+
const columns = columnNames(db, "audit_events", { includeGenerated: true });
|
|
27158
|
+
const complete = ["scope_key", "outbox_owed", "synced_at"].every((c) => columns.includes(c));
|
|
27159
|
+
if (!complete) return;
|
|
27160
|
+
db.exec(SCOPE_OWED_INDEX_DDL);
|
|
27161
|
+
}
|
|
27882
27162
|
function ensureScanLedgerTable(db) {
|
|
27883
27163
|
db.exec(`CREATE TABLE IF NOT EXISTS scan_ledger (
|
|
27884
27164
|
path TEXT PRIMARY KEY,
|
|
27885
27165
|
mtime TEXT NOT NULL,
|
|
27886
27166
|
content_hash TEXT NOT NULL,
|
|
27887
27167
|
ruleset_hash TEXT NOT NULL,
|
|
27888
|
-
scanned_at INTEGER NOT NULL
|
|
27168
|
+
scanned_at INTEGER NOT NULL,
|
|
27169
|
+
scope_key TEXT,
|
|
27170
|
+
scope_root TEXT
|
|
27889
27171
|
)`);
|
|
27172
|
+
ensureScanLedgerScopeKeyColumn(db);
|
|
27173
|
+
ensureScanLedgerScopeRootColumn(db);
|
|
27174
|
+
}
|
|
27175
|
+
var SCAN_LEDGER_SCOPE_KEY_DDL = "ALTER TABLE scan_ledger ADD COLUMN scope_key TEXT";
|
|
27176
|
+
var SCAN_LEDGER_SCOPE_ROOT_DDL = "ALTER TABLE scan_ledger ADD COLUMN scope_root TEXT";
|
|
27177
|
+
function ensureScanLedgerScopeKeyColumn(db) {
|
|
27178
|
+
ensureScanLedgerColumn(db, "scope_key", SCAN_LEDGER_SCOPE_KEY_DDL);
|
|
27179
|
+
}
|
|
27180
|
+
function ensureScanLedgerScopeRootColumn(db) {
|
|
27181
|
+
ensureScanLedgerColumn(db, "scope_root", SCAN_LEDGER_SCOPE_ROOT_DDL);
|
|
27182
|
+
}
|
|
27183
|
+
function ensureScanLedgerColumn(db, column, ddl) {
|
|
27184
|
+
if (!schemaObjectExists(db, "table", "scan_ledger")) return;
|
|
27185
|
+
if (hasScanLedgerColumn(db, column)) return;
|
|
27186
|
+
withTransaction(
|
|
27187
|
+
db,
|
|
27188
|
+
() => {
|
|
27189
|
+
if (!hasScanLedgerColumn(db, column)) db.exec(ddl);
|
|
27190
|
+
},
|
|
27191
|
+
"IMMEDIATE"
|
|
27192
|
+
);
|
|
27193
|
+
}
|
|
27194
|
+
function hasScanLedgerColumn(db, column) {
|
|
27195
|
+
return columnNames(db, "scan_ledger").includes(column);
|
|
27890
27196
|
}
|
|
27891
27197
|
function ensureHistorySyncTable(db) {
|
|
27892
27198
|
db.exec(`CREATE TABLE IF NOT EXISTS history_sync (
|
|
@@ -27937,6 +27243,106 @@ function ensureRuleProbeCacheTable(db) {
|
|
|
27937
27243
|
)`);
|
|
27938
27244
|
}
|
|
27939
27245
|
|
|
27246
|
+
// ../../packages/persistence/src/mod-policy-snapshot.ts
|
|
27247
|
+
import { createHash as createHash2 } from "crypto";
|
|
27248
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
27249
|
+
import { join as join4 } from "path";
|
|
27250
|
+
var MOD_POLICY_SNAPSHOT_FILENAME = "mod-policy.json";
|
|
27251
|
+
function modPolicySnapshotPath(dataDir2) {
|
|
27252
|
+
return join4(dataDir2, MOD_POLICY_SNAPSHOT_FILENAME);
|
|
27253
|
+
}
|
|
27254
|
+
function buildModPolicySnapshot(input2, generatedAt = /* @__PURE__ */ new Date()) {
|
|
27255
|
+
const byRule = /* @__PURE__ */ new Map();
|
|
27256
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
27257
|
+
for (const policy of input2.policies) {
|
|
27258
|
+
if (!policy.enabled) continue;
|
|
27259
|
+
if ("ruleId" in policy.target) {
|
|
27260
|
+
if (!byRule.has(policy.target.ruleId)) byRule.set(policy.target.ruleId, policy.action);
|
|
27261
|
+
} else if (!byCategory.has(policy.target.category)) {
|
|
27262
|
+
byCategory.set(policy.target.category, policy.action);
|
|
27263
|
+
}
|
|
27264
|
+
}
|
|
27265
|
+
const categoryActions = {};
|
|
27266
|
+
for (const category of DetectionCategory.options) {
|
|
27267
|
+
categoryActions[category] = byCategory.get(category) ?? DEFAULT_ACTIONS[category];
|
|
27268
|
+
}
|
|
27269
|
+
return {
|
|
27270
|
+
version: MOD_POLICY_SNAPSHOT_VERSION,
|
|
27271
|
+
generatedAt: generatedAt.toISOString(),
|
|
27272
|
+
// `examples` is documentation the mod never reads, and a custom pack's are
|
|
27273
|
+
// whatever its author pasted in, so they stay behind.
|
|
27274
|
+
...input2.rules !== void 0 ? { rules: input2.rules.map(withoutExamples) } : {},
|
|
27275
|
+
ruleActions: Object.fromEntries(byRule),
|
|
27276
|
+
categoryActions,
|
|
27277
|
+
exceptionRuleIds: [...new Set(input2.exceptionRuleIds)].sort()
|
|
27278
|
+
};
|
|
27279
|
+
}
|
|
27280
|
+
function assignedRuleActionPolicies(installed) {
|
|
27281
|
+
const out = [];
|
|
27282
|
+
for (const [ruleId, action] of installed.ruleActions) {
|
|
27283
|
+
if (installed.assignedRules.has(ruleId))
|
|
27284
|
+
out.push({ target: { ruleId }, action, enabled: true });
|
|
27285
|
+
}
|
|
27286
|
+
return out;
|
|
27287
|
+
}
|
|
27288
|
+
function withoutExamples(rule) {
|
|
27289
|
+
const copy = { ...rule };
|
|
27290
|
+
delete copy.examples;
|
|
27291
|
+
return copy;
|
|
27292
|
+
}
|
|
27293
|
+
function sameContent(a, b) {
|
|
27294
|
+
return JSON.stringify({ ...a, generatedAt: "" }) === JSON.stringify({ ...b, generatedAt: "" });
|
|
27295
|
+
}
|
|
27296
|
+
function readModPolicySnapshot(dataDir2) {
|
|
27297
|
+
try {
|
|
27298
|
+
const text = readFileSync2(modPolicySnapshotPath(dataDir2), "utf8");
|
|
27299
|
+
if (text.length > MOD_POLICY_SNAPSHOT_MAX_BYTES) return null;
|
|
27300
|
+
const parsed = ModPolicySnapshot.safeParse(JSON.parse(text));
|
|
27301
|
+
return parsed.success ? parsed.data : null;
|
|
27302
|
+
} catch {
|
|
27303
|
+
return null;
|
|
27304
|
+
}
|
|
27305
|
+
}
|
|
27306
|
+
function writeModPolicySnapshot(dataDir2, snapshot) {
|
|
27307
|
+
const text = JSON.stringify(snapshot);
|
|
27308
|
+
if (Buffer.byteLength(text) > MOD_POLICY_SNAPSHOT_MAX_BYTES) return false;
|
|
27309
|
+
const existing = readModPolicySnapshot(dataDir2);
|
|
27310
|
+
if (existing !== null && sameContent(existing, snapshot)) return false;
|
|
27311
|
+
ensureDataDirSync(dataDir2);
|
|
27312
|
+
writeOwnerOnlyFileSync(modPolicySnapshotPath(dataDir2), text);
|
|
27313
|
+
return true;
|
|
27314
|
+
}
|
|
27315
|
+
function regexProbeKey(matcher) {
|
|
27316
|
+
return createHash2("sha256").update(`${matcher.pattern} ${matcher.flags}`).digest("hex");
|
|
27317
|
+
}
|
|
27318
|
+
function vetRulesForMod(rules, sources, previouslyVetted = /* @__PURE__ */ new Set()) {
|
|
27319
|
+
const bundled = new Set(sources.bundledRegexMatchers().map(regexProbeKey));
|
|
27320
|
+
return rules.filter((rule) => {
|
|
27321
|
+
if (rule.matcher.type !== "regex") return true;
|
|
27322
|
+
const key = regexProbeKey(rule.matcher);
|
|
27323
|
+
const verdict = sources.probeVerdict(key);
|
|
27324
|
+
if (verdict === "quarantined") return false;
|
|
27325
|
+
return verdict === "safe" || bundled.has(key) || previouslyVetted.has(key);
|
|
27326
|
+
});
|
|
27327
|
+
}
|
|
27328
|
+
function modPolicyInputFromStore(sources, previouslyVetted = /* @__PURE__ */ new Set()) {
|
|
27329
|
+
const policies = sources.readPolicies();
|
|
27330
|
+
const snapshot = sources.installedRuleset();
|
|
27331
|
+
const usable = snapshot.installedPacks > 0 && (snapshot.enabledPacks === 0 || snapshot.invalidRules === 0 && snapshot.rules.length > 0);
|
|
27332
|
+
const empty = snapshot.installedPacks > 0 && snapshot.enabledPacks === 0;
|
|
27333
|
+
return {
|
|
27334
|
+
...usable ? { rules: empty ? [] : vetRulesForMod(snapshot.rules, sources, previouslyVetted) } : {},
|
|
27335
|
+
policies: [...policies, ...usable && !empty ? assignedRuleActionPolicies(snapshot) : []],
|
|
27336
|
+
exceptionRuleIds: sources.activeExceptionRuleIds()
|
|
27337
|
+
};
|
|
27338
|
+
}
|
|
27339
|
+
function refreshModPolicySnapshot(dataDir2, sources) {
|
|
27340
|
+
try {
|
|
27341
|
+
writeModPolicySnapshot(dataDir2, buildModPolicySnapshot(modPolicyInputFromStore(sources)));
|
|
27342
|
+
} catch {
|
|
27343
|
+
}
|
|
27344
|
+
}
|
|
27345
|
+
|
|
27940
27346
|
// ../../packages/persistence/src/internal/json.ts
|
|
27941
27347
|
function safeJson(s, fallback) {
|
|
27942
27348
|
if (s == null) return fallback;
|
|
@@ -28111,6 +27517,11 @@ var TIMELINE_COLUMNS = `
|
|
|
28111
27517
|
json_extract(attributes, '$.targetId') AS target_id,
|
|
28112
27518
|
json_extract(attributes, '$.internal') AS internal,
|
|
28113
27519
|
json_extract(attributes, '$.flagged') AS flagged`;
|
|
27520
|
+
var CALL_PROMPT_TOKENS = `(coalesce(input_tokens, 0) + coalesce(cache_read_input_tokens, 0)
|
|
27521
|
+
+ coalesce(ephemeral_1h_input_tokens, 0) + coalesce(ephemeral_5m_input_tokens, 0))`;
|
|
27522
|
+
var CALL_BAND = LONG_CONTEXT_THRESHOLDS.length === 0 ? "0" : LONG_CONTEXT_THRESHOLDS.map((t) => `(${CALL_PROMPT_TOKENS} > ${String(Math.trunc(t))})`).join(
|
|
27523
|
+
" + "
|
|
27524
|
+
);
|
|
28114
27525
|
var LLM_USAGE_SELECT = `
|
|
28115
27526
|
SELECT root_session_id AS sessionId,
|
|
28116
27527
|
provider,
|
|
@@ -28122,9 +27533,10 @@ var LLM_USAGE_SELECT = `
|
|
|
28122
27533
|
coalesce(sum(cache_read_input_tokens), 0) AS cacheReadTokens,
|
|
28123
27534
|
coalesce(sum(ephemeral_1h_input_tokens), 0) AS ephemeral1hTokens,
|
|
28124
27535
|
coalesce(sum(ephemeral_5m_input_tokens), 0) AS ephemeral5mTokens,
|
|
28125
|
-
coalesce(sum(web_search_requests), 0) AS webSearchRequests
|
|
27536
|
+
coalesce(sum(web_search_requests), 0) AS webSearchRequests,
|
|
27537
|
+
coalesce(max(${CALL_PROMPT_TOKENS}), 0) AS promptTokens`;
|
|
28126
27538
|
var LLM_USAGE_SCOPE = `event_type = 'llm_call' AND attributes IS NOT NULL AND root_session_id IS NOT NULL`;
|
|
28127
|
-
var LLM_USAGE_GROUP = `GROUP BY root_session_id, provider, model, service_tier`;
|
|
27539
|
+
var LLM_USAGE_GROUP = `GROUP BY root_session_id, provider, model, service_tier, ${CALL_BAND}`;
|
|
28128
27540
|
function usageLeaves(rows) {
|
|
28129
27541
|
return rows.map((row) => {
|
|
28130
27542
|
const attributes = {
|
|
@@ -28139,7 +27551,7 @@ function usageLeaves(rows) {
|
|
|
28139
27551
|
if (row.provider !== null) attributes.provider = row.provider;
|
|
28140
27552
|
if (row.model !== null) attributes.model = row.model;
|
|
28141
27553
|
if (row.serviceTier !== null) attributes.service_tier = row.serviceTier;
|
|
28142
|
-
return { sessionId: row.sessionId, attributes };
|
|
27554
|
+
return { sessionId: row.sessionId, attributes, promptTokens: row.promptTokens };
|
|
28143
27555
|
});
|
|
28144
27556
|
}
|
|
28145
27557
|
var SESSION_ROOT = `event_type = 'session'`;
|
|
@@ -29473,9 +28885,10 @@ var ACTIVE_REVEAL_GRANT_PREDICATE = `capability = 'reveal_to_model'
|
|
|
29473
28885
|
AND conditions IS NULL
|
|
29474
28886
|
AND ${ACTIVE_PREDICATE}`;
|
|
29475
28887
|
var SqliteExceptionsRepository = class {
|
|
29476
|
-
constructor(db, now = () => Date.now()) {
|
|
28888
|
+
constructor(db, now = () => Date.now(), onChange = () => void 0) {
|
|
29477
28889
|
this.db = db;
|
|
29478
28890
|
this.now = now;
|
|
28891
|
+
this.onChange = onChange;
|
|
29479
28892
|
this.consumeStmt = db.prepare(
|
|
29480
28893
|
`UPDATE exceptions
|
|
29481
28894
|
SET use_count = use_count + 1, last_used_at = :now, updated_at = :now
|
|
@@ -29494,6 +28907,7 @@ var SqliteExceptionsRepository = class {
|
|
|
29494
28907
|
}
|
|
29495
28908
|
db;
|
|
29496
28909
|
now;
|
|
28910
|
+
onChange;
|
|
29497
28911
|
consumeStmt;
|
|
29498
28912
|
insertBlockedStmt;
|
|
29499
28913
|
sweepBlockedStmt;
|
|
@@ -29509,7 +28923,9 @@ var SqliteExceptionsRepository = class {
|
|
|
29509
28923
|
*/
|
|
29510
28924
|
create(input2) {
|
|
29511
28925
|
try {
|
|
29512
|
-
|
|
28926
|
+
const created = this.createSync(input2);
|
|
28927
|
+
this.onChange();
|
|
28928
|
+
return Promise.resolve(created);
|
|
29513
28929
|
} catch (err) {
|
|
29514
28930
|
return Promise.reject(err instanceof Error ? err : new Error(String(err)));
|
|
29515
28931
|
}
|
|
@@ -29640,6 +29056,7 @@ var SqliteExceptionsRepository = class {
|
|
|
29640
29056
|
SET revoked_at = :now, revoked_by = :revokedBy, revoke_reason = :reason, updated_at = :now
|
|
29641
29057
|
WHERE id = :id AND revoked_at IS NULL`
|
|
29642
29058
|
).run({ id, revokedBy, reason: reason ?? null, now });
|
|
29059
|
+
if (Number(result.changes) === 1) this.onChange();
|
|
29643
29060
|
return Promise.resolve(Number(result.changes) === 1);
|
|
29644
29061
|
}
|
|
29645
29062
|
/**
|
|
@@ -29652,6 +29069,15 @@ var SqliteExceptionsRepository = class {
|
|
|
29652
29069
|
const result = this.consumeStmt.run({ id, now });
|
|
29653
29070
|
return Promise.resolve(Number(result.changes) === 1);
|
|
29654
29071
|
}
|
|
29072
|
+
/** The rule ids with at least one active grant, under any key version. */
|
|
29073
|
+
activeRuleIds(now = this.now()) {
|
|
29074
|
+
return allRows(
|
|
29075
|
+
this.db.prepare(
|
|
29076
|
+
`SELECT DISTINCT rule_id AS ruleId FROM exceptions WHERE ${ACTIVE_PREDICATE}`
|
|
29077
|
+
),
|
|
29078
|
+
{ now }
|
|
29079
|
+
).map((row) => row.ruleId);
|
|
29080
|
+
}
|
|
29655
29081
|
/**
|
|
29656
29082
|
* The evaluation subset of every active grant under one fingerprint key
|
|
29657
29083
|
* version — what rides the policy bundle to the hook. Grants written under
|
|
@@ -30775,28 +30201,28 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30775
30201
|
};
|
|
30776
30202
|
|
|
30777
30203
|
// ../../packages/persistence/src/repositories/installed-packs.ts
|
|
30778
|
-
import { createHash as
|
|
30204
|
+
import { createHash as createHash3, randomUUID as randomUUID4 } from "crypto";
|
|
30779
30205
|
|
|
30780
30206
|
// ../../packages/persistence/src/policy-floor.ts
|
|
30781
|
-
import { readFileSync as
|
|
30782
|
-
import { join as
|
|
30207
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
30208
|
+
import { join as join7 } from "path";
|
|
30783
30209
|
|
|
30784
30210
|
// ../../packages/persistence/src/local-layout.ts
|
|
30785
30211
|
import { renameSync as renameSync3 } from "fs";
|
|
30786
30212
|
import { mkdir } from "fs/promises";
|
|
30787
30213
|
import { homedir } from "os";
|
|
30788
|
-
import { join as
|
|
30214
|
+
import { join as join5 } from "path";
|
|
30789
30215
|
function defaultDataDir() {
|
|
30790
|
-
return
|
|
30216
|
+
return join5(homedir(), ".aka");
|
|
30791
30217
|
}
|
|
30792
30218
|
function settingsDir(base = defaultDataDir()) {
|
|
30793
|
-
return
|
|
30219
|
+
return join5(base, "settings");
|
|
30794
30220
|
}
|
|
30795
30221
|
function dataDir(base = defaultDataDir()) {
|
|
30796
|
-
return
|
|
30222
|
+
return join5(base, "data");
|
|
30797
30223
|
}
|
|
30798
30224
|
function dbPath(base = defaultDataDir()) {
|
|
30799
|
-
return
|
|
30225
|
+
return join5(dataDir(base), "aka.db");
|
|
30800
30226
|
}
|
|
30801
30227
|
function ensureLayoutDirSync(dir = defaultDataDir()) {
|
|
30802
30228
|
ensureDataDirSync(dir);
|
|
@@ -30809,8 +30235,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
30809
30235
|
for (const { name, dest } of moves) {
|
|
30810
30236
|
try {
|
|
30811
30237
|
ensureDataDirSync(dest);
|
|
30812
|
-
const moved =
|
|
30813
|
-
renameSync3(
|
|
30238
|
+
const moved = join5(dest, name);
|
|
30239
|
+
renameSync3(join5(base, name), moved);
|
|
30814
30240
|
tightenFile(moved);
|
|
30815
30241
|
} catch {
|
|
30816
30242
|
}
|
|
@@ -30818,8 +30244,8 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
30818
30244
|
}
|
|
30819
30245
|
|
|
30820
30246
|
// ../../packages/persistence/src/settings.ts
|
|
30821
|
-
import { readFileSync as
|
|
30822
|
-
import { join as
|
|
30247
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
30248
|
+
import { join as join6 } from "path";
|
|
30823
30249
|
|
|
30824
30250
|
// ../../packages/persistence/src/file-lock.ts
|
|
30825
30251
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -30827,7 +30253,7 @@ import {
|
|
|
30827
30253
|
closeSync,
|
|
30828
30254
|
existsSync as existsSync2,
|
|
30829
30255
|
openSync,
|
|
30830
|
-
readFileSync as
|
|
30256
|
+
readFileSync as readFileSync3,
|
|
30831
30257
|
rmSync as rmSync5,
|
|
30832
30258
|
statSync as statSync3,
|
|
30833
30259
|
writeFileSync as writeFileSync2
|
|
@@ -30863,7 +30289,7 @@ function lockPathFor(file2) {
|
|
|
30863
30289
|
function readLockBody(lock) {
|
|
30864
30290
|
let raw;
|
|
30865
30291
|
try {
|
|
30866
|
-
raw =
|
|
30292
|
+
raw = readFileSync3(lock, "utf8");
|
|
30867
30293
|
} catch {
|
|
30868
30294
|
return null;
|
|
30869
30295
|
}
|
|
@@ -31036,16 +30462,16 @@ function isThenable(value) {
|
|
|
31036
30462
|
}
|
|
31037
30463
|
|
|
31038
30464
|
// ../../packages/persistence/src/managed-settings.ts
|
|
31039
|
-
import { readFileSync as
|
|
30465
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
31040
30466
|
import { posix, win32 } from "path";
|
|
31041
|
-
function managedSettingsPaths(
|
|
31042
|
-
if (
|
|
30467
|
+
function managedSettingsPaths(platform = process.platform) {
|
|
30468
|
+
if (platform === "darwin") {
|
|
31043
30469
|
return [
|
|
31044
30470
|
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
31045
30471
|
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
31046
30472
|
];
|
|
31047
30473
|
}
|
|
31048
|
-
if (
|
|
30474
|
+
if (platform === "win32") {
|
|
31049
30475
|
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
31050
30476
|
}
|
|
31051
30477
|
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
@@ -31055,7 +30481,7 @@ function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPath
|
|
|
31055
30481
|
for (const path of paths) {
|
|
31056
30482
|
let text;
|
|
31057
30483
|
try {
|
|
31058
|
-
text =
|
|
30484
|
+
text = readFileSync4(path, "utf8");
|
|
31059
30485
|
} catch {
|
|
31060
30486
|
continue;
|
|
31061
30487
|
}
|
|
@@ -31125,7 +30551,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
31125
30551
|
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
31126
30552
|
}
|
|
31127
30553
|
function readUserSettings(base) {
|
|
31128
|
-
const record2 = readJson(
|
|
30554
|
+
const record2 = readJson(join6(settingsDir(base), SETTINGS_FILENAME));
|
|
31129
30555
|
if (!record2) return defaultWorkspaceSettings();
|
|
31130
30556
|
try {
|
|
31131
30557
|
return WorkspaceSettings.parse(record2);
|
|
@@ -31206,7 +30632,7 @@ function withoutManagedKeys(applied, managed, pinned, touched, connection) {
|
|
|
31206
30632
|
function applyOnboarding(answers2, base = defaultDataDir(), managedOverride) {
|
|
31207
30633
|
const dir = settingsDir(base);
|
|
31208
30634
|
ensureDataDirSync(dir);
|
|
31209
|
-
const file2 =
|
|
30635
|
+
const file2 = join6(dir, SETTINGS_FILENAME);
|
|
31210
30636
|
const managedSettings = managedOverride === void 0 ? readManagedSettings() : managedOverride;
|
|
31211
30637
|
const managed = managedContextOf(managedSettings);
|
|
31212
30638
|
return withFileLock(file2, () => {
|
|
@@ -31238,7 +30664,7 @@ function applyOnboarding(answers2, base = defaultDataDir(), managedOverride) {
|
|
|
31238
30664
|
function readJson(file2) {
|
|
31239
30665
|
let text;
|
|
31240
30666
|
try {
|
|
31241
|
-
text =
|
|
30667
|
+
text = readFileSync5(file2, "utf8");
|
|
31242
30668
|
} catch {
|
|
31243
30669
|
return null;
|
|
31244
30670
|
}
|
|
@@ -31278,7 +30704,7 @@ var PolicyFloorError = class extends Error {
|
|
|
31278
30704
|
};
|
|
31279
30705
|
function readCachedPolicyBundle(base = defaultDataDir()) {
|
|
31280
30706
|
try {
|
|
31281
|
-
const raw =
|
|
30707
|
+
const raw = readFileSync6(join7(dataDir(base), POLICY_CACHE_FILENAME), "utf8");
|
|
31282
30708
|
const parsed = JSON.parse(raw);
|
|
31283
30709
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
31284
30710
|
return PolicyBundle.parse(parsed.bundle);
|
|
@@ -31402,7 +30828,7 @@ function inventorySignature(packs) {
|
|
|
31402
30828
|
return packs.map((p) => `${p.namespace}/${p.packId}@${p.version}#${hashRules(p.rulesJson)}`).sort().join(",");
|
|
31403
30829
|
}
|
|
31404
30830
|
function hashRules(rulesJson) {
|
|
31405
|
-
return
|
|
30831
|
+
return createHash3("sha256").update(rulesJson).digest("hex");
|
|
31406
30832
|
}
|
|
31407
30833
|
function parseVersion(v) {
|
|
31408
30834
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -31444,9 +30870,10 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31444
30870
|
* from `openLocalDatabase`, which is the single construction site that owns a
|
|
31445
30871
|
* real `~/.aka`.
|
|
31446
30872
|
*/
|
|
31447
|
-
constructor(db, baseDir) {
|
|
30873
|
+
constructor(db, baseDir, onChange = () => void 0) {
|
|
31448
30874
|
this.db = db;
|
|
31449
30875
|
this.baseDir = baseDir;
|
|
30876
|
+
this.onChange = onChange;
|
|
31450
30877
|
this.insertMissingStmt = db.prepare(
|
|
31451
30878
|
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, policy_id, created_at, updated_at)
|
|
31452
30879
|
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :policyId, :now, :now)
|
|
@@ -31475,6 +30902,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31475
30902
|
}
|
|
31476
30903
|
db;
|
|
31477
30904
|
baseDir;
|
|
30905
|
+
onChange;
|
|
31478
30906
|
insertMissingStmt;
|
|
31479
30907
|
upsertAvailableStmt;
|
|
31480
30908
|
signatureStmt;
|
|
@@ -31547,6 +30975,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31547
30975
|
},
|
|
31548
30976
|
"IMMEDIATE"
|
|
31549
30977
|
);
|
|
30978
|
+
this.onChange();
|
|
31550
30979
|
} catch {
|
|
31551
30980
|
}
|
|
31552
30981
|
}
|
|
@@ -31621,6 +31050,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31621
31050
|
},
|
|
31622
31051
|
"IMMEDIATE"
|
|
31623
31052
|
);
|
|
31053
|
+
if (changed) this.onChange();
|
|
31624
31054
|
return changed;
|
|
31625
31055
|
}
|
|
31626
31056
|
/**
|
|
@@ -31862,6 +31292,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31862
31292
|
`UPDATE installed_packs SET policy_id = :policyId, updated_at = :now
|
|
31863
31293
|
WHERE namespace = :namespace AND pack_id = :packId`
|
|
31864
31294
|
).run({ policyId, now: Date.now(), namespace, packId });
|
|
31295
|
+
if (Number(res.changes) > 0) this.onChange();
|
|
31865
31296
|
return Number(res.changes) > 0;
|
|
31866
31297
|
}
|
|
31867
31298
|
/**
|
|
@@ -31886,6 +31317,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31886
31317
|
`UPDATE installed_packs SET enabled = :enabled, updated_at = :now
|
|
31887
31318
|
WHERE namespace = :namespace AND pack_id = :packId`
|
|
31888
31319
|
).run({ enabled: boolToInt(enabled), now: Date.now(), namespace, packId });
|
|
31320
|
+
if (Number(res.changes) > 0) this.onChange();
|
|
31889
31321
|
return Number(res.changes) > 0;
|
|
31890
31322
|
}
|
|
31891
31323
|
// Fingerprint of the recorded available mirror — compared against the
|
|
@@ -32783,13 +32215,19 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
32783
32215
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
32784
32216
|
var SEED_BATCH_WINDOW_MS = 6e4;
|
|
32785
32217
|
var SqlitePoliciesRepository = class {
|
|
32786
|
-
constructor(db) {
|
|
32218
|
+
constructor(db, onChange = () => void 0) {
|
|
32787
32219
|
this.db = db;
|
|
32220
|
+
this.onChange = onChange;
|
|
32788
32221
|
}
|
|
32789
32222
|
db;
|
|
32223
|
+
onChange;
|
|
32790
32224
|
readPolicies() {
|
|
32225
|
+
return Promise.resolve(this.listPolicies());
|
|
32226
|
+
}
|
|
32227
|
+
/** The synchronous read behind {@link readPolicies}. */
|
|
32228
|
+
listPolicies() {
|
|
32791
32229
|
const rows = allRows(this.db.prepare("SELECT * FROM policies"));
|
|
32792
|
-
|
|
32230
|
+
return mapRowsTolerant(rows, (row) => {
|
|
32793
32231
|
const target = JSON.parse(row.target);
|
|
32794
32232
|
const customKeywords = row.custom_keywords ? JSON.parse(row.custom_keywords) : void 0;
|
|
32795
32233
|
return Policy.parse({
|
|
@@ -32801,7 +32239,6 @@ var SqlitePoliciesRepository = class {
|
|
|
32801
32239
|
customKeywords
|
|
32802
32240
|
});
|
|
32803
32241
|
});
|
|
32804
|
-
return Promise.resolve(policies);
|
|
32805
32242
|
}
|
|
32806
32243
|
// Seed one policy per bundled category at Monitor so the detection-type config
|
|
32807
32244
|
// exists from first run. An unassigned pack's rules follow these rows, so
|
|
@@ -32812,7 +32249,7 @@ var SqlitePoliciesRepository = class {
|
|
|
32812
32249
|
const count = countScalar(this.db, "SELECT count(*) AS n FROM policies");
|
|
32813
32250
|
if (count > 0) {
|
|
32814
32251
|
this.markEarlierChoices();
|
|
32815
|
-
this.monitorUntouchedSeeds();
|
|
32252
|
+
if (this.monitorUntouchedSeeds()) this.onChange();
|
|
32816
32253
|
return;
|
|
32817
32254
|
}
|
|
32818
32255
|
const stmt = this.db.prepare(
|
|
@@ -32829,6 +32266,7 @@ var SqlitePoliciesRepository = class {
|
|
|
32829
32266
|
});
|
|
32830
32267
|
}
|
|
32831
32268
|
});
|
|
32269
|
+
this.onChange();
|
|
32832
32270
|
}
|
|
32833
32271
|
// Before this build, upsertCategoryAction INSERTed a new row with updated_at
|
|
32834
32272
|
// equal to created_at, so a choice made for a category that had no row yet
|
|
@@ -32894,7 +32332,7 @@ var SqlitePoliciesRepository = class {
|
|
|
32894
32332
|
).filter(
|
|
32895
32333
|
(row) => DEFAULT_ACTIONS[row.category] === row.action
|
|
32896
32334
|
);
|
|
32897
|
-
if (untouched.length === 0) return;
|
|
32335
|
+
if (untouched.length === 0) return false;
|
|
32898
32336
|
const stmt = this.db.prepare(
|
|
32899
32337
|
`UPDATE policies SET action = 'log'
|
|
32900
32338
|
WHERE scope = 'global' AND json_extract(target, '$.category') = :category
|
|
@@ -32905,6 +32343,7 @@ var SqlitePoliciesRepository = class {
|
|
|
32905
32343
|
stmt.run({ category: row.category, seeded: row.action });
|
|
32906
32344
|
}
|
|
32907
32345
|
});
|
|
32346
|
+
return true;
|
|
32908
32347
|
}
|
|
32909
32348
|
// Insert-or-update the single global per-category policy row, keyed on the
|
|
32910
32349
|
// existing uq_policies_scope_target unique index (scope, target). `action`
|
|
@@ -32921,6 +32360,7 @@ var SqlitePoliciesRepository = class {
|
|
|
32921
32360
|
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32922
32361
|
updated_at = MAX(excluded.updated_at, policies.created_at + 1)`
|
|
32923
32362
|
).run({ id: randomUUID6(), target: JSON.stringify({ category }), action, now });
|
|
32363
|
+
this.onChange();
|
|
32924
32364
|
}
|
|
32925
32365
|
// Caps every global per-category policy currently set to block/redact down
|
|
32926
32366
|
// to warn (see warn-era-cap.ts). Rule-targeted policies are untouched.
|
|
@@ -32931,6 +32371,7 @@ var SqlitePoliciesRepository = class {
|
|
|
32931
32371
|
WHERE scope='global' AND action IN ('block','redact')
|
|
32932
32372
|
AND json_extract(target,'$.category') IS NOT NULL`
|
|
32933
32373
|
).run({ now: Date.now() });
|
|
32374
|
+
if (Number(info.changes) > 0) this.onChange();
|
|
32934
32375
|
return Number(info.changes);
|
|
32935
32376
|
}
|
|
32936
32377
|
// Whether the category's row was ever written after it was created — by the
|
|
@@ -33250,31 +32691,45 @@ var SqliteScanLedgerRepository = class {
|
|
|
33250
32691
|
constructor(db) {
|
|
33251
32692
|
this.db = db;
|
|
33252
32693
|
this.upsertStmt = db.prepare(
|
|
33253
|
-
`INSERT INTO scan_ledger
|
|
33254
|
-
|
|
32694
|
+
`INSERT INTO scan_ledger
|
|
32695
|
+
(path, mtime, content_hash, ruleset_hash, scope_key, scope_root, scanned_at)
|
|
32696
|
+
VALUES (:path, :mtime, :contentHash, :rulesetHash, :scopeKey, :scopeRoot, :scannedAt)
|
|
33255
32697
|
ON CONFLICT (path) DO UPDATE SET
|
|
33256
32698
|
mtime = excluded.mtime,
|
|
33257
32699
|
content_hash = excluded.content_hash,
|
|
33258
32700
|
ruleset_hash = excluded.ruleset_hash,
|
|
32701
|
+
scope_key = excluded.scope_key,
|
|
32702
|
+
scope_root = excluded.scope_root,
|
|
33259
32703
|
scanned_at = excluded.scanned_at`
|
|
33260
32704
|
);
|
|
33261
32705
|
this.readStmt = db.prepare(
|
|
33262
|
-
`SELECT path, mtime, content_hash AS contentHash
|
|
32706
|
+
`SELECT path, mtime, content_hash AS contentHash, scope_key AS scopeKey,
|
|
32707
|
+
scope_root AS scopeRoot
|
|
33263
32708
|
FROM scan_ledger WHERE ruleset_hash = :rulesetHash`
|
|
33264
32709
|
);
|
|
33265
32710
|
this.pathsStmt = db.prepare(`SELECT path FROM scan_ledger`);
|
|
32711
|
+
this.pathKeysStmt = db.prepare(`SELECT path, scope_key AS scopeKey FROM scan_ledger`);
|
|
33266
32712
|
}
|
|
33267
32713
|
db;
|
|
33268
32714
|
upsertStmt;
|
|
33269
32715
|
readStmt;
|
|
33270
32716
|
pathsStmt;
|
|
32717
|
+
pathKeysStmt;
|
|
33271
32718
|
// Previously scanned files under THIS ruleset, keyed by path. Rows from an
|
|
33272
32719
|
// older ruleset are simply absent, which reads as "never scanned".
|
|
33273
32720
|
entriesForRuleset(rulesetHash) {
|
|
33274
|
-
const rows = allRows(this.readStmt, {
|
|
33275
|
-
|
|
33276
|
-
|
|
33277
|
-
|
|
32721
|
+
const rows = allRows(this.readStmt, { rulesetHash });
|
|
32722
|
+
return new Map(
|
|
32723
|
+
rows.map((r) => [
|
|
32724
|
+
r.path,
|
|
32725
|
+
{
|
|
32726
|
+
mtime: r.mtime,
|
|
32727
|
+
contentHash: r.contentHash,
|
|
32728
|
+
...r.scopeKey !== null ? { scopeKey: r.scopeKey } : {},
|
|
32729
|
+
...r.scopeRoot !== null ? { scopeRoot: r.scopeRoot } : {}
|
|
32730
|
+
}
|
|
32731
|
+
])
|
|
32732
|
+
);
|
|
33278
32733
|
}
|
|
33279
32734
|
// Every ledgered path, whatever ruleset it was scanned under — the set a
|
|
33280
32735
|
// deletion sweep checks against disk. A file deleted before a ruleset change
|
|
@@ -33283,6 +32738,14 @@ var SqliteScanLedgerRepository = class {
|
|
|
33283
32738
|
allPaths() {
|
|
33284
32739
|
return allRows(this.pathsStmt).map((r) => r.path);
|
|
33285
32740
|
}
|
|
32741
|
+
// Every ledgered path with the repository it was in when it was last read,
|
|
32742
|
+
// whatever ruleset it was scanned under: what a deletion sweep needs to say
|
|
32743
|
+
// which repository a vanished file belonged to. `undefined` for a row with no
|
|
32744
|
+
// key, which is every row written before the column existed.
|
|
32745
|
+
pathKeys() {
|
|
32746
|
+
const rows = allRows(this.pathKeysStmt);
|
|
32747
|
+
return new Map(rows.map((r) => [r.path, r.scopeKey ?? void 0]));
|
|
32748
|
+
}
|
|
33286
32749
|
upsertEntries(entries) {
|
|
33287
32750
|
if (entries.length === 0) return;
|
|
33288
32751
|
const scannedAt = Date.now();
|
|
@@ -33293,6 +32756,8 @@ var SqliteScanLedgerRepository = class {
|
|
|
33293
32756
|
mtime: entry.mtime,
|
|
33294
32757
|
contentHash: entry.contentHash,
|
|
33295
32758
|
rulesetHash: entry.rulesetHash,
|
|
32759
|
+
scopeKey: entry.scopeKey ?? null,
|
|
32760
|
+
scopeRoot: entry.scopeRoot ?? null,
|
|
33296
32761
|
scannedAt
|
|
33297
32762
|
});
|
|
33298
32763
|
}
|
|
@@ -34380,6 +33845,11 @@ function withoutDroppedFiles(reconcile, droppedFiles) {
|
|
|
34380
33845
|
deletedFiles: reconcile.deletedFiles.filter((file2) => !dropped.has(file2))
|
|
34381
33846
|
};
|
|
34382
33847
|
}
|
|
33848
|
+
function withoutTrailingSlashes(path) {
|
|
33849
|
+
let end = path.length;
|
|
33850
|
+
while (end > 0 && path.charCodeAt(end - 1) === 47) end--;
|
|
33851
|
+
return path.slice(0, end);
|
|
33852
|
+
}
|
|
34383
33853
|
function toEndpointSummary(row) {
|
|
34384
33854
|
return {
|
|
34385
33855
|
id: row.id,
|
|
@@ -34667,7 +34137,7 @@ var SqliteSharesRepository = class {
|
|
|
34667
34137
|
*/
|
|
34668
34138
|
reconcileCallSites(projectKey, reconcile) {
|
|
34669
34139
|
if (reconcile.mode === "walk") {
|
|
34670
|
-
const prefix = reconcile.walkedPrefix
|
|
34140
|
+
const prefix = withoutTrailingSlashes(reconcile.walkedPrefix);
|
|
34671
34141
|
this.db.prepare(
|
|
34672
34142
|
`DELETE FROM share_call_site
|
|
34673
34143
|
WHERE project_key = :key
|
|
@@ -35235,7 +34705,7 @@ function backupLegacyStore(db, file2) {
|
|
|
35235
34705
|
discardStore(file2, backup);
|
|
35236
34706
|
return backup;
|
|
35237
34707
|
}
|
|
35238
|
-
function openAndInitialize(file2, base, skipTags) {
|
|
34708
|
+
function openAndInitialize(file2, base, skipTags, shippedRegexMatchers2) {
|
|
35239
34709
|
let db = openWithPragmas(file2);
|
|
35240
34710
|
try {
|
|
35241
34711
|
if (isForeignSqliteLineage(db)) {
|
|
@@ -35247,8 +34717,15 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
35247
34717
|
}
|
|
35248
34718
|
applyMigrations(db, file2, { skipTags });
|
|
35249
34719
|
tightenPerms(file2);
|
|
35250
|
-
const
|
|
35251
|
-
const
|
|
34720
|
+
const modPolicy = {};
|
|
34721
|
+
const onPolicyStateChange = () => {
|
|
34722
|
+
if (modPolicy.current !== void 0)
|
|
34723
|
+
refreshModPolicySnapshot(dirname2(file2), modPolicy.current);
|
|
34724
|
+
};
|
|
34725
|
+
const policies = new SqlitePoliciesRepository(db, onPolicyStateChange);
|
|
34726
|
+
const installedPacks = new SqliteInstalledPacksRepository(db, base, onPolicyStateChange);
|
|
34727
|
+
const ruleProbeCache = new SqliteRuleProbeCacheRepository(db);
|
|
34728
|
+
const exceptions = new SqliteExceptionsRepository(db, void 0, onPolicyStateChange);
|
|
35252
34729
|
const repositories = {
|
|
35253
34730
|
events: new SqliteEventsRepository(db),
|
|
35254
34731
|
findings: new SqliteFindingsRepository(db),
|
|
@@ -35257,9 +34734,9 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
35257
34734
|
scanLedger: new SqliteScanLedgerRepository(db),
|
|
35258
34735
|
historySync: new SqliteHistorySyncRepository(db),
|
|
35259
34736
|
secretVault: new SqliteSecretVaultRepository(db),
|
|
35260
|
-
exceptions
|
|
34737
|
+
exceptions,
|
|
35261
34738
|
resolutions: new SqliteResolutionsRepository(db),
|
|
35262
|
-
ruleProbeCache
|
|
34739
|
+
ruleProbeCache,
|
|
35263
34740
|
bodyRetention: new SqliteBodyRetentionRepository(db),
|
|
35264
34741
|
security: new SqliteSecurityRepository(db),
|
|
35265
34742
|
detections: new SqliteDetectionsRepository(db),
|
|
@@ -35277,6 +34754,13 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
35277
34754
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
35278
34755
|
configInventory: new SqliteConfigInventoryRepository(db)
|
|
35279
34756
|
};
|
|
34757
|
+
modPolicy.current = {
|
|
34758
|
+
installedRuleset: () => installedPacks.installedRuleset(),
|
|
34759
|
+
readPolicies: () => policies.listPolicies(),
|
|
34760
|
+
activeExceptionRuleIds: () => exceptions.activeRuleIds(),
|
|
34761
|
+
probeVerdict: (key) => ruleProbeCache.getVerdict(key)?.verdict,
|
|
34762
|
+
bundledRegexMatchers: () => shippedRegexMatchers2
|
|
34763
|
+
};
|
|
35280
34764
|
policies.seedDefaults();
|
|
35281
34765
|
return { db, ...repositories };
|
|
35282
34766
|
} catch (err) {
|
|
@@ -35288,7 +34772,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
35288
34772
|
var DEFERRED_TAGS = new Set(DEFERRED_MIGRATION_TAGS);
|
|
35289
34773
|
function openLocalDatabase(dir, options = {}) {
|
|
35290
34774
|
ensureDataDirSync(dir);
|
|
35291
|
-
const file2 =
|
|
34775
|
+
const file2 = join8(dir, DB_FILENAME);
|
|
35292
34776
|
reapStalePartials(file2);
|
|
35293
34777
|
const {
|
|
35294
34778
|
db,
|
|
@@ -35324,7 +34808,8 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
35324
34808
|
// `dataDir()` — so its parent is the `~/.aka` base the layout splits into
|
|
35325
34809
|
// settings/ and data/, and the pack-policy floor needs both halves.
|
|
35326
34810
|
dirname2(dir),
|
|
35327
|
-
options.applyDeferredMigrations === true ? void 0 : DEFERRED_TAGS
|
|
34811
|
+
options.applyDeferredMigrations === true ? void 0 : DEFERRED_TAGS,
|
|
34812
|
+
options.shippedRegexMatchers ?? []
|
|
35328
34813
|
);
|
|
35329
34814
|
function captureRowId(event) {
|
|
35330
34815
|
return captureId(
|
|
@@ -35589,39 +35074,39 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
35589
35074
|
}
|
|
35590
35075
|
|
|
35591
35076
|
// ../../packages/persistence/src/egress-wire.ts
|
|
35592
|
-
import { createHash as
|
|
35077
|
+
import { createHash as createHash4 } from "crypto";
|
|
35593
35078
|
var SLASH = "/".charCodeAt(0);
|
|
35594
35079
|
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
35595
35080
|
|
|
35596
35081
|
// ../../packages/persistence/src/finding-key.ts
|
|
35597
|
-
import { createHash as
|
|
35082
|
+
import { createHash as createHash5 } from "crypto";
|
|
35598
35083
|
|
|
35599
35084
|
// ../../packages/persistence/src/fingerprint.ts
|
|
35600
35085
|
import { createHmac, randomBytes } from "crypto";
|
|
35601
|
-
import { existsSync as existsSync3, readFileSync as
|
|
35602
|
-
import { join as
|
|
35603
|
-
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
35086
|
+
import { existsSync as existsSync3, readFileSync as readFileSync7 } from "fs";
|
|
35087
|
+
import { join as join9 } from "path";
|
|
35604
35088
|
|
|
35605
35089
|
// ../../packages/persistence/src/forward-health.ts
|
|
35606
|
-
import { readFileSync as
|
|
35607
|
-
import { join as
|
|
35090
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
35091
|
+
import { join as join10 } from "path";
|
|
35608
35092
|
|
|
35609
35093
|
// ../../packages/persistence/src/history-backfill.ts
|
|
35610
35094
|
import { existsSync as existsSync4 } from "fs";
|
|
35611
|
-
import { join as
|
|
35095
|
+
import { join as join11 } from "path";
|
|
35612
35096
|
|
|
35613
35097
|
// ../../packages/persistence/src/history-preview.ts
|
|
35614
35098
|
import { existsSync as existsSync5 } from "fs";
|
|
35615
|
-
import { join as
|
|
35616
|
-
import { DatabaseSync as
|
|
35099
|
+
import { join as join12 } from "path";
|
|
35100
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
35617
35101
|
|
|
35618
35102
|
// ../../packages/persistence/src/history-sync-state.ts
|
|
35619
|
-
import { readFileSync as
|
|
35620
|
-
import { join as
|
|
35103
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
35104
|
+
import { join as join13 } from "path";
|
|
35105
|
+
var COUNTS_SCOPES = new Set(AttachmentMode.options);
|
|
35621
35106
|
|
|
35622
35107
|
// ../../packages/persistence/src/store-symlinks.ts
|
|
35623
35108
|
import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
35624
|
-
import { dirname as dirname3, join as
|
|
35109
|
+
import { dirname as dirname3, join as join14, resolve } from "path";
|
|
35625
35110
|
|
|
35626
35111
|
// ../../packages/persistence/src/vault/crypto.ts
|
|
35627
35112
|
import {
|
|
@@ -35635,19 +35120,19 @@ import {
|
|
|
35635
35120
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
35636
35121
|
import { execFileSync } from "child_process";
|
|
35637
35122
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
35638
|
-
import { chmodSync as chmodSync3, readFileSync as
|
|
35639
|
-
import { join as
|
|
35123
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
35124
|
+
import { join as join15 } from "path";
|
|
35640
35125
|
|
|
35641
35126
|
// ../../packages/persistence/src/vault/vault.ts
|
|
35642
35127
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
35643
35128
|
|
|
35644
35129
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
35645
35130
|
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
35646
|
-
import { join as
|
|
35131
|
+
import { join as join16 } from "path";
|
|
35647
35132
|
var MARKER = "warn-era-capped";
|
|
35648
35133
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
35649
35134
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
35650
|
-
const marker =
|
|
35135
|
+
const marker = join16(dataDir2, MARKER);
|
|
35651
35136
|
if (existsSync7(marker)) return { capped: 0, skipped: "already-run" };
|
|
35652
35137
|
const capped = db.policies.capCategoryActions();
|
|
35653
35138
|
writeFileSync4(marker, `${new Date(Date.now()).toISOString()}
|
|
@@ -35657,7 +35142,7 @@ function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
|
35657
35142
|
|
|
35658
35143
|
// ../../packages/plugin-sdk/src/config.ts
|
|
35659
35144
|
import { existsSync as existsSync8 } from "fs";
|
|
35660
|
-
import { join as
|
|
35145
|
+
import { join as join17 } from "path";
|
|
35661
35146
|
|
|
35662
35147
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
35663
35148
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -35711,7 +35196,7 @@ function resolveProvider() {
|
|
|
35711
35196
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
35712
35197
|
try {
|
|
35713
35198
|
ensureLayoutDirSync(base);
|
|
35714
|
-
const settingsFile =
|
|
35199
|
+
const settingsFile = join17(settingsDir(base), "settings.json");
|
|
35715
35200
|
if (existsSync8(settingsFile)) tightenFile(settingsFile);
|
|
35716
35201
|
} catch {
|
|
35717
35202
|
}
|
|
@@ -35734,11 +35219,6 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
35734
35219
|
}
|
|
35735
35220
|
}
|
|
35736
35221
|
|
|
35737
|
-
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
35738
|
-
import { readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
35739
|
-
import { homedir as homedir2 } from "os";
|
|
35740
|
-
import { basename as basename3, join as join18 } from "path";
|
|
35741
|
-
|
|
35742
35222
|
// ../../packages/detections/src/egress/registry.ts
|
|
35743
35223
|
var EXTRACTOR_VERSION = "3";
|
|
35744
35224
|
var PROVIDER_REGISTRY = [
|
|
@@ -36413,12 +35893,12 @@ var RegexMatcher2 = class {
|
|
|
36413
35893
|
rule.matcher,
|
|
36414
35894
|
() => new RegExp(pattern, flags2.includes("d") ? flags2 : `${flags2}d`)
|
|
36415
35895
|
);
|
|
36416
|
-
const
|
|
35896
|
+
const scanText = text.length > MAX_REGEX_INPUT_LENGTH ? text.slice(0, MAX_REGEX_INPUT_LENGTH) : text;
|
|
36417
35897
|
const spans = [];
|
|
36418
35898
|
let m;
|
|
36419
|
-
const maxIterations =
|
|
35899
|
+
const maxIterations = scanText.length + 1;
|
|
36420
35900
|
let iterations = 0;
|
|
36421
|
-
while ((m = re.exec(
|
|
35901
|
+
while ((m = re.exec(scanText)) !== null) {
|
|
36422
35902
|
if (++iterations > maxIterations) break;
|
|
36423
35903
|
const group = captureGroup != null ? m[captureGroup] : m[0];
|
|
36424
35904
|
if (m[0].length === 0) re.lastIndex++;
|
|
@@ -36572,86 +36052,2218 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
36572
36052
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
36573
36053
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
36574
36054
|
|
|
36575
|
-
// ../../
|
|
36576
|
-
|
|
36577
|
-
|
|
36578
|
-
|
|
36055
|
+
// ../../rules/code-flaws/auth-jwt-no-verify.json
|
|
36056
|
+
var auth_jwt_no_verify_default = {
|
|
36057
|
+
specVersion: 1,
|
|
36058
|
+
id: "code-flaws/auth-jwt-no-verify",
|
|
36059
|
+
name: "JWT decoded without signature verification",
|
|
36060
|
+
category: "code_flaw",
|
|
36061
|
+
severity: "critical",
|
|
36062
|
+
matcher: {
|
|
36063
|
+
type: "regex",
|
|
36064
|
+
pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
|
|
36065
|
+
flags: "gi"
|
|
36066
|
+
},
|
|
36067
|
+
requiresNearby: {
|
|
36068
|
+
labels: ["jwt", "decode", "token"],
|
|
36069
|
+
windowChars: 160
|
|
36070
|
+
},
|
|
36071
|
+
examples: [
|
|
36072
|
+
'jwt.decode(token, options={"verify_signature": False})',
|
|
36073
|
+
"jwt.decode(token, algorithms=[])"
|
|
36074
|
+
]
|
|
36075
|
+
};
|
|
36579
36076
|
|
|
36580
|
-
// ../../
|
|
36581
|
-
|
|
36077
|
+
// ../../rules/code-flaws/auth-ssl-verify-false.json
|
|
36078
|
+
var auth_ssl_verify_false_default = {
|
|
36079
|
+
specVersion: 1,
|
|
36080
|
+
id: "code-flaws/auth-ssl-verify-false",
|
|
36081
|
+
name: "SSL certificate verification disabled",
|
|
36082
|
+
category: "code_flaw",
|
|
36083
|
+
severity: "high",
|
|
36084
|
+
matcher: {
|
|
36085
|
+
type: "regex",
|
|
36086
|
+
pattern: "\\brequests\\.(get|post|put|delete|patch|request)\\s*\\([^)]*verify\\s*=\\s*False",
|
|
36087
|
+
flags: "gi"
|
|
36088
|
+
},
|
|
36089
|
+
examples: [
|
|
36090
|
+
"requests.get(url, verify=False)",
|
|
36091
|
+
"requests.post(endpoint, data=payload, verify=False)"
|
|
36092
|
+
],
|
|
36093
|
+
appliesTo: {
|
|
36094
|
+
extensions: [".py"]
|
|
36095
|
+
}
|
|
36096
|
+
};
|
|
36582
36097
|
|
|
36583
|
-
// ../../
|
|
36584
|
-
|
|
36585
|
-
|
|
36586
|
-
|
|
36098
|
+
// ../../rules/code-flaws/cmd-inject-exec.json
|
|
36099
|
+
var cmd_inject_exec_default = {
|
|
36100
|
+
specVersion: 1,
|
|
36101
|
+
id: "code-flaws/cmd-inject-exec",
|
|
36102
|
+
name: "Command injection via Java Runtime.exec",
|
|
36103
|
+
category: "code_flaw",
|
|
36104
|
+
severity: "critical",
|
|
36105
|
+
matcher: {
|
|
36106
|
+
type: "regex",
|
|
36107
|
+
pattern: "Runtime\\.getRuntime\\(\\)\\.exec\\(",
|
|
36108
|
+
flags: "g"
|
|
36109
|
+
},
|
|
36110
|
+
requiresNearby: {
|
|
36111
|
+
labels: ["input", "request", "param", "user"],
|
|
36112
|
+
windowChars: 200
|
|
36113
|
+
},
|
|
36114
|
+
examples: ["Runtime.getRuntime().exec(userInput)"],
|
|
36115
|
+
appliesTo: {
|
|
36116
|
+
extensions: [".java"]
|
|
36117
|
+
}
|
|
36118
|
+
};
|
|
36587
36119
|
|
|
36588
|
-
// ../../
|
|
36589
|
-
|
|
36590
|
-
|
|
36120
|
+
// ../../rules/code-flaws/cmd-inject-node-exec.json
|
|
36121
|
+
var cmd_inject_node_exec_default = {
|
|
36122
|
+
specVersion: 1,
|
|
36123
|
+
id: "code-flaws/cmd-inject-node-exec",
|
|
36124
|
+
name: "Command injection via Node.js exec with variable argument",
|
|
36125
|
+
category: "code_flaw",
|
|
36126
|
+
severity: "critical",
|
|
36127
|
+
matcher: {
|
|
36128
|
+
type: "regex",
|
|
36129
|
+
pattern: `(?:\\b(?:(?:node_)?child_process|childProcess|cp)\\s*\\??\\.\\s*|\\brequire\\s*\\(\\s*['"](?:node:)?child_process['"]\\s*\\)\\s*\\??\\.\\s*|(?<![\\w$.]))(exec(?:Sync)?\\s*\\(\\s*)(?!['"\`])`,
|
|
36130
|
+
flags: "g",
|
|
36131
|
+
captureGroup: 1
|
|
36132
|
+
},
|
|
36133
|
+
requiresNearby: {
|
|
36134
|
+
labels: ["input", "request", "param", "argv", "user", "query", "body"],
|
|
36135
|
+
windowChars: 200
|
|
36136
|
+
},
|
|
36137
|
+
examples: ["exec(req.query.cmd)", "execSync(userInput)"],
|
|
36138
|
+
appliesTo: {
|
|
36139
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]
|
|
36140
|
+
}
|
|
36141
|
+
};
|
|
36591
36142
|
|
|
36592
|
-
// ../../
|
|
36593
|
-
|
|
36594
|
-
|
|
36143
|
+
// ../../rules/code-flaws/cmd-inject-shell.json
|
|
36144
|
+
var cmd_inject_shell_default = {
|
|
36145
|
+
specVersion: 1,
|
|
36146
|
+
id: "code-flaws/cmd-inject-shell",
|
|
36147
|
+
name: "Command injection via subprocess shell=True",
|
|
36148
|
+
category: "code_flaw",
|
|
36149
|
+
severity: "critical",
|
|
36150
|
+
matcher: {
|
|
36151
|
+
type: "regex",
|
|
36152
|
+
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
|
|
36153
|
+
flags: "gi"
|
|
36154
|
+
},
|
|
36155
|
+
requiresNearby: {
|
|
36156
|
+
labels: ["input", "request", "param", "argv", "user"],
|
|
36157
|
+
windowChars: 300
|
|
36158
|
+
},
|
|
36159
|
+
examples: ["subprocess.run(user_input, shell=True)"],
|
|
36160
|
+
appliesTo: {
|
|
36161
|
+
extensions: [".py"]
|
|
36162
|
+
}
|
|
36163
|
+
};
|
|
36595
36164
|
|
|
36596
|
-
// ../../
|
|
36597
|
-
|
|
36598
|
-
|
|
36599
|
-
|
|
36600
|
-
|
|
36601
|
-
|
|
36602
|
-
|
|
36603
|
-
|
|
36604
|
-
|
|
36605
|
-
|
|
36606
|
-
|
|
36607
|
-
|
|
36165
|
+
// ../../rules/code-flaws/crypto-insecure-random.json
|
|
36166
|
+
var crypto_insecure_random_default = {
|
|
36167
|
+
specVersion: 1,
|
|
36168
|
+
id: "code-flaws/crypto-insecure-random",
|
|
36169
|
+
name: "Insecure random number generator used for security-sensitive value",
|
|
36170
|
+
category: "code_flaw",
|
|
36171
|
+
severity: "medium",
|
|
36172
|
+
matcher: {
|
|
36173
|
+
type: "regex",
|
|
36174
|
+
pattern: "\\b(Math\\.random\\(\\)|random\\.random\\(\\)|random\\.randint\\()",
|
|
36175
|
+
flags: "gi"
|
|
36176
|
+
},
|
|
36177
|
+
requiresNearby: {
|
|
36178
|
+
labels: ["token", "session", "key", "password", "secret", "nonce", "salt"],
|
|
36179
|
+
windowChars: 160
|
|
36180
|
+
},
|
|
36181
|
+
examples: ["const token = Math.random().toString(36)", "session_key = str(random.random())"],
|
|
36182
|
+
appliesTo: {
|
|
36183
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".py"]
|
|
36184
|
+
}
|
|
36185
|
+
};
|
|
36186
|
+
|
|
36187
|
+
// ../../rules/code-flaws/crypto-weak-hash-md5.json
|
|
36188
|
+
var crypto_weak_hash_md5_default = {
|
|
36189
|
+
specVersion: 1,
|
|
36190
|
+
id: "code-flaws/crypto-weak-hash-md5",
|
|
36191
|
+
name: "Weak cryptographic hash: MD5",
|
|
36192
|
+
category: "code_flaw",
|
|
36193
|
+
severity: "medium",
|
|
36194
|
+
matcher: {
|
|
36195
|
+
type: "regex",
|
|
36196
|
+
pattern: `(hashlib\\.md5\\s*\\(|MD5\\.(?:digest|hash)\\b|Digest::MD5|MessageDigest\\.getInstance\\s*\\(\\s*["']MD5["'])`,
|
|
36197
|
+
flags: "gi"
|
|
36198
|
+
},
|
|
36199
|
+
examples: ["hashlib.md5(password.encode())", 'MessageDigest.getInstance("MD5")'],
|
|
36200
|
+
appliesTo: {
|
|
36201
|
+
extensions: [".py", ".rb", ".java"]
|
|
36202
|
+
}
|
|
36203
|
+
};
|
|
36204
|
+
|
|
36205
|
+
// ../../rules/code-flaws/crypto-weak-hash-sha1.json
|
|
36206
|
+
var crypto_weak_hash_sha1_default = {
|
|
36207
|
+
specVersion: 1,
|
|
36208
|
+
id: "code-flaws/crypto-weak-hash-sha1",
|
|
36209
|
+
name: "Weak cryptographic hash: SHA-1 in security context",
|
|
36210
|
+
category: "code_flaw",
|
|
36211
|
+
severity: "medium",
|
|
36212
|
+
matcher: {
|
|
36213
|
+
type: "regex",
|
|
36214
|
+
pattern: `(hashlib\\.sha1\\s*\\(|SHA1\\.(?:digest|hash)\\b|Digest::SHA1|MessageDigest\\.getInstance\\s*\\(\\s*["']SHA-?1["'])`,
|
|
36215
|
+
flags: "gi"
|
|
36216
|
+
},
|
|
36217
|
+
requiresNearby: {
|
|
36218
|
+
labels: ["password", "credential", "hash", "token", "secret"],
|
|
36219
|
+
windowChars: 160
|
|
36220
|
+
},
|
|
36221
|
+
examples: [
|
|
36222
|
+
"password_hash = hashlib.sha1(password.encode()).hexdigest()",
|
|
36223
|
+
'MessageDigest.getInstance("SHA1")'
|
|
36224
|
+
],
|
|
36225
|
+
appliesTo: {
|
|
36226
|
+
extensions: [".py", ".rb", ".java"]
|
|
36227
|
+
}
|
|
36228
|
+
};
|
|
36229
|
+
|
|
36230
|
+
// ../../rules/code-flaws/deser-java-ois.json
|
|
36231
|
+
var deser_java_ois_default = {
|
|
36232
|
+
specVersion: 1,
|
|
36233
|
+
id: "code-flaws/deser-java-ois",
|
|
36234
|
+
name: "Insecure deserialization via Java ObjectInputStream",
|
|
36235
|
+
category: "code_flaw",
|
|
36236
|
+
severity: "critical",
|
|
36237
|
+
matcher: {
|
|
36238
|
+
type: "regex",
|
|
36239
|
+
pattern: "\\bObjectInputStream\\b",
|
|
36240
|
+
flags: "g"
|
|
36241
|
+
},
|
|
36242
|
+
requiresNearby: {
|
|
36243
|
+
labels: ["readObject"],
|
|
36244
|
+
windowChars: 200
|
|
36245
|
+
},
|
|
36246
|
+
examples: [
|
|
36247
|
+
"ObjectInputStream ois = new ObjectInputStream(inputStream); Object obj = ois.readObject();"
|
|
36248
|
+
],
|
|
36249
|
+
appliesTo: {
|
|
36250
|
+
extensions: [".java"]
|
|
36251
|
+
}
|
|
36252
|
+
};
|
|
36253
|
+
|
|
36254
|
+
// ../../rules/code-flaws/deser-pickle.json
|
|
36255
|
+
var deser_pickle_default = {
|
|
36256
|
+
specVersion: 1,
|
|
36257
|
+
id: "code-flaws/deser-pickle",
|
|
36258
|
+
name: "Insecure deserialization via Python pickle",
|
|
36259
|
+
category: "code_flaw",
|
|
36260
|
+
severity: "critical",
|
|
36261
|
+
matcher: {
|
|
36262
|
+
type: "regex",
|
|
36263
|
+
pattern: "\\bpickle\\.loads?\\s*\\(",
|
|
36264
|
+
flags: "gi"
|
|
36265
|
+
},
|
|
36266
|
+
examples: ["data = pickle.loads(user_data)", "obj = pickle.load(request.stream)"],
|
|
36267
|
+
appliesTo: {
|
|
36268
|
+
extensions: [".py"]
|
|
36269
|
+
}
|
|
36270
|
+
};
|
|
36271
|
+
|
|
36272
|
+
// ../../rules/code-flaws/deser-yaml-unsafe.json
|
|
36273
|
+
var deser_yaml_unsafe_default = {
|
|
36274
|
+
specVersion: 1,
|
|
36275
|
+
id: "code-flaws/deser-yaml-unsafe",
|
|
36276
|
+
name: "Insecure deserialization via yaml.load without SafeLoader",
|
|
36277
|
+
category: "code_flaw",
|
|
36278
|
+
severity: "high",
|
|
36279
|
+
matcher: {
|
|
36280
|
+
type: "regex",
|
|
36281
|
+
pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
|
|
36282
|
+
flags: "gi"
|
|
36283
|
+
},
|
|
36284
|
+
examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
|
|
36285
|
+
appliesTo: {
|
|
36286
|
+
extensions: [".py"]
|
|
36287
|
+
}
|
|
36288
|
+
};
|
|
36289
|
+
|
|
36290
|
+
// ../../rules/code-flaws/dev-debug-enabled.json
|
|
36291
|
+
var dev_debug_enabled_default = {
|
|
36292
|
+
specVersion: 1,
|
|
36293
|
+
id: "code-flaws/dev-debug-enabled",
|
|
36294
|
+
name: "Debug mode enabled in configuration",
|
|
36295
|
+
category: "code_flaw",
|
|
36296
|
+
severity: "medium",
|
|
36297
|
+
matcher: {
|
|
36298
|
+
type: "regex",
|
|
36299
|
+
pattern: "\\bdebug\\s*[=:]\\s*(true|1|yes)",
|
|
36300
|
+
flags: "gi"
|
|
36301
|
+
},
|
|
36302
|
+
examples: ["DEBUG = True", "debug: true", "app.debug = True"]
|
|
36303
|
+
};
|
|
36304
|
+
|
|
36305
|
+
// ../../rules/code-flaws/dev-placeholder-secret.json
|
|
36306
|
+
var dev_placeholder_secret_default = {
|
|
36307
|
+
specVersion: 1,
|
|
36308
|
+
id: "code-flaws/dev-placeholder-secret",
|
|
36309
|
+
name: "Placeholder or default secret left in code",
|
|
36310
|
+
category: "code_flaw",
|
|
36311
|
+
severity: "high",
|
|
36312
|
+
matcher: {
|
|
36313
|
+
type: "keyword",
|
|
36314
|
+
keywords: [
|
|
36315
|
+
"changeme",
|
|
36316
|
+
"placeholder",
|
|
36317
|
+
"your-secret",
|
|
36318
|
+
"dev-secret",
|
|
36319
|
+
"replace-me",
|
|
36320
|
+
"todo-secret"
|
|
36321
|
+
],
|
|
36322
|
+
caseSensitive: false
|
|
36323
|
+
},
|
|
36324
|
+
requiresNearby: {
|
|
36325
|
+
labels: ["key", "secret", "password", "token"],
|
|
36326
|
+
windowChars: 80
|
|
36327
|
+
},
|
|
36328
|
+
examples: ["SECRET_KEY = 'changeme'", "api_token = 'your-secret'"]
|
|
36329
|
+
};
|
|
36330
|
+
|
|
36331
|
+
// ../../rules/code-flaws/dev-wildcard-cors.json
|
|
36332
|
+
var dev_wildcard_cors_default = {
|
|
36333
|
+
specVersion: 1,
|
|
36334
|
+
id: "code-flaws/dev-wildcard-cors",
|
|
36335
|
+
name: "CORS wildcard allowing all origins",
|
|
36336
|
+
category: "code_flaw",
|
|
36337
|
+
severity: "medium",
|
|
36338
|
+
matcher: {
|
|
36339
|
+
type: "regex",
|
|
36340
|
+
pattern: `(Access-Control-Allow-Origin:\\s*\\*|origin:\\s*["']\\*["']|allow_all_origins\\s*=\\s*True|CORS_ALLOW_ALL_ORIGINS\\s*=\\s*True)`,
|
|
36341
|
+
flags: "gi"
|
|
36342
|
+
},
|
|
36343
|
+
examples: [
|
|
36344
|
+
"Access-Control-Allow-Origin: *",
|
|
36345
|
+
"cors({ origin: '*' })",
|
|
36346
|
+
"CORS_ALLOW_ALL_ORIGINS = True"
|
|
36347
|
+
]
|
|
36348
|
+
};
|
|
36349
|
+
|
|
36350
|
+
// ../../rules/code-flaws/eval-dynamic-exec.json
|
|
36351
|
+
var eval_dynamic_exec_default = {
|
|
36352
|
+
specVersion: 1,
|
|
36353
|
+
id: "code-flaws/eval-dynamic-exec",
|
|
36354
|
+
name: "Dynamic code execution with user-controlled input",
|
|
36355
|
+
category: "code_flaw",
|
|
36356
|
+
severity: "critical",
|
|
36357
|
+
matcher: {
|
|
36358
|
+
type: "regex",
|
|
36359
|
+
pattern: "\\b(eval|exec)\\s*\\(\\s*(?!['\"`])",
|
|
36360
|
+
flags: "g"
|
|
36361
|
+
},
|
|
36362
|
+
requiresNearby: {
|
|
36363
|
+
labels: ["input", "request", "param", "user", "query", "body"],
|
|
36364
|
+
windowChars: 200
|
|
36365
|
+
},
|
|
36366
|
+
examples: ["eval(request.body.code)", "exec(user_input)"]
|
|
36367
|
+
};
|
|
36608
36368
|
|
|
36609
|
-
// ../../
|
|
36610
|
-
var
|
|
36611
|
-
|
|
36612
|
-
|
|
36369
|
+
// ../../rules/code-flaws/hardcoded-password.json
|
|
36370
|
+
var hardcoded_password_default = {
|
|
36371
|
+
specVersion: 1,
|
|
36372
|
+
id: "code-flaws/hardcoded-password",
|
|
36373
|
+
name: "Hardcoded password in source code",
|
|
36374
|
+
category: "code_flaw",
|
|
36375
|
+
severity: "high",
|
|
36376
|
+
matcher: {
|
|
36377
|
+
type: "regex",
|
|
36378
|
+
pattern: `(?:password|passwd|pwd)\\s*=\\s*["']([^"']{3,})["']`,
|
|
36379
|
+
flags: "gi",
|
|
36380
|
+
captureGroup: 1
|
|
36381
|
+
},
|
|
36382
|
+
postValidators: [
|
|
36383
|
+
{
|
|
36384
|
+
name: "entropy",
|
|
36385
|
+
config: {
|
|
36386
|
+
minLength: 8,
|
|
36387
|
+
threshold: 3
|
|
36388
|
+
}
|
|
36389
|
+
}
|
|
36390
|
+
],
|
|
36391
|
+
examples: ['password = "Tr0ub4dor&3"', "DB_PASSWORD = 'c0rr3ctH0rseBatt3ry'"]
|
|
36613
36392
|
};
|
|
36614
|
-
|
|
36615
|
-
|
|
36616
|
-
|
|
36617
|
-
|
|
36618
|
-
|
|
36393
|
+
|
|
36394
|
+
// ../../rules/code-flaws/hardcoded-secret-key.json
|
|
36395
|
+
var hardcoded_secret_key_default = {
|
|
36396
|
+
specVersion: 1,
|
|
36397
|
+
id: "code-flaws/hardcoded-secret-key",
|
|
36398
|
+
name: "Hardcoded API key or secret key in source code",
|
|
36399
|
+
category: "code_flaw",
|
|
36400
|
+
severity: "high",
|
|
36401
|
+
matcher: {
|
|
36402
|
+
type: "regex",
|
|
36403
|
+
pattern: `\\b(secret[_-]?key|api[_-]?key|auth[_-]?token)\\s*=\\s*["'][^"']{8,}["']`,
|
|
36404
|
+
flags: "gi"
|
|
36619
36405
|
},
|
|
36620
|
-
[
|
|
36621
|
-
|
|
36622
|
-
|
|
36623
|
-
|
|
36406
|
+
postValidators: ["entropy"],
|
|
36407
|
+
examples: [
|
|
36408
|
+
'SECRET_KEY = "a9f2c8e1b4d7f3a6c9e2b5d8f1a4c7e0"',
|
|
36409
|
+
"api_key = 'sk-proj-abc123XYZ789def456'"
|
|
36410
|
+
]
|
|
36411
|
+
};
|
|
36412
|
+
|
|
36413
|
+
// ../../rules/code-flaws/path-traversal-join.json
|
|
36414
|
+
var path_traversal_join_default = {
|
|
36415
|
+
specVersion: 1,
|
|
36416
|
+
id: "code-flaws/path-traversal-join",
|
|
36417
|
+
name: "Path traversal via os.path.join with user-controlled component",
|
|
36418
|
+
category: "code_flaw",
|
|
36419
|
+
severity: "high",
|
|
36420
|
+
matcher: {
|
|
36421
|
+
type: "regex",
|
|
36422
|
+
pattern: "os\\.path\\.join\\s*\\([^,)]+,\\s*(request|req|params|user)",
|
|
36423
|
+
flags: "gi"
|
|
36424
|
+
},
|
|
36425
|
+
examples: [
|
|
36426
|
+
"os.path.join(base_dir, request.args['file'])",
|
|
36427
|
+
"os.path.join(upload_dir, user_filename)"
|
|
36428
|
+
],
|
|
36429
|
+
appliesTo: {
|
|
36430
|
+
extensions: [".py"]
|
|
36624
36431
|
}
|
|
36625
36432
|
};
|
|
36626
|
-
|
|
36627
|
-
|
|
36433
|
+
|
|
36434
|
+
// ../../rules/code-flaws/path-traversal-open.json
|
|
36435
|
+
var path_traversal_open_default = {
|
|
36436
|
+
specVersion: 1,
|
|
36437
|
+
id: "code-flaws/path-traversal-open",
|
|
36438
|
+
name: "Path traversal via open() with user-controlled path",
|
|
36439
|
+
category: "code_flaw",
|
|
36440
|
+
severity: "high",
|
|
36441
|
+
matcher: {
|
|
36442
|
+
type: "regex",
|
|
36443
|
+
pattern: "\\bopen\\s*\\(\\s*(request|req|params|argv|input)",
|
|
36444
|
+
flags: "gi"
|
|
36445
|
+
},
|
|
36446
|
+
requiresNearby: {
|
|
36447
|
+
labels: ["request", "param", "input", "argv", "user"],
|
|
36448
|
+
windowChars: 200
|
|
36449
|
+
},
|
|
36450
|
+
examples: ["open(request.args['filename'])", "open(params['path'])"],
|
|
36451
|
+
appliesTo: {
|
|
36452
|
+
extensions: [".py", ".rb"]
|
|
36453
|
+
}
|
|
36628
36454
|
};
|
|
36629
|
-
|
|
36630
|
-
|
|
36631
|
-
|
|
36632
|
-
|
|
36633
|
-
|
|
36455
|
+
|
|
36456
|
+
// ../../rules/code-flaws/prototype-pollution-merge.json
|
|
36457
|
+
var prototype_pollution_merge_default = {
|
|
36458
|
+
specVersion: 1,
|
|
36459
|
+
id: "code-flaws/prototype-pollution-merge",
|
|
36460
|
+
name: "Prototype pollution via merge with user-controlled input",
|
|
36461
|
+
category: "code_flaw",
|
|
36462
|
+
severity: "high",
|
|
36463
|
+
matcher: {
|
|
36464
|
+
type: "regex",
|
|
36465
|
+
pattern: "(Object\\.assign\\s*\\(\\s*\\w+\\s*,\\s*(req|request|body|params|query)|_\\.merge\\s*\\(\\s*\\w+\\s*,\\s*(req|request))",
|
|
36466
|
+
flags: "gi"
|
|
36467
|
+
},
|
|
36468
|
+
examples: ["Object.assign(config, req.body)", "_.merge(target, request.body)"],
|
|
36469
|
+
appliesTo: {
|
|
36470
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]
|
|
36634
36471
|
}
|
|
36635
36472
|
};
|
|
36636
36473
|
|
|
36637
|
-
// ../../
|
|
36638
|
-
var
|
|
36639
|
-
|
|
36640
|
-
|
|
36474
|
+
// ../../rules/code-flaws/regex-redos-backtrack.json
|
|
36475
|
+
var regex_redos_backtrack_default = {
|
|
36476
|
+
specVersion: 1,
|
|
36477
|
+
id: "code-flaws/regex-redos-backtrack",
|
|
36478
|
+
name: "ReDoS via catastrophic backtracking pattern",
|
|
36479
|
+
category: "code_flaw",
|
|
36480
|
+
severity: "medium",
|
|
36481
|
+
matcher: {
|
|
36482
|
+
type: "regex",
|
|
36483
|
+
pattern: "\\((?:\\?:)?(?:\\\\.|\\[[^\\]]*\\]|[^\\\\()\\[\\]+*?|])[+*](?:(?:\\\\.|\\[[^\\]]*\\]|[^\\\\()\\[\\]+*?|])\\*)?\\)[+*]|\\((?:\\?:)?([^()|]+)\\|\\1\\)[+*]",
|
|
36484
|
+
flags: "g"
|
|
36485
|
+
},
|
|
36486
|
+
examples: ["/(a+)+/", "/(\\w+\\s*)+/"]
|
|
36487
|
+
};
|
|
36488
|
+
|
|
36489
|
+
// ../../rules/code-flaws/sql-inject-concat-dot.json
|
|
36490
|
+
var sql_inject_concat_dot_default = {
|
|
36491
|
+
specVersion: 1,
|
|
36492
|
+
id: "code-flaws/sql-inject-concat-dot",
|
|
36493
|
+
name: "SQL injection via string concatenation (PHP dot operator)",
|
|
36494
|
+
category: "code_flaw",
|
|
36495
|
+
severity: "high",
|
|
36496
|
+
matcher: {
|
|
36497
|
+
type: "regex",
|
|
36498
|
+
pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
|
|
36499
|
+
flags: "gi"
|
|
36500
|
+
},
|
|
36501
|
+
appliesTo: {
|
|
36502
|
+
extensions: [".php"]
|
|
36503
|
+
},
|
|
36504
|
+
examples: ['$query = "SELECT * FROM orders WHERE user = " . $username;']
|
|
36505
|
+
};
|
|
36506
|
+
|
|
36507
|
+
// ../../rules/code-flaws/sql-inject-concat.json
|
|
36508
|
+
var sql_inject_concat_default = {
|
|
36509
|
+
specVersion: 1,
|
|
36510
|
+
id: "code-flaws/sql-inject-concat",
|
|
36511
|
+
name: "SQL injection via string concatenation",
|
|
36512
|
+
category: "code_flaw",
|
|
36513
|
+
severity: "high",
|
|
36514
|
+
matcher: {
|
|
36515
|
+
type: "regex",
|
|
36516
|
+
pattern: `["']\\s*(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?["']\\s*\\+`,
|
|
36517
|
+
flags: "gi"
|
|
36518
|
+
},
|
|
36519
|
+
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
36520
|
+
};
|
|
36521
|
+
|
|
36522
|
+
// ../../rules/code-flaws/sql-inject-format.json
|
|
36523
|
+
var sql_inject_format_default = {
|
|
36524
|
+
specVersion: 1,
|
|
36525
|
+
id: "code-flaws/sql-inject-format",
|
|
36526
|
+
name: "SQL injection via format string or f-string",
|
|
36527
|
+
category: "code_flaw",
|
|
36528
|
+
severity: "high",
|
|
36529
|
+
matcher: {
|
|
36530
|
+
type: "regex",
|
|
36531
|
+
pattern: "\\b(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?(?:[%][sd]|\\{[^}]+\\})",
|
|
36532
|
+
flags: "gi"
|
|
36533
|
+
},
|
|
36534
|
+
examples: [
|
|
36535
|
+
'f"SELECT * FROM users WHERE id = {user_id}"',
|
|
36536
|
+
`"SELECT * FROM users WHERE name = '%s'" % name`
|
|
36537
|
+
]
|
|
36538
|
+
};
|
|
36539
|
+
|
|
36540
|
+
// ../../rules/code-flaws/sql-inject-interp.json
|
|
36541
|
+
var sql_inject_interp_default = {
|
|
36542
|
+
specVersion: 1,
|
|
36543
|
+
id: "code-flaws/sql-inject-interp",
|
|
36544
|
+
name: "SQL injection via Ruby string interpolation or PHP variable",
|
|
36545
|
+
category: "code_flaw",
|
|
36546
|
+
severity: "high",
|
|
36547
|
+
matcher: {
|
|
36548
|
+
type: "regex",
|
|
36549
|
+
pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
|
|
36550
|
+
flags: "gi"
|
|
36551
|
+
},
|
|
36552
|
+
examples: [
|
|
36553
|
+
'"SELECT * FROM users WHERE id = #{params[:id]}"',
|
|
36554
|
+
'"SELECT * FROM users WHERE id = $userId"'
|
|
36555
|
+
],
|
|
36556
|
+
appliesTo: {
|
|
36557
|
+
extensions: [".rb", ".php"]
|
|
36558
|
+
}
|
|
36559
|
+
};
|
|
36560
|
+
|
|
36561
|
+
// ../../rules/code-flaws/ssrf-user-url.json
|
|
36562
|
+
var ssrf_user_url_default = {
|
|
36563
|
+
specVersion: 1,
|
|
36564
|
+
id: "code-flaws/ssrf-user-url",
|
|
36565
|
+
name: "Server-side request forgery via user-controlled URL",
|
|
36566
|
+
category: "code_flaw",
|
|
36567
|
+
severity: "high",
|
|
36568
|
+
matcher: {
|
|
36569
|
+
type: "regex",
|
|
36570
|
+
pattern: "(fetch|axios\\.\\w+|requests\\.get|urllib\\.request\\.urlopen)\\s*\\(\\s*(req|request|params|query|body)",
|
|
36571
|
+
flags: "gi"
|
|
36572
|
+
},
|
|
36573
|
+
examples: ["fetch(req.query.url)", "requests.get(request.form['url'])"],
|
|
36574
|
+
appliesTo: {
|
|
36575
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".py"]
|
|
36576
|
+
}
|
|
36577
|
+
};
|
|
36578
|
+
|
|
36579
|
+
// ../../rules/code-flaws/xss-dangerously-set.json
|
|
36580
|
+
var xss_dangerously_set_default = {
|
|
36581
|
+
specVersion: 1,
|
|
36582
|
+
id: "code-flaws/xss-dangerously-set",
|
|
36583
|
+
name: "XSS via React dangerouslySetInnerHTML",
|
|
36584
|
+
category: "code_flaw",
|
|
36585
|
+
severity: "high",
|
|
36586
|
+
matcher: {
|
|
36587
|
+
type: "keyword",
|
|
36588
|
+
keywords: ["dangerouslySetInnerHTML"],
|
|
36589
|
+
caseSensitive: true
|
|
36590
|
+
},
|
|
36591
|
+
examples: ["<div dangerouslySetInnerHTML={{ __html: userContent }} />"],
|
|
36592
|
+
appliesTo: {
|
|
36593
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"]
|
|
36594
|
+
}
|
|
36595
|
+
};
|
|
36596
|
+
|
|
36597
|
+
// ../../rules/code-flaws/xss-inner-html.json
|
|
36598
|
+
var xss_inner_html_default = {
|
|
36599
|
+
specVersion: 1,
|
|
36600
|
+
id: "code-flaws/xss-inner-html",
|
|
36601
|
+
name: "XSS via innerHTML assignment",
|
|
36602
|
+
category: "code_flaw",
|
|
36603
|
+
severity: "high",
|
|
36604
|
+
matcher: {
|
|
36605
|
+
type: "keyword",
|
|
36606
|
+
keywords: ["innerHTML =", "innerHTML="],
|
|
36607
|
+
caseSensitive: true
|
|
36608
|
+
},
|
|
36609
|
+
examples: ["element.innerHTML = userInput"],
|
|
36610
|
+
appliesTo: {
|
|
36611
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]
|
|
36612
|
+
}
|
|
36613
|
+
};
|
|
36614
|
+
|
|
36615
|
+
// ../../rules/code-flaws/xss-unescaped-render.json
|
|
36616
|
+
var xss_unescaped_render_default = {
|
|
36617
|
+
specVersion: 1,
|
|
36618
|
+
id: "code-flaws/xss-unescaped-render",
|
|
36619
|
+
name: "XSS via unescaped template rendering",
|
|
36620
|
+
category: "code_flaw",
|
|
36621
|
+
severity: "high",
|
|
36622
|
+
matcher: {
|
|
36623
|
+
type: "regex",
|
|
36624
|
+
pattern: "(\\braw\\s*\\(|\\bhtml_safe\\b|\\|\\s*safe\\b|\\bmark_safe\\s*\\()",
|
|
36625
|
+
flags: "gi"
|
|
36626
|
+
},
|
|
36627
|
+
examples: ["<%= raw(user_comment) %>", "{{ user_input | safe }}", "mark_safe(user_html)"],
|
|
36628
|
+
appliesTo: {
|
|
36629
|
+
extensions: [".rb", ".py"]
|
|
36630
|
+
}
|
|
36631
|
+
};
|
|
36632
|
+
|
|
36633
|
+
// ../../rules/command-risk/credential-file-read.json
|
|
36634
|
+
var credential_file_read_default = {
|
|
36635
|
+
specVersion: 1,
|
|
36636
|
+
id: "command-risk/credential-file-read",
|
|
36637
|
+
name: "Dump of a credential-bearing file",
|
|
36638
|
+
category: "custom",
|
|
36639
|
+
severity: "medium",
|
|
36640
|
+
matcher: {
|
|
36641
|
+
type: "regex",
|
|
36642
|
+
pattern: `\\b(?:cat|bat|less|more|head|tail|sed|awk|nl|xxd|strings|base64)(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}(?:cat|bat|less|more|head|tail|sed|awk|nl|xxd|strings|base64))[ \\t]+(?:[^\\s;|&]{1,200}[ \\t]+){0,8}?["']?(?:[^\\s;|&"']*/)?(?:\\.env(?!\\.(?:example|sample|template|dist))(?:\\.[A-Za-z0-9_-]+)?|[A-Za-z0-9_-]*\\.env|\\.zshenv|\\.zshrc|\\.zprofile|\\.bashrc|\\.bash_profile|\\.netrc|\\.npmrc|\\.pgpass|\\.git-credentials|\\.aws/(?:credentials|config)|(?:[A-Za-z0-9_.-]*[_.-])?auth\\.json|\\.?credentials\\.json|id_(?:rsa|ed25519|ecdsa|dsa))(?=$|[\\s"';|&)])`,
|
|
36643
|
+
flags: "gm"
|
|
36644
|
+
},
|
|
36645
|
+
examples: ["cat ~/.zshenv", "cat /tmp/host-auth.json"],
|
|
36646
|
+
appliesTo: {
|
|
36647
|
+
eventKinds: ["tool_use"]
|
|
36648
|
+
}
|
|
36649
|
+
};
|
|
36650
|
+
|
|
36651
|
+
// ../../rules/command-risk/curl-pipe-shell.json
|
|
36652
|
+
var curl_pipe_shell_default = {
|
|
36653
|
+
specVersion: 1,
|
|
36654
|
+
id: "command-risk/curl-pipe-shell",
|
|
36655
|
+
name: "curl/wget piped to a shell",
|
|
36656
|
+
category: "custom",
|
|
36657
|
+
severity: "high",
|
|
36658
|
+
matcher: {
|
|
36659
|
+
type: "regex",
|
|
36660
|
+
pattern: `\\b(?:curl|wget)(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}(?:curl|wget))\\b(?:[^\\n|;&\\\\]|\\\\[\\s\\S]){0,300}\\|[ \\t]*(?:(?:sudo|doas|env)(?:[ \\t]+[^\\s|;&]{1,200}){0,4}?[ \\t]+)?(?:[^\\s|;&]{0,200}/)?(?:ba|z|da|k)?sh(?![\\w.-])`,
|
|
36661
|
+
flags: "gm"
|
|
36662
|
+
},
|
|
36663
|
+
examples: [
|
|
36664
|
+
"curl -fsSL https://get.example.dev/install.sh | bash",
|
|
36665
|
+
"wget -qO- https://get.example.dev/setup | sudo sh -s -- --yes"
|
|
36666
|
+
],
|
|
36667
|
+
appliesTo: {
|
|
36668
|
+
eventKinds: ["tool_use"]
|
|
36669
|
+
}
|
|
36670
|
+
};
|
|
36671
|
+
|
|
36672
|
+
// ../../rules/command-risk/git-force-push.json
|
|
36673
|
+
var git_force_push_default = {
|
|
36674
|
+
specVersion: 1,
|
|
36675
|
+
id: "command-risk/git-force-push",
|
|
36676
|
+
name: "git push --force / -f",
|
|
36677
|
+
category: "custom",
|
|
36678
|
+
severity: "high",
|
|
36679
|
+
matcher: {
|
|
36680
|
+
type: "regex",
|
|
36681
|
+
pattern: `\\bgit(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}git)(?:[ \\t]+(?:-[Cc][ \\t]+[^\\s;|&]{1,200}|--[a-z][a-z-]{0,40}(?:=[^\\s;|&]{1,200})?)){0,4}[ \\t]+push(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+(?:-[A-Za-z]*f[A-Za-z]*|--force(?![\\w-])|\\+[^\\s;|&+]{1,200})(?=[\\s;|&)"'\\x60]|$)`,
|
|
36682
|
+
flags: "gm"
|
|
36683
|
+
},
|
|
36684
|
+
examples: ["git push -q -f origin feature-x", "git push --force origin main"],
|
|
36685
|
+
appliesTo: {
|
|
36686
|
+
eventKinds: ["tool_use"]
|
|
36687
|
+
}
|
|
36688
|
+
};
|
|
36689
|
+
|
|
36690
|
+
// ../../rules/command-risk/git-reset-hard.json
|
|
36691
|
+
var git_reset_hard_default = {
|
|
36692
|
+
specVersion: 1,
|
|
36693
|
+
id: "command-risk/git-reset-hard",
|
|
36694
|
+
name: "git reset --hard at command position",
|
|
36695
|
+
category: "custom",
|
|
36696
|
+
severity: "high",
|
|
36697
|
+
matcher: {
|
|
36698
|
+
type: "regex",
|
|
36699
|
+
pattern: `\\bgit(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}git)(?:[ \\t]+(?:-[Cc][ \\t]+[^\\s;|&]{1,200}|--[a-z][a-z-]{0,40}(?:=[^\\s;|&]{1,200})?)){0,4}[ \\t]+reset(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+--hard\\b`,
|
|
36700
|
+
flags: "gm"
|
|
36701
|
+
},
|
|
36702
|
+
examples: ["git reset --hard HEAD~1", "cd /tmp/demo-repo && git reset --hard origin/main"],
|
|
36703
|
+
appliesTo: {
|
|
36704
|
+
eventKinds: ["tool_use"]
|
|
36705
|
+
}
|
|
36706
|
+
};
|
|
36707
|
+
|
|
36708
|
+
// ../../rules/command-risk/pkill-broad.json
|
|
36709
|
+
var pkill_broad_default = {
|
|
36710
|
+
specVersion: 1,
|
|
36711
|
+
id: "command-risk/pkill-broad",
|
|
36712
|
+
name: "pkill -f (command-line pattern kill)",
|
|
36713
|
+
category: "custom",
|
|
36714
|
+
severity: "medium",
|
|
36715
|
+
matcher: {
|
|
36716
|
+
type: "regex",
|
|
36717
|
+
pattern: `\\bpkill(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}pkill)(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+(?:-[A-Za-z0-9]*f[A-Za-z0-9]*|--full)[ \\t]+["'\\w]`,
|
|
36718
|
+
flags: "gm"
|
|
36719
|
+
},
|
|
36720
|
+
examples: ['pkill -f "Brave Browser"', 'pkill -TERM -f "bun src/main.ts"'],
|
|
36721
|
+
appliesTo: {
|
|
36722
|
+
eventKinds: ["tool_use"]
|
|
36723
|
+
}
|
|
36724
|
+
};
|
|
36725
|
+
|
|
36726
|
+
// ../../rules/command-risk/rm-rf-home-or-shared.json
|
|
36727
|
+
var rm_rf_home_or_shared_default = {
|
|
36728
|
+
specVersion: 1,
|
|
36729
|
+
id: "command-risk/rm-rf-home-or-shared",
|
|
36730
|
+
name: "Recursive rm of home, /Users or a system directory",
|
|
36731
|
+
category: "custom",
|
|
36732
|
+
severity: "high",
|
|
36733
|
+
matcher: {
|
|
36734
|
+
type: "regex",
|
|
36735
|
+
pattern: `\\brm(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}rm)(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+(?:-[A-Za-z]*[rR][A-Za-z]*|--recursive)(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+["']?(?:~|\\$HOME(?!\\w)|\\$\\{HOME\\}|/(?:Users|home)(?=[/\\s"';|&)]|$)|/(?:etc|var|usr|bin|sbin|lib|opt|System|Library)?/?\\*?(?=[\\s"';|&)]|$)|\\.\\.(?:/\\.\\.)*/?(?=[\\s"';|&)]|$))`,
|
|
36736
|
+
flags: "gm"
|
|
36737
|
+
},
|
|
36738
|
+
examples: [
|
|
36739
|
+
"rm -rf ~/projects/demo-app/$WORKDIR",
|
|
36740
|
+
"rm -rf ~/worktrees/x ~/.claude-demo/projects/-Users-x"
|
|
36741
|
+
],
|
|
36742
|
+
appliesTo: {
|
|
36743
|
+
eventKinds: ["tool_use"]
|
|
36744
|
+
}
|
|
36745
|
+
};
|
|
36746
|
+
|
|
36747
|
+
// ../../rules/core-code-context/db-table-name.json
|
|
36748
|
+
var db_table_name_default = {
|
|
36749
|
+
specVersion: 1,
|
|
36750
|
+
id: "core-code-context/db-table-name",
|
|
36751
|
+
name: "Internal database table/column name",
|
|
36752
|
+
category: "code_context",
|
|
36753
|
+
severity: "low",
|
|
36754
|
+
matcher: {
|
|
36755
|
+
type: "keyword",
|
|
36756
|
+
keywords: [
|
|
36757
|
+
"SELECT * FROM ",
|
|
36758
|
+
"SELECT COUNT(*) FROM ",
|
|
36759
|
+
"INSERT INTO ",
|
|
36760
|
+
"DELETE FROM ",
|
|
36761
|
+
"CREATE TABLE ",
|
|
36762
|
+
"ALTER TABLE ",
|
|
36763
|
+
"DROP TABLE ",
|
|
36764
|
+
"FROM users",
|
|
36765
|
+
"FROM orders",
|
|
36766
|
+
"FROM employees",
|
|
36767
|
+
"FROM customers",
|
|
36768
|
+
"FROM accounts",
|
|
36769
|
+
"FROM transactions",
|
|
36770
|
+
"FROM products",
|
|
36771
|
+
"FROM payments"
|
|
36772
|
+
],
|
|
36773
|
+
caseSensitive: false
|
|
36774
|
+
},
|
|
36775
|
+
examples: ["SELECT * FROM users WHERE id = 1"]
|
|
36776
|
+
};
|
|
36777
|
+
|
|
36778
|
+
// ../../rules/core-code-context/feature-flag.json
|
|
36779
|
+
var feature_flag_default = {
|
|
36780
|
+
specVersion: 1,
|
|
36781
|
+
id: "core-code-context/feature-flag",
|
|
36782
|
+
name: "Feature flag / toggle name",
|
|
36783
|
+
category: "code_context",
|
|
36784
|
+
severity: "low",
|
|
36785
|
+
matcher: {
|
|
36786
|
+
type: "keyword",
|
|
36787
|
+
keywords: [
|
|
36788
|
+
"feature_flag:",
|
|
36789
|
+
"feature_toggle:",
|
|
36790
|
+
"feature-flag:",
|
|
36791
|
+
"feature-toggle:",
|
|
36792
|
+
"FF_",
|
|
36793
|
+
"FEATURE_FLAG_",
|
|
36794
|
+
"FEATURE_TOGGLE_",
|
|
36795
|
+
"unleash:",
|
|
36796
|
+
"launchdarkly:",
|
|
36797
|
+
"split.io:"
|
|
36798
|
+
],
|
|
36799
|
+
caseSensitive: false
|
|
36800
|
+
},
|
|
36801
|
+
examples: ["feature_flag: new-checkout-flow", "FF_ENABLE_DARK_MODE"]
|
|
36802
|
+
};
|
|
36803
|
+
|
|
36804
|
+
// ../../rules/core-code-context/file-path.json
|
|
36805
|
+
var file_path_default = {
|
|
36806
|
+
specVersion: 1,
|
|
36807
|
+
id: "core-code-context/file-path",
|
|
36808
|
+
name: "User home / identity-bearing file path",
|
|
36809
|
+
category: "code_context",
|
|
36810
|
+
severity: "low",
|
|
36811
|
+
matcher: {
|
|
36812
|
+
type: "regex",
|
|
36813
|
+
pattern: "(?:/home|/Users)/[A-Za-z0-9_.@-]+(?:/[A-Za-z0-9_.@+-]+)*|/root(?:/[A-Za-z0-9_.@+-]+)+|[A-Za-z]:\\\\[Uu]sers\\\\[A-Za-z0-9_.-]+(?:\\\\[A-Za-z0-9_.-]+)*",
|
|
36814
|
+
flags: "g"
|
|
36815
|
+
},
|
|
36816
|
+
examples: [
|
|
36817
|
+
"/home/user/.ssh/id_rsa",
|
|
36818
|
+
"/Users/jane/projects/acme/secrets.env",
|
|
36819
|
+
"C:\\Users\\admin\\config.yml"
|
|
36820
|
+
]
|
|
36821
|
+
};
|
|
36822
|
+
|
|
36823
|
+
// ../../rules/core-code-context/gcp-service-account-email.json
|
|
36824
|
+
var gcp_service_account_email_default = {
|
|
36825
|
+
specVersion: 1,
|
|
36826
|
+
id: "core-code-context/gcp-service-account-email",
|
|
36827
|
+
name: "GCP service account email",
|
|
36828
|
+
category: "code_context",
|
|
36829
|
+
severity: "low",
|
|
36830
|
+
matcher: {
|
|
36831
|
+
type: "regex",
|
|
36832
|
+
pattern: "(?<![a-z0-9-])[a-z0-9-]{3,}@[a-z0-9][a-z0-9-]{2,60}\\.iam\\.gserviceaccount\\.com\\b",
|
|
36833
|
+
flags: "g"
|
|
36834
|
+
},
|
|
36835
|
+
examples: [
|
|
36836
|
+
"deploy-bot@sample-project.iam.gserviceaccount.com",
|
|
36837
|
+
"12345678-1234-1234-1234-123456789012@my-project.iam.gserviceaccount.com"
|
|
36838
|
+
]
|
|
36839
|
+
};
|
|
36840
|
+
|
|
36841
|
+
// ../../rules/core-code-context/internal-domain.json
|
|
36842
|
+
var internal_domain_default = {
|
|
36843
|
+
specVersion: 1,
|
|
36844
|
+
id: "core-code-context/internal-domain",
|
|
36845
|
+
name: "Internal domain / hostname",
|
|
36846
|
+
category: "code_context",
|
|
36847
|
+
severity: "low",
|
|
36848
|
+
matcher: {
|
|
36849
|
+
type: "regex",
|
|
36850
|
+
pattern: "(?<![A-Za-z0-9.-])[A-Za-z0-9][A-Za-z0-9.-]{0,251}\\.(?:internal|corp|local|lan|intranet|private|staging|test|qa)(?:\\.(?:com|net|org|io|co|app))?\\b(?!\\.[A-Za-z0-9-]+(?!\\.?[A-Za-z0-9]))(?!\\.(?:d|tsx?|jsx?|mjs|cjs|json|md|py|sh|ya?ml|toml|txt|log|snap|html|css|rs|go)\\b)",
|
|
36851
|
+
flags: "gi"
|
|
36852
|
+
},
|
|
36853
|
+
examples: ["db.internal.com", "app.corp.local", "api.staging.example.com"]
|
|
36854
|
+
};
|
|
36855
|
+
|
|
36856
|
+
// ../../rules/core-code-context/internal-ip.json
|
|
36857
|
+
var internal_ip_default = {
|
|
36858
|
+
specVersion: 1,
|
|
36859
|
+
id: "core-code-context/internal-ip",
|
|
36860
|
+
name: "Internal (RFC 1918) IP address",
|
|
36861
|
+
category: "code_context",
|
|
36862
|
+
severity: "low",
|
|
36863
|
+
matcher: {
|
|
36864
|
+
type: "regex",
|
|
36865
|
+
pattern: "(?<!\\d\\.?)(?:10\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|172\\.(?:1[6-9]|2\\d|3[01])\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|192\\.168\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))(?!\\d|\\.\\d+\\.\\d)",
|
|
36866
|
+
flags: "g"
|
|
36867
|
+
},
|
|
36868
|
+
examples: ["10.0.0.1", "192.168.1.1", "172.16.0.1"]
|
|
36869
|
+
};
|
|
36870
|
+
|
|
36871
|
+
// ../../rules/core-code-context/internal-url.json
|
|
36872
|
+
var internal_url_default = {
|
|
36873
|
+
specVersion: 1,
|
|
36874
|
+
id: "core-code-context/internal-url",
|
|
36875
|
+
name: "Internal environment URL",
|
|
36876
|
+
category: "code_context",
|
|
36877
|
+
severity: "low",
|
|
36878
|
+
matcher: {
|
|
36879
|
+
type: "keyword",
|
|
36880
|
+
keywords: [
|
|
36881
|
+
"https://staging.",
|
|
36882
|
+
"https://dev.",
|
|
36883
|
+
"https://qa.",
|
|
36884
|
+
"https://test.",
|
|
36885
|
+
"http://staging.",
|
|
36886
|
+
"http://dev.",
|
|
36887
|
+
"http://qa.",
|
|
36888
|
+
"http://test.",
|
|
36889
|
+
".staging.com",
|
|
36890
|
+
".dev.com",
|
|
36891
|
+
".qa.com",
|
|
36892
|
+
"staging.internal",
|
|
36893
|
+
"dev.internal"
|
|
36894
|
+
],
|
|
36895
|
+
caseSensitive: false
|
|
36896
|
+
},
|
|
36897
|
+
examples: ["https://staging.example.com"]
|
|
36898
|
+
};
|
|
36899
|
+
|
|
36900
|
+
// ../../rules/core-code-context/localhost-ref.json
|
|
36901
|
+
var localhost_ref_default = {
|
|
36902
|
+
specVersion: 1,
|
|
36903
|
+
id: "core-code-context/localhost-ref",
|
|
36904
|
+
name: "Localhost reference",
|
|
36905
|
+
category: "code_context",
|
|
36906
|
+
severity: "low",
|
|
36907
|
+
matcher: {
|
|
36908
|
+
type: "regex",
|
|
36909
|
+
pattern: "(?<![A-Za-z0-9_])(?:localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|(?<![A-Za-z0-9_]\\[)::1(?!:|\\.[0-9]))(?![A-Za-z0-9_])",
|
|
36910
|
+
flags: "g"
|
|
36911
|
+
},
|
|
36912
|
+
examples: ["localhost", "127.0.0.1", "0.0.0.0", "::1"]
|
|
36913
|
+
};
|
|
36914
|
+
|
|
36915
|
+
// ../../rules/core-code-context/stack-trace.json
|
|
36916
|
+
var stack_trace_default = {
|
|
36917
|
+
specVersion: 1,
|
|
36918
|
+
id: "core-code-context/stack-trace",
|
|
36919
|
+
name: "Stack trace (internal code structure)",
|
|
36920
|
+
category: "code_context",
|
|
36921
|
+
severity: "low",
|
|
36922
|
+
matcher: {
|
|
36923
|
+
type: "regex",
|
|
36924
|
+
pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
|
|
36925
|
+
flags: "g"
|
|
36926
|
+
},
|
|
36927
|
+
examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
|
|
36928
|
+
};
|
|
36929
|
+
|
|
36930
|
+
// ../../rules/core-financial/credit-card.json
|
|
36931
|
+
var credit_card_default = {
|
|
36932
|
+
specVersion: 1,
|
|
36933
|
+
id: "core-financial/credit-card",
|
|
36934
|
+
name: "Credit/debit card number",
|
|
36935
|
+
category: "financial",
|
|
36936
|
+
severity: "critical",
|
|
36937
|
+
matcher: {
|
|
36938
|
+
type: "regex",
|
|
36939
|
+
pattern: "(?<![.\\d])\\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})\\b",
|
|
36940
|
+
flags: "g"
|
|
36941
|
+
},
|
|
36942
|
+
postValidators: ["luhn"],
|
|
36943
|
+
examples: ["4111111111111111", "5500000000000004"]
|
|
36944
|
+
};
|
|
36945
|
+
|
|
36946
|
+
// ../../rules/core-financial/cusip.json
|
|
36947
|
+
var cusip_default = {
|
|
36948
|
+
specVersion: 1,
|
|
36949
|
+
id: "core-financial/cusip",
|
|
36950
|
+
name: "CUSIP security identifier",
|
|
36951
|
+
category: "financial",
|
|
36952
|
+
severity: "medium",
|
|
36953
|
+
matcher: {
|
|
36954
|
+
type: "regex",
|
|
36955
|
+
pattern: "\\bcusip\\b[\\s#:=-]{0,8}(\\d{3}[A-Z0-9]{2}[A-Z0-9*#@]\\d{2}[0-9])\\b",
|
|
36956
|
+
flags: "gi",
|
|
36957
|
+
captureGroup: 1
|
|
36958
|
+
},
|
|
36959
|
+
examples: ["CUSIP: 037833100", "CUSIP 931142103"]
|
|
36960
|
+
};
|
|
36961
|
+
|
|
36962
|
+
// ../../rules/core-financial/cvv.json
|
|
36963
|
+
var cvv_default = {
|
|
36964
|
+
specVersion: 1,
|
|
36965
|
+
id: "core-financial/cvv",
|
|
36966
|
+
name: "Card security code (CVV/CVC)",
|
|
36967
|
+
category: "financial",
|
|
36968
|
+
severity: "high",
|
|
36969
|
+
matcher: {
|
|
36970
|
+
type: "regex",
|
|
36971
|
+
pattern: "\\b(?:CVV|CVC|CID|security\\s+code|card\\s+code)[:\\s]*\\d{3,4}\\b",
|
|
36972
|
+
flags: "gi"
|
|
36973
|
+
},
|
|
36974
|
+
examples: ["CVV: 123", "CVC: 456"]
|
|
36975
|
+
};
|
|
36976
|
+
|
|
36977
|
+
// ../../rules/core-financial/iban.json
|
|
36978
|
+
var iban_default = {
|
|
36979
|
+
specVersion: 1,
|
|
36980
|
+
id: "core-financial/iban",
|
|
36981
|
+
name: "International Bank Account Number",
|
|
36982
|
+
category: "financial",
|
|
36983
|
+
severity: "high",
|
|
36984
|
+
matcher: {
|
|
36985
|
+
type: "regex",
|
|
36986
|
+
pattern: "\\b[A-Z]{2}\\d{2}[A-Z0-9 ]{10,30}\\b",
|
|
36987
|
+
flags: "g"
|
|
36988
|
+
},
|
|
36989
|
+
requiresNearby: {
|
|
36990
|
+
labels: ["iban", "bank", "account", "bic", "swift"],
|
|
36991
|
+
windowChars: 160
|
|
36992
|
+
},
|
|
36993
|
+
examples: ["IBAN: GB82 WEST 1234 5698 7654 32", "IBAN: DE89 3704 0044 0532 0130 00"]
|
|
36994
|
+
};
|
|
36995
|
+
|
|
36996
|
+
// ../../rules/core-financial/paypal.json
|
|
36997
|
+
var paypal_default = {
|
|
36998
|
+
specVersion: 1,
|
|
36999
|
+
id: "core-financial/paypal",
|
|
37000
|
+
name: "PayPal transaction/merchant ID",
|
|
37001
|
+
category: "financial",
|
|
37002
|
+
severity: "medium",
|
|
37003
|
+
matcher: {
|
|
37004
|
+
type: "regex",
|
|
37005
|
+
pattern: "paypal.{0,30}?\\b([A-Z0-9]{17})\\b",
|
|
37006
|
+
flags: "gi",
|
|
37007
|
+
captureGroup: 1
|
|
37008
|
+
},
|
|
37009
|
+
examples: ["PayPal transaction ID: 9HW7382910ABCDEF1"]
|
|
37010
|
+
};
|
|
37011
|
+
|
|
37012
|
+
// ../../rules/core-financial/routing-number.json
|
|
37013
|
+
var routing_number_default = {
|
|
37014
|
+
specVersion: 1,
|
|
37015
|
+
id: "core-financial/routing-number",
|
|
37016
|
+
name: "US bank routing number (ABA)",
|
|
37017
|
+
category: "financial",
|
|
37018
|
+
severity: "high",
|
|
37019
|
+
matcher: {
|
|
37020
|
+
type: "regex",
|
|
37021
|
+
pattern: "\\b(?:routing|aba|rtn)\\b[\\s#:=-]{0,8}(\\d{9})\\b",
|
|
37022
|
+
flags: "gi",
|
|
37023
|
+
captureGroup: 1
|
|
37024
|
+
},
|
|
37025
|
+
examples: ["Routing: 021000021", "ABA 111000025"]
|
|
37026
|
+
};
|
|
37027
|
+
|
|
37028
|
+
// ../../rules/core-financial/salary.json
|
|
37029
|
+
var salary_default = {
|
|
37030
|
+
specVersion: 1,
|
|
37031
|
+
id: "core-financial/salary",
|
|
37032
|
+
name: "Salary/compensation (contextual)",
|
|
37033
|
+
category: "financial",
|
|
37034
|
+
severity: "low",
|
|
37035
|
+
matcher: {
|
|
37036
|
+
type: "keyword",
|
|
37037
|
+
keywords: [
|
|
37038
|
+
"my salary is",
|
|
37039
|
+
"my base salary",
|
|
37040
|
+
"annual compensation",
|
|
37041
|
+
"total comp",
|
|
37042
|
+
"my tc is",
|
|
37043
|
+
"my package is",
|
|
37044
|
+
"i make $",
|
|
37045
|
+
"i earn $",
|
|
37046
|
+
"offered $"
|
|
37047
|
+
],
|
|
37048
|
+
caseSensitive: false
|
|
37049
|
+
},
|
|
37050
|
+
examples: ["My salary is $150,000"]
|
|
37051
|
+
};
|
|
37052
|
+
|
|
37053
|
+
// ../../rules/core-financial/swift.json
|
|
37054
|
+
var swift_default = {
|
|
37055
|
+
specVersion: 1,
|
|
37056
|
+
id: "core-financial/swift",
|
|
37057
|
+
name: "SWIFT/BIC code",
|
|
37058
|
+
category: "financial",
|
|
37059
|
+
severity: "high",
|
|
37060
|
+
matcher: {
|
|
37061
|
+
type: "regex",
|
|
37062
|
+
pattern: "\\b(?:[Ss][Ww][Ii][Ff][Tt]|[Bb][Ii][Cc])\\b[\\s#:=-]{0,8}([A-Z]{6}[A-Z0-9]{2}(?:[A-Z0-9]{3})?)\\b",
|
|
37063
|
+
flags: "g",
|
|
37064
|
+
captureGroup: 1
|
|
37065
|
+
},
|
|
37066
|
+
examples: ["SWIFT: BOFAUS3N", "BIC: CHASGB2LXXX"]
|
|
37067
|
+
};
|
|
37068
|
+
|
|
37069
|
+
// ../../rules/core-phi/biometric-ref.json
|
|
37070
|
+
var biometric_ref_default = {
|
|
37071
|
+
specVersion: 1,
|
|
37072
|
+
id: "core-phi/biometric-ref",
|
|
37073
|
+
name: "Biometric data reference",
|
|
37074
|
+
category: "phi",
|
|
37075
|
+
severity: "high",
|
|
37076
|
+
matcher: {
|
|
37077
|
+
type: "keyword",
|
|
37078
|
+
keywords: [
|
|
37079
|
+
"fingerprint data",
|
|
37080
|
+
"fingerprint scan",
|
|
37081
|
+
"my iris scan",
|
|
37082
|
+
"my retina scan",
|
|
37083
|
+
"my biometric",
|
|
37084
|
+
"my facial recognition",
|
|
37085
|
+
"my voiceprint",
|
|
37086
|
+
"my palm print",
|
|
37087
|
+
"my hand geometry"
|
|
37088
|
+
],
|
|
37089
|
+
caseSensitive: false
|
|
37090
|
+
},
|
|
37091
|
+
examples: ["My fingerprint data is stored in the biometric database"]
|
|
37092
|
+
};
|
|
37093
|
+
|
|
37094
|
+
// ../../rules/core-phi/genetic-data.json
|
|
37095
|
+
var genetic_data_default = {
|
|
37096
|
+
specVersion: 1,
|
|
37097
|
+
id: "core-phi/genetic-data",
|
|
37098
|
+
name: "Genetic/DNA sequence reference",
|
|
37099
|
+
category: "phi",
|
|
37100
|
+
severity: "high",
|
|
37101
|
+
matcher: {
|
|
37102
|
+
type: "keyword",
|
|
37103
|
+
keywords: [
|
|
37104
|
+
"my dna sequence",
|
|
37105
|
+
"my genome",
|
|
37106
|
+
"my genetic",
|
|
37107
|
+
"dna test results",
|
|
37108
|
+
"genetic test results",
|
|
37109
|
+
"my 23andme",
|
|
37110
|
+
"my ancestrydna",
|
|
37111
|
+
"gene variant",
|
|
37112
|
+
"my genotype",
|
|
37113
|
+
"my haplogroup"
|
|
37114
|
+
],
|
|
37115
|
+
caseSensitive: false
|
|
37116
|
+
},
|
|
37117
|
+
examples: ["My DNA sequence shows a variant in the BRCA1 gene"]
|
|
37118
|
+
};
|
|
37119
|
+
|
|
37120
|
+
// ../../rules/core-phi/group-id.json
|
|
37121
|
+
var group_id_default = {
|
|
37122
|
+
specVersion: 1,
|
|
37123
|
+
id: "core-phi/group-id",
|
|
37124
|
+
name: "Health plan group ID",
|
|
37125
|
+
category: "phi",
|
|
37126
|
+
severity: "high",
|
|
37127
|
+
matcher: {
|
|
37128
|
+
type: "regex",
|
|
37129
|
+
pattern: "\\bgroup\\s*(?:id|number|no|#)\\s*[:#]?\\s*[A-Za-z0-9]{6,20}\\b",
|
|
37130
|
+
flags: "gi"
|
|
37131
|
+
},
|
|
37132
|
+
requiresNearby: {
|
|
37133
|
+
ruleIds: ["core-phi/member-id"],
|
|
37134
|
+
labels: ["member id", "subscriber", "health plan"],
|
|
37135
|
+
windowChars: 200,
|
|
37136
|
+
confidenceBoost: 0.05
|
|
37137
|
+
},
|
|
37138
|
+
examples: ["Member ID: ABC987654321, Group ID: GRP12345678"]
|
|
37139
|
+
};
|
|
37140
|
+
|
|
37141
|
+
// ../../rules/core-phi/hipaa-identifier.json
|
|
37142
|
+
var hipaa_identifier_default = {
|
|
37143
|
+
specVersion: 1,
|
|
37144
|
+
id: "core-phi/hipaa-identifier",
|
|
37145
|
+
name: "HIPAA standard identifier (health plan / beneficiary / claim number)",
|
|
37146
|
+
category: "phi",
|
|
37147
|
+
severity: "high",
|
|
37148
|
+
matcher: {
|
|
37149
|
+
type: "regex",
|
|
37150
|
+
pattern: "\\b(?:health\\s+plan|beneficiary|claim\\s+number|subscriber)[:\\s]*[A-Za-z0-9]{8,20}\\b",
|
|
37151
|
+
flags: "gi"
|
|
37152
|
+
},
|
|
37153
|
+
examples: ["Health Plan: XYZ123456789", "Beneficiary: ABC987654321"]
|
|
37154
|
+
};
|
|
37155
|
+
|
|
37156
|
+
// ../../rules/core-phi/icd10-code.json
|
|
37157
|
+
var icd10_code_default = {
|
|
37158
|
+
specVersion: 1,
|
|
37159
|
+
id: "core-phi/icd10-code",
|
|
37160
|
+
name: "ICD-10 diagnosis code",
|
|
37161
|
+
category: "phi",
|
|
37162
|
+
severity: "medium",
|
|
37163
|
+
matcher: {
|
|
37164
|
+
type: "regex",
|
|
37165
|
+
pattern: "(?:icd[- ]?10|diagnosis|\\bdx\\b).{0,12}?([A-Z][0-9]{2}(?:\\.[0-9]{1,4})?)\\b",
|
|
37166
|
+
flags: "gi",
|
|
37167
|
+
captureGroup: 1
|
|
37168
|
+
},
|
|
37169
|
+
examples: ["ICD-10: I10", "Diagnosis code E11.9", "dx: J45.909"]
|
|
37170
|
+
};
|
|
37171
|
+
|
|
37172
|
+
// ../../rules/core-phi/member-id.json
|
|
37173
|
+
var member_id_default = {
|
|
37174
|
+
specVersion: 1,
|
|
37175
|
+
id: "core-phi/member-id",
|
|
37176
|
+
name: "Health plan member ID",
|
|
37177
|
+
category: "phi",
|
|
37178
|
+
severity: "high",
|
|
37179
|
+
matcher: {
|
|
37180
|
+
type: "regex",
|
|
37181
|
+
pattern: "\\bmember\\s*(?:id|number|no|#)\\s*[:#]?\\s*[A-Za-z0-9]{6,20}\\b",
|
|
37182
|
+
flags: "gi"
|
|
37183
|
+
},
|
|
37184
|
+
examples: ["Member ID: ABC987654321"]
|
|
37185
|
+
};
|
|
37186
|
+
|
|
37187
|
+
// ../../rules/core-phi/mrn.json
|
|
37188
|
+
var mrn_default = {
|
|
37189
|
+
specVersion: 1,
|
|
37190
|
+
id: "core-phi/mrn",
|
|
37191
|
+
name: "Medical Record Number",
|
|
37192
|
+
category: "phi",
|
|
37193
|
+
severity: "high",
|
|
37194
|
+
matcher: {
|
|
37195
|
+
type: "regex",
|
|
37196
|
+
pattern: "\\b(?:MRN|MR#|medical\\s+record)[:\\s]*[A-Za-z0-9]{6,16}\\b",
|
|
37197
|
+
flags: "gi"
|
|
37198
|
+
},
|
|
37199
|
+
examples: ["MRN: 1234567890", "Medical Record: ABCD1234"]
|
|
37200
|
+
};
|
|
37201
|
+
|
|
37202
|
+
// ../../rules/core-phi/ndc-code.json
|
|
37203
|
+
var ndc_code_default = {
|
|
37204
|
+
specVersion: 1,
|
|
37205
|
+
id: "core-phi/ndc-code",
|
|
37206
|
+
name: "National Drug Code (NDC)",
|
|
37207
|
+
category: "phi",
|
|
37208
|
+
severity: "medium",
|
|
37209
|
+
matcher: {
|
|
37210
|
+
type: "regex",
|
|
37211
|
+
pattern: "\\b\\d{4,5}-\\d{3,4}-\\d{1,2}\\b",
|
|
37212
|
+
flags: "g"
|
|
37213
|
+
},
|
|
37214
|
+
examples: ["0002-1427-01", "68788-6965-1"]
|
|
37215
|
+
};
|
|
37216
|
+
|
|
37217
|
+
// ../../rules/core-pii/dob.json
|
|
37218
|
+
var dob_default = {
|
|
37219
|
+
specVersion: 1,
|
|
37220
|
+
id: "core-pii/dob",
|
|
37221
|
+
name: "Date of birth",
|
|
37222
|
+
category: "pii",
|
|
37223
|
+
severity: "high",
|
|
37224
|
+
matcher: {
|
|
37225
|
+
type: "regex",
|
|
37226
|
+
pattern: "\\b(?:(?:19[4-9]\\d|20[0-1]\\d)[/-]\\d{1,2}[/-]\\d{1,2}|\\d{1,2}[/-]\\d{1,2}[/-](?:19[4-9]\\d|20[0-1]\\d))\\b",
|
|
37227
|
+
flags: "g"
|
|
37228
|
+
},
|
|
37229
|
+
requiresNearby: {
|
|
37230
|
+
categories: ["pii"],
|
|
37231
|
+
labels: [
|
|
37232
|
+
"dob",
|
|
37233
|
+
"date of birth",
|
|
37234
|
+
"birth",
|
|
37235
|
+
"d.o.b",
|
|
37236
|
+
"nascimento",
|
|
37237
|
+
"naissance",
|
|
37238
|
+
"nacimiento",
|
|
37239
|
+
"geburtsdatum",
|
|
37240
|
+
"nascita"
|
|
37241
|
+
],
|
|
37242
|
+
windowChars: 160
|
|
37243
|
+
},
|
|
37244
|
+
examples: ["DOB: 1985-03-22", "Date of birth: 03/22/1985"]
|
|
37245
|
+
};
|
|
37246
|
+
|
|
37247
|
+
// ../../rules/core-pii/drivers-license-us.json
|
|
37248
|
+
var drivers_license_us_default = {
|
|
37249
|
+
specVersion: 1,
|
|
37250
|
+
id: "core-pii/drivers-license-us",
|
|
37251
|
+
name: "US driver's license number",
|
|
37252
|
+
category: "pii",
|
|
37253
|
+
severity: "high",
|
|
37254
|
+
matcher: {
|
|
37255
|
+
type: "regex",
|
|
37256
|
+
pattern: "(?:driver'?s?\\s*licen[sc]e|licen[sc]e|\\bDL\\b).{0,10}?([A-Z]\\d{6,8}|\\d{8,9})\\b",
|
|
37257
|
+
flags: "gi",
|
|
37258
|
+
captureGroup: 1
|
|
37259
|
+
},
|
|
37260
|
+
examples: ["Driver's License: D1234567", "DL: 123456789"]
|
|
37261
|
+
};
|
|
37262
|
+
|
|
37263
|
+
// ../../rules/core-pii/email.json
|
|
37264
|
+
var email_default = {
|
|
37265
|
+
specVersion: 1,
|
|
37266
|
+
id: "core-pii/email",
|
|
37267
|
+
name: "Email address",
|
|
37268
|
+
category: "pii",
|
|
37269
|
+
severity: "medium",
|
|
37270
|
+
matcher: {
|
|
37271
|
+
type: "regex",
|
|
37272
|
+
pattern: "(?<![A-Za-z0-9._%+-])[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\\.[A-Za-z]{2,24}\\b",
|
|
37273
|
+
flags: "g"
|
|
37274
|
+
},
|
|
37275
|
+
examples: ["user@example.com"]
|
|
37276
|
+
};
|
|
37277
|
+
|
|
37278
|
+
// ../../rules/core-pii/home-address.json
|
|
37279
|
+
var home_address_default = {
|
|
37280
|
+
specVersion: 1,
|
|
37281
|
+
id: "core-pii/home-address",
|
|
37282
|
+
name: "Home address (contextual)",
|
|
37283
|
+
category: "pii",
|
|
37284
|
+
severity: "medium",
|
|
37285
|
+
matcher: {
|
|
37286
|
+
type: "keyword",
|
|
37287
|
+
keywords: [
|
|
37288
|
+
"my address is",
|
|
37289
|
+
"home address",
|
|
37290
|
+
"shipping address",
|
|
37291
|
+
"billing address",
|
|
37292
|
+
"mailing address",
|
|
37293
|
+
"my home is at",
|
|
37294
|
+
"i reside at"
|
|
37295
|
+
],
|
|
37296
|
+
caseSensitive: false
|
|
37297
|
+
},
|
|
37298
|
+
examples: ["My address is 123 Main St, Springfield, IL 62701"]
|
|
37299
|
+
};
|
|
37300
|
+
|
|
37301
|
+
// ../../rules/core-pii/ip-address.json
|
|
37302
|
+
var ip_address_default = {
|
|
37303
|
+
specVersion: 1,
|
|
37304
|
+
id: "core-pii/ip-address",
|
|
37305
|
+
name: "IP address",
|
|
37306
|
+
category: "pii",
|
|
37307
|
+
severity: "low",
|
|
37308
|
+
matcher: {
|
|
37309
|
+
type: "regex",
|
|
37310
|
+
pattern: "(?<!\\d\\.)\\b(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\b(?!\\.\\d+\\.\\d)",
|
|
37311
|
+
flags: "g"
|
|
37312
|
+
},
|
|
37313
|
+
examples: ["192.168.1.1", "10.0.0.1"]
|
|
37314
|
+
};
|
|
37315
|
+
|
|
37316
|
+
// ../../rules/core-pii/mac-address.json
|
|
37317
|
+
var mac_address_default = {
|
|
37318
|
+
specVersion: 1,
|
|
37319
|
+
id: "core-pii/mac-address",
|
|
37320
|
+
name: "MAC address",
|
|
37321
|
+
category: "pii",
|
|
37322
|
+
severity: "low",
|
|
37323
|
+
matcher: {
|
|
37324
|
+
type: "regex",
|
|
37325
|
+
pattern: "\\b(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\\b",
|
|
37326
|
+
flags: "g"
|
|
37327
|
+
},
|
|
37328
|
+
examples: ["AA:BB:CC:DD:EE:FF"]
|
|
37329
|
+
};
|
|
37330
|
+
|
|
37331
|
+
// ../../rules/core-pii/name.json
|
|
37332
|
+
var name_default = {
|
|
37333
|
+
specVersion: 1,
|
|
37334
|
+
id: "core-pii/name",
|
|
37335
|
+
name: "Personal name (contextual)",
|
|
37336
|
+
category: "pii",
|
|
37337
|
+
severity: "medium",
|
|
37338
|
+
matcher: {
|
|
37339
|
+
type: "keyword",
|
|
37340
|
+
keywords: [
|
|
37341
|
+
"my name is",
|
|
37342
|
+
"my full name",
|
|
37343
|
+
"i am called",
|
|
37344
|
+
"please call me",
|
|
37345
|
+
"name:\n",
|
|
37346
|
+
'"full_name": "',
|
|
37347
|
+
'"fullName": "'
|
|
37348
|
+
],
|
|
37349
|
+
caseSensitive: false
|
|
37350
|
+
},
|
|
37351
|
+
examples: ["My name is John Doe"]
|
|
37352
|
+
};
|
|
37353
|
+
|
|
37354
|
+
// ../../rules/core-pii/national-id.json
|
|
37355
|
+
var national_id_default = {
|
|
37356
|
+
specVersion: 1,
|
|
37357
|
+
id: "core-pii/national-id",
|
|
37358
|
+
name: "National ID number (multi-country)",
|
|
37359
|
+
category: "pii",
|
|
37360
|
+
severity: "high",
|
|
37361
|
+
matcher: {
|
|
37362
|
+
type: "regex",
|
|
37363
|
+
pattern: "\\b[A-Z]{2}\\d{6}[A-D]\\b|\\b[2-9]\\d{11}\\b|(?:national\\s*id|aadhaar|\\bSIN\\b).{0,10}?\\d{3}[\\s-]?\\d{3}[\\s-]?\\d{3}\\b",
|
|
37364
|
+
flags: "gi"
|
|
37365
|
+
},
|
|
37366
|
+
requiresNearby: {
|
|
37367
|
+
labels: [
|
|
37368
|
+
"national id",
|
|
37369
|
+
"national identity",
|
|
37370
|
+
"national insurance",
|
|
37371
|
+
"nino",
|
|
37372
|
+
"ni",
|
|
37373
|
+
"aadhaar",
|
|
37374
|
+
"sin",
|
|
37375
|
+
"identity number",
|
|
37376
|
+
"id number"
|
|
37377
|
+
],
|
|
37378
|
+
windowChars: 160
|
|
37379
|
+
},
|
|
37380
|
+
examples: ["Aadhaar: 234567890123", "NI: AB123456C", "SIN: 123-456-789"]
|
|
37381
|
+
};
|
|
37382
|
+
|
|
37383
|
+
// ../../rules/core-pii/passport-us.json
|
|
37384
|
+
var passport_us_default = {
|
|
37385
|
+
specVersion: 1,
|
|
37386
|
+
id: "core-pii/passport-us",
|
|
37387
|
+
name: "US passport number",
|
|
37388
|
+
category: "pii",
|
|
37389
|
+
severity: "high",
|
|
37390
|
+
matcher: {
|
|
37391
|
+
type: "regex",
|
|
37392
|
+
pattern: "\\b[A-Z]\\d{8}\\b",
|
|
37393
|
+
flags: "g"
|
|
37394
|
+
},
|
|
37395
|
+
requiresNearby: {
|
|
37396
|
+
labels: ["passport"],
|
|
37397
|
+
windowChars: 160
|
|
37398
|
+
},
|
|
37399
|
+
examples: ["Passport: A12345678"]
|
|
37400
|
+
};
|
|
37401
|
+
|
|
37402
|
+
// ../../rules/core-pii/phone-intl.json
|
|
37403
|
+
var phone_intl_default = {
|
|
37404
|
+
specVersion: 1,
|
|
37405
|
+
id: "core-pii/phone-intl",
|
|
37406
|
+
name: "International phone number",
|
|
37407
|
+
category: "pii",
|
|
37408
|
+
severity: "high",
|
|
37409
|
+
matcher: {
|
|
37410
|
+
type: "regex",
|
|
37411
|
+
pattern: "\\+(?=(?:\\D?\\d){8})\\d{1,3}(?:[-.\\s]\\d{1,14}){1,5}\\b",
|
|
37412
|
+
flags: "g"
|
|
37413
|
+
},
|
|
37414
|
+
examples: ["+44 20 7946 0958", "+86 138 0013 8000"]
|
|
37415
|
+
};
|
|
37416
|
+
|
|
37417
|
+
// ../../rules/core-pii/phone-us.json
|
|
37418
|
+
var phone_us_default = {
|
|
37419
|
+
specVersion: 1,
|
|
37420
|
+
id: "core-pii/phone-us",
|
|
37421
|
+
name: "US phone number",
|
|
37422
|
+
category: "pii",
|
|
37423
|
+
severity: "high",
|
|
37424
|
+
matcher: {
|
|
37425
|
+
type: "regex",
|
|
37426
|
+
pattern: "(?<!\\d)(?:\\+?1[-.\\s]?)?(?:\\([2-9]\\d{2}\\)[-.\\s]?|[2-9]\\d{2}[-.\\s])\\d{3}[-.\\s]\\d{4}(?!\\d)",
|
|
37427
|
+
flags: "g"
|
|
37428
|
+
},
|
|
37429
|
+
requiresNearby: {
|
|
37430
|
+
labels: ["phone", "call", "mobile", "cell", "tel", "telephone", "contact", "fax", "dial"],
|
|
37431
|
+
windowChars: 160
|
|
37432
|
+
},
|
|
37433
|
+
examples: ["(555) 123-4567", "+1-555-123-4567"]
|
|
37434
|
+
};
|
|
37435
|
+
|
|
37436
|
+
// ../../rules/core-pii/ssn.json
|
|
37437
|
+
var ssn_default = {
|
|
37438
|
+
specVersion: 1,
|
|
37439
|
+
id: "core-pii/ssn",
|
|
37440
|
+
name: "US Social Security Number",
|
|
37441
|
+
category: "pii",
|
|
37442
|
+
severity: "high",
|
|
37443
|
+
matcher: {
|
|
37444
|
+
type: "regex",
|
|
37445
|
+
pattern: "\\b(?!000|666|9\\d{2})\\d{3}[\\s\\-](?!00)\\d{2}[\\s\\-](?!0000)\\d{4}\\b",
|
|
37446
|
+
flags: "g"
|
|
37447
|
+
},
|
|
37448
|
+
examples: ["123-45-6789"]
|
|
37449
|
+
};
|
|
37450
|
+
|
|
37451
|
+
// ../../rules/core-pii/vin.json
|
|
37452
|
+
var vin_default = {
|
|
37453
|
+
specVersion: 1,
|
|
37454
|
+
id: "core-pii/vin",
|
|
37455
|
+
name: "Vehicle Identification Number",
|
|
37456
|
+
category: "pii",
|
|
37457
|
+
severity: "medium",
|
|
37458
|
+
matcher: {
|
|
37459
|
+
type: "regex",
|
|
37460
|
+
pattern: "\\b(?=[A-HJ-NPR-Z0-9]{0,16}[A-HJ-NPR-Z])(?=[A-HJ-NPR-Z0-9]{0,16}\\d)[A-HJ-NPR-Z0-9]{17}\\b",
|
|
37461
|
+
flags: "g"
|
|
37462
|
+
},
|
|
37463
|
+
examples: ["1HGCM82633A004352"]
|
|
37464
|
+
};
|
|
37465
|
+
|
|
37466
|
+
// ../../rules/core-pii/zip.json
|
|
37467
|
+
var zip_default = {
|
|
37468
|
+
specVersion: 1,
|
|
37469
|
+
id: "core-pii/zip",
|
|
37470
|
+
name: "US ZIP / ZIP+4 postal code",
|
|
37471
|
+
category: "pii",
|
|
37472
|
+
severity: "low",
|
|
37473
|
+
matcher: {
|
|
37474
|
+
type: "regex",
|
|
37475
|
+
pattern: "\\b\\d{5}(?:-\\d{4})?\\b",
|
|
37476
|
+
flags: "g"
|
|
37477
|
+
},
|
|
37478
|
+
requiresNearby: {
|
|
37479
|
+
ruleIds: ["core-pii/home-address"],
|
|
37480
|
+
labels: [
|
|
37481
|
+
"address",
|
|
37482
|
+
"street",
|
|
37483
|
+
"avenue",
|
|
37484
|
+
"boulevard",
|
|
37485
|
+
"mailing",
|
|
37486
|
+
"shipping",
|
|
37487
|
+
"billing",
|
|
37488
|
+
"suite",
|
|
37489
|
+
"p.o. box",
|
|
37490
|
+
"po box",
|
|
37491
|
+
"postal"
|
|
37492
|
+
],
|
|
37493
|
+
windowChars: 120
|
|
37494
|
+
},
|
|
37495
|
+
examples: ["Shipping address: 123 Main Street, Springfield, IL 94107-1234"]
|
|
37496
|
+
};
|
|
37497
|
+
|
|
37498
|
+
// ../../rules/secrets-infra/api-key-header.json
|
|
37499
|
+
var api_key_header_default = {
|
|
37500
|
+
specVersion: 1,
|
|
37501
|
+
id: "secrets-infra/api-key-header",
|
|
37502
|
+
name: "API key in a custom HTTP header",
|
|
37503
|
+
category: "secret",
|
|
37504
|
+
severity: "high",
|
|
37505
|
+
matcher: {
|
|
37506
|
+
type: "regex",
|
|
37507
|
+
pattern: `["']?\\bapi-?key\\b["']?\\s*:\\s*["']?([A-Za-z0-9+/_\\-.]{16,500})["']?`,
|
|
37508
|
+
flags: "gi",
|
|
37509
|
+
captureGroup: 1
|
|
37510
|
+
},
|
|
37511
|
+
postValidators: ["entropy"],
|
|
37512
|
+
examples: ["X-Api-Key: aBc123XyZ789kLmNoPqRsTuVwXyZ1234567890"]
|
|
37513
|
+
};
|
|
37514
|
+
|
|
37515
|
+
// ../../rules/secrets-infra/basic-auth-header.json
|
|
37516
|
+
var basic_auth_header_default = {
|
|
37517
|
+
specVersion: 1,
|
|
37518
|
+
id: "secrets-infra/basic-auth-header",
|
|
37519
|
+
name: "HTTP Basic auth Authorization header",
|
|
37520
|
+
category: "secret",
|
|
37521
|
+
severity: "critical",
|
|
37522
|
+
matcher: {
|
|
37523
|
+
type: "regex",
|
|
37524
|
+
pattern: "authorization\\s*:\\s*basic\\s+[A-Za-z0-9+/=]{16,}",
|
|
37525
|
+
flags: "gi"
|
|
37526
|
+
},
|
|
37527
|
+
examples: ["Authorization: Basic dXNlcjpwYXNzd29yZDEyMzQ="]
|
|
37528
|
+
};
|
|
37529
|
+
|
|
37530
|
+
// ../../rules/secrets-infra/basic-auth-url.json
|
|
37531
|
+
var basic_auth_url_default = {
|
|
37532
|
+
specVersion: 1,
|
|
37533
|
+
id: "secrets-infra/basic-auth-url",
|
|
37534
|
+
name: "URL with embedded basic auth credentials",
|
|
37535
|
+
category: "secret",
|
|
37536
|
+
severity: "critical",
|
|
37537
|
+
matcher: {
|
|
37538
|
+
type: "regex",
|
|
37539
|
+
pattern: "https?://[A-Za-z0-9_%\\-]+:[A-Za-z0-9_%\\-]+@[A-Za-z0-9.\\-]+",
|
|
37540
|
+
flags: "g"
|
|
37541
|
+
},
|
|
37542
|
+
examples: ["https://user:password@example.com/path"]
|
|
37543
|
+
};
|
|
37544
|
+
|
|
37545
|
+
// ../../rules/secrets-infra/bearer-token.json
|
|
37546
|
+
var bearer_token_default = {
|
|
37547
|
+
specVersion: 1,
|
|
37548
|
+
id: "secrets-infra/bearer-token",
|
|
37549
|
+
name: "Generic Authorization Bearer token",
|
|
37550
|
+
category: "secret",
|
|
37551
|
+
severity: "high",
|
|
37552
|
+
matcher: {
|
|
37553
|
+
type: "regex",
|
|
37554
|
+
pattern: "\\b(?:Bearer|bearer)\\s+([A-Za-z0-9_\\-.]{20,500})",
|
|
37555
|
+
flags: "g",
|
|
37556
|
+
captureGroup: 1
|
|
37557
|
+
},
|
|
37558
|
+
postValidators: ["entropy"],
|
|
37559
|
+
examples: [
|
|
37560
|
+
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
|
|
37561
|
+
]
|
|
37562
|
+
};
|
|
37563
|
+
|
|
37564
|
+
// ../../rules/secrets-infra/db-connection-string.json
|
|
37565
|
+
var db_connection_string_default = {
|
|
37566
|
+
specVersion: 1,
|
|
37567
|
+
id: "secrets-infra/db-connection-string",
|
|
37568
|
+
name: "Database connection string with credentials",
|
|
37569
|
+
category: "secret",
|
|
37570
|
+
severity: "critical",
|
|
37571
|
+
matcher: {
|
|
37572
|
+
type: "regex",
|
|
37573
|
+
pattern: "\\b(?:postgres(?:ql)?|mysql|mongodb(?:\\+srv)?|redis|rediss)://[A-Za-z0-9_%\\-]+:[A-Za-z0-9_%\\-]+@[A-Za-z0-9.\\-]+(?:\\:\\d+)?",
|
|
37574
|
+
flags: "g"
|
|
37575
|
+
},
|
|
37576
|
+
examples: ["postgresql://user:password@localhost:5432/mydb"]
|
|
37577
|
+
};
|
|
37578
|
+
|
|
37579
|
+
// ../../rules/secrets-infra/docker-config-auth.json
|
|
37580
|
+
var docker_config_auth_default = {
|
|
37581
|
+
specVersion: 1,
|
|
37582
|
+
id: "secrets-infra/docker-config-auth",
|
|
37583
|
+
name: "Docker config.json auth (base64-encoded)",
|
|
37584
|
+
category: "secret",
|
|
37585
|
+
severity: "critical",
|
|
37586
|
+
matcher: {
|
|
37587
|
+
type: "regex",
|
|
37588
|
+
pattern: '"auth"\\s*:\\s*"[A-Za-z0-9+/]{12,}={0,2}"',
|
|
37589
|
+
flags: "g"
|
|
37590
|
+
},
|
|
37591
|
+
examples: ['"auths": {"https://index.docker.io/v1/": {"auth": "dXNlcjpwYXNzd29yZA=="}}']
|
|
37592
|
+
};
|
|
37593
|
+
|
|
37594
|
+
// ../../rules/secrets-infra/env-key-value.json
|
|
37595
|
+
var env_key_value_default = {
|
|
37596
|
+
specVersion: 1,
|
|
37597
|
+
id: "secrets-infra/env-key-value",
|
|
37598
|
+
name: "Environment variable assignment with sensitive key",
|
|
37599
|
+
category: "secret",
|
|
37600
|
+
severity: "high",
|
|
37601
|
+
matcher: {
|
|
37602
|
+
type: "regex",
|
|
37603
|
+
pattern: `\\b[A-Za-z0-9_]*(?:API_KEY|API_SECRET|SECRET_KEY|SECRET|TOKEN|PASSWORD|PASS|CREDENTIALS|PRIVATE_KEY|ENCRYPTION_KEY|SIGNING_KEY)\\s*=\\s*["']?([^\\s"']{4,})`,
|
|
37604
|
+
flags: "gi",
|
|
37605
|
+
captureGroup: 1
|
|
37606
|
+
},
|
|
37607
|
+
examples: ["API_KEY=aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890"]
|
|
37608
|
+
};
|
|
37609
|
+
|
|
37610
|
+
// ../../rules/secrets-infra/generic-high-entropy-secret.json
|
|
37611
|
+
var generic_high_entropy_secret_default = {
|
|
37612
|
+
specVersion: 1,
|
|
37613
|
+
id: "secrets-infra/generic-high-entropy-secret",
|
|
37614
|
+
name: "Generic high-entropy secret assigned to a credential-shaped field",
|
|
37615
|
+
category: "secret",
|
|
37616
|
+
severity: "high",
|
|
37617
|
+
matcher: {
|
|
37618
|
+
type: "regex",
|
|
37619
|
+
pattern: `(?<![A-Za-z0-9_-])[A-Za-z0-9_]{0,34}(?:(?:secret|token|(?<!no)passw(?:or)?d|credentials?|(?<!api[_-]?)key)(?:["']?\\s*:|\\s+=)|(?:(?<!no)passwd|credential|(?<!api[_-]?)(?<!secret_)(?<!private_)(?<!encryption_)(?<!signing_)key)=)\\s*["']?((?!eyJ)[A-Za-z0-9+/_\\-]{20,200})`,
|
|
37620
|
+
flags: "gi",
|
|
37621
|
+
captureGroup: 1
|
|
37622
|
+
},
|
|
37623
|
+
postValidators: ["entropy"],
|
|
37624
|
+
examples: [
|
|
37625
|
+
'authToken: "aBc123XyZ789kLmNoPqRsTuVwXyZ1234567890"',
|
|
37626
|
+
"MASTER_KEY=aBc123XyZ789kLmNoPqRsTuVwXyZ1234567890"
|
|
37627
|
+
]
|
|
37628
|
+
};
|
|
37629
|
+
|
|
37630
|
+
// ../../rules/secrets-infra/jwt-token.json
|
|
37631
|
+
var jwt_token_default = {
|
|
37632
|
+
specVersion: 1,
|
|
37633
|
+
id: "secrets-infra/jwt-token",
|
|
37634
|
+
name: "JSON Web Token (JWT)",
|
|
37635
|
+
category: "secret",
|
|
37636
|
+
severity: "high",
|
|
37637
|
+
matcher: {
|
|
37638
|
+
type: "regex",
|
|
37639
|
+
pattern: "\\beyJ[A-Za-z0-9_\\-+/]+\\.[A-Za-z0-9_\\-+/]+\\.[A-Za-z0-9_\\-+/]+\\b",
|
|
37640
|
+
flags: "g"
|
|
37641
|
+
},
|
|
37642
|
+
postValidators: ["entropy"],
|
|
37643
|
+
examples: [
|
|
37644
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
|
|
37645
|
+
]
|
|
37646
|
+
};
|
|
37647
|
+
|
|
37648
|
+
// ../../rules/secrets-infra/kubeconfig-token.json
|
|
37649
|
+
var kubeconfig_token_default = {
|
|
37650
|
+
specVersion: 1,
|
|
37651
|
+
id: "secrets-infra/kubeconfig-token",
|
|
37652
|
+
name: "Kubernetes kubeconfig embedded token",
|
|
37653
|
+
category: "secret",
|
|
37654
|
+
severity: "critical",
|
|
37655
|
+
matcher: {
|
|
37656
|
+
type: "regex",
|
|
37657
|
+
pattern: "\\b(?:client-(?:certificate|key)-data|token):\\s+([A-Za-z0-9+/=_.-]{20,})",
|
|
37658
|
+
flags: "g",
|
|
37659
|
+
captureGroup: 1
|
|
37660
|
+
},
|
|
37661
|
+
examples: ["token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9..."]
|
|
37662
|
+
};
|
|
37663
|
+
|
|
37664
|
+
// ../../rules/secrets-infra/password-field.json
|
|
37665
|
+
var password_field_default = {
|
|
37666
|
+
specVersion: 1,
|
|
37667
|
+
id: "secrets-infra/password-field",
|
|
37668
|
+
name: "JSON/YAML field with password value",
|
|
37669
|
+
category: "secret",
|
|
37670
|
+
severity: "high",
|
|
37671
|
+
matcher: {
|
|
37672
|
+
type: "regex",
|
|
37673
|
+
pattern: `["']?\\b(?:password|passwd|pwd|pass|secret|token|api[_-]?key|apikey)\\b["']?\\s*:\\s*["'](?!(?:fail|pass|true|false|null|none|string|required)["'])([^"'\\n]{4,})["']`,
|
|
37674
|
+
flags: "gi",
|
|
37675
|
+
captureGroup: 1
|
|
37676
|
+
},
|
|
37677
|
+
examples: ['"password": "supersecret123"']
|
|
37678
|
+
};
|
|
37679
|
+
|
|
37680
|
+
// ../../rules/secrets-infra/pgp-private-key.json
|
|
37681
|
+
var pgp_private_key_default = {
|
|
37682
|
+
specVersion: 1,
|
|
37683
|
+
id: "secrets-infra/pgp-private-key",
|
|
37684
|
+
name: "PGP private key block",
|
|
37685
|
+
category: "secret",
|
|
37686
|
+
severity: "critical",
|
|
37687
|
+
matcher: {
|
|
37688
|
+
type: "regex",
|
|
37689
|
+
pattern: "-----BEGIN PGP PRIVATE KEY BLOCK-----",
|
|
37690
|
+
flags: "g"
|
|
37691
|
+
},
|
|
37692
|
+
examples: [
|
|
37693
|
+
"-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: Keybase Go 1.0.0\n...\n-----END PGP PRIVATE KEY BLOCK-----"
|
|
37694
|
+
]
|
|
37695
|
+
};
|
|
37696
|
+
|
|
37697
|
+
// ../../rules/secrets-infra/ssh-private-key.json
|
|
37698
|
+
var ssh_private_key_default = {
|
|
37699
|
+
specVersion: 1,
|
|
37700
|
+
id: "secrets-infra/ssh-private-key",
|
|
37701
|
+
name: "SSH private key",
|
|
37702
|
+
category: "secret",
|
|
37703
|
+
severity: "critical",
|
|
37704
|
+
matcher: {
|
|
37705
|
+
type: "regex",
|
|
37706
|
+
pattern: "-----BEGIN ((?:RSA |DSA |EC |OPENSSH |SSH2 |ENCRYPTED )?)PRIVATE KEY-----(?:(?:[A-Za-z0-9+/=\\s\\\\:,]|-(?!-)){0,8000}?-----END \\1PRIVATE KEY-----)?",
|
|
37707
|
+
flags: "g"
|
|
37708
|
+
},
|
|
37709
|
+
examples: [
|
|
37710
|
+
"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA...\n-----END RSA PRIVATE KEY-----"
|
|
37711
|
+
]
|
|
37712
|
+
};
|
|
37713
|
+
|
|
37714
|
+
// ../../rules/secrets/anthropic-api-key.json
|
|
37715
|
+
var anthropic_api_key_default = {
|
|
37716
|
+
specVersion: 1,
|
|
37717
|
+
id: "secrets/anthropic-api-key",
|
|
37718
|
+
name: "Anthropic API key",
|
|
37719
|
+
category: "secret",
|
|
37720
|
+
severity: "critical",
|
|
37721
|
+
matcher: {
|
|
37722
|
+
type: "regex",
|
|
37723
|
+
pattern: "\\bsk-ant-[A-Za-z0-9_-]{40,}",
|
|
37724
|
+
flags: "g"
|
|
37725
|
+
},
|
|
37726
|
+
postValidators: ["entropy"],
|
|
37727
|
+
examples: ["sk-ant-AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz"]
|
|
37728
|
+
};
|
|
36641
37729
|
|
|
36642
|
-
// ../../
|
|
36643
|
-
|
|
37730
|
+
// ../../rules/secrets/aws-access-key.json
|
|
37731
|
+
var aws_access_key_default = {
|
|
37732
|
+
specVersion: 1,
|
|
37733
|
+
id: "secrets/aws-access-key",
|
|
37734
|
+
name: "AWS Access Key ID",
|
|
37735
|
+
category: "secret",
|
|
37736
|
+
severity: "critical",
|
|
37737
|
+
matcher: {
|
|
37738
|
+
type: "regex",
|
|
37739
|
+
pattern: "\\b(AKIA|ASIA|AROA|AIDA|ANPA|ANVA|APKA)[A-Z0-9]{16}\\b",
|
|
37740
|
+
flags: "g"
|
|
37741
|
+
},
|
|
37742
|
+
postValidators: ["entropy"],
|
|
37743
|
+
examples: ["AKIAIOSFODNN7EXAMPLE"]
|
|
37744
|
+
};
|
|
36644
37745
|
|
|
36645
|
-
// ../../
|
|
36646
|
-
|
|
36647
|
-
|
|
37746
|
+
// ../../rules/secrets/aws-secret-key.json
|
|
37747
|
+
var aws_secret_key_default = {
|
|
37748
|
+
specVersion: 1,
|
|
37749
|
+
id: "secrets/aws-secret-key",
|
|
37750
|
+
name: "AWS Secret Access Key",
|
|
37751
|
+
category: "secret",
|
|
37752
|
+
severity: "critical",
|
|
37753
|
+
matcher: {
|
|
37754
|
+
type: "regex",
|
|
37755
|
+
pattern: `aws[_.-]?secret[_.-]?(?:access[_.-]?)?key["'\\s:=]{1,5}([A-Za-z0-9/+]{40})`,
|
|
37756
|
+
flags: "gi",
|
|
37757
|
+
captureGroup: 1
|
|
37758
|
+
},
|
|
37759
|
+
postValidators: ["entropy"],
|
|
37760
|
+
examples: ["AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"]
|
|
37761
|
+
};
|
|
36648
37762
|
|
|
36649
|
-
// ../../
|
|
36650
|
-
|
|
36651
|
-
|
|
37763
|
+
// ../../rules/secrets/azure-connection-string.json
|
|
37764
|
+
var azure_connection_string_default = {
|
|
37765
|
+
specVersion: 1,
|
|
37766
|
+
id: "secrets/azure-connection-string",
|
|
37767
|
+
name: "Azure connection string",
|
|
37768
|
+
category: "secret",
|
|
37769
|
+
severity: "critical",
|
|
37770
|
+
matcher: {
|
|
37771
|
+
type: "regex",
|
|
37772
|
+
pattern: "(?<![A-Za-z0-9])(?:DefaultEndpointsProtocol|AccountEndpoint|AccountName|AccountKey|SharedAccessSignature|SharedAccessKeyName|SharedAccessKey|EndpointSuffix|BlobEndpoint|QueueEndpoint|TableEndpoint|FileEndpoint|HostName|Endpoint)=(?![{<($])[^\\x3B\\r\\n]{1,400}\\x3B(?:[A-Za-z][A-Za-z0-9_]{0,39}=[^\\x3B\\r\\n]{1,400}\\x3B){0,10}(?:DefaultEndpointsProtocol|AccountEndpoint|AccountName|AccountKey|SharedAccessSignature|SharedAccessKeyName|SharedAccessKey|EndpointSuffix|BlobEndpoint|QueueEndpoint|TableEndpoint|FileEndpoint|HostName|Endpoint)=(?![{<($])[^\\x3B\\r\\n]{1,400}(?:\\x3B[A-Za-z][A-Za-z0-9_]{0,39}=[^\\x3B\\r\\n]{1,400}){0,10}",
|
|
37773
|
+
flags: "g"
|
|
37774
|
+
},
|
|
37775
|
+
examples: ["AccountName=mystorage;AccountKey=abc123=="]
|
|
37776
|
+
};
|
|
36652
37777
|
|
|
36653
|
-
// ../../
|
|
36654
|
-
|
|
37778
|
+
// ../../rules/secrets/cloudflare-api-key.json
|
|
37779
|
+
var cloudflare_api_key_default = {
|
|
37780
|
+
specVersion: 1,
|
|
37781
|
+
id: "secrets/cloudflare-api-key",
|
|
37782
|
+
name: "Cloudflare API token",
|
|
37783
|
+
category: "secret",
|
|
37784
|
+
severity: "critical",
|
|
37785
|
+
matcher: {
|
|
37786
|
+
type: "regex",
|
|
37787
|
+
pattern: `cloudflare.{0,40}?(?<![?&][A-Za-z0-9_]{1,20})(?<!sha(?:1|256|384|512))["'\\s:=]([A-Za-z0-9_-]{40})`,
|
|
37788
|
+
flags: "gi",
|
|
37789
|
+
captureGroup: 1
|
|
37790
|
+
},
|
|
37791
|
+
postValidators: ["entropy"],
|
|
37792
|
+
examples: ["CLOUDFLARE_API_TOKEN=kQ9fL2mP7xR4tY6wB1nC8vD3jH5sZ0aG2eU4iO7p"]
|
|
37793
|
+
};
|
|
37794
|
+
|
|
37795
|
+
// ../../rules/secrets/datadog-key.json
|
|
37796
|
+
var datadog_key_default = {
|
|
37797
|
+
specVersion: 1,
|
|
37798
|
+
id: "secrets/datadog-key",
|
|
37799
|
+
name: "Datadog API/Application key",
|
|
37800
|
+
category: "secret",
|
|
37801
|
+
severity: "critical",
|
|
37802
|
+
matcher: {
|
|
37803
|
+
type: "regex",
|
|
37804
|
+
pattern: "\\b(?:DD_API_KEY|DD_APP_KEY|DATADOG_API_KEY|DATADOG_APP_KEY)[\\s:=]+([A-Za-z0-9]{32,40})\\b",
|
|
37805
|
+
flags: "gi",
|
|
37806
|
+
captureGroup: 1
|
|
37807
|
+
},
|
|
37808
|
+
postValidators: ["entropy"],
|
|
37809
|
+
examples: ["DD_API_KEY=a3F5g8H1j4K7m2N0p9Q6r1S4t7U0v3W8"]
|
|
37810
|
+
};
|
|
37811
|
+
|
|
37812
|
+
// ../../rules/secrets/digitalocean-token.json
|
|
37813
|
+
var digitalocean_token_default = {
|
|
37814
|
+
specVersion: 1,
|
|
37815
|
+
id: "secrets/digitalocean-token",
|
|
37816
|
+
name: "DigitalOcean Personal Access Token",
|
|
37817
|
+
category: "secret",
|
|
37818
|
+
severity: "critical",
|
|
37819
|
+
matcher: {
|
|
37820
|
+
type: "regex",
|
|
37821
|
+
pattern: "\\bdop_v1_[A-Za-z0-9]{64}\\b",
|
|
37822
|
+
flags: "g"
|
|
37823
|
+
},
|
|
37824
|
+
examples: ["dop_v1_1234567890123456789012345678901234567890123456789012345678901234"]
|
|
37825
|
+
};
|
|
37826
|
+
|
|
37827
|
+
// ../../rules/secrets/discord-token.json
|
|
37828
|
+
var discord_token_default = {
|
|
37829
|
+
specVersion: 1,
|
|
37830
|
+
id: "secrets/discord-token",
|
|
37831
|
+
name: "Discord bot token",
|
|
37832
|
+
category: "secret",
|
|
37833
|
+
severity: "critical",
|
|
37834
|
+
matcher: {
|
|
37835
|
+
type: "regex",
|
|
37836
|
+
pattern: "\\b[A-Za-z0-9]{24}\\.[A-Za-z0-9]{6}\\.[A-Za-z0-9_\\-]{27}\\b",
|
|
37837
|
+
flags: "g"
|
|
37838
|
+
},
|
|
37839
|
+
postValidators: ["entropy"],
|
|
37840
|
+
examples: ["AbCdEfGhIjKlMnOpQrStUvWx.YzAbCd.ABCdEfGhIjKlMnOpQrStUvWxYzAbCdEf"]
|
|
37841
|
+
};
|
|
37842
|
+
|
|
37843
|
+
// ../../rules/secrets/gcp-service-account-key.json
|
|
37844
|
+
var gcp_service_account_key_default = {
|
|
37845
|
+
specVersion: 1,
|
|
37846
|
+
id: "secrets/gcp-service-account-key",
|
|
37847
|
+
name: "GCP service account key file",
|
|
37848
|
+
category: "secret",
|
|
37849
|
+
severity: "critical",
|
|
37850
|
+
matcher: {
|
|
37851
|
+
type: "regex",
|
|
37852
|
+
pattern: '"private_key_id"\\s*:\\s*"([a-f0-9]{40})"',
|
|
37853
|
+
flags: "g",
|
|
37854
|
+
captureGroup: 1
|
|
37855
|
+
},
|
|
37856
|
+
requiresNearby: {
|
|
37857
|
+
labels: ["service_account", "client_email"],
|
|
37858
|
+
windowChars: 400
|
|
37859
|
+
},
|
|
37860
|
+
examples: [
|
|
37861
|
+
'{"type": "service_account", "project_id": "sample-project", "private_key_id": "0a1b2c3d0a1b2c3d0a1b2c3d0a1b2c3d0a1b2c3d"}'
|
|
37862
|
+
]
|
|
37863
|
+
};
|
|
37864
|
+
|
|
37865
|
+
// ../../rules/secrets/github-pat.json
|
|
37866
|
+
var github_pat_default = {
|
|
37867
|
+
specVersion: 1,
|
|
37868
|
+
id: "secrets/github-pat",
|
|
37869
|
+
name: "GitHub Personal Access Token (classic and fine-grained)",
|
|
37870
|
+
category: "secret",
|
|
37871
|
+
severity: "critical",
|
|
37872
|
+
matcher: {
|
|
37873
|
+
type: "regex",
|
|
37874
|
+
pattern: "\\b(?:gh[psou]_[A-Za-z0-9]{36}|github_pat_[0-9A-Za-z_]{82})\\b",
|
|
37875
|
+
flags: "g"
|
|
37876
|
+
},
|
|
37877
|
+
examples: [
|
|
37878
|
+
"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",
|
|
37879
|
+
"ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890"
|
|
37880
|
+
]
|
|
37881
|
+
};
|
|
37882
|
+
|
|
37883
|
+
// ../../rules/secrets/gitlab-token.json
|
|
37884
|
+
var gitlab_token_default = {
|
|
37885
|
+
specVersion: 1,
|
|
37886
|
+
id: "secrets/gitlab-token",
|
|
37887
|
+
name: "GitLab Personal/Project Access Token",
|
|
37888
|
+
category: "secret",
|
|
37889
|
+
severity: "critical",
|
|
37890
|
+
matcher: {
|
|
37891
|
+
type: "regex",
|
|
37892
|
+
pattern: "\\bglpat-[A-Za-z0-9\\-_]{20,40}\\b",
|
|
37893
|
+
flags: "g"
|
|
37894
|
+
},
|
|
37895
|
+
postValidators: ["entropy"],
|
|
37896
|
+
examples: ["glpat-ABCdEfGhIjKlMnOpQrStUvWxYz1234567890"]
|
|
37897
|
+
};
|
|
37898
|
+
|
|
37899
|
+
// ../../rules/secrets/heroku-api-key.json
|
|
37900
|
+
var heroku_api_key_default = {
|
|
37901
|
+
specVersion: 1,
|
|
37902
|
+
id: "secrets/heroku-api-key",
|
|
37903
|
+
name: "Heroku API key",
|
|
37904
|
+
category: "secret",
|
|
37905
|
+
severity: "critical",
|
|
37906
|
+
matcher: {
|
|
37907
|
+
type: "regex",
|
|
37908
|
+
pattern: "heroku.{0,40}?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})",
|
|
37909
|
+
flags: "gi",
|
|
37910
|
+
captureGroup: 1
|
|
37911
|
+
},
|
|
37912
|
+
examples: ["HEROKU_API_KEY=3f8a1c2e-9b4d-4e6f-a1b2-c3d4e5f6a7b8"]
|
|
37913
|
+
};
|
|
37914
|
+
|
|
37915
|
+
// ../../rules/secrets/npm-token.json
|
|
37916
|
+
var npm_token_default = {
|
|
37917
|
+
specVersion: 1,
|
|
37918
|
+
id: "secrets/npm-token",
|
|
37919
|
+
name: "npm access token",
|
|
37920
|
+
category: "secret",
|
|
37921
|
+
severity: "critical",
|
|
37922
|
+
matcher: {
|
|
37923
|
+
type: "regex",
|
|
37924
|
+
pattern: "\\bnpm_[A-Za-z0-9]{36,60}\\b",
|
|
37925
|
+
flags: "g"
|
|
37926
|
+
},
|
|
37927
|
+
postValidators: ["entropy"],
|
|
37928
|
+
examples: ["npm_AbCdEfGhIjKlMnOpQrStUvWxYz1234567890AbCdEfGhIjKlMnO"]
|
|
37929
|
+
};
|
|
37930
|
+
|
|
37931
|
+
// ../../rules/secrets/openai-api-key.json
|
|
37932
|
+
var openai_api_key_default = {
|
|
37933
|
+
specVersion: 1,
|
|
37934
|
+
id: "secrets/openai-api-key",
|
|
37935
|
+
name: "OpenAI API key",
|
|
37936
|
+
category: "secret",
|
|
37937
|
+
severity: "critical",
|
|
37938
|
+
matcher: {
|
|
37939
|
+
type: "regex",
|
|
37940
|
+
pattern: "\\bsk-proj-[A-Za-z0-9]{20,60}\\b|\\bsk-[A-Za-z0-9]{40,55}\\b",
|
|
37941
|
+
flags: "g"
|
|
37942
|
+
},
|
|
37943
|
+
postValidators: ["entropy"],
|
|
37944
|
+
examples: ["sk-proj-AbCdEfGhIjKlMnOpQrStUvWxYz1234567890AbCdEfGhIjK"]
|
|
37945
|
+
};
|
|
37946
|
+
|
|
37947
|
+
// ../../rules/secrets/pulumi-access-token.json
|
|
37948
|
+
var pulumi_access_token_default = {
|
|
37949
|
+
specVersion: 1,
|
|
37950
|
+
id: "secrets/pulumi-access-token",
|
|
37951
|
+
name: "Pulumi access token",
|
|
37952
|
+
category: "secret",
|
|
37953
|
+
severity: "critical",
|
|
37954
|
+
matcher: {
|
|
37955
|
+
type: "regex",
|
|
37956
|
+
pattern: "\\bpul-[A-Za-z0-9]{20,60}\\b",
|
|
37957
|
+
flags: "g"
|
|
37958
|
+
},
|
|
37959
|
+
postValidators: ["entropy"],
|
|
37960
|
+
examples: ["pul-ABCdEfGhIjKlMnOpQrStUvWxYz1234567890"]
|
|
37961
|
+
};
|
|
37962
|
+
|
|
37963
|
+
// ../../rules/secrets/sendgrid-key.json
|
|
37964
|
+
var sendgrid_key_default = {
|
|
37965
|
+
specVersion: 1,
|
|
37966
|
+
id: "secrets/sendgrid-key",
|
|
37967
|
+
name: "SendGrid API key",
|
|
37968
|
+
category: "secret",
|
|
37969
|
+
severity: "critical",
|
|
37970
|
+
matcher: {
|
|
37971
|
+
type: "regex",
|
|
37972
|
+
pattern: "\\bSG\\.[A-Za-z0-9_\\-]{20,60}\\b",
|
|
37973
|
+
flags: "g"
|
|
37974
|
+
},
|
|
37975
|
+
postValidators: ["entropy"],
|
|
37976
|
+
examples: ["SG.AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz"]
|
|
37977
|
+
};
|
|
37978
|
+
|
|
37979
|
+
// ../../rules/secrets/slack-token.json
|
|
37980
|
+
var slack_token_default = {
|
|
37981
|
+
specVersion: 1,
|
|
37982
|
+
id: "secrets/slack-token",
|
|
37983
|
+
name: "Slack API token",
|
|
37984
|
+
category: "secret",
|
|
37985
|
+
severity: "critical",
|
|
37986
|
+
matcher: {
|
|
37987
|
+
type: "regex",
|
|
37988
|
+
pattern: "\\b(?:xox[baprs]-[A-Za-z0-9]{10,60}|xapp-[A-Za-z0-9-]{10,60})\\b",
|
|
37989
|
+
flags: "g"
|
|
37990
|
+
},
|
|
37991
|
+
examples: ["xoxb-123456789012-123456789012-ABCdEfGhIjKlMnOpQrStUvWx"]
|
|
37992
|
+
};
|
|
37993
|
+
|
|
37994
|
+
// ../../rules/secrets/stripe-live-key.json
|
|
37995
|
+
var stripe_live_key_default = {
|
|
37996
|
+
specVersion: 1,
|
|
37997
|
+
id: "secrets/stripe-live-key",
|
|
37998
|
+
name: "Stripe live API key",
|
|
37999
|
+
category: "secret",
|
|
38000
|
+
severity: "critical",
|
|
38001
|
+
matcher: {
|
|
38002
|
+
type: "regex",
|
|
38003
|
+
pattern: "\\b(?:sk|pk|rk)_live_[A-Za-z0-9]{24,40}\\b",
|
|
38004
|
+
flags: "g"
|
|
38005
|
+
},
|
|
38006
|
+
postValidators: ["entropy"],
|
|
38007
|
+
examples: ["sk_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ"]
|
|
38008
|
+
};
|
|
38009
|
+
|
|
38010
|
+
// ../../rules/secrets/tailscale-key.json
|
|
38011
|
+
var tailscale_key_default = {
|
|
38012
|
+
specVersion: 1,
|
|
38013
|
+
id: "secrets/tailscale-key",
|
|
38014
|
+
name: "Tailscale auth/API/client key",
|
|
38015
|
+
category: "secret",
|
|
38016
|
+
severity: "critical",
|
|
38017
|
+
matcher: {
|
|
38018
|
+
type: "regex",
|
|
38019
|
+
pattern: "\\btskey-(?:auth|api|client)-(?![Xx]+-)[A-Za-z0-9]{8,32}-[A-Za-z0-9]{16,64}\\b",
|
|
38020
|
+
flags: "g"
|
|
38021
|
+
},
|
|
38022
|
+
examples: [
|
|
38023
|
+
"sudo tailscale up --auth-key=tskey-auth-kAb3Xk9QzCNTRL-Ab3Xk9QzAb3Xk9QzAb3Xk9QzAb3Xk9Qz",
|
|
38024
|
+
"TS_API_KEY=tskey-api-kEXAMPLE1CNTRL-EXAMPLEEXAMPLEEXAMPLEEXAMPLE12"
|
|
38025
|
+
]
|
|
38026
|
+
};
|
|
38027
|
+
|
|
38028
|
+
// ../../rules/secrets/terraform-cloud-token.json
|
|
38029
|
+
var terraform_cloud_token_default = {
|
|
38030
|
+
specVersion: 1,
|
|
38031
|
+
id: "secrets/terraform-cloud-token",
|
|
38032
|
+
name: "Terraform Cloud / TFE user token",
|
|
38033
|
+
category: "secret",
|
|
38034
|
+
severity: "critical",
|
|
38035
|
+
matcher: {
|
|
38036
|
+
type: "regex",
|
|
38037
|
+
pattern: "\\b[A-Za-z0-9]{14}\\.atlasv1\\.[A-Za-z0-9_\\-]{60,80}\\b",
|
|
38038
|
+
flags: "g"
|
|
38039
|
+
},
|
|
38040
|
+
postValidators: ["entropy"],
|
|
38041
|
+
examples: [
|
|
38042
|
+
"AbCdEfGhIjKlMnOp.atlasv1.XyZ1234567890123456789012345678901234567890123456789012345678901234567890"
|
|
38043
|
+
]
|
|
38044
|
+
};
|
|
38045
|
+
|
|
38046
|
+
// ../../rules/secrets/twilio-key.json
|
|
38047
|
+
var twilio_key_default = {
|
|
38048
|
+
specVersion: 1,
|
|
38049
|
+
id: "secrets/twilio-key",
|
|
38050
|
+
name: "Twilio Account SID",
|
|
38051
|
+
category: "secret",
|
|
38052
|
+
severity: "critical",
|
|
38053
|
+
matcher: {
|
|
38054
|
+
type: "regex",
|
|
38055
|
+
pattern: "\\bAC[A-Za-z0-9]{32}\\b",
|
|
38056
|
+
flags: "g"
|
|
38057
|
+
},
|
|
38058
|
+
examples: ["AC12345678901234567890123456789012"]
|
|
38059
|
+
};
|
|
38060
|
+
|
|
38061
|
+
// ../../rules/secrets/vault-token.json
|
|
38062
|
+
var vault_token_default = {
|
|
38063
|
+
specVersion: 1,
|
|
38064
|
+
id: "secrets/vault-token",
|
|
38065
|
+
name: "HashiCorp Vault token",
|
|
38066
|
+
category: "secret",
|
|
38067
|
+
severity: "critical",
|
|
38068
|
+
matcher: {
|
|
38069
|
+
type: "regex",
|
|
38070
|
+
pattern: "\\b(?:hvs\\.[A-Za-z0-9\\-_]{20,200}|s\\.(?=[A-Za-z0-9_-]{0,49}\\d)(?=[A-Za-z0-9_-]{0,49}[A-Z])[A-Za-z0-9\\-_]{20,50})\\b",
|
|
38071
|
+
flags: "g"
|
|
38072
|
+
},
|
|
38073
|
+
postValidators: ["entropy"],
|
|
38074
|
+
examples: ["hvs.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890"]
|
|
38075
|
+
};
|
|
38076
|
+
|
|
38077
|
+
// ../../packages/plugin-sdk/src/bundled-packs.generated.ts
|
|
38078
|
+
var BUNDLED_PACKS = [
|
|
38079
|
+
{
|
|
38080
|
+
packId: "code-flaws",
|
|
38081
|
+
name: "Code Security Flaws",
|
|
38082
|
+
version: "0.1.0",
|
|
38083
|
+
rawRules: [
|
|
38084
|
+
sql_inject_concat_default,
|
|
38085
|
+
sql_inject_concat_dot_default,
|
|
38086
|
+
sql_inject_format_default,
|
|
38087
|
+
sql_inject_interp_default,
|
|
38088
|
+
cmd_inject_shell_default,
|
|
38089
|
+
cmd_inject_exec_default,
|
|
38090
|
+
cmd_inject_node_exec_default,
|
|
38091
|
+
xss_inner_html_default,
|
|
38092
|
+
xss_dangerously_set_default,
|
|
38093
|
+
xss_unescaped_render_default,
|
|
38094
|
+
deser_pickle_default,
|
|
38095
|
+
deser_yaml_unsafe_default,
|
|
38096
|
+
deser_java_ois_default,
|
|
38097
|
+
hardcoded_password_default,
|
|
38098
|
+
hardcoded_secret_key_default,
|
|
38099
|
+
dev_debug_enabled_default,
|
|
38100
|
+
dev_placeholder_secret_default,
|
|
38101
|
+
dev_wildcard_cors_default,
|
|
38102
|
+
auth_ssl_verify_false_default,
|
|
38103
|
+
auth_jwt_no_verify_default,
|
|
38104
|
+
path_traversal_open_default,
|
|
38105
|
+
path_traversal_join_default,
|
|
38106
|
+
crypto_weak_hash_md5_default,
|
|
38107
|
+
crypto_weak_hash_sha1_default,
|
|
38108
|
+
crypto_insecure_random_default,
|
|
38109
|
+
prototype_pollution_merge_default,
|
|
38110
|
+
eval_dynamic_exec_default,
|
|
38111
|
+
ssrf_user_url_default,
|
|
38112
|
+
regex_redos_backtrack_default
|
|
38113
|
+
]
|
|
38114
|
+
},
|
|
38115
|
+
{
|
|
38116
|
+
packId: "command-risk",
|
|
38117
|
+
name: "Risky agent commands",
|
|
38118
|
+
version: "0.1.0",
|
|
38119
|
+
defaultPolicy: "warn",
|
|
38120
|
+
rawRules: [
|
|
38121
|
+
pkill_broad_default,
|
|
38122
|
+
rm_rf_home_or_shared_default,
|
|
38123
|
+
git_force_push_default,
|
|
38124
|
+
git_reset_hard_default,
|
|
38125
|
+
curl_pipe_shell_default,
|
|
38126
|
+
credential_file_read_default
|
|
38127
|
+
]
|
|
38128
|
+
},
|
|
38129
|
+
{
|
|
38130
|
+
packId: "core-code-context",
|
|
38131
|
+
name: "Code Context",
|
|
38132
|
+
version: "0.2.1",
|
|
38133
|
+
rawRules: [
|
|
38134
|
+
internal_ip_default,
|
|
38135
|
+
localhost_ref_default,
|
|
38136
|
+
internal_domain_default,
|
|
38137
|
+
file_path_default,
|
|
38138
|
+
stack_trace_default,
|
|
38139
|
+
internal_url_default,
|
|
38140
|
+
feature_flag_default,
|
|
38141
|
+
db_table_name_default,
|
|
38142
|
+
gcp_service_account_email_default
|
|
38143
|
+
]
|
|
38144
|
+
},
|
|
38145
|
+
{
|
|
38146
|
+
packId: "core-financial",
|
|
38147
|
+
name: "Financial Information",
|
|
38148
|
+
version: "0.1.1",
|
|
38149
|
+
rawRules: [
|
|
38150
|
+
credit_card_default,
|
|
38151
|
+
iban_default,
|
|
38152
|
+
routing_number_default,
|
|
38153
|
+
swift_default,
|
|
38154
|
+
cvv_default,
|
|
38155
|
+
cusip_default,
|
|
38156
|
+
paypal_default,
|
|
38157
|
+
salary_default
|
|
38158
|
+
]
|
|
38159
|
+
},
|
|
38160
|
+
{
|
|
38161
|
+
packId: "core-phi",
|
|
38162
|
+
name: "Protected Health Information",
|
|
38163
|
+
version: "0.1.0",
|
|
38164
|
+
rawRules: [
|
|
38165
|
+
mrn_default,
|
|
38166
|
+
hipaa_identifier_default,
|
|
38167
|
+
member_id_default,
|
|
38168
|
+
group_id_default,
|
|
38169
|
+
icd10_code_default,
|
|
38170
|
+
ndc_code_default,
|
|
38171
|
+
genetic_data_default,
|
|
38172
|
+
biometric_ref_default
|
|
38173
|
+
]
|
|
38174
|
+
},
|
|
38175
|
+
{
|
|
38176
|
+
packId: "core-pii",
|
|
38177
|
+
name: "Core PII",
|
|
38178
|
+
version: "0.2.2",
|
|
38179
|
+
rawRules: [
|
|
38180
|
+
email_default,
|
|
38181
|
+
ssn_default,
|
|
38182
|
+
phone_us_default,
|
|
38183
|
+
phone_intl_default,
|
|
38184
|
+
ip_address_default,
|
|
38185
|
+
dob_default,
|
|
38186
|
+
drivers_license_us_default,
|
|
38187
|
+
passport_us_default,
|
|
38188
|
+
home_address_default,
|
|
38189
|
+
name_default,
|
|
38190
|
+
vin_default,
|
|
38191
|
+
mac_address_default,
|
|
38192
|
+
national_id_default,
|
|
38193
|
+
zip_default
|
|
38194
|
+
]
|
|
38195
|
+
},
|
|
38196
|
+
{
|
|
38197
|
+
packId: "secrets",
|
|
38198
|
+
name: "Secrets & Credentials",
|
|
38199
|
+
version: "0.2.0",
|
|
38200
|
+
defaultPolicy: "warn",
|
|
38201
|
+
rawRules: [
|
|
38202
|
+
aws_access_key_default,
|
|
38203
|
+
aws_secret_key_default,
|
|
38204
|
+
azure_connection_string_default,
|
|
38205
|
+
openai_api_key_default,
|
|
38206
|
+
anthropic_api_key_default,
|
|
38207
|
+
stripe_live_key_default,
|
|
38208
|
+
slack_token_default,
|
|
38209
|
+
discord_token_default,
|
|
38210
|
+
sendgrid_key_default,
|
|
38211
|
+
twilio_key_default,
|
|
38212
|
+
gitlab_token_default,
|
|
38213
|
+
digitalocean_token_default,
|
|
38214
|
+
datadog_key_default,
|
|
38215
|
+
npm_token_default,
|
|
38216
|
+
heroku_api_key_default,
|
|
38217
|
+
cloudflare_api_key_default,
|
|
38218
|
+
pulumi_access_token_default,
|
|
38219
|
+
terraform_cloud_token_default,
|
|
38220
|
+
vault_token_default,
|
|
38221
|
+
github_pat_default,
|
|
38222
|
+
gcp_service_account_key_default,
|
|
38223
|
+
tailscale_key_default
|
|
38224
|
+
]
|
|
38225
|
+
},
|
|
38226
|
+
{
|
|
38227
|
+
packId: "secrets-infra",
|
|
38228
|
+
name: "Infrastructure Secrets",
|
|
38229
|
+
version: "0.1.1",
|
|
38230
|
+
rawRules: [
|
|
38231
|
+
ssh_private_key_default,
|
|
38232
|
+
db_connection_string_default,
|
|
38233
|
+
jwt_token_default,
|
|
38234
|
+
basic_auth_url_default,
|
|
38235
|
+
basic_auth_header_default,
|
|
38236
|
+
pgp_private_key_default,
|
|
38237
|
+
bearer_token_default,
|
|
38238
|
+
env_key_value_default,
|
|
38239
|
+
password_field_default,
|
|
38240
|
+
docker_config_auth_default,
|
|
38241
|
+
kubeconfig_token_default,
|
|
38242
|
+
api_key_header_default,
|
|
38243
|
+
generic_high_entropy_secret_default
|
|
38244
|
+
]
|
|
38245
|
+
}
|
|
38246
|
+
];
|
|
38247
|
+
|
|
38248
|
+
// ../../packages/plugin-sdk/src/rule-packs.ts
|
|
38249
|
+
var BUNDLED_NAMESPACE = "aka";
|
|
38250
|
+
var cachedDetections;
|
|
38251
|
+
function bundledDetections() {
|
|
38252
|
+
cachedDetections ??= BUNDLED_PACKS.map((pack) => ({
|
|
38253
|
+
namespace: BUNDLED_NAMESPACE,
|
|
38254
|
+
packId: pack.packId,
|
|
38255
|
+
version: pack.version,
|
|
38256
|
+
name: pack.name,
|
|
38257
|
+
rules: pack.rawRules.map((raw) => Rule.parse(raw)),
|
|
38258
|
+
defaultPolicyId: pack.defaultPolicy
|
|
38259
|
+
}));
|
|
38260
|
+
return cachedDetections;
|
|
38261
|
+
}
|
|
38262
|
+
function shippedRegexMatchers() {
|
|
38263
|
+
return bundledDetections().flatMap((pack) => pack.rules).flatMap(
|
|
38264
|
+
(rule) => rule.matcher.type === "regex" ? [{ pattern: rule.matcher.pattern, flags: rule.matcher.flags }] : []
|
|
38265
|
+
);
|
|
38266
|
+
}
|
|
36655
38267
|
|
|
36656
38268
|
// ../../packages/plugin-sdk/src/posture.ts
|
|
36657
38269
|
function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
@@ -36666,50 +38278,6 @@ function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
|
36666
38278
|
}
|
|
36667
38279
|
}
|
|
36668
38280
|
|
|
36669
|
-
// ../../packages/plugin-sdk/src/project-files.ts
|
|
36670
|
-
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
|
|
36671
|
-
import { basename as basename5, join as join24 } from "path";
|
|
36672
|
-
|
|
36673
|
-
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
36674
|
-
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
36675
|
-
if (typeof v === "string" && v.trim() === "") return void 0;
|
|
36676
|
-
return v;
|
|
36677
|
-
}, external_exports.string().optional()).catch(void 0);
|
|
36678
|
-
var optionalFlag = external_exports.preprocess((v) => {
|
|
36679
|
-
if (typeof v !== "string") return false;
|
|
36680
|
-
const normalized = v.trim().toLowerCase();
|
|
36681
|
-
return normalized !== "" && normalized !== "0" && normalized !== "false";
|
|
36682
|
-
}, external_exports.boolean()).catch(false);
|
|
36683
|
-
var antigravityProviderEnvShape = {
|
|
36684
|
-
GOOGLE_GENAI_USE_VERTEXAI: optionalFlag,
|
|
36685
|
-
GOOGLE_GEMINI_BASE_URL: optionalBaseUrl2
|
|
36686
|
-
};
|
|
36687
|
-
var AntigravityProviderEnvSchema = external_exports.object(antigravityProviderEnvShape);
|
|
36688
|
-
|
|
36689
|
-
// ../../packages/plugin-sdk/src/provider-env-codex.ts
|
|
36690
|
-
var optionalBaseUrl3 = external_exports.preprocess((v) => {
|
|
36691
|
-
if (typeof v === "string" && v.trim() === "") return void 0;
|
|
36692
|
-
return v;
|
|
36693
|
-
}, external_exports.string().optional()).catch(void 0);
|
|
36694
|
-
var codexProviderEnvShape = {
|
|
36695
|
-
OPENAI_BASE_URL: optionalBaseUrl3
|
|
36696
|
-
};
|
|
36697
|
-
var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
36698
|
-
|
|
36699
|
-
// ../../packages/plugin-sdk/src/runtime.ts
|
|
36700
|
-
import { randomUUID as randomUUID15 } from "crypto";
|
|
36701
|
-
|
|
36702
|
-
// ../../packages/plugin-sdk/src/scope-key.ts
|
|
36703
|
-
import { existsSync as existsSync12 } from "fs";
|
|
36704
|
-
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join25, normalize } from "path";
|
|
36705
|
-
|
|
36706
|
-
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
36707
|
-
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
36708
|
-
|
|
36709
|
-
// ../../packages/plugin-sdk/src/throttle.ts
|
|
36710
|
-
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
36711
|
-
import { join as join26 } from "path";
|
|
36712
|
-
|
|
36713
38281
|
// ../../packages/setup-wizard/src/onboard-posture.ts
|
|
36714
38282
|
function parsePosture(json2) {
|
|
36715
38283
|
const raw = JSON.parse(json2);
|
|
@@ -36730,8 +38298,8 @@ function parsePosture(json2) {
|
|
|
36730
38298
|
}
|
|
36731
38299
|
|
|
36732
38300
|
// ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
|
|
36733
|
-
import { writeFileSync as
|
|
36734
|
-
import { join as
|
|
38301
|
+
import { writeFileSync as writeFileSync5 } from "fs";
|
|
38302
|
+
import { join as join18 } from "path";
|
|
36735
38303
|
|
|
36736
38304
|
// ../../packages/setup-wizard/src/triage/merge.ts
|
|
36737
38305
|
var RANK = Object.fromEntries(
|
|
@@ -36739,9 +38307,9 @@ var RANK = Object.fromEntries(
|
|
|
36739
38307
|
);
|
|
36740
38308
|
|
|
36741
38309
|
// ../../packages/setup-wizard/src/triage/plan-file.ts
|
|
36742
|
-
import { mkdtempSync, readFileSync as
|
|
38310
|
+
import { mkdtempSync, readFileSync as readFileSync11, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
36743
38311
|
import { tmpdir } from "os";
|
|
36744
|
-
import { basename as
|
|
38312
|
+
import { basename as basename2, dirname as dirname4, join as join19 } from "path";
|
|
36745
38313
|
var SuppressionEntrySchema = external_exports.object({
|
|
36746
38314
|
ruleId: external_exports.string(),
|
|
36747
38315
|
category: DetectionCategory,
|
|
@@ -36828,10 +38396,10 @@ function show(body) {
|
|
|
36828
38396
|
}
|
|
36829
38397
|
|
|
36830
38398
|
// src/skills-registry.ts
|
|
36831
|
-
import { readdirSync as
|
|
36832
|
-
import { join as
|
|
36833
|
-
import { fileURLToPath
|
|
36834
|
-
var SKILLS_DIR =
|
|
38399
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync12 } from "fs";
|
|
38400
|
+
import { join as join20 } from "path";
|
|
38401
|
+
import { fileURLToPath } from "url";
|
|
38402
|
+
var SKILLS_DIR = fileURLToPath(new URL("../skills", import.meta.url));
|
|
36835
38403
|
|
|
36836
38404
|
// src/render.ts
|
|
36837
38405
|
var SEVERITY_GLYPH = {
|
|
@@ -36914,7 +38482,7 @@ if (Object.keys(answers).length > 0) {
|
|
|
36914
38482
|
}
|
|
36915
38483
|
try {
|
|
36916
38484
|
const dataDir2 = loadConfig().dataDir;
|
|
36917
|
-
const db = openLocalDatabase(dataDir2);
|
|
38485
|
+
const db = openLocalDatabase(dataDir2, { shippedRegexMatchers: shippedRegexMatchers() });
|
|
36918
38486
|
try {
|
|
36919
38487
|
const { capped } = capWarnEraEnforcementOnce(db, settings.policy, dataDir2);
|
|
36920
38488
|
if (capped > 0) {
|
|
@@ -36940,7 +38508,9 @@ if (rawPosture !== void 0 || useFloor) {
|
|
|
36940
38508
|
else if (rawPosture !== void 0) posture = parsePosture(rawPosture);
|
|
36941
38509
|
else fail("--posture requires a JSON value");
|
|
36942
38510
|
const mode = rawPosture !== void 0 || recalibrate ? "overwrite" : "fill-gaps";
|
|
36943
|
-
const db = openLocalDatabase(loadConfig().dataDir
|
|
38511
|
+
const db = openLocalDatabase(loadConfig().dataDir, {
|
|
38512
|
+
shippedRegexMatchers: shippedRegexMatchers()
|
|
38513
|
+
});
|
|
36944
38514
|
try {
|
|
36945
38515
|
applyCategoryPosture(posture, db.policies, mode);
|
|
36946
38516
|
const categoryCount = Object.keys(posture).length;
|