@akasecurity/ai-tc-codex 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/.codex-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/apply-suppressions.js +88 -12
- package/scripts/backfill.js +103 -16
- package/scripts/content-retention.js +37 -0
- package/scripts/filescan.js +148 -49
- package/scripts/firstrun.js +100 -15
- package/scripts/history-sync.js +100 -15
- package/scripts/onboard.js +62 -5
- package/scripts/post-tool-use.js +103 -16
- package/scripts/pre-tool-use.js +103 -16
- package/scripts/query.js +100 -15
- package/scripts/reconcile.js +101 -15
- package/scripts/remediate.js +110 -19
- package/scripts/scan-worker.js +42 -8
- package/scripts/session-start.js +146 -48
- package/scripts/stop.js +100 -15
- package/scripts/sync.js +148 -49
- package/scripts/user-prompt-submit.js +103 -16
|
@@ -15129,6 +15129,21 @@ function registerPack(pack) {
|
|
|
15129
15129
|
function getLoadedRules() {
|
|
15130
15130
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
15131
15131
|
}
|
|
15132
|
+
function outsideWrittenRegions(candidates, context) {
|
|
15133
|
+
const regions = context?.writtenRegions;
|
|
15134
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
15135
|
+
return candidates.filter((c) => {
|
|
15136
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
15137
|
+
const { start, end } = c.match.span;
|
|
15138
|
+
return !regions.some(
|
|
15139
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
15140
|
+
c.rule,
|
|
15141
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
15142
|
+
"code_change"
|
|
15143
|
+
)
|
|
15144
|
+
);
|
|
15145
|
+
});
|
|
15146
|
+
}
|
|
15132
15147
|
function spansOverlap(a, b) {
|
|
15133
15148
|
return a.start < b.end && a.end > b.start;
|
|
15134
15149
|
}
|
|
@@ -15316,17 +15331,20 @@ function scanEncoded(text2, ruleset, context) {
|
|
|
15316
15331
|
function scanText(text2, ruleset, context) {
|
|
15317
15332
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
15318
15333
|
const normalization = normalizeFormatChars(text2);
|
|
15319
|
-
const originalCandidates =
|
|
15334
|
+
const originalCandidates = outsideWrittenRegions(
|
|
15335
|
+
buildCandidates(text2, ruleset, extension, context?.eventKind),
|
|
15336
|
+
context
|
|
15337
|
+
);
|
|
15320
15338
|
if (!normalization) return gate(originalCandidates, text2, void 0);
|
|
15321
15339
|
const pooledOriginal = originalCandidates.map(
|
|
15322
15340
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
15323
15341
|
);
|
|
15324
|
-
const normalizedCandidates =
|
|
15325
|
-
normalization.normalized,
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
context
|
|
15329
|
-
)
|
|
15342
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
15343
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
15344
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text2)
|
|
15345
|
+
),
|
|
15346
|
+
context
|
|
15347
|
+
);
|
|
15330
15348
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text2, normalization);
|
|
15331
15349
|
return mergeOverlappingSameRule(findings, text2);
|
|
15332
15350
|
}
|
|
@@ -15387,6 +15405,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
15387
15405
|
"code-flaws/sql-inject-concat-dot",
|
|
15388
15406
|
"code-flaws/sql-inject-format",
|
|
15389
15407
|
"code-flaws/sql-inject-interp",
|
|
15408
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
15390
15409
|
"code-flaws/ssrf-user-url",
|
|
15391
15410
|
"code-flaws/xss-dangerously-set",
|
|
15392
15411
|
"code-flaws/xss-inner-html",
|
|
@@ -16525,7 +16544,7 @@ var sql_inject_concat_dot_default = {
|
|
|
16525
16544
|
severity: "high",
|
|
16526
16545
|
matcher: {
|
|
16527
16546
|
type: "regex",
|
|
16528
|
-
pattern:
|
|
16547
|
+
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*\\.",
|
|
16529
16548
|
flags: "gi"
|
|
16530
16549
|
},
|
|
16531
16550
|
appliesTo: {
|
|
@@ -16543,7 +16562,7 @@ var sql_inject_concat_default = {
|
|
|
16543
16562
|
severity: "high",
|
|
16544
16563
|
matcher: {
|
|
16545
16564
|
type: "regex",
|
|
16546
|
-
pattern:
|
|
16565
|
+
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*\\+",
|
|
16547
16566
|
flags: "gi"
|
|
16548
16567
|
},
|
|
16549
16568
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -16558,7 +16577,7 @@ var sql_inject_format_default = {
|
|
|
16558
16577
|
severity: "high",
|
|
16559
16578
|
matcher: {
|
|
16560
16579
|
type: "regex",
|
|
16561
|
-
pattern:
|
|
16580
|
+
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]+\\})",
|
|
16562
16581
|
flags: "gi"
|
|
16563
16582
|
},
|
|
16564
16583
|
examples: [
|
|
@@ -16567,6 +16586,24 @@ var sql_inject_format_default = {
|
|
|
16567
16586
|
]
|
|
16568
16587
|
};
|
|
16569
16588
|
|
|
16589
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
16590
|
+
var sql_inject_interp_multiline_default = {
|
|
16591
|
+
specVersion: 1,
|
|
16592
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
16593
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
16594
|
+
category: "code_flaw",
|
|
16595
|
+
severity: "high",
|
|
16596
|
+
matcher: {
|
|
16597
|
+
type: "regex",
|
|
16598
|
+
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_])',
|
|
16599
|
+
flags: "gi"
|
|
16600
|
+
},
|
|
16601
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
16602
|
+
appliesTo: {
|
|
16603
|
+
extensions: [".rb", ".php"]
|
|
16604
|
+
}
|
|
16605
|
+
};
|
|
16606
|
+
|
|
16570
16607
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
16571
16608
|
var sql_inject_interp_default = {
|
|
16572
16609
|
specVersion: 1,
|
|
@@ -16576,7 +16613,7 @@ var sql_inject_interp_default = {
|
|
|
16576
16613
|
severity: "high",
|
|
16577
16614
|
matcher: {
|
|
16578
16615
|
type: "regex",
|
|
16579
|
-
pattern: "([\
|
|
16616
|
+
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_])',
|
|
16580
16617
|
flags: "gi"
|
|
16581
16618
|
},
|
|
16582
16619
|
examples: [
|
|
@@ -18304,12 +18341,13 @@ var BUNDLED_PACKS = [
|
|
|
18304
18341
|
{
|
|
18305
18342
|
packId: "code-flaws",
|
|
18306
18343
|
name: "Code Security Flaws",
|
|
18307
|
-
version: "0.1.
|
|
18344
|
+
version: "0.1.6",
|
|
18308
18345
|
rawRules: [
|
|
18309
18346
|
sql_inject_concat_default,
|
|
18310
18347
|
sql_inject_concat_dot_default,
|
|
18311
18348
|
sql_inject_format_default,
|
|
18312
18349
|
sql_inject_interp_default,
|
|
18350
|
+
sql_inject_interp_multiline_default,
|
|
18313
18351
|
cmd_inject_shell_default,
|
|
18314
18352
|
cmd_inject_exec_default,
|
|
18315
18353
|
cmd_inject_node_exec_default,
|
|
@@ -18341,6 +18379,7 @@ var BUNDLED_PACKS = [
|
|
|
18341
18379
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
18342
18380
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
18343
18381
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
18382
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
18344
18383
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
18345
18384
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
18346
18385
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -28442,6 +28481,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
28442
28481
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
28443
28482
|
);
|
|
28444
28483
|
}
|
|
28484
|
+
/**
|
|
28485
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
28486
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
28487
|
+
* every row.
|
|
28488
|
+
*
|
|
28489
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
28490
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
28491
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
28492
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
28493
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
28494
|
+
*
|
|
28495
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
28496
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
28497
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
28498
|
+
*
|
|
28499
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
28500
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
28501
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
28502
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
28503
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
28504
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
28505
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
28506
|
+
*/
|
|
28507
|
+
countFingerprintEpochs(currentVersion) {
|
|
28508
|
+
const row = getRow(
|
|
28509
|
+
this.db.prepare(
|
|
28510
|
+
`SELECT COUNT(*) AS total,
|
|
28511
|
+
COALESCE(
|
|
28512
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
28513
|
+
0
|
|
28514
|
+
) AS stale
|
|
28515
|
+
FROM secret_vault`
|
|
28516
|
+
),
|
|
28517
|
+
{ currentVersion }
|
|
28518
|
+
) ?? { stale: 0, total: 0 };
|
|
28519
|
+
return { stale: row.stale, total: row.total };
|
|
28520
|
+
}
|
|
28445
28521
|
};
|
|
28446
28522
|
|
|
28447
28523
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -30298,13 +30374,22 @@ var SecretVault = class {
|
|
|
30298
30374
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
30299
30375
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
30300
30376
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
30377
|
+
*
|
|
30378
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
30379
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
30380
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
30381
|
+
* than a bare success count.
|
|
30301
30382
|
*/
|
|
30302
30383
|
async refreshFingerprints(next) {
|
|
30303
30384
|
let refreshed = 0;
|
|
30385
|
+
let skipped = 0;
|
|
30304
30386
|
for (const row of this.#repo.listAll()) {
|
|
30305
30387
|
try {
|
|
30306
30388
|
const raw = await this.#openRow(row);
|
|
30307
|
-
if (raw === null)
|
|
30389
|
+
if (raw === null) {
|
|
30390
|
+
skipped += 1;
|
|
30391
|
+
continue;
|
|
30392
|
+
}
|
|
30308
30393
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
30309
30394
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
30310
30395
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -30312,10 +30397,10 @@ var SecretVault = class {
|
|
|
30312
30397
|
});
|
|
30313
30398
|
refreshed += 1;
|
|
30314
30399
|
} catch {
|
|
30315
|
-
|
|
30400
|
+
skipped += 1;
|
|
30316
30401
|
}
|
|
30317
30402
|
}
|
|
30318
|
-
return refreshed;
|
|
30403
|
+
return { refreshed, skipped };
|
|
30319
30404
|
}
|
|
30320
30405
|
/**
|
|
30321
30406
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -31245,6 +31330,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
31245
31330
|
text: text2,
|
|
31246
31331
|
filePath: context?.filePath,
|
|
31247
31332
|
eventKind: context?.eventKind,
|
|
31333
|
+
writtenRegions: context?.writtenRegions,
|
|
31248
31334
|
attribute: scanOpts?.attribute === true
|
|
31249
31335
|
}),
|
|
31250
31336
|
reply: (message) => {
|
|
@@ -32225,7 +32311,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
32225
32311
|
input.text,
|
|
32226
32312
|
{
|
|
32227
32313
|
filePath: input.metadata?.filePath,
|
|
32228
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
32314
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
32315
|
+
writtenRegions: opts2.writtenRegions
|
|
32229
32316
|
},
|
|
32230
32317
|
{
|
|
32231
32318
|
sourceTool: input.sourceTool,
|