@akasecurity/ai-tc-copilot 0.9.22 → 0.9.23
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 +4 -4
- package/plugin.json +1 -1
- package/scripts/content-retention.js +37 -0
- package/scripts/history-sync.js +100 -15
- package/scripts/post-tool-use.js +103 -16
- package/scripts/pre-tool-use.js +103 -16
- package/scripts/scan-worker.js +42 -8
- package/scripts/session-start.js +146 -48
- package/scripts/sync.js +148 -49
- package/scripts/user-prompt-submit.js +103 -16
|
@@ -15119,6 +15119,21 @@ function registerPack(pack) {
|
|
|
15119
15119
|
function getLoadedRules() {
|
|
15120
15120
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
15121
15121
|
}
|
|
15122
|
+
function outsideWrittenRegions(candidates, context) {
|
|
15123
|
+
const regions = context?.writtenRegions;
|
|
15124
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
15125
|
+
return candidates.filter((c) => {
|
|
15126
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
15127
|
+
const { start, end } = c.match.span;
|
|
15128
|
+
return !regions.some(
|
|
15129
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
15130
|
+
c.rule,
|
|
15131
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
15132
|
+
"code_change"
|
|
15133
|
+
)
|
|
15134
|
+
);
|
|
15135
|
+
});
|
|
15136
|
+
}
|
|
15122
15137
|
function spansOverlap(a, b) {
|
|
15123
15138
|
return a.start < b.end && a.end > b.start;
|
|
15124
15139
|
}
|
|
@@ -15306,17 +15321,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
15306
15321
|
function scanText(text, ruleset, context) {
|
|
15307
15322
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
15308
15323
|
const normalization = normalizeFormatChars(text);
|
|
15309
|
-
const originalCandidates =
|
|
15324
|
+
const originalCandidates = outsideWrittenRegions(
|
|
15325
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
15326
|
+
context
|
|
15327
|
+
);
|
|
15310
15328
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
15311
15329
|
const pooledOriginal = originalCandidates.map(
|
|
15312
15330
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
15313
15331
|
);
|
|
15314
|
-
const normalizedCandidates =
|
|
15315
|
-
normalization.normalized,
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
context
|
|
15319
|
-
)
|
|
15332
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
15333
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
15334
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
15335
|
+
),
|
|
15336
|
+
context
|
|
15337
|
+
);
|
|
15320
15338
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
15321
15339
|
return mergeOverlappingSameRule(findings, text);
|
|
15322
15340
|
}
|
|
@@ -15377,6 +15395,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
15377
15395
|
"code-flaws/sql-inject-concat-dot",
|
|
15378
15396
|
"code-flaws/sql-inject-format",
|
|
15379
15397
|
"code-flaws/sql-inject-interp",
|
|
15398
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
15380
15399
|
"code-flaws/ssrf-user-url",
|
|
15381
15400
|
"code-flaws/xss-dangerously-set",
|
|
15382
15401
|
"code-flaws/xss-inner-html",
|
|
@@ -16515,7 +16534,7 @@ var sql_inject_concat_dot_default = {
|
|
|
16515
16534
|
severity: "high",
|
|
16516
16535
|
matcher: {
|
|
16517
16536
|
type: "regex",
|
|
16518
|
-
pattern:
|
|
16537
|
+
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*\\.",
|
|
16519
16538
|
flags: "gi"
|
|
16520
16539
|
},
|
|
16521
16540
|
appliesTo: {
|
|
@@ -16533,7 +16552,7 @@ var sql_inject_concat_default = {
|
|
|
16533
16552
|
severity: "high",
|
|
16534
16553
|
matcher: {
|
|
16535
16554
|
type: "regex",
|
|
16536
|
-
pattern:
|
|
16555
|
+
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*\\+",
|
|
16537
16556
|
flags: "gi"
|
|
16538
16557
|
},
|
|
16539
16558
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -16548,7 +16567,7 @@ var sql_inject_format_default = {
|
|
|
16548
16567
|
severity: "high",
|
|
16549
16568
|
matcher: {
|
|
16550
16569
|
type: "regex",
|
|
16551
|
-
pattern:
|
|
16570
|
+
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]+\\})",
|
|
16552
16571
|
flags: "gi"
|
|
16553
16572
|
},
|
|
16554
16573
|
examples: [
|
|
@@ -16557,6 +16576,24 @@ var sql_inject_format_default = {
|
|
|
16557
16576
|
]
|
|
16558
16577
|
};
|
|
16559
16578
|
|
|
16579
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
16580
|
+
var sql_inject_interp_multiline_default = {
|
|
16581
|
+
specVersion: 1,
|
|
16582
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
16583
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
16584
|
+
category: "code_flaw",
|
|
16585
|
+
severity: "high",
|
|
16586
|
+
matcher: {
|
|
16587
|
+
type: "regex",
|
|
16588
|
+
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_])',
|
|
16589
|
+
flags: "gi"
|
|
16590
|
+
},
|
|
16591
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
16592
|
+
appliesTo: {
|
|
16593
|
+
extensions: [".rb", ".php"]
|
|
16594
|
+
}
|
|
16595
|
+
};
|
|
16596
|
+
|
|
16560
16597
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
16561
16598
|
var sql_inject_interp_default = {
|
|
16562
16599
|
specVersion: 1,
|
|
@@ -16566,7 +16603,7 @@ var sql_inject_interp_default = {
|
|
|
16566
16603
|
severity: "high",
|
|
16567
16604
|
matcher: {
|
|
16568
16605
|
type: "regex",
|
|
16569
|
-
pattern: "([\
|
|
16606
|
+
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_])',
|
|
16570
16607
|
flags: "gi"
|
|
16571
16608
|
},
|
|
16572
16609
|
examples: [
|
|
@@ -18294,12 +18331,13 @@ var BUNDLED_PACKS = [
|
|
|
18294
18331
|
{
|
|
18295
18332
|
packId: "code-flaws",
|
|
18296
18333
|
name: "Code Security Flaws",
|
|
18297
|
-
version: "0.1.
|
|
18334
|
+
version: "0.1.6",
|
|
18298
18335
|
rawRules: [
|
|
18299
18336
|
sql_inject_concat_default,
|
|
18300
18337
|
sql_inject_concat_dot_default,
|
|
18301
18338
|
sql_inject_format_default,
|
|
18302
18339
|
sql_inject_interp_default,
|
|
18340
|
+
sql_inject_interp_multiline_default,
|
|
18303
18341
|
cmd_inject_shell_default,
|
|
18304
18342
|
cmd_inject_exec_default,
|
|
18305
18343
|
cmd_inject_node_exec_default,
|
|
@@ -18331,6 +18369,7 @@ var BUNDLED_PACKS = [
|
|
|
18331
18369
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
18332
18370
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
18333
18371
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
18372
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
18334
18373
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
18335
18374
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
18336
18375
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -28423,6 +28462,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
28423
28462
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
28424
28463
|
);
|
|
28425
28464
|
}
|
|
28465
|
+
/**
|
|
28466
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
28467
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
28468
|
+
* every row.
|
|
28469
|
+
*
|
|
28470
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
28471
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
28472
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
28473
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
28474
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
28475
|
+
*
|
|
28476
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
28477
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
28478
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
28479
|
+
*
|
|
28480
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
28481
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
28482
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
28483
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
28484
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
28485
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
28486
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
28487
|
+
*/
|
|
28488
|
+
countFingerprintEpochs(currentVersion) {
|
|
28489
|
+
const row = getRow(
|
|
28490
|
+
this.db.prepare(
|
|
28491
|
+
`SELECT COUNT(*) AS total,
|
|
28492
|
+
COALESCE(
|
|
28493
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
28494
|
+
0
|
|
28495
|
+
) AS stale
|
|
28496
|
+
FROM secret_vault`
|
|
28497
|
+
),
|
|
28498
|
+
{ currentVersion }
|
|
28499
|
+
) ?? { stale: 0, total: 0 };
|
|
28500
|
+
return { stale: row.stale, total: row.total };
|
|
28501
|
+
}
|
|
28426
28502
|
};
|
|
28427
28503
|
|
|
28428
28504
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -30279,13 +30355,22 @@ var SecretVault = class {
|
|
|
30279
30355
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
30280
30356
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
30281
30357
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
30358
|
+
*
|
|
30359
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
30360
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
30361
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
30362
|
+
* than a bare success count.
|
|
30282
30363
|
*/
|
|
30283
30364
|
async refreshFingerprints(next) {
|
|
30284
30365
|
let refreshed = 0;
|
|
30366
|
+
let skipped = 0;
|
|
30285
30367
|
for (const row of this.#repo.listAll()) {
|
|
30286
30368
|
try {
|
|
30287
30369
|
const raw = await this.#openRow(row);
|
|
30288
|
-
if (raw === null)
|
|
30370
|
+
if (raw === null) {
|
|
30371
|
+
skipped += 1;
|
|
30372
|
+
continue;
|
|
30373
|
+
}
|
|
30289
30374
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
30290
30375
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
30291
30376
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -30293,10 +30378,10 @@ var SecretVault = class {
|
|
|
30293
30378
|
});
|
|
30294
30379
|
refreshed += 1;
|
|
30295
30380
|
} catch {
|
|
30296
|
-
|
|
30381
|
+
skipped += 1;
|
|
30297
30382
|
}
|
|
30298
30383
|
}
|
|
30299
|
-
return refreshed;
|
|
30384
|
+
return { refreshed, skipped };
|
|
30300
30385
|
}
|
|
30301
30386
|
/**
|
|
30302
30387
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -31226,6 +31311,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
31226
31311
|
text,
|
|
31227
31312
|
filePath: context?.filePath,
|
|
31228
31313
|
eventKind: context?.eventKind,
|
|
31314
|
+
writtenRegions: context?.writtenRegions,
|
|
31229
31315
|
attribute: scanOpts?.attribute === true
|
|
31230
31316
|
}),
|
|
31231
31317
|
reply: (message) => {
|
|
@@ -31990,7 +32076,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
31990
32076
|
input.text,
|
|
31991
32077
|
{
|
|
31992
32078
|
filePath: input.metadata?.filePath,
|
|
31993
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
32079
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
32080
|
+
writtenRegions: opts2.writtenRegions
|
|
31994
32081
|
},
|
|
31995
32082
|
{
|
|
31996
32083
|
sourceTool: input.sourceTool,
|