@akasecurity/ai-tc-copilot 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/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/content-retention.js +97 -19
- package/scripts/fail-open-count.js +32 -6
- package/scripts/history-sync.js +160 -34
- package/scripts/post-tool-use.js +183 -37
- package/scripts/pre-tool-use.js +183 -37
- package/scripts/scan-worker.js +74 -14
- package/scripts/session-start.js +254 -94
- package/scripts/sync.js +244 -87
- package/scripts/user-prompt-submit.js +183 -37
package/scripts/session-start.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) + SPACE : run,
|
|
228
229
|
ESCAPE + SPACE
|
|
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 basename8 = 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 ? basename8 : 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 = (message2, 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);
|
|
@@ -9647,7 +9659,11 @@ var ListFindingTypesQuery = object({
|
|
|
9647
9659
|
// and so is not bounded by what any page happens to hold.
|
|
9648
9660
|
includeId: string2().optional(),
|
|
9649
9661
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
9650
|
-
cursor: string2().optional()
|
|
9662
|
+
cursor: string2().optional(),
|
|
9663
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9664
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9665
|
+
// from wherever it lands.
|
|
9666
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9651
9667
|
});
|
|
9652
9668
|
var ListFindingTypesResponse = object({
|
|
9653
9669
|
totals: object({
|
|
@@ -9728,7 +9744,11 @@ var ListFindingInstancesQuery = object({
|
|
|
9728
9744
|
sessionId: string2().optional(),
|
|
9729
9745
|
from: iso_exports.datetime().optional(),
|
|
9730
9746
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
9731
|
-
cursor: string2().optional()
|
|
9747
|
+
cursor: string2().optional(),
|
|
9748
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9749
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9750
|
+
// from wherever it lands.
|
|
9751
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9732
9752
|
});
|
|
9733
9753
|
var ListFindingInstancesResponse = object({
|
|
9734
9754
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -9800,7 +9820,11 @@ var ListFindingLocationsQuery = object({
|
|
|
9800
9820
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
9801
9821
|
includeId: string2().optional(),
|
|
9802
9822
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
9803
|
-
cursor: string2().optional()
|
|
9823
|
+
cursor: string2().optional(),
|
|
9824
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9825
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9826
|
+
// from wherever it lands.
|
|
9827
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9804
9828
|
});
|
|
9805
9829
|
var ListFindingLocationsResponse = object({
|
|
9806
9830
|
totals: object({
|
|
@@ -12432,7 +12456,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
12432
12456
|
var ListVaultInventoryQuery = object({
|
|
12433
12457
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12434
12458
|
// Opaque; names the last row of the page just served.
|
|
12435
|
-
cursor: string2().optional()
|
|
12459
|
+
cursor: string2().optional(),
|
|
12460
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12461
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12462
|
+
// from wherever it lands.
|
|
12463
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12436
12464
|
});
|
|
12437
12465
|
var ListVaultInventoryResponse = object({
|
|
12438
12466
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -12444,7 +12472,11 @@ var ListVaultInventoryResponse = object({
|
|
|
12444
12472
|
});
|
|
12445
12473
|
var ListVaultReuseQuery = object({
|
|
12446
12474
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12447
|
-
cursor: string2().optional()
|
|
12475
|
+
cursor: string2().optional(),
|
|
12476
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12477
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12478
|
+
// from wherever it lands.
|
|
12479
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12448
12480
|
});
|
|
12449
12481
|
var ListVaultReuseResponse = object({
|
|
12450
12482
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -12460,9 +12492,15 @@ var ListVaultDerefsQuery = object({
|
|
|
12460
12492
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
12461
12493
|
includeBatched: boolean2().optional(),
|
|
12462
12494
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12463
|
-
cursor: string2().optional()
|
|
12495
|
+
cursor: string2().optional(),
|
|
12496
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12497
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12498
|
+
// from wherever it lands.
|
|
12499
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12464
12500
|
});
|
|
12465
12501
|
var ListVaultDerefsResponse = object({
|
|
12502
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
12503
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
12466
12504
|
items: array(VaultDeref),
|
|
12467
12505
|
nextCursor: string2().nullable(),
|
|
12468
12506
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -21474,7 +21512,7 @@ var SqliteFindingsRepository = class {
|
|
|
21474
21512
|
};
|
|
21475
21513
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
21476
21514
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
21477
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
21515
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
21478
21516
|
const page = sorted.slice(start, start + limit);
|
|
21479
21517
|
const lastOnPage = page.at(-1);
|
|
21480
21518
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -21568,7 +21606,7 @@ var SqliteFindingsRepository = class {
|
|
|
21568
21606
|
accumulator.add(row);
|
|
21569
21607
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
21570
21608
|
total += 1;
|
|
21571
|
-
if (!isPastCursor(row)) continue;
|
|
21609
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
21572
21610
|
if (items.length < limit) {
|
|
21573
21611
|
items.push(toInstanceDetail(row));
|
|
21574
21612
|
last = row;
|
|
@@ -21657,7 +21695,7 @@ var SqliteFindingsRepository = class {
|
|
|
21657
21695
|
}
|
|
21658
21696
|
}
|
|
21659
21697
|
sorted.sort(compareLocationOrder);
|
|
21660
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
21698
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
21661
21699
|
const page = sorted.slice(start, start + limit);
|
|
21662
21700
|
const lastOnPage = page.at(-1);
|
|
21663
21701
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -24285,6 +24323,9 @@ function pageLimit(requested, fallback) {
|
|
|
24285
24323
|
if (requested === void 0) return fallback;
|
|
24286
24324
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
24287
24325
|
}
|
|
24326
|
+
function pageOffset(requested) {
|
|
24327
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
24328
|
+
}
|
|
24288
24329
|
function encodeReuseCursor(payload) {
|
|
24289
24330
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
24290
24331
|
}
|
|
@@ -24632,7 +24673,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24632
24673
|
*/
|
|
24633
24674
|
listInventory(query = {}, now = Date.now()) {
|
|
24634
24675
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24635
|
-
const
|
|
24676
|
+
const offset = pageOffset(query.offset);
|
|
24677
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24636
24678
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
24637
24679
|
const rows = allRows(
|
|
24638
24680
|
this.db.prepare(
|
|
@@ -24646,11 +24688,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
24646
24688
|
FROM secret_vault v
|
|
24647
24689
|
${where}
|
|
24648
24690
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
24649
|
-
LIMIT :limit`
|
|
24691
|
+
LIMIT :limit OFFSET :offset`
|
|
24650
24692
|
),
|
|
24651
24693
|
bindParams({
|
|
24652
24694
|
now,
|
|
24653
24695
|
limit: limit + 1,
|
|
24696
|
+
offset,
|
|
24654
24697
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
24655
24698
|
})
|
|
24656
24699
|
);
|
|
@@ -24674,7 +24717,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24674
24717
|
*/
|
|
24675
24718
|
listReuse(query = {}, now = Date.now()) {
|
|
24676
24719
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24677
|
-
const
|
|
24720
|
+
const offset = pageOffset(query.offset);
|
|
24721
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
24678
24722
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
24679
24723
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
24680
24724
|
const rows = allRows(
|
|
@@ -24689,11 +24733,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
24689
24733
|
FROM secret_vault v
|
|
24690
24734
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
24691
24735
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
24692
|
-
LIMIT :limit`
|
|
24736
|
+
LIMIT :limit OFFSET :offset`
|
|
24693
24737
|
),
|
|
24694
24738
|
bindParams({
|
|
24695
24739
|
now,
|
|
24696
24740
|
limit: limit + 1,
|
|
24741
|
+
offset,
|
|
24697
24742
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
24698
24743
|
})
|
|
24699
24744
|
);
|
|
@@ -24718,7 +24763,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24718
24763
|
*/
|
|
24719
24764
|
listDerefs(query = {}) {
|
|
24720
24765
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
24721
|
-
const
|
|
24766
|
+
const offset = pageOffset(query.offset);
|
|
24767
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24722
24768
|
const conditions = [];
|
|
24723
24769
|
if (query.includeBatched !== true) {
|
|
24724
24770
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -24731,21 +24777,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
24731
24777
|
this.db.prepare(
|
|
24732
24778
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
24733
24779
|
FROM secret_vault_deref ${where}
|
|
24734
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
24780
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
24735
24781
|
),
|
|
24736
24782
|
bindParams({
|
|
24737
24783
|
limit: limit + 1,
|
|
24784
|
+
offset,
|
|
24738
24785
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
24739
24786
|
})
|
|
24740
24787
|
);
|
|
24741
24788
|
const hasMore = rows.length > limit;
|
|
24742
24789
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
24743
24790
|
const last = page[page.length - 1];
|
|
24744
|
-
const
|
|
24745
|
-
this.db
|
|
24746
|
-
|
|
24747
|
-
|
|
24791
|
+
const counts = getRow(
|
|
24792
|
+
this.db.prepare(
|
|
24793
|
+
`SELECT count(*) AS total,
|
|
24794
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
24795
|
+
FROM secret_vault_deref`
|
|
24796
|
+
)
|
|
24797
|
+
) ?? { total: 0, hidden: 0 };
|
|
24798
|
+
const includeBatched = query.includeBatched === true;
|
|
24799
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
24748
24800
|
return {
|
|
24801
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
24749
24802
|
items: page.map((r) => ({
|
|
24750
24803
|
id: r.id,
|
|
24751
24804
|
pointerId: r.pointer_id,
|
|
@@ -24770,6 +24823,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
24770
24823
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
24771
24824
|
);
|
|
24772
24825
|
}
|
|
24826
|
+
/**
|
|
24827
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
24828
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
24829
|
+
* every row.
|
|
24830
|
+
*
|
|
24831
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
24832
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
24833
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
24834
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
24835
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
24836
|
+
*
|
|
24837
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
24838
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
24839
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
24840
|
+
*
|
|
24841
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
24842
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
24843
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
24844
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
24845
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
24846
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
24847
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
24848
|
+
*/
|
|
24849
|
+
countFingerprintEpochs(currentVersion) {
|
|
24850
|
+
const row = getRow(
|
|
24851
|
+
this.db.prepare(
|
|
24852
|
+
`SELECT COUNT(*) AS total,
|
|
24853
|
+
COALESCE(
|
|
24854
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
24855
|
+
0
|
|
24856
|
+
) AS stale
|
|
24857
|
+
FROM secret_vault`
|
|
24858
|
+
),
|
|
24859
|
+
{ currentVersion }
|
|
24860
|
+
) ?? { stale: 0, total: 0 };
|
|
24861
|
+
return { stale: row.stale, total: row.total };
|
|
24862
|
+
}
|
|
24773
24863
|
};
|
|
24774
24864
|
|
|
24775
24865
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -26568,13 +26658,22 @@ var SecretVault = class {
|
|
|
26568
26658
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
26569
26659
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
26570
26660
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
26661
|
+
*
|
|
26662
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
26663
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
26664
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
26665
|
+
* than a bare success count.
|
|
26571
26666
|
*/
|
|
26572
26667
|
async refreshFingerprints(next) {
|
|
26573
26668
|
let refreshed = 0;
|
|
26669
|
+
let skipped = 0;
|
|
26574
26670
|
for (const row of this.#repo.listAll()) {
|
|
26575
26671
|
try {
|
|
26576
26672
|
const raw = await this.#openRow(row);
|
|
26577
|
-
if (raw === null)
|
|
26673
|
+
if (raw === null) {
|
|
26674
|
+
skipped += 1;
|
|
26675
|
+
continue;
|
|
26676
|
+
}
|
|
26578
26677
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
26579
26678
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
26580
26679
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -26582,10 +26681,10 @@ var SecretVault = class {
|
|
|
26582
26681
|
});
|
|
26583
26682
|
refreshed += 1;
|
|
26584
26683
|
} catch {
|
|
26585
|
-
|
|
26684
|
+
skipped += 1;
|
|
26586
26685
|
}
|
|
26587
26686
|
}
|
|
26588
|
-
return refreshed;
|
|
26687
|
+
return { refreshed, skipped };
|
|
26589
26688
|
}
|
|
26590
26689
|
/**
|
|
26591
26690
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -27924,6 +28023,21 @@ function registerPack(pack) {
|
|
|
27924
28023
|
function getLoadedRules() {
|
|
27925
28024
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
27926
28025
|
}
|
|
28026
|
+
function outsideWrittenRegions(candidates, context) {
|
|
28027
|
+
const regions = context?.writtenRegions;
|
|
28028
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
28029
|
+
return candidates.filter((c) => {
|
|
28030
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
28031
|
+
const { start, end } = c.match.span;
|
|
28032
|
+
return !regions.some(
|
|
28033
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
28034
|
+
c.rule,
|
|
28035
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
28036
|
+
"code_change"
|
|
28037
|
+
)
|
|
28038
|
+
);
|
|
28039
|
+
});
|
|
28040
|
+
}
|
|
27927
28041
|
function spansOverlap(a, b) {
|
|
27928
28042
|
return a.start < b.end && a.end > b.start;
|
|
27929
28043
|
}
|
|
@@ -28111,17 +28225,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
28111
28225
|
function scanText(text, ruleset, context) {
|
|
28112
28226
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
28113
28227
|
const normalization = normalizeFormatChars(text);
|
|
28114
|
-
const originalCandidates =
|
|
28228
|
+
const originalCandidates = outsideWrittenRegions(
|
|
28229
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
28230
|
+
context
|
|
28231
|
+
);
|
|
28115
28232
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
28116
28233
|
const pooledOriginal = originalCandidates.map(
|
|
28117
28234
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
28118
28235
|
);
|
|
28119
|
-
const normalizedCandidates =
|
|
28120
|
-
normalization.normalized,
|
|
28121
|
-
|
|
28122
|
-
|
|
28123
|
-
context
|
|
28124
|
-
)
|
|
28236
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
28237
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
28238
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
28239
|
+
),
|
|
28240
|
+
context
|
|
28241
|
+
);
|
|
28125
28242
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
28126
28243
|
return mergeOverlappingSameRule(findings, text);
|
|
28127
28244
|
}
|
|
@@ -28182,6 +28299,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
28182
28299
|
"code-flaws/sql-inject-concat-dot",
|
|
28183
28300
|
"code-flaws/sql-inject-format",
|
|
28184
28301
|
"code-flaws/sql-inject-interp",
|
|
28302
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
28185
28303
|
"code-flaws/ssrf-user-url",
|
|
28186
28304
|
"code-flaws/xss-dangerously-set",
|
|
28187
28305
|
"code-flaws/xss-inner-html",
|
|
@@ -29474,7 +29592,7 @@ var sql_inject_concat_dot_default = {
|
|
|
29474
29592
|
severity: "high",
|
|
29475
29593
|
matcher: {
|
|
29476
29594
|
type: "regex",
|
|
29477
|
-
pattern:
|
|
29595
|
+
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*\\.",
|
|
29478
29596
|
flags: "gi"
|
|
29479
29597
|
},
|
|
29480
29598
|
appliesTo: {
|
|
@@ -29492,7 +29610,7 @@ var sql_inject_concat_default = {
|
|
|
29492
29610
|
severity: "high",
|
|
29493
29611
|
matcher: {
|
|
29494
29612
|
type: "regex",
|
|
29495
|
-
pattern:
|
|
29613
|
+
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*\\+",
|
|
29496
29614
|
flags: "gi"
|
|
29497
29615
|
},
|
|
29498
29616
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -29507,7 +29625,7 @@ var sql_inject_format_default = {
|
|
|
29507
29625
|
severity: "high",
|
|
29508
29626
|
matcher: {
|
|
29509
29627
|
type: "regex",
|
|
29510
|
-
pattern:
|
|
29628
|
+
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]+\\})",
|
|
29511
29629
|
flags: "gi"
|
|
29512
29630
|
},
|
|
29513
29631
|
examples: [
|
|
@@ -29516,6 +29634,24 @@ var sql_inject_format_default = {
|
|
|
29516
29634
|
]
|
|
29517
29635
|
};
|
|
29518
29636
|
|
|
29637
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
29638
|
+
var sql_inject_interp_multiline_default = {
|
|
29639
|
+
specVersion: 1,
|
|
29640
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
29641
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
29642
|
+
category: "code_flaw",
|
|
29643
|
+
severity: "high",
|
|
29644
|
+
matcher: {
|
|
29645
|
+
type: "regex",
|
|
29646
|
+
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_])',
|
|
29647
|
+
flags: "gi"
|
|
29648
|
+
},
|
|
29649
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
29650
|
+
appliesTo: {
|
|
29651
|
+
extensions: [".rb", ".php"]
|
|
29652
|
+
}
|
|
29653
|
+
};
|
|
29654
|
+
|
|
29519
29655
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
29520
29656
|
var sql_inject_interp_default = {
|
|
29521
29657
|
specVersion: 1,
|
|
@@ -29525,7 +29661,7 @@ var sql_inject_interp_default = {
|
|
|
29525
29661
|
severity: "high",
|
|
29526
29662
|
matcher: {
|
|
29527
29663
|
type: "regex",
|
|
29528
|
-
pattern: "([\
|
|
29664
|
+
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_])',
|
|
29529
29665
|
flags: "gi"
|
|
29530
29666
|
},
|
|
29531
29667
|
examples: [
|
|
@@ -31253,12 +31389,13 @@ var BUNDLED_PACKS = [
|
|
|
31253
31389
|
{
|
|
31254
31390
|
packId: "code-flaws",
|
|
31255
31391
|
name: "Code Security Flaws",
|
|
31256
|
-
version: "0.1.
|
|
31392
|
+
version: "0.1.6",
|
|
31257
31393
|
rawRules: [
|
|
31258
31394
|
sql_inject_concat_default,
|
|
31259
31395
|
sql_inject_concat_dot_default,
|
|
31260
31396
|
sql_inject_format_default,
|
|
31261
31397
|
sql_inject_interp_default,
|
|
31398
|
+
sql_inject_interp_multiline_default,
|
|
31262
31399
|
cmd_inject_shell_default,
|
|
31263
31400
|
cmd_inject_exec_default,
|
|
31264
31401
|
cmd_inject_node_exec_default,
|
|
@@ -31290,6 +31427,7 @@ var BUNDLED_PACKS = [
|
|
|
31290
31427
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
31291
31428
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
31292
31429
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
31430
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
31293
31431
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
31294
31432
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
31295
31433
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -31640,7 +31778,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
31640
31778
|
}
|
|
31641
31779
|
|
|
31642
31780
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
31643
|
-
import { readdirSync as readdirSync3,
|
|
31781
|
+
import { readdirSync as readdirSync3, realpathSync as realpathSync2, statSync as statSync8 } from "fs";
|
|
31644
31782
|
import { homedir as homedir3 } from "os";
|
|
31645
31783
|
import { basename as basename4, join as join25, resolve as resolve3 } from "path";
|
|
31646
31784
|
|
|
@@ -32013,8 +32151,25 @@ function maskText(text) {
|
|
|
32013
32151
|
return scanText2(text).masked;
|
|
32014
32152
|
}
|
|
32015
32153
|
|
|
32154
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
32155
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
32156
|
+
function notRegularFile(path) {
|
|
32157
|
+
return `not a regular file: ${path}`;
|
|
32158
|
+
}
|
|
32159
|
+
function readRegularFile(path, maxBytes) {
|
|
32160
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
32161
|
+
try {
|
|
32162
|
+
const stat2 = fstatSync(fd);
|
|
32163
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
32164
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
32165
|
+
return readFileSync16(fd, "utf8");
|
|
32166
|
+
} finally {
|
|
32167
|
+
closeSync2(fd);
|
|
32168
|
+
}
|
|
32169
|
+
}
|
|
32170
|
+
|
|
32016
32171
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
32017
|
-
import { existsSync as existsSync9,
|
|
32172
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
32018
32173
|
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
32019
32174
|
function remoteWithoutCredentials(remote) {
|
|
32020
32175
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -32185,9 +32340,10 @@ function resolveGitContext(root) {
|
|
|
32185
32340
|
const headRoot = basename3(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
32186
32341
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
32187
32342
|
}
|
|
32343
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
32188
32344
|
function safeRead(path) {
|
|
32189
32345
|
try {
|
|
32190
|
-
return
|
|
32346
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
32191
32347
|
} catch {
|
|
32192
32348
|
return void 0;
|
|
32193
32349
|
}
|
|
@@ -32478,9 +32634,13 @@ function collectConfigFiles(scan2, claudeDir, cwd) {
|
|
|
32478
32634
|
dirConfigFile(scan2, join25(cwd, ".claude", "commands"), "Slash commands", "command");
|
|
32479
32635
|
dirConfigFile(scan2, join25(cwd, ".claude", "agents"), "Subagents", "subagent");
|
|
32480
32636
|
}
|
|
32481
|
-
function configFileEntry(scan2, path, scope, kind) {
|
|
32637
|
+
function configFileEntry(scan2, path, scope, kind, nonFile) {
|
|
32482
32638
|
try {
|
|
32483
32639
|
const stat2 = statSync8(path);
|
|
32640
|
+
if (nonFile !== "keep" && !stat2.isFile()) {
|
|
32641
|
+
if (nonFile === "report") scan2.errors.push({ source: path, reason: notRegularFile(path) });
|
|
32642
|
+
return void 0;
|
|
32643
|
+
}
|
|
32484
32644
|
return { name: basename4(path), path, scope, kind, updatedAt: stat2.mtime.toISOString() };
|
|
32485
32645
|
} catch (err) {
|
|
32486
32646
|
if (!isAbsent(err)) scan2.errors.push({ source: path, reason: message(err) });
|
|
@@ -32488,7 +32648,7 @@ function configFileEntry(scan2, path, scope, kind) {
|
|
|
32488
32648
|
}
|
|
32489
32649
|
}
|
|
32490
32650
|
function settingsConfigFile(scan2, path, scope, kind) {
|
|
32491
|
-
const entry = configFileEntry(scan2, path, scope, kind);
|
|
32651
|
+
const entry = configFileEntry(scan2, path, scope, kind, "skip");
|
|
32492
32652
|
if (!entry) return;
|
|
32493
32653
|
const raw = readOptional(scan2, path, false);
|
|
32494
32654
|
if (raw !== void 0) {
|
|
@@ -32506,7 +32666,7 @@ function settingsConfigFile(scan2, path, scope, kind) {
|
|
|
32506
32666
|
scan2.configFiles.push(entry);
|
|
32507
32667
|
}
|
|
32508
32668
|
function memoryConfigFile(scan2, path, scope, kind) {
|
|
32509
|
-
const entry = configFileEntry(scan2, path, scope, kind);
|
|
32669
|
+
const entry = configFileEntry(scan2, path, scope, kind, "report");
|
|
32510
32670
|
if (!entry) return;
|
|
32511
32671
|
const raw = readOptional(scan2, path);
|
|
32512
32672
|
if (raw !== void 0) {
|
|
@@ -32517,7 +32677,7 @@ function memoryConfigFile(scan2, path, scope, kind) {
|
|
|
32517
32677
|
scan2.configFiles.push(entry);
|
|
32518
32678
|
}
|
|
32519
32679
|
function mcpJsonConfigFile(scan2, path) {
|
|
32520
|
-
const entry = configFileEntry(scan2, path, "project", "MCP servers");
|
|
32680
|
+
const entry = configFileEntry(scan2, path, "project", "MCP servers", "skip");
|
|
32521
32681
|
if (!entry) return;
|
|
32522
32682
|
const raw = readOptional(scan2, path, false);
|
|
32523
32683
|
if (raw !== void 0) {
|
|
@@ -32537,7 +32697,7 @@ function mcpJsonConfigFile(scan2, path) {
|
|
|
32537
32697
|
scan2.configFiles.push(entry);
|
|
32538
32698
|
}
|
|
32539
32699
|
function dirConfigFile(scan2, path, kind, noun) {
|
|
32540
|
-
const entry = configFileEntry(scan2, path, "project", kind);
|
|
32700
|
+
const entry = configFileEntry(scan2, path, "project", kind, "keep");
|
|
32541
32701
|
if (!entry) return;
|
|
32542
32702
|
try {
|
|
32543
32703
|
const count = countMarkdownFiles(path, 0);
|
|
@@ -32733,7 +32893,7 @@ function dedupeMcpServers(servers) {
|
|
|
32733
32893
|
}
|
|
32734
32894
|
function readOptional(scan2, path, record2 = true) {
|
|
32735
32895
|
try {
|
|
32736
|
-
return
|
|
32896
|
+
return readRegularFile(path);
|
|
32737
32897
|
} catch (err) {
|
|
32738
32898
|
if (record2 && !isAbsent(err)) scan2.errors.push({ source: path, reason: message(err) });
|
|
32739
32899
|
return void 0;
|
|
@@ -33013,6 +33173,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
33013
33173
|
text,
|
|
33014
33174
|
filePath: context?.filePath,
|
|
33015
33175
|
eventKind: context?.eventKind,
|
|
33176
|
+
writtenRegions: context?.writtenRegions,
|
|
33016
33177
|
attribute: scanOpts?.attribute === true
|
|
33017
33178
|
}),
|
|
33018
33179
|
reply: (message2) => {
|
|
@@ -33312,11 +33473,10 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
33312
33473
|
|
|
33313
33474
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
33314
33475
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
33315
|
-
import { readFileSync as readFileSync18 } from "fs";
|
|
33316
33476
|
import { join as join26 } from "path";
|
|
33317
33477
|
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
33318
33478
|
try {
|
|
33319
|
-
return { matcher: (0, import_ignore.default)().add(
|
|
33479
|
+
return { matcher: (0, import_ignore.default)().add(readRegularFile(join26(dir, filename))), anchorLen };
|
|
33320
33480
|
} catch {
|
|
33321
33481
|
return void 0;
|
|
33322
33482
|
}
|
|
@@ -33373,7 +33533,7 @@ function resolveInventoryContext(input) {
|
|
|
33373
33533
|
}
|
|
33374
33534
|
|
|
33375
33535
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
33376
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
33536
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync17, writeFileSync as writeFileSync5 } from "fs";
|
|
33377
33537
|
import { join as join27 } from "path";
|
|
33378
33538
|
var SESSION_START_MARKER = "session-start-last";
|
|
33379
33539
|
function claimSessionStart(dataDir2, sessionId) {
|
|
@@ -33385,7 +33545,7 @@ function claimOncePerSession(dataDir2, marker, sessionId) {
|
|
|
33385
33545
|
const path = join27(dataDir2, marker);
|
|
33386
33546
|
let recent = [];
|
|
33387
33547
|
try {
|
|
33388
|
-
recent =
|
|
33548
|
+
recent = readFileSync17(path, "utf8").split("\n").filter(Boolean);
|
|
33389
33549
|
if (recent.includes(sessionId)) return false;
|
|
33390
33550
|
} catch {
|
|
33391
33551
|
}
|
|
@@ -34709,7 +34869,7 @@ function sessionToolIsKeyed(tool) {
|
|
|
34709
34869
|
|
|
34710
34870
|
// ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
|
|
34711
34871
|
import { createHash as createHash11 } from "crypto";
|
|
34712
|
-
import { readFileSync as
|
|
34872
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
34713
34873
|
import { join as join34 } from "path";
|
|
34714
34874
|
|
|
34715
34875
|
// ../../packages/plugin-runtime/src/attached/config-inventory-wire.ts
|
|
@@ -34809,7 +34969,7 @@ async function publishByRename(tmp, file, move = rename2) {
|
|
|
34809
34969
|
|
|
34810
34970
|
// ../../packages/plugin-runtime/src/attached/capture-settings.ts
|
|
34811
34971
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
34812
|
-
import { readFileSync as
|
|
34972
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
34813
34973
|
import { rm, writeFile as writeFile2 } from "fs/promises";
|
|
34814
34974
|
import { join as join32 } from "path";
|
|
34815
34975
|
var HookCaptureSettingsSchema = CaptureSettings.pick({
|
|
@@ -35197,7 +35357,7 @@ function reportKey(request) {
|
|
|
35197
35357
|
function readStagedEntries(dataDir2) {
|
|
35198
35358
|
let parsed2;
|
|
35199
35359
|
try {
|
|
35200
|
-
parsed2 = JSON.parse(
|
|
35360
|
+
parsed2 = JSON.parse(readFileSync19(stagedConfigInventoryPath(dataDir2), "utf8"));
|
|
35201
35361
|
} catch {
|
|
35202
35362
|
return [];
|
|
35203
35363
|
}
|
|
@@ -35221,7 +35381,7 @@ function isTimestamp(value) {
|
|
|
35221
35381
|
}
|
|
35222
35382
|
|
|
35223
35383
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
35224
|
-
import { readFileSync as
|
|
35384
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
35225
35385
|
import { join as join35 } from "path";
|
|
35226
35386
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
35227
35387
|
function forwardDropsPath(dataDir2) {
|
|
@@ -35243,7 +35403,7 @@ function recordForwardDrops(dataDir2, count, nowMs) {
|
|
|
35243
35403
|
}
|
|
35244
35404
|
function readForwardDrops(dataDir2) {
|
|
35245
35405
|
try {
|
|
35246
|
-
const parsed2 = JSON.parse(
|
|
35406
|
+
const parsed2 = JSON.parse(readFileSync20(forwardDropsPath(dataDir2), "utf8"));
|
|
35247
35407
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
35248
35408
|
const record2 = parsed2;
|
|
35249
35409
|
if (typeof record2.droppedForwards !== "number" || !Number.isFinite(record2.droppedForwards)) {
|
|
@@ -36347,7 +36507,7 @@ function toWireInspection(insp, nameKey) {
|
|
|
36347
36507
|
}
|
|
36348
36508
|
|
|
36349
36509
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
36350
|
-
import { readFileSync as
|
|
36510
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
36351
36511
|
|
|
36352
36512
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
36353
36513
|
import { readFile as readFile3, stat } from "fs/promises";
|
|
@@ -36400,7 +36560,7 @@ function readManifestBuild(manifestUrl, packageName) {
|
|
|
36400
36560
|
if (!manifestBuildCache.has(key)) {
|
|
36401
36561
|
let build;
|
|
36402
36562
|
try {
|
|
36403
|
-
const manifest = JSON.parse(
|
|
36563
|
+
const manifest = JSON.parse(readFileSync21(manifestUrl, "utf8"));
|
|
36404
36564
|
build = typeof manifest.version === "string" && manifest.version.length > 0 ? { package: packageName, version: manifest.version } : void 0;
|
|
36405
36565
|
} catch {
|
|
36406
36566
|
build = void 0;
|
|
@@ -36435,7 +36595,7 @@ async function readInstalledVersionBounded(installRoot) {
|
|
|
36435
36595
|
}
|
|
36436
36596
|
|
|
36437
36597
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
36438
|
-
import { readFileSync as
|
|
36598
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
36439
36599
|
import { join as join37 } from "path";
|
|
36440
36600
|
var POSTURE_REPORT_STATE_FILENAME = ATTACHED_POSTURE_REPORT_FILENAME;
|
|
36441
36601
|
var OUTCOME_KEYS = {
|
|
@@ -36711,11 +36871,11 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
|
36711
36871
|
}
|
|
36712
36872
|
|
|
36713
36873
|
// ../../packages/plugin-runtime/src/attached/label-drops.ts
|
|
36714
|
-
import { readFileSync as
|
|
36874
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
36715
36875
|
import { join as join39 } from "path";
|
|
36716
36876
|
|
|
36717
36877
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
36718
|
-
import { readFileSync as
|
|
36878
|
+
import { readFileSync as readFileSync24 } from "fs";
|
|
36719
36879
|
import { join as join40 } from "path";
|
|
36720
36880
|
|
|
36721
36881
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
@@ -37359,7 +37519,7 @@ function buildSessionRoot(sessionId, input, ctx, resolved, provider, branch, sco
|
|
|
37359
37519
|
}
|
|
37360
37520
|
|
|
37361
37521
|
// src/build-info.ts
|
|
37362
|
-
import { readFileSync as
|
|
37522
|
+
import { readFileSync as readFileSync25 } from "fs";
|
|
37363
37523
|
var PLUGIN_PACKAGE = "@akasecurity/ai-tc-copilot";
|
|
37364
37524
|
var MANIFEST_URL = new URL("../plugin.json", import.meta.url);
|
|
37365
37525
|
var MANIFEST_ARGV_INDEX = 3;
|
|
@@ -37370,7 +37530,7 @@ function harnessVersionFromArgv(argv = process.argv) {
|
|
|
37370
37530
|
const manifestPath = argv[MANIFEST_ARGV_INDEX];
|
|
37371
37531
|
if (!manifestPath) return void 0;
|
|
37372
37532
|
try {
|
|
37373
|
-
const manifest = JSON.parse(
|
|
37533
|
+
const manifest = JSON.parse(readFileSync25(manifestPath, "utf8"));
|
|
37374
37534
|
return typeof manifest.version === "string" ? manifest.version : void 0;
|
|
37375
37535
|
} catch {
|
|
37376
37536
|
return void 0;
|
|
@@ -37590,7 +37750,7 @@ async function runHookEntry(handler, failOpen) {
|
|
|
37590
37750
|
}
|
|
37591
37751
|
|
|
37592
37752
|
// src/hooks/store-health.ts
|
|
37593
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
37753
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync26, writeFileSync as writeFileSync7 } from "fs";
|
|
37594
37754
|
import { dirname as dirname11, join as join42 } from "path";
|
|
37595
37755
|
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
37596
37756
|
var RECENT_SESSIONS2 = 32;
|
|
@@ -37610,7 +37770,7 @@ function alreadyClaimed(dirs, marker, sessionId) {
|
|
|
37610
37770
|
}
|
|
37611
37771
|
function readRecent(dir, marker) {
|
|
37612
37772
|
try {
|
|
37613
|
-
return
|
|
37773
|
+
return readFileSync26(join42(dir, marker), "utf8").split("\n").filter(Boolean);
|
|
37614
37774
|
} catch {
|
|
37615
37775
|
return [];
|
|
37616
37776
|
}
|