@akasecurity/ai-tc-codex 0.9.22 → 0.9.24
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 +1 -1
- package/scripts/apply-suppressions.js +148 -31
- package/scripts/backfill.js +186 -40
- package/scripts/content-retention.js +97 -19
- package/scripts/filescan.js +242 -85
- package/scripts/firstrun.js +174 -47
- package/scripts/history-sync.js +160 -34
- package/scripts/intro.js +32 -6
- package/scripts/onboard.js +122 -24
- package/scripts/post-tool-use.js +200 -54
- package/scripts/pre-tool-use.js +200 -54
- package/scripts/query.js +173 -46
- package/scripts/reconcile.js +196 -51
- package/scripts/remediate.js +190 -40
- package/scripts/scan-worker.js +74 -14
- package/scripts/session-start.js +280 -120
- package/scripts/start-light.js +32 -6
- package/scripts/stop.js +178 -51
- package/scripts/sync.js +244 -87
- package/scripts/user-prompt-submit.js +206 -60
package/scripts/sync.js
CHANGED
|
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.
|
|
35
|
+
// ../../node_modules/.pnpm/ignore@7.0.14/node_modules/ignore/index.js
|
|
36
36
|
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.
|
|
37
|
+
"../../node_modules/.pnpm/ignore@7.0.14/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -46,6 +46,7 @@ var require_ignore = __commonJS({
|
|
|
46
46
|
var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
47
47
|
var BOM = "\uFEFF";
|
|
48
48
|
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
49
|
+
var REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
|
|
49
50
|
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
50
51
|
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
51
52
|
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
@@ -227,6 +228,20 @@ var require_ignore = __commonJS({
|
|
|
227
228
|
(_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE2 : run,
|
|
228
229
|
ESCAPE + SPACE2
|
|
229
230
|
],
|
|
231
|
+
// git's wildmatch() reads a run of two or more asterisks as one globstar
|
|
232
|
+
// whenever the run fills a path segment: it starts the pattern or follows
|
|
233
|
+
// a `/`, and it ends the pattern or comes before a `/`. A run of two is
|
|
234
|
+
// already `**`; a longer one is folded into `**` here, so the steps
|
|
235
|
+
// below only ever have to know `**`.
|
|
236
|
+
// `***/foo` -> `**/foo`, `a/***/b` -> `a/**/b`, `a/***` -> `a/**`
|
|
237
|
+
// git also takes a run beside a literal prefix (`a***/b`) or beside an
|
|
238
|
+
// escaped slash (`***\/b`) as a globstar, and this does not; the README
|
|
239
|
+
// lists both, under "A run of asterisks".
|
|
240
|
+
[
|
|
241
|
+
/(^|\/)\*{3,}(?=\/|$)/g,
|
|
242
|
+
(_, start) => `${start}**`,
|
|
243
|
+
"*"
|
|
244
|
+
],
|
|
230
245
|
// Escape metacharacters
|
|
231
246
|
// which is written down by users but means special for regular expressions.
|
|
232
247
|
// > There are 12 characters with special meanings:
|
|
@@ -488,6 +503,9 @@ var require_ignore = __commonJS({
|
|
|
488
503
|
return out;
|
|
489
504
|
};
|
|
490
505
|
var makeRegexPrefix = (pattern) => {
|
|
506
|
+
if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) {
|
|
507
|
+
pattern = "**";
|
|
508
|
+
}
|
|
491
509
|
const { source, sources } = extractBrackets(pattern);
|
|
492
510
|
const replaced = REPLACERS.reduce(
|
|
493
511
|
// A pass whose matcher finds nothing hands back the very string it was
|
|
@@ -703,39 +721,33 @@ var require_ignore = __commonJS({
|
|
|
703
721
|
}
|
|
704
722
|
// Test one single path without recursively checking parent directories
|
|
705
723
|
//
|
|
706
|
-
// -
|
|
707
|
-
//
|
|
708
|
-
|
|
709
|
-
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
710
|
-
// @returns {TestResult} true if a file is ignored
|
|
711
|
-
test(path2, checkUnignored, mode) {
|
|
712
|
-
let ignored = false;
|
|
713
|
-
let unignored = false;
|
|
714
|
-
let matchedRule;
|
|
724
|
+
// - mode `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
725
|
+
// @returns {TestResult}
|
|
726
|
+
test(path2, mode) {
|
|
715
727
|
const rules = this._rules;
|
|
716
728
|
const { length } = rules;
|
|
717
729
|
const shortcut = this._basenameCount * 2 >= length;
|
|
718
730
|
const basename7 = shortcut ? basenameOf(path2) : path2;
|
|
719
|
-
for (let index =
|
|
731
|
+
for (let index = length - 1; index >= 0; index--) {
|
|
720
732
|
const rule = rules[index];
|
|
721
|
-
|
|
722
|
-
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
723
|
-
if (!skip && rule[mode].test(
|
|
733
|
+
if (rule[mode].test(
|
|
724
734
|
shortcut && rule._basenameOnly ? basename7 : path2
|
|
725
735
|
)) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
736
|
+
const { negative } = rule;
|
|
737
|
+
const ret = {
|
|
738
|
+
ignored: !negative,
|
|
739
|
+
unignored: negative
|
|
740
|
+
};
|
|
741
|
+
if (!negative) {
|
|
742
|
+
ret.rule = rule;
|
|
743
|
+
}
|
|
744
|
+
return ret;
|
|
729
745
|
}
|
|
730
746
|
}
|
|
731
|
-
|
|
732
|
-
ignored,
|
|
733
|
-
unignored
|
|
747
|
+
return {
|
|
748
|
+
ignored: false,
|
|
749
|
+
unignored: false
|
|
734
750
|
};
|
|
735
|
-
if (matchedRule) {
|
|
736
|
-
ret.rule = matchedRule;
|
|
737
|
-
}
|
|
738
|
-
return ret;
|
|
739
751
|
}
|
|
740
752
|
};
|
|
741
753
|
var throwError = (message, Ctor) => {
|
|
@@ -808,36 +820,36 @@ var require_ignore = __commonJS({
|
|
|
808
820
|
return this.add(pattern);
|
|
809
821
|
}
|
|
810
822
|
// @returns {TestResult}
|
|
811
|
-
_test(originalPath, cache
|
|
823
|
+
_test(originalPath, cache) {
|
|
812
824
|
const path2 = originalPath && checkPath.convert(originalPath);
|
|
813
825
|
checkPath(
|
|
814
826
|
path2,
|
|
815
827
|
originalPath,
|
|
816
828
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
817
829
|
);
|
|
818
|
-
return this._t(path2, cache
|
|
830
|
+
return this._t(path2, cache);
|
|
819
831
|
}
|
|
820
832
|
checkIgnore(path2) {
|
|
821
833
|
if (path2.charCodeAt(path2.length - 1) !== SLASH_CODE) {
|
|
822
834
|
return this.test(path2);
|
|
823
835
|
}
|
|
824
|
-
const dir = this._t(path2, this._testCache
|
|
836
|
+
const dir = this._t(path2, this._testCache);
|
|
825
837
|
if (dir.ignored) {
|
|
826
838
|
return dir;
|
|
827
839
|
}
|
|
828
840
|
const literal2 = this._rules.testLiteral(path2);
|
|
829
841
|
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
830
842
|
}
|
|
831
|
-
_t(path2, cache
|
|
843
|
+
_t(path2, cache) {
|
|
832
844
|
if (path2 in cache) {
|
|
833
845
|
return cache[path2];
|
|
834
846
|
}
|
|
835
847
|
const parentPath = parentOf(path2);
|
|
836
|
-
const parent = parentPath ? this._t(parentPath, cache
|
|
837
|
-
return cache[path2] = parent && parent.ignored ? parent : this._rules.test(path2,
|
|
848
|
+
const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
|
|
849
|
+
return cache[path2] = parent && parent.ignored ? parent : this._rules.test(path2, MODE_IGNORE);
|
|
838
850
|
}
|
|
839
851
|
ignores(path2) {
|
|
840
|
-
return this._test(path2, this._ignoreCache
|
|
852
|
+
return this._test(path2, this._ignoreCache).ignored;
|
|
841
853
|
}
|
|
842
854
|
createFilter() {
|
|
843
855
|
return (path2) => !this.ignores(path2);
|
|
@@ -847,7 +859,7 @@ var require_ignore = __commonJS({
|
|
|
847
859
|
}
|
|
848
860
|
// @returns {TestResult}
|
|
849
861
|
test(path2) {
|
|
850
|
-
return this._test(path2, this._testCache
|
|
862
|
+
return this._test(path2, this._testCache);
|
|
851
863
|
}
|
|
852
864
|
};
|
|
853
865
|
var factory = (options) => new Ignore(options);
|
|
@@ -9644,7 +9656,11 @@ var ListFindingTypesQuery = object({
|
|
|
9644
9656
|
// and so is not bounded by what any page happens to hold.
|
|
9645
9657
|
includeId: string2().optional(),
|
|
9646
9658
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
9647
|
-
cursor: string2().optional()
|
|
9659
|
+
cursor: string2().optional(),
|
|
9660
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9661
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9662
|
+
// from wherever it lands.
|
|
9663
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9648
9664
|
});
|
|
9649
9665
|
var ListFindingTypesResponse = object({
|
|
9650
9666
|
totals: object({
|
|
@@ -9725,7 +9741,11 @@ var ListFindingInstancesQuery = object({
|
|
|
9725
9741
|
sessionId: string2().optional(),
|
|
9726
9742
|
from: iso_exports.datetime().optional(),
|
|
9727
9743
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
9728
|
-
cursor: string2().optional()
|
|
9744
|
+
cursor: string2().optional(),
|
|
9745
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9746
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9747
|
+
// from wherever it lands.
|
|
9748
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9729
9749
|
});
|
|
9730
9750
|
var ListFindingInstancesResponse = object({
|
|
9731
9751
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -9797,7 +9817,11 @@ var ListFindingLocationsQuery = object({
|
|
|
9797
9817
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
9798
9818
|
includeId: string2().optional(),
|
|
9799
9819
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
9800
|
-
cursor: string2().optional()
|
|
9820
|
+
cursor: string2().optional(),
|
|
9821
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9822
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9823
|
+
// from wherever it lands.
|
|
9824
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9801
9825
|
});
|
|
9802
9826
|
var ListFindingLocationsResponse = object({
|
|
9803
9827
|
totals: object({
|
|
@@ -12434,7 +12458,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
12434
12458
|
var ListVaultInventoryQuery = object({
|
|
12435
12459
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12436
12460
|
// Opaque; names the last row of the page just served.
|
|
12437
|
-
cursor: string2().optional()
|
|
12461
|
+
cursor: string2().optional(),
|
|
12462
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12463
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12464
|
+
// from wherever it lands.
|
|
12465
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12438
12466
|
});
|
|
12439
12467
|
var ListVaultInventoryResponse = object({
|
|
12440
12468
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -12446,7 +12474,11 @@ var ListVaultInventoryResponse = object({
|
|
|
12446
12474
|
});
|
|
12447
12475
|
var ListVaultReuseQuery = object({
|
|
12448
12476
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12449
|
-
cursor: string2().optional()
|
|
12477
|
+
cursor: string2().optional(),
|
|
12478
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12479
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12480
|
+
// from wherever it lands.
|
|
12481
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12450
12482
|
});
|
|
12451
12483
|
var ListVaultReuseResponse = object({
|
|
12452
12484
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -12462,9 +12494,15 @@ var ListVaultDerefsQuery = object({
|
|
|
12462
12494
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
12463
12495
|
includeBatched: boolean2().optional(),
|
|
12464
12496
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12465
|
-
cursor: string2().optional()
|
|
12497
|
+
cursor: string2().optional(),
|
|
12498
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12499
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12500
|
+
// from wherever it lands.
|
|
12501
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12466
12502
|
});
|
|
12467
12503
|
var ListVaultDerefsResponse = object({
|
|
12504
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
12505
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
12468
12506
|
items: array(VaultDeref),
|
|
12469
12507
|
nextCursor: string2().nullable(),
|
|
12470
12508
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -21829,7 +21867,7 @@ var SqliteFindingsRepository = class {
|
|
|
21829
21867
|
};
|
|
21830
21868
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
21831
21869
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
21832
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
21870
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
21833
21871
|
const page = sorted.slice(start, start + limit);
|
|
21834
21872
|
const lastOnPage = page.at(-1);
|
|
21835
21873
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -21923,7 +21961,7 @@ var SqliteFindingsRepository = class {
|
|
|
21923
21961
|
accumulator.add(row);
|
|
21924
21962
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
21925
21963
|
total += 1;
|
|
21926
|
-
if (!isPastCursor(row)) continue;
|
|
21964
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
21927
21965
|
if (items.length < limit) {
|
|
21928
21966
|
items.push(toInstanceDetail(row));
|
|
21929
21967
|
last = row;
|
|
@@ -22012,7 +22050,7 @@ var SqliteFindingsRepository = class {
|
|
|
22012
22050
|
}
|
|
22013
22051
|
}
|
|
22014
22052
|
sorted.sort(compareLocationOrder);
|
|
22015
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
22053
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
22016
22054
|
const page = sorted.slice(start, start + limit);
|
|
22017
22055
|
const lastOnPage = page.at(-1);
|
|
22018
22056
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -24640,6 +24678,9 @@ function pageLimit(requested, fallback) {
|
|
|
24640
24678
|
if (requested === void 0) return fallback;
|
|
24641
24679
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
24642
24680
|
}
|
|
24681
|
+
function pageOffset(requested) {
|
|
24682
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
24683
|
+
}
|
|
24643
24684
|
function encodeReuseCursor(payload) {
|
|
24644
24685
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
24645
24686
|
}
|
|
@@ -24987,7 +25028,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24987
25028
|
*/
|
|
24988
25029
|
listInventory(query = {}, now = Date.now()) {
|
|
24989
25030
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24990
|
-
const
|
|
25031
|
+
const offset = pageOffset(query.offset);
|
|
25032
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24991
25033
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
24992
25034
|
const rows = allRows(
|
|
24993
25035
|
this.db.prepare(
|
|
@@ -25001,11 +25043,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
25001
25043
|
FROM secret_vault v
|
|
25002
25044
|
${where}
|
|
25003
25045
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
25004
|
-
LIMIT :limit`
|
|
25046
|
+
LIMIT :limit OFFSET :offset`
|
|
25005
25047
|
),
|
|
25006
25048
|
bindParams({
|
|
25007
25049
|
now,
|
|
25008
25050
|
limit: limit + 1,
|
|
25051
|
+
offset,
|
|
25009
25052
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
25010
25053
|
})
|
|
25011
25054
|
);
|
|
@@ -25029,7 +25072,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
25029
25072
|
*/
|
|
25030
25073
|
listReuse(query = {}, now = Date.now()) {
|
|
25031
25074
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
25032
|
-
const
|
|
25075
|
+
const offset = pageOffset(query.offset);
|
|
25076
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
25033
25077
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
25034
25078
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
25035
25079
|
const rows = allRows(
|
|
@@ -25044,11 +25088,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
25044
25088
|
FROM secret_vault v
|
|
25045
25089
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
25046
25090
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
25047
|
-
LIMIT :limit`
|
|
25091
|
+
LIMIT :limit OFFSET :offset`
|
|
25048
25092
|
),
|
|
25049
25093
|
bindParams({
|
|
25050
25094
|
now,
|
|
25051
25095
|
limit: limit + 1,
|
|
25096
|
+
offset,
|
|
25052
25097
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
25053
25098
|
})
|
|
25054
25099
|
);
|
|
@@ -25073,7 +25118,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
25073
25118
|
*/
|
|
25074
25119
|
listDerefs(query = {}) {
|
|
25075
25120
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
25076
|
-
const
|
|
25121
|
+
const offset = pageOffset(query.offset);
|
|
25122
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
25077
25123
|
const conditions = [];
|
|
25078
25124
|
if (query.includeBatched !== true) {
|
|
25079
25125
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -25086,21 +25132,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
25086
25132
|
this.db.prepare(
|
|
25087
25133
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
25088
25134
|
FROM secret_vault_deref ${where}
|
|
25089
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
25135
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
25090
25136
|
),
|
|
25091
25137
|
bindParams({
|
|
25092
25138
|
limit: limit + 1,
|
|
25139
|
+
offset,
|
|
25093
25140
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
25094
25141
|
})
|
|
25095
25142
|
);
|
|
25096
25143
|
const hasMore = rows.length > limit;
|
|
25097
25144
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
25098
25145
|
const last = page[page.length - 1];
|
|
25099
|
-
const
|
|
25100
|
-
this.db
|
|
25101
|
-
|
|
25102
|
-
|
|
25146
|
+
const counts = getRow(
|
|
25147
|
+
this.db.prepare(
|
|
25148
|
+
`SELECT count(*) AS total,
|
|
25149
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
25150
|
+
FROM secret_vault_deref`
|
|
25151
|
+
)
|
|
25152
|
+
) ?? { total: 0, hidden: 0 };
|
|
25153
|
+
const includeBatched = query.includeBatched === true;
|
|
25154
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
25103
25155
|
return {
|
|
25156
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
25104
25157
|
items: page.map((r) => ({
|
|
25105
25158
|
id: r.id,
|
|
25106
25159
|
pointerId: r.pointer_id,
|
|
@@ -25125,6 +25178,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
25125
25178
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
25126
25179
|
);
|
|
25127
25180
|
}
|
|
25181
|
+
/**
|
|
25182
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
25183
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
25184
|
+
* every row.
|
|
25185
|
+
*
|
|
25186
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
25187
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
25188
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
25189
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
25190
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
25191
|
+
*
|
|
25192
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
25193
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
25194
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
25195
|
+
*
|
|
25196
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
25197
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
25198
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
25199
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
25200
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
25201
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
25202
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
25203
|
+
*/
|
|
25204
|
+
countFingerprintEpochs(currentVersion) {
|
|
25205
|
+
const row = getRow(
|
|
25206
|
+
this.db.prepare(
|
|
25207
|
+
`SELECT COUNT(*) AS total,
|
|
25208
|
+
COALESCE(
|
|
25209
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
25210
|
+
0
|
|
25211
|
+
) AS stale
|
|
25212
|
+
FROM secret_vault`
|
|
25213
|
+
),
|
|
25214
|
+
{ currentVersion }
|
|
25215
|
+
) ?? { stale: 0, total: 0 };
|
|
25216
|
+
return { stale: row.stale, total: row.total };
|
|
25217
|
+
}
|
|
25128
25218
|
};
|
|
25129
25219
|
|
|
25130
25220
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -26972,13 +27062,22 @@ var SecretVault = class {
|
|
|
26972
27062
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
26973
27063
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
26974
27064
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
27065
|
+
*
|
|
27066
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
27067
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
27068
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
27069
|
+
* than a bare success count.
|
|
26975
27070
|
*/
|
|
26976
27071
|
async refreshFingerprints(next) {
|
|
26977
27072
|
let refreshed = 0;
|
|
27073
|
+
let skipped = 0;
|
|
26978
27074
|
for (const row of this.#repo.listAll()) {
|
|
26979
27075
|
try {
|
|
26980
27076
|
const raw = await this.#openRow(row);
|
|
26981
|
-
if (raw === null)
|
|
27077
|
+
if (raw === null) {
|
|
27078
|
+
skipped += 1;
|
|
27079
|
+
continue;
|
|
27080
|
+
}
|
|
26982
27081
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
26983
27082
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
26984
27083
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -26986,10 +27085,10 @@ var SecretVault = class {
|
|
|
26986
27085
|
});
|
|
26987
27086
|
refreshed += 1;
|
|
26988
27087
|
} catch {
|
|
26989
|
-
|
|
27088
|
+
skipped += 1;
|
|
26990
27089
|
}
|
|
26991
27090
|
}
|
|
26992
|
-
return refreshed;
|
|
27091
|
+
return { refreshed, skipped };
|
|
26993
27092
|
}
|
|
26994
27093
|
/**
|
|
26995
27094
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -29538,6 +29637,21 @@ function registerPack(pack) {
|
|
|
29538
29637
|
function getLoadedRules() {
|
|
29539
29638
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
29540
29639
|
}
|
|
29640
|
+
function outsideWrittenRegions(candidates, context) {
|
|
29641
|
+
const regions = context?.writtenRegions;
|
|
29642
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
29643
|
+
return candidates.filter((c) => {
|
|
29644
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
29645
|
+
const { start, end } = c.match.span;
|
|
29646
|
+
return !regions.some(
|
|
29647
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
29648
|
+
c.rule,
|
|
29649
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
29650
|
+
"code_change"
|
|
29651
|
+
)
|
|
29652
|
+
);
|
|
29653
|
+
});
|
|
29654
|
+
}
|
|
29541
29655
|
function spansOverlap(a, b) {
|
|
29542
29656
|
return a.start < b.end && a.end > b.start;
|
|
29543
29657
|
}
|
|
@@ -29725,17 +29839,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
29725
29839
|
function scanText(text, ruleset, context) {
|
|
29726
29840
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
29727
29841
|
const normalization = normalizeFormatChars(text);
|
|
29728
|
-
const originalCandidates =
|
|
29842
|
+
const originalCandidates = outsideWrittenRegions(
|
|
29843
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
29844
|
+
context
|
|
29845
|
+
);
|
|
29729
29846
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
29730
29847
|
const pooledOriginal = originalCandidates.map(
|
|
29731
29848
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
29732
29849
|
);
|
|
29733
|
-
const normalizedCandidates =
|
|
29734
|
-
normalization.normalized,
|
|
29735
|
-
|
|
29736
|
-
|
|
29737
|
-
context
|
|
29738
|
-
)
|
|
29850
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
29851
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
29852
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
29853
|
+
),
|
|
29854
|
+
context
|
|
29855
|
+
);
|
|
29739
29856
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
29740
29857
|
return mergeOverlappingSameRule(findings, text);
|
|
29741
29858
|
}
|
|
@@ -29796,6 +29913,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
29796
29913
|
"code-flaws/sql-inject-concat-dot",
|
|
29797
29914
|
"code-flaws/sql-inject-format",
|
|
29798
29915
|
"code-flaws/sql-inject-interp",
|
|
29916
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
29799
29917
|
"code-flaws/ssrf-user-url",
|
|
29800
29918
|
"code-flaws/xss-dangerously-set",
|
|
29801
29919
|
"code-flaws/xss-inner-html",
|
|
@@ -30934,7 +31052,7 @@ var sql_inject_concat_dot_default = {
|
|
|
30934
31052
|
severity: "high",
|
|
30935
31053
|
matcher: {
|
|
30936
31054
|
type: "regex",
|
|
30937
|
-
pattern:
|
|
31055
|
+
pattern: "([\"'])(?=((?:(?!\\1)[^\\n])*?\\b(?:select\\b(?:(?!\\1|\\bselect\\b)[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?!\\1)['\"%]|between\\b)))))\\2(?:(?!\\1(?:(?!\\1)[^\\n])*?\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?[\"']\\s*\\.",
|
|
30938
31056
|
flags: "gi"
|
|
30939
31057
|
},
|
|
30940
31058
|
appliesTo: {
|
|
@@ -30952,7 +31070,7 @@ var sql_inject_concat_default = {
|
|
|
30952
31070
|
severity: "high",
|
|
30953
31071
|
matcher: {
|
|
30954
31072
|
type: "regex",
|
|
30955
|
-
pattern:
|
|
31073
|
+
pattern: "([\"'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?!\\1)['\"%]|between\\b))))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?[\"']\\s*\\+",
|
|
30956
31074
|
flags: "gi"
|
|
30957
31075
|
},
|
|
30958
31076
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -30967,7 +31085,7 @@ var sql_inject_format_default = {
|
|
|
30967
31085
|
severity: "high",
|
|
30968
31086
|
matcher: {
|
|
30969
31087
|
type: "regex",
|
|
30970
|
-
pattern:
|
|
31088
|
+
pattern: "([\"'`])\\s*(?=((?:select\\b(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b)|\\1)[^\\n])*?\\bfrom\\b)|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))\\2(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b)|\\1)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|([\"'`])\\s*(?=((?:(?!\\3)[^\\n])*?\\bwhere\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?=(?!\\3)['\"%])|between\\b))))\\4(?:(?!\\bwhere\\b|\\3)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|(?<=^|\\n)[ \\t]*(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))\\5(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))[^\\n])*?(?:=\\s*['\"]?\\s*(?:%[sd]|\\{[^{}\\n]+\\})|[#$]\\{[^{}\\n]+\\})",
|
|
30971
31089
|
flags: "gi"
|
|
30972
31090
|
},
|
|
30973
31091
|
examples: [
|
|
@@ -30976,6 +31094,24 @@ var sql_inject_format_default = {
|
|
|
30976
31094
|
]
|
|
30977
31095
|
};
|
|
30978
31096
|
|
|
31097
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
31098
|
+
var sql_inject_interp_multiline_default = {
|
|
31099
|
+
specVersion: 1,
|
|
31100
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
31101
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
31102
|
+
category: "code_flaw",
|
|
31103
|
+
severity: "high",
|
|
31104
|
+
matcher: {
|
|
31105
|
+
type: "regex",
|
|
31106
|
+
pattern: '(?<=^|\\n)[ \\t]*(?=(?:select\\b(?:[^\\n]*\\n){0,3}?[^\\n]*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+\\w+)\\s+){0,2}into\\b|update\\s+(?:(?:low_priority|ignore|or\\s+\\w+)\\s+){0,2}(?:only\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?(?:\\s*,\\s*(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?){0,7}\\s+set(?:\\s+|(?=`))(?:(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+\\s*=|#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;),]|\\n|$|(?:where|order|limit)\\b)))|delete\\s+(?:(?:low_priority|quick|ignore)\\s+){0,3}(?:from\\b|[\\w.`]+(?:\\s*,\\s*[\\w.`]+)*\\s+from\\s+[\\w.`]+(?:\\s+(?:as\\s+)?\\w+)?\\s+(?:(?:inner|cross|(?:left|right)(?:\\s+outer)?)\\s+)?(?:join|using|where)\\b)|where\\s+(?:(?:not\\s+)?(?:\\(\\s*)*(?:#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;)]|\\n|$|(?:and|or|order|group|limit)\\b)))|(?:not\\s+)?exists\\s*\\(|(?:not\\s+)?(?:\\(\\s*)*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?(?:\\s*,\\s*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?){0,4}\\s*(?:\\)\\s*)?(?:[=<>!~@|&:%^*/+-]+|\\b(?:is|in|not|i?like|regexp|rlike|similar\\s+to|glob|between|against|match|exists|and|or)\\b))))(?:select|insert|update|delete|where)\\s[^\\n]*?(?:#\\{|\\$[a-z_])',
|
|
31107
|
+
flags: "gi"
|
|
31108
|
+
},
|
|
31109
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
31110
|
+
appliesTo: {
|
|
31111
|
+
extensions: [".rb", ".php"]
|
|
31112
|
+
}
|
|
31113
|
+
};
|
|
31114
|
+
|
|
30979
31115
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
30980
31116
|
var sql_inject_interp_default = {
|
|
30981
31117
|
specVersion: 1,
|
|
@@ -30985,7 +31121,7 @@ var sql_inject_interp_default = {
|
|
|
30985
31121
|
severity: "high",
|
|
30986
31122
|
matcher: {
|
|
30987
31123
|
type: "regex",
|
|
30988
|
-
pattern: "([\
|
|
31124
|
+
pattern: '(?<![\\w\'"`})\\]])(["\'`])[ \\t]*(?=(?:select\\b(?:#\\{(?:[^{}\\n]|\\{(?:[^{}\\n]|\\{[^{}\\n]{0,100}\\}){0,100}\\}){0,200}\\}|\\{\\$[^}\\n]{0,200}\\}|\\\\(?!\\1[ \\t]*(?:select|insert|update|delete|where)\\b).|(?!\\1)(?!#\\{|\\{\\$|\\\\)[\\s\\S]){0,1000}?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+\\w+)\\s+){0,2}(?:into\\b|[\\w.`]+\\s*\\()|update\\s+(?:(?:low_priority|ignore|or\\s+\\w+)\\s+){0,2}(?:only\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?(?:\\s*,\\s*(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?){0,7}(?:(?:\\s+\\w+){0,2}\\s+join\\b(?:(?!\\bset\\b)(?!\\1)[^\\n]){1,300})?\\s+set(?:\\s+|(?=`))(?:(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+\\s*=|#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;),]|\\n|$|(?:where|order|limit)\\b)))|delete\\s+(?:(?:low_priority|quick|ignore)\\s+){0,3}(?:from\\b|[\\w.`]+(?:\\s*,\\s*[\\w.`]+)*\\s+from\\s+[\\w.`]+(?:\\s+(?:as\\s+)?\\w+)?\\s+(?:(?:inner|cross|(?:left|right)(?:\\s+outer)?)\\s+)?(?:join|using|where)\\b)|where\\s+(?:(?:not\\s+)?(?:\\(\\s*)*(?:#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;)]|\\n|$|(?:and|or|order|group|limit)\\b)))|(?:not\\s+)?exists\\s*\\(|(?:not\\s+)?(?:\\(\\s*)*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?(?:\\s*,\\s*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?){0,4}\\s*(?:\\)\\s*)?(?:[=<>!~@|&:%^*/+-]+|\\b(?:is|in|not|i?like|regexp|rlike|similar\\s+to|glob|between|against|match|exists|and|or)\\b))))\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])',
|
|
30989
31125
|
flags: "gi"
|
|
30990
31126
|
},
|
|
30991
31127
|
examples: [
|
|
@@ -32713,12 +32849,13 @@ var BUNDLED_PACKS = [
|
|
|
32713
32849
|
{
|
|
32714
32850
|
packId: "code-flaws",
|
|
32715
32851
|
name: "Code Security Flaws",
|
|
32716
|
-
version: "0.1.
|
|
32852
|
+
version: "0.1.6",
|
|
32717
32853
|
rawRules: [
|
|
32718
32854
|
sql_inject_concat_default,
|
|
32719
32855
|
sql_inject_concat_dot_default,
|
|
32720
32856
|
sql_inject_format_default,
|
|
32721
32857
|
sql_inject_interp_default,
|
|
32858
|
+
sql_inject_interp_multiline_default,
|
|
32722
32859
|
cmd_inject_shell_default,
|
|
32723
32860
|
cmd_inject_exec_default,
|
|
32724
32861
|
cmd_inject_node_exec_default,
|
|
@@ -32750,6 +32887,7 @@ var BUNDLED_PACKS = [
|
|
|
32750
32887
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
32751
32888
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
32752
32889
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
32890
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
32753
32891
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
32754
32892
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
32755
32893
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -33426,8 +33564,25 @@ function bundledMaskingRules() {
|
|
|
33426
33564
|
return ensureBundledPacks() ? getLoadedRules() : null;
|
|
33427
33565
|
}
|
|
33428
33566
|
|
|
33567
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
33568
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
33569
|
+
function notRegularFile(path2) {
|
|
33570
|
+
return `not a regular file: ${path2}`;
|
|
33571
|
+
}
|
|
33572
|
+
function readRegularFile(path2, maxBytes) {
|
|
33573
|
+
const fd = openSync2(path2, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
33574
|
+
try {
|
|
33575
|
+
const stat2 = fstatSync(fd);
|
|
33576
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path2));
|
|
33577
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path2}`);
|
|
33578
|
+
return readFileSync16(fd, "utf8");
|
|
33579
|
+
} finally {
|
|
33580
|
+
closeSync2(fd);
|
|
33581
|
+
}
|
|
33582
|
+
}
|
|
33583
|
+
|
|
33429
33584
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
33430
|
-
import { existsSync as existsSync9,
|
|
33585
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
33431
33586
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
33432
33587
|
function remoteWithoutCredentials(remote) {
|
|
33433
33588
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -33538,9 +33693,10 @@ function resolveGitContext(root) {
|
|
|
33538
33693
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
33539
33694
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
33540
33695
|
}
|
|
33696
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
33541
33697
|
function safeRead(path2) {
|
|
33542
33698
|
try {
|
|
33543
|
-
return
|
|
33699
|
+
return readRegularFile(path2, MAX_GIT_METADATA_BYTES);
|
|
33544
33700
|
} catch {
|
|
33545
33701
|
return void 0;
|
|
33546
33702
|
}
|
|
@@ -33861,6 +34017,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
33861
34017
|
text,
|
|
33862
34018
|
filePath: context?.filePath,
|
|
33863
34019
|
eventKind: context?.eventKind,
|
|
34020
|
+
writtenRegions: context?.writtenRegions,
|
|
33864
34021
|
attribute: scanOpts?.attribute === true
|
|
33865
34022
|
}),
|
|
33866
34023
|
reply: (message) => {
|
|
@@ -34160,11 +34317,10 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
34160
34317
|
|
|
34161
34318
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
34162
34319
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
34163
|
-
import { readFileSync as readFileSync17 } from "fs";
|
|
34164
34320
|
import { join as join25 } from "path";
|
|
34165
34321
|
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
34166
34322
|
try {
|
|
34167
|
-
return { matcher: (0, import_ignore.default)().add(
|
|
34323
|
+
return { matcher: (0, import_ignore.default)().add(readRegularFile(join25(dir, filename))), anchorLen };
|
|
34168
34324
|
} catch {
|
|
34169
34325
|
return void 0;
|
|
34170
34326
|
}
|
|
@@ -34662,7 +34818,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
34662
34818
|
input.text,
|
|
34663
34819
|
{
|
|
34664
34820
|
filePath: input.metadata?.filePath,
|
|
34665
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
34821
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
34822
|
+
writtenRegions: opts2.writtenRegions
|
|
34666
34823
|
},
|
|
34667
34824
|
{
|
|
34668
34825
|
sourceTool: input.sourceTool,
|
|
@@ -36407,7 +36564,7 @@ function sessionToolIsKeyed(tool) {
|
|
|
36407
36564
|
|
|
36408
36565
|
// ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
|
|
36409
36566
|
import { createHash as createHash12 } from "crypto";
|
|
36410
|
-
import { readFileSync as
|
|
36567
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
36411
36568
|
import { join as join29 } from "path";
|
|
36412
36569
|
|
|
36413
36570
|
// ../../packages/plugin-runtime/src/attached/config-inventory-wire.ts
|
|
@@ -36507,7 +36664,7 @@ async function publishByRename(tmp, file, move = rename2) {
|
|
|
36507
36664
|
|
|
36508
36665
|
// ../../packages/plugin-runtime/src/attached/capture-settings.ts
|
|
36509
36666
|
import { randomUUID as randomUUID18 } from "crypto";
|
|
36510
|
-
import { readFileSync as
|
|
36667
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
36511
36668
|
import { rm, writeFile as writeFile2 } from "fs/promises";
|
|
36512
36669
|
import { join as join27 } from "path";
|
|
36513
36670
|
var HookCaptureSettingsSchema = CaptureSettings.pick({
|
|
@@ -36978,7 +37135,7 @@ function machineWideDigest(requests) {
|
|
|
36978
37135
|
function readStagedEntries(dataDir2) {
|
|
36979
37136
|
let parsed2;
|
|
36980
37137
|
try {
|
|
36981
|
-
parsed2 = JSON.parse(
|
|
37138
|
+
parsed2 = JSON.parse(readFileSync18(stagedConfigInventoryPath(dataDir2), "utf8"));
|
|
36982
37139
|
} catch {
|
|
36983
37140
|
return [];
|
|
36984
37141
|
}
|
|
@@ -37012,7 +37169,7 @@ function readStagedReports(dataDir2) {
|
|
|
37012
37169
|
function readDelivered(dataDir2, attachment) {
|
|
37013
37170
|
const empty = { attachment, reports: {}, global: {} };
|
|
37014
37171
|
try {
|
|
37015
|
-
const parsed2 = JSON.parse(
|
|
37172
|
+
const parsed2 = JSON.parse(readFileSync18(configInventoryStatePath(dataDir2), "utf8"));
|
|
37016
37173
|
if (parsed2?.attachment !== attachment) return empty;
|
|
37017
37174
|
const reports = {};
|
|
37018
37175
|
for (const [key, value] of Object.entries(asRecord(parsed2.reports))) {
|
|
@@ -37053,7 +37210,7 @@ function asRecord(value) {
|
|
|
37053
37210
|
}
|
|
37054
37211
|
|
|
37055
37212
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
37056
|
-
import { readFileSync as
|
|
37213
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
37057
37214
|
import { join as join30 } from "path";
|
|
37058
37215
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
37059
37216
|
function forwardDropsPath(dataDir2) {
|
|
@@ -37075,7 +37232,7 @@ function recordForwardDrops(dataDir2, count, nowMs) {
|
|
|
37075
37232
|
}
|
|
37076
37233
|
function readForwardDrops(dataDir2) {
|
|
37077
37234
|
try {
|
|
37078
|
-
const parsed2 = JSON.parse(
|
|
37235
|
+
const parsed2 = JSON.parse(readFileSync19(forwardDropsPath(dataDir2), "utf8"));
|
|
37079
37236
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
37080
37237
|
const record2 = parsed2;
|
|
37081
37238
|
if (typeof record2.droppedForwards !== "number" || !Number.isFinite(record2.droppedForwards)) {
|
|
@@ -38179,7 +38336,7 @@ function toWireInspection(insp, nameKey) {
|
|
|
38179
38336
|
}
|
|
38180
38337
|
|
|
38181
38338
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
38182
|
-
import { readFileSync as
|
|
38339
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
38183
38340
|
|
|
38184
38341
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
38185
38342
|
import { readFile as readFile3, stat } from "fs/promises";
|
|
@@ -38252,7 +38409,7 @@ async function readInstalledVersionBounded(installRoot) {
|
|
|
38252
38409
|
}
|
|
38253
38410
|
|
|
38254
38411
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
38255
|
-
import { readFileSync as
|
|
38412
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
38256
38413
|
import { join as join32 } from "path";
|
|
38257
38414
|
var POSTURE_REPORT_STATE_FILENAME = ATTACHED_POSTURE_REPORT_FILENAME;
|
|
38258
38415
|
var OUTCOME_KEYS = {
|
|
@@ -38528,7 +38685,7 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
|
38528
38685
|
}
|
|
38529
38686
|
|
|
38530
38687
|
// ../../packages/plugin-runtime/src/attached/label-drops.ts
|
|
38531
|
-
import { readFileSync as
|
|
38688
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
38532
38689
|
import { join as join34 } from "path";
|
|
38533
38690
|
function path(dataDir2) {
|
|
38534
38691
|
return join34(dataDir2, ATTACHED_LABEL_SYNC_FILENAME);
|
|
@@ -38549,7 +38706,7 @@ function recordUnsendableLabels(dataDir2, count, nowMs) {
|
|
|
38549
38706
|
}
|
|
38550
38707
|
function readUnsendableLabels(dataDir2) {
|
|
38551
38708
|
try {
|
|
38552
|
-
const parsed2 = JSON.parse(
|
|
38709
|
+
const parsed2 = JSON.parse(readFileSync22(path(dataDir2), "utf8"));
|
|
38553
38710
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
38554
38711
|
const record2 = parsed2;
|
|
38555
38712
|
if (typeof record2.unsendable !== "number" || !Number.isFinite(record2.unsendable)) return null;
|
|
@@ -38562,7 +38719,7 @@ function readUnsendableLabels(dataDir2) {
|
|
|
38562
38719
|
}
|
|
38563
38720
|
|
|
38564
38721
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
38565
|
-
import { readFileSync as
|
|
38722
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
38566
38723
|
import { join as join35 } from "path";
|
|
38567
38724
|
var SYNC_STATE_FILENAME = ATTACHED_SYNC_STATE_FILENAME;
|
|
38568
38725
|
function syncStatePath(dataDir2) {
|
|
@@ -39178,14 +39335,14 @@ var DISCOVER_SKIP = /* @__PURE__ */ new Set([
|
|
|
39178
39335
|
import { basename as basename6, relative as relative3 } from "path";
|
|
39179
39336
|
|
|
39180
39337
|
// ../../packages/scanner/src/scan.ts
|
|
39181
|
-
import { existsSync as existsSync13, readFileSync as
|
|
39338
|
+
import { existsSync as existsSync13, readFileSync as readFileSync25 } from "fs";
|
|
39182
39339
|
import { dirname as dirname13, extname as extname2, isAbsolute as isAbsolute4, relative as relative5 } from "path";
|
|
39183
39340
|
|
|
39184
39341
|
// ../../packages/scanner/src/manifests.ts
|
|
39185
39342
|
import { statSync as statSync11 } from "fs";
|
|
39186
39343
|
|
|
39187
39344
|
// ../../packages/scanner/src/walk.ts
|
|
39188
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
39345
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync24, statSync as statSync10 } from "fs";
|
|
39189
39346
|
import { homedir as homedir3 } from "os";
|
|
39190
39347
|
import { join as join38, relative as relative4, sep as sep7 } from "path";
|
|
39191
39348
|
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
@@ -39313,7 +39470,7 @@ function* walkSourceFiles(opts = {}) {
|
|
|
39313
39470
|
if (opts.shouldRead && !opts.shouldRead(meta3)) continue;
|
|
39314
39471
|
let content;
|
|
39315
39472
|
try {
|
|
39316
|
-
content =
|
|
39473
|
+
content = readFileSync24(file.path, "utf8");
|
|
39317
39474
|
} catch {
|
|
39318
39475
|
continue;
|
|
39319
39476
|
}
|
|
@@ -39761,7 +39918,7 @@ function scanManifests(egress, ledger, updates, rootDir, scopeKeyOf2, onReposito
|
|
|
39761
39918
|
}
|
|
39762
39919
|
let content;
|
|
39763
39920
|
try {
|
|
39764
|
-
content =
|
|
39921
|
+
content = readFileSync25(manifest.path, "utf8");
|
|
39765
39922
|
} catch {
|
|
39766
39923
|
continue;
|
|
39767
39924
|
}
|