@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/filescan.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(path, 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(path, 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(path) : path;
|
|
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 : path
|
|
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 path = originalPath && checkPath.convert(originalPath);
|
|
813
825
|
checkPath(
|
|
814
826
|
path,
|
|
815
827
|
originalPath,
|
|
816
828
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
817
829
|
);
|
|
818
|
-
return this._t(path, cache
|
|
830
|
+
return this._t(path, cache);
|
|
819
831
|
}
|
|
820
832
|
checkIgnore(path) {
|
|
821
833
|
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
822
834
|
return this.test(path);
|
|
823
835
|
}
|
|
824
|
-
const dir = this._t(path, this._testCache
|
|
836
|
+
const dir = this._t(path, this._testCache);
|
|
825
837
|
if (dir.ignored) {
|
|
826
838
|
return dir;
|
|
827
839
|
}
|
|
828
840
|
const literal2 = this._rules.testLiteral(path);
|
|
829
841
|
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
830
842
|
}
|
|
831
|
-
_t(path, cache
|
|
843
|
+
_t(path, cache) {
|
|
832
844
|
if (path in cache) {
|
|
833
845
|
return cache[path];
|
|
834
846
|
}
|
|
835
847
|
const parentPath = parentOf(path);
|
|
836
|
-
const parent = parentPath ? this._t(parentPath, cache
|
|
837
|
-
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path,
|
|
848
|
+
const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
|
|
849
|
+
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, MODE_IGNORE);
|
|
838
850
|
}
|
|
839
851
|
ignores(path) {
|
|
840
|
-
return this._test(path, this._ignoreCache
|
|
852
|
+
return this._test(path, this._ignoreCache).ignored;
|
|
841
853
|
}
|
|
842
854
|
createFilter() {
|
|
843
855
|
return (path) => !this.ignores(path);
|
|
@@ -847,7 +859,7 @@ var require_ignore = __commonJS({
|
|
|
847
859
|
}
|
|
848
860
|
// @returns {TestResult}
|
|
849
861
|
test(path) {
|
|
850
|
-
return this._test(path, this._testCache
|
|
862
|
+
return this._test(path, 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({
|
|
@@ -12519,7 +12543,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
12519
12543
|
var ListVaultInventoryQuery = object({
|
|
12520
12544
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12521
12545
|
// Opaque; names the last row of the page just served.
|
|
12522
|
-
cursor: string2().optional()
|
|
12546
|
+
cursor: string2().optional(),
|
|
12547
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12548
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12549
|
+
// from wherever it lands.
|
|
12550
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12523
12551
|
});
|
|
12524
12552
|
var ListVaultInventoryResponse = object({
|
|
12525
12553
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -12531,7 +12559,11 @@ var ListVaultInventoryResponse = object({
|
|
|
12531
12559
|
});
|
|
12532
12560
|
var ListVaultReuseQuery = object({
|
|
12533
12561
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12534
|
-
cursor: string2().optional()
|
|
12562
|
+
cursor: string2().optional(),
|
|
12563
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12564
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12565
|
+
// from wherever it lands.
|
|
12566
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12535
12567
|
});
|
|
12536
12568
|
var ListVaultReuseResponse = object({
|
|
12537
12569
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -12547,9 +12579,15 @@ var ListVaultDerefsQuery = object({
|
|
|
12547
12579
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
12548
12580
|
includeBatched: boolean2().optional(),
|
|
12549
12581
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12550
|
-
cursor: string2().optional()
|
|
12582
|
+
cursor: string2().optional(),
|
|
12583
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12584
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12585
|
+
// from wherever it lands.
|
|
12586
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12551
12587
|
});
|
|
12552
12588
|
var ListVaultDerefsResponse = object({
|
|
12589
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
12590
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
12553
12591
|
items: array(VaultDeref),
|
|
12554
12592
|
nextCursor: string2().nullable(),
|
|
12555
12593
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -21570,7 +21608,7 @@ var SqliteFindingsRepository = class {
|
|
|
21570
21608
|
};
|
|
21571
21609
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
21572
21610
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
21573
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
21611
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
21574
21612
|
const page = sorted.slice(start, start + limit);
|
|
21575
21613
|
const lastOnPage = page.at(-1);
|
|
21576
21614
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -21664,7 +21702,7 @@ var SqliteFindingsRepository = class {
|
|
|
21664
21702
|
accumulator.add(row);
|
|
21665
21703
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
21666
21704
|
total += 1;
|
|
21667
|
-
if (!isPastCursor(row)) continue;
|
|
21705
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
21668
21706
|
if (items.length < limit) {
|
|
21669
21707
|
items.push(toInstanceDetail(row));
|
|
21670
21708
|
last = row;
|
|
@@ -21753,7 +21791,7 @@ var SqliteFindingsRepository = class {
|
|
|
21753
21791
|
}
|
|
21754
21792
|
}
|
|
21755
21793
|
sorted.sort(compareLocationOrder);
|
|
21756
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
21794
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
21757
21795
|
const page = sorted.slice(start, start + limit);
|
|
21758
21796
|
const lastOnPage = page.at(-1);
|
|
21759
21797
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -24381,6 +24419,9 @@ function pageLimit(requested, fallback) {
|
|
|
24381
24419
|
if (requested === void 0) return fallback;
|
|
24382
24420
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
24383
24421
|
}
|
|
24422
|
+
function pageOffset(requested) {
|
|
24423
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
24424
|
+
}
|
|
24384
24425
|
function encodeReuseCursor(payload) {
|
|
24385
24426
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
24386
24427
|
}
|
|
@@ -24728,7 +24769,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24728
24769
|
*/
|
|
24729
24770
|
listInventory(query = {}, now = Date.now()) {
|
|
24730
24771
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24731
|
-
const
|
|
24772
|
+
const offset = pageOffset(query.offset);
|
|
24773
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24732
24774
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
24733
24775
|
const rows = allRows(
|
|
24734
24776
|
this.db.prepare(
|
|
@@ -24742,11 +24784,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
24742
24784
|
FROM secret_vault v
|
|
24743
24785
|
${where}
|
|
24744
24786
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
24745
|
-
LIMIT :limit`
|
|
24787
|
+
LIMIT :limit OFFSET :offset`
|
|
24746
24788
|
),
|
|
24747
24789
|
bindParams({
|
|
24748
24790
|
now,
|
|
24749
24791
|
limit: limit + 1,
|
|
24792
|
+
offset,
|
|
24750
24793
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
24751
24794
|
})
|
|
24752
24795
|
);
|
|
@@ -24770,7 +24813,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24770
24813
|
*/
|
|
24771
24814
|
listReuse(query = {}, now = Date.now()) {
|
|
24772
24815
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24773
|
-
const
|
|
24816
|
+
const offset = pageOffset(query.offset);
|
|
24817
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
24774
24818
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
24775
24819
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
24776
24820
|
const rows = allRows(
|
|
@@ -24785,11 +24829,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
24785
24829
|
FROM secret_vault v
|
|
24786
24830
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
24787
24831
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
24788
|
-
LIMIT :limit`
|
|
24832
|
+
LIMIT :limit OFFSET :offset`
|
|
24789
24833
|
),
|
|
24790
24834
|
bindParams({
|
|
24791
24835
|
now,
|
|
24792
24836
|
limit: limit + 1,
|
|
24837
|
+
offset,
|
|
24793
24838
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
24794
24839
|
})
|
|
24795
24840
|
);
|
|
@@ -24814,7 +24859,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24814
24859
|
*/
|
|
24815
24860
|
listDerefs(query = {}) {
|
|
24816
24861
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
24817
|
-
const
|
|
24862
|
+
const offset = pageOffset(query.offset);
|
|
24863
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24818
24864
|
const conditions = [];
|
|
24819
24865
|
if (query.includeBatched !== true) {
|
|
24820
24866
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -24827,21 +24873,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
24827
24873
|
this.db.prepare(
|
|
24828
24874
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
24829
24875
|
FROM secret_vault_deref ${where}
|
|
24830
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
24876
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
24831
24877
|
),
|
|
24832
24878
|
bindParams({
|
|
24833
24879
|
limit: limit + 1,
|
|
24880
|
+
offset,
|
|
24834
24881
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
24835
24882
|
})
|
|
24836
24883
|
);
|
|
24837
24884
|
const hasMore = rows.length > limit;
|
|
24838
24885
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
24839
24886
|
const last = page[page.length - 1];
|
|
24840
|
-
const
|
|
24841
|
-
this.db
|
|
24842
|
-
|
|
24843
|
-
|
|
24887
|
+
const counts = getRow(
|
|
24888
|
+
this.db.prepare(
|
|
24889
|
+
`SELECT count(*) AS total,
|
|
24890
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
24891
|
+
FROM secret_vault_deref`
|
|
24892
|
+
)
|
|
24893
|
+
) ?? { total: 0, hidden: 0 };
|
|
24894
|
+
const includeBatched = query.includeBatched === true;
|
|
24895
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
24844
24896
|
return {
|
|
24897
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
24845
24898
|
items: page.map((r) => ({
|
|
24846
24899
|
id: r.id,
|
|
24847
24900
|
pointerId: r.pointer_id,
|
|
@@ -24866,6 +24919,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
24866
24919
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
24867
24920
|
);
|
|
24868
24921
|
}
|
|
24922
|
+
/**
|
|
24923
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
24924
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
24925
|
+
* every row.
|
|
24926
|
+
*
|
|
24927
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
24928
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
24929
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
24930
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
24931
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
24932
|
+
*
|
|
24933
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
24934
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
24935
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
24936
|
+
*
|
|
24937
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
24938
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
24939
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
24940
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
24941
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
24942
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
24943
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
24944
|
+
*/
|
|
24945
|
+
countFingerprintEpochs(currentVersion) {
|
|
24946
|
+
const row = getRow(
|
|
24947
|
+
this.db.prepare(
|
|
24948
|
+
`SELECT COUNT(*) AS total,
|
|
24949
|
+
COALESCE(
|
|
24950
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
24951
|
+
0
|
|
24952
|
+
) AS stale
|
|
24953
|
+
FROM secret_vault`
|
|
24954
|
+
),
|
|
24955
|
+
{ currentVersion }
|
|
24956
|
+
) ?? { stale: 0, total: 0 };
|
|
24957
|
+
return { stale: row.stale, total: row.total };
|
|
24958
|
+
}
|
|
24869
24959
|
};
|
|
24870
24960
|
|
|
24871
24961
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -26695,13 +26785,22 @@ var SecretVault = class {
|
|
|
26695
26785
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
26696
26786
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
26697
26787
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
26788
|
+
*
|
|
26789
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
26790
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
26791
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
26792
|
+
* than a bare success count.
|
|
26698
26793
|
*/
|
|
26699
26794
|
async refreshFingerprints(next) {
|
|
26700
26795
|
let refreshed = 0;
|
|
26796
|
+
let skipped = 0;
|
|
26701
26797
|
for (const row of this.#repo.listAll()) {
|
|
26702
26798
|
try {
|
|
26703
26799
|
const raw = await this.#openRow(row);
|
|
26704
|
-
if (raw === null)
|
|
26800
|
+
if (raw === null) {
|
|
26801
|
+
skipped += 1;
|
|
26802
|
+
continue;
|
|
26803
|
+
}
|
|
26705
26804
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
26706
26805
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
26707
26806
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -26709,10 +26808,10 @@ var SecretVault = class {
|
|
|
26709
26808
|
});
|
|
26710
26809
|
refreshed += 1;
|
|
26711
26810
|
} catch {
|
|
26712
|
-
|
|
26811
|
+
skipped += 1;
|
|
26713
26812
|
}
|
|
26714
26813
|
}
|
|
26715
|
-
return refreshed;
|
|
26814
|
+
return { refreshed, skipped };
|
|
26716
26815
|
}
|
|
26717
26816
|
/**
|
|
26718
26817
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -29261,6 +29360,21 @@ function registerPack(pack) {
|
|
|
29261
29360
|
function getLoadedRules() {
|
|
29262
29361
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
29263
29362
|
}
|
|
29363
|
+
function outsideWrittenRegions(candidates, context) {
|
|
29364
|
+
const regions = context?.writtenRegions;
|
|
29365
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
29366
|
+
return candidates.filter((c) => {
|
|
29367
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
29368
|
+
const { start, end } = c.match.span;
|
|
29369
|
+
return !regions.some(
|
|
29370
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
29371
|
+
c.rule,
|
|
29372
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
29373
|
+
"code_change"
|
|
29374
|
+
)
|
|
29375
|
+
);
|
|
29376
|
+
});
|
|
29377
|
+
}
|
|
29264
29378
|
function spansOverlap(a, b) {
|
|
29265
29379
|
return a.start < b.end && a.end > b.start;
|
|
29266
29380
|
}
|
|
@@ -29448,17 +29562,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
29448
29562
|
function scanText(text, ruleset, context) {
|
|
29449
29563
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
29450
29564
|
const normalization = normalizeFormatChars(text);
|
|
29451
|
-
const originalCandidates =
|
|
29565
|
+
const originalCandidates = outsideWrittenRegions(
|
|
29566
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
29567
|
+
context
|
|
29568
|
+
);
|
|
29452
29569
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
29453
29570
|
const pooledOriginal = originalCandidates.map(
|
|
29454
29571
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
29455
29572
|
);
|
|
29456
|
-
const normalizedCandidates =
|
|
29457
|
-
normalization.normalized,
|
|
29458
|
-
|
|
29459
|
-
|
|
29460
|
-
context
|
|
29461
|
-
)
|
|
29573
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
29574
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
29575
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
29576
|
+
),
|
|
29577
|
+
context
|
|
29578
|
+
);
|
|
29462
29579
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
29463
29580
|
return mergeOverlappingSameRule(findings, text);
|
|
29464
29581
|
}
|
|
@@ -29519,6 +29636,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
29519
29636
|
"code-flaws/sql-inject-concat-dot",
|
|
29520
29637
|
"code-flaws/sql-inject-format",
|
|
29521
29638
|
"code-flaws/sql-inject-interp",
|
|
29639
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
29522
29640
|
"code-flaws/ssrf-user-url",
|
|
29523
29641
|
"code-flaws/xss-dangerously-set",
|
|
29524
29642
|
"code-flaws/xss-inner-html",
|
|
@@ -30657,7 +30775,7 @@ var sql_inject_concat_dot_default = {
|
|
|
30657
30775
|
severity: "high",
|
|
30658
30776
|
matcher: {
|
|
30659
30777
|
type: "regex",
|
|
30660
|
-
pattern:
|
|
30778
|
+
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*\\.",
|
|
30661
30779
|
flags: "gi"
|
|
30662
30780
|
},
|
|
30663
30781
|
appliesTo: {
|
|
@@ -30675,7 +30793,7 @@ var sql_inject_concat_default = {
|
|
|
30675
30793
|
severity: "high",
|
|
30676
30794
|
matcher: {
|
|
30677
30795
|
type: "regex",
|
|
30678
|
-
pattern:
|
|
30796
|
+
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*\\+",
|
|
30679
30797
|
flags: "gi"
|
|
30680
30798
|
},
|
|
30681
30799
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -30690,7 +30808,7 @@ var sql_inject_format_default = {
|
|
|
30690
30808
|
severity: "high",
|
|
30691
30809
|
matcher: {
|
|
30692
30810
|
type: "regex",
|
|
30693
|
-
pattern:
|
|
30811
|
+
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]+\\})",
|
|
30694
30812
|
flags: "gi"
|
|
30695
30813
|
},
|
|
30696
30814
|
examples: [
|
|
@@ -30699,6 +30817,24 @@ var sql_inject_format_default = {
|
|
|
30699
30817
|
]
|
|
30700
30818
|
};
|
|
30701
30819
|
|
|
30820
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
30821
|
+
var sql_inject_interp_multiline_default = {
|
|
30822
|
+
specVersion: 1,
|
|
30823
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
30824
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
30825
|
+
category: "code_flaw",
|
|
30826
|
+
severity: "high",
|
|
30827
|
+
matcher: {
|
|
30828
|
+
type: "regex",
|
|
30829
|
+
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_])',
|
|
30830
|
+
flags: "gi"
|
|
30831
|
+
},
|
|
30832
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
30833
|
+
appliesTo: {
|
|
30834
|
+
extensions: [".rb", ".php"]
|
|
30835
|
+
}
|
|
30836
|
+
};
|
|
30837
|
+
|
|
30702
30838
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
30703
30839
|
var sql_inject_interp_default = {
|
|
30704
30840
|
specVersion: 1,
|
|
@@ -30708,7 +30844,7 @@ var sql_inject_interp_default = {
|
|
|
30708
30844
|
severity: "high",
|
|
30709
30845
|
matcher: {
|
|
30710
30846
|
type: "regex",
|
|
30711
|
-
pattern: "([\
|
|
30847
|
+
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_])',
|
|
30712
30848
|
flags: "gi"
|
|
30713
30849
|
},
|
|
30714
30850
|
examples: [
|
|
@@ -32436,12 +32572,13 @@ var BUNDLED_PACKS = [
|
|
|
32436
32572
|
{
|
|
32437
32573
|
packId: "code-flaws",
|
|
32438
32574
|
name: "Code Security Flaws",
|
|
32439
|
-
version: "0.1.
|
|
32575
|
+
version: "0.1.6",
|
|
32440
32576
|
rawRules: [
|
|
32441
32577
|
sql_inject_concat_default,
|
|
32442
32578
|
sql_inject_concat_dot_default,
|
|
32443
32579
|
sql_inject_format_default,
|
|
32444
32580
|
sql_inject_interp_default,
|
|
32581
|
+
sql_inject_interp_multiline_default,
|
|
32445
32582
|
cmd_inject_shell_default,
|
|
32446
32583
|
cmd_inject_exec_default,
|
|
32447
32584
|
cmd_inject_node_exec_default,
|
|
@@ -32473,6 +32610,7 @@ var BUNDLED_PACKS = [
|
|
|
32473
32610
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
32474
32611
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
32475
32612
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
32613
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
32476
32614
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
32477
32615
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
32478
32616
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -33149,8 +33287,25 @@ function bundledMaskingRules() {
|
|
|
33149
33287
|
return ensureBundledPacks() ? getLoadedRules() : null;
|
|
33150
33288
|
}
|
|
33151
33289
|
|
|
33290
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
33291
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
33292
|
+
function notRegularFile(path) {
|
|
33293
|
+
return `not a regular file: ${path}`;
|
|
33294
|
+
}
|
|
33295
|
+
function readRegularFile(path, maxBytes) {
|
|
33296
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
33297
|
+
try {
|
|
33298
|
+
const stat2 = fstatSync(fd);
|
|
33299
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
33300
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
33301
|
+
return readFileSync16(fd, "utf8");
|
|
33302
|
+
} finally {
|
|
33303
|
+
closeSync2(fd);
|
|
33304
|
+
}
|
|
33305
|
+
}
|
|
33306
|
+
|
|
33152
33307
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
33153
|
-
import { existsSync as existsSync9,
|
|
33308
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
33154
33309
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
33155
33310
|
function remoteWithoutCredentials(remote) {
|
|
33156
33311
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -33261,9 +33416,10 @@ function resolveGitContext(root) {
|
|
|
33261
33416
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
33262
33417
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
33263
33418
|
}
|
|
33419
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
33264
33420
|
function safeRead(path) {
|
|
33265
33421
|
try {
|
|
33266
|
-
return
|
|
33422
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
33267
33423
|
} catch {
|
|
33268
33424
|
return void 0;
|
|
33269
33425
|
}
|
|
@@ -33584,6 +33740,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
33584
33740
|
text,
|
|
33585
33741
|
filePath: context?.filePath,
|
|
33586
33742
|
eventKind: context?.eventKind,
|
|
33743
|
+
writtenRegions: context?.writtenRegions,
|
|
33587
33744
|
attribute: scanOpts?.attribute === true
|
|
33588
33745
|
}),
|
|
33589
33746
|
reply: (message) => {
|
|
@@ -33883,11 +34040,10 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
33883
34040
|
|
|
33884
34041
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
33885
34042
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
33886
|
-
import { readFileSync as readFileSync17 } from "fs";
|
|
33887
34043
|
import { join as join25 } from "path";
|
|
33888
34044
|
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
33889
34045
|
try {
|
|
33890
|
-
return { matcher: (0, import_ignore.default)().add(
|
|
34046
|
+
return { matcher: (0, import_ignore.default)().add(readRegularFile(join25(dir, filename))), anchorLen };
|
|
33891
34047
|
} catch {
|
|
33892
34048
|
return void 0;
|
|
33893
34049
|
}
|
|
@@ -34385,7 +34541,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
34385
34541
|
input.text,
|
|
34386
34542
|
{
|
|
34387
34543
|
filePath: input.metadata?.filePath,
|
|
34388
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
34544
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
34545
|
+
writtenRegions: opts2.writtenRegions
|
|
34389
34546
|
},
|
|
34390
34547
|
{
|
|
34391
34548
|
sourceTool: input.sourceTool,
|
|
@@ -35275,7 +35432,7 @@ function renderMultiRepoSummary(summary, opts = {}) {
|
|
|
35275
35432
|
}
|
|
35276
35433
|
|
|
35277
35434
|
// ../../packages/scanner/src/scan.ts
|
|
35278
|
-
import { existsSync as existsSync13, readFileSync as
|
|
35435
|
+
import { existsSync as existsSync13, readFileSync as readFileSync25 } from "fs";
|
|
35279
35436
|
import { dirname as dirname13, extname as extname2, isAbsolute as isAbsolute4, relative as relative5 } from "path";
|
|
35280
35437
|
|
|
35281
35438
|
// ../../packages/plugin-runtime/src/account-scope.ts
|
|
@@ -36345,7 +36502,7 @@ function sessionToolIsKeyed(tool) {
|
|
|
36345
36502
|
|
|
36346
36503
|
// ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
|
|
36347
36504
|
import { createHash as createHash12 } from "crypto";
|
|
36348
|
-
import { readFileSync as
|
|
36505
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
36349
36506
|
import { join as join30 } from "path";
|
|
36350
36507
|
|
|
36351
36508
|
// ../../packages/plugin-runtime/src/attached/config-inventory-wire.ts
|
|
@@ -36445,7 +36602,7 @@ async function publishByRename(tmp, file, move = rename2) {
|
|
|
36445
36602
|
|
|
36446
36603
|
// ../../packages/plugin-runtime/src/attached/capture-settings.ts
|
|
36447
36604
|
import { randomUUID as randomUUID18 } from "crypto";
|
|
36448
|
-
import { readFileSync as
|
|
36605
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
36449
36606
|
import { rm, writeFile as writeFile2 } from "fs/promises";
|
|
36450
36607
|
import { join as join28 } from "path";
|
|
36451
36608
|
var HookCaptureSettingsSchema = CaptureSettings.pick({
|
|
@@ -36833,7 +36990,7 @@ function reportKey(request) {
|
|
|
36833
36990
|
function readStagedEntries(dataDir2) {
|
|
36834
36991
|
let parsed2;
|
|
36835
36992
|
try {
|
|
36836
|
-
parsed2 = JSON.parse(
|
|
36993
|
+
parsed2 = JSON.parse(readFileSync18(stagedConfigInventoryPath(dataDir2), "utf8"));
|
|
36837
36994
|
} catch {
|
|
36838
36995
|
return [];
|
|
36839
36996
|
}
|
|
@@ -36857,7 +37014,7 @@ function isTimestamp(value) {
|
|
|
36857
37014
|
}
|
|
36858
37015
|
|
|
36859
37016
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
36860
|
-
import { readFileSync as
|
|
37017
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
36861
37018
|
import { join as join31 } from "path";
|
|
36862
37019
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
36863
37020
|
function forwardDropsPath(dataDir2) {
|
|
@@ -36879,7 +37036,7 @@ function recordForwardDrops(dataDir2, count, nowMs) {
|
|
|
36879
37036
|
}
|
|
36880
37037
|
function readForwardDrops(dataDir2) {
|
|
36881
37038
|
try {
|
|
36882
|
-
const parsed2 = JSON.parse(
|
|
37039
|
+
const parsed2 = JSON.parse(readFileSync19(forwardDropsPath(dataDir2), "utf8"));
|
|
36883
37040
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
36884
37041
|
const record2 = parsed2;
|
|
36885
37042
|
if (typeof record2.droppedForwards !== "number" || !Number.isFinite(record2.droppedForwards)) {
|
|
@@ -37983,7 +38140,7 @@ function toWireInspection(insp, nameKey) {
|
|
|
37983
38140
|
}
|
|
37984
38141
|
|
|
37985
38142
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
37986
|
-
import { readFileSync as
|
|
38143
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
37987
38144
|
|
|
37988
38145
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
37989
38146
|
import { readFile as readFile3, stat } from "fs/promises";
|
|
@@ -38056,7 +38213,7 @@ async function readInstalledVersionBounded(installRoot) {
|
|
|
38056
38213
|
}
|
|
38057
38214
|
|
|
38058
38215
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
38059
|
-
import { readFileSync as
|
|
38216
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
38060
38217
|
import { join as join33 } from "path";
|
|
38061
38218
|
var POSTURE_REPORT_STATE_FILENAME = ATTACHED_POSTURE_REPORT_FILENAME;
|
|
38062
38219
|
var OUTCOME_KEYS = {
|
|
@@ -38332,11 +38489,11 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
|
38332
38489
|
}
|
|
38333
38490
|
|
|
38334
38491
|
// ../../packages/plugin-runtime/src/attached/label-drops.ts
|
|
38335
|
-
import { readFileSync as
|
|
38492
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
38336
38493
|
import { join as join35 } from "path";
|
|
38337
38494
|
|
|
38338
38495
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
38339
|
-
import { readFileSync as
|
|
38496
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
38340
38497
|
import { join as join36 } from "path";
|
|
38341
38498
|
|
|
38342
38499
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
@@ -38544,7 +38701,7 @@ function sendScanSightings(base, input, deps = {}) {
|
|
|
38544
38701
|
import { statSync as statSync11 } from "fs";
|
|
38545
38702
|
|
|
38546
38703
|
// ../../packages/scanner/src/walk.ts
|
|
38547
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
38704
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync24, statSync as statSync10 } from "fs";
|
|
38548
38705
|
import { homedir as homedir3 } from "os";
|
|
38549
38706
|
import { join as join38, relative as relative4, sep as sep7 } from "path";
|
|
38550
38707
|
var import_ignore2 = __toESM(require_ignore(), 1);
|
|
@@ -38672,7 +38829,7 @@ function* walkSourceFiles(opts = {}) {
|
|
|
38672
38829
|
if (opts.shouldRead && !opts.shouldRead(meta3)) continue;
|
|
38673
38830
|
let content;
|
|
38674
38831
|
try {
|
|
38675
|
-
content =
|
|
38832
|
+
content = readFileSync24(file.path, "utf8");
|
|
38676
38833
|
} catch {
|
|
38677
38834
|
continue;
|
|
38678
38835
|
}
|
|
@@ -39120,7 +39277,7 @@ function scanManifests(egress, ledger, updates, rootDir, scopeKeyOf2, onReposito
|
|
|
39120
39277
|
}
|
|
39121
39278
|
let content;
|
|
39122
39279
|
try {
|
|
39123
|
-
content =
|
|
39280
|
+
content = readFileSync25(manifest.path, "utf8");
|
|
39124
39281
|
} catch {
|
|
39125
39282
|
continue;
|
|
39126
39283
|
}
|