@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
|
@@ -8782,7 +8782,11 @@ var ListFindingTypesQuery = object({
|
|
|
8782
8782
|
// and so is not bounded by what any page happens to hold.
|
|
8783
8783
|
includeId: string2().optional(),
|
|
8784
8784
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8785
|
-
cursor: string2().optional()
|
|
8785
|
+
cursor: string2().optional(),
|
|
8786
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8787
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8788
|
+
// from wherever it lands.
|
|
8789
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8786
8790
|
});
|
|
8787
8791
|
var ListFindingTypesResponse = object({
|
|
8788
8792
|
totals: object({
|
|
@@ -8863,7 +8867,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8863
8867
|
sessionId: string2().optional(),
|
|
8864
8868
|
from: iso_exports.datetime().optional(),
|
|
8865
8869
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8866
|
-
cursor: string2().optional()
|
|
8870
|
+
cursor: string2().optional(),
|
|
8871
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8872
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8873
|
+
// from wherever it lands.
|
|
8874
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8867
8875
|
});
|
|
8868
8876
|
var ListFindingInstancesResponse = object({
|
|
8869
8877
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8935,7 +8943,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8935
8943
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8936
8944
|
includeId: string2().optional(),
|
|
8937
8945
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8938
|
-
cursor: string2().optional()
|
|
8946
|
+
cursor: string2().optional(),
|
|
8947
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8948
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8949
|
+
// from wherever it lands.
|
|
8950
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8939
8951
|
});
|
|
8940
8952
|
var ListFindingLocationsResponse = object({
|
|
8941
8953
|
totals: object({
|
|
@@ -11572,7 +11584,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11572
11584
|
var ListVaultInventoryQuery = object({
|
|
11573
11585
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11574
11586
|
// Opaque; names the last row of the page just served.
|
|
11575
|
-
cursor: string2().optional()
|
|
11587
|
+
cursor: string2().optional(),
|
|
11588
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11589
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11590
|
+
// from wherever it lands.
|
|
11591
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11576
11592
|
});
|
|
11577
11593
|
var ListVaultInventoryResponse = object({
|
|
11578
11594
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11584,7 +11600,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11584
11600
|
});
|
|
11585
11601
|
var ListVaultReuseQuery = object({
|
|
11586
11602
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11587
|
-
cursor: string2().optional()
|
|
11603
|
+
cursor: string2().optional(),
|
|
11604
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11605
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11606
|
+
// from wherever it lands.
|
|
11607
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11588
11608
|
});
|
|
11589
11609
|
var ListVaultReuseResponse = object({
|
|
11590
11610
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11600,9 +11620,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11600
11620
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11601
11621
|
includeBatched: boolean2().optional(),
|
|
11602
11622
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11603
|
-
cursor: string2().optional()
|
|
11623
|
+
cursor: string2().optional(),
|
|
11624
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11625
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11626
|
+
// from wherever it lands.
|
|
11627
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11604
11628
|
});
|
|
11605
11629
|
var ListVaultDerefsResponse = object({
|
|
11630
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11631
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11606
11632
|
items: array(VaultDeref),
|
|
11607
11633
|
nextCursor: string2().nullable(),
|
|
11608
11634
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -15119,6 +15145,21 @@ function registerPack(pack) {
|
|
|
15119
15145
|
function getLoadedRules() {
|
|
15120
15146
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
15121
15147
|
}
|
|
15148
|
+
function outsideWrittenRegions(candidates, context) {
|
|
15149
|
+
const regions = context?.writtenRegions;
|
|
15150
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
15151
|
+
return candidates.filter((c) => {
|
|
15152
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
15153
|
+
const { start, end } = c.match.span;
|
|
15154
|
+
return !regions.some(
|
|
15155
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
15156
|
+
c.rule,
|
|
15157
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
15158
|
+
"code_change"
|
|
15159
|
+
)
|
|
15160
|
+
);
|
|
15161
|
+
});
|
|
15162
|
+
}
|
|
15122
15163
|
function spansOverlap(a, b) {
|
|
15123
15164
|
return a.start < b.end && a.end > b.start;
|
|
15124
15165
|
}
|
|
@@ -15306,17 +15347,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
15306
15347
|
function scanText(text, ruleset, context) {
|
|
15307
15348
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
15308
15349
|
const normalization = normalizeFormatChars(text);
|
|
15309
|
-
const originalCandidates =
|
|
15350
|
+
const originalCandidates = outsideWrittenRegions(
|
|
15351
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
15352
|
+
context
|
|
15353
|
+
);
|
|
15310
15354
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
15311
15355
|
const pooledOriginal = originalCandidates.map(
|
|
15312
15356
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
15313
15357
|
);
|
|
15314
|
-
const normalizedCandidates =
|
|
15315
|
-
normalization.normalized,
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
context
|
|
15319
|
-
)
|
|
15358
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
15359
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
15360
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
15361
|
+
),
|
|
15362
|
+
context
|
|
15363
|
+
);
|
|
15320
15364
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
15321
15365
|
return mergeOverlappingSameRule(findings, text);
|
|
15322
15366
|
}
|
|
@@ -15377,6 +15421,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
15377
15421
|
"code-flaws/sql-inject-concat-dot",
|
|
15378
15422
|
"code-flaws/sql-inject-format",
|
|
15379
15423
|
"code-flaws/sql-inject-interp",
|
|
15424
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
15380
15425
|
"code-flaws/ssrf-user-url",
|
|
15381
15426
|
"code-flaws/xss-dangerously-set",
|
|
15382
15427
|
"code-flaws/xss-inner-html",
|
|
@@ -16515,7 +16560,7 @@ var sql_inject_concat_dot_default = {
|
|
|
16515
16560
|
severity: "high",
|
|
16516
16561
|
matcher: {
|
|
16517
16562
|
type: "regex",
|
|
16518
|
-
pattern:
|
|
16563
|
+
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
16564
|
flags: "gi"
|
|
16520
16565
|
},
|
|
16521
16566
|
appliesTo: {
|
|
@@ -16533,7 +16578,7 @@ var sql_inject_concat_default = {
|
|
|
16533
16578
|
severity: "high",
|
|
16534
16579
|
matcher: {
|
|
16535
16580
|
type: "regex",
|
|
16536
|
-
pattern:
|
|
16581
|
+
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
16582
|
flags: "gi"
|
|
16538
16583
|
},
|
|
16539
16584
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -16548,7 +16593,7 @@ var sql_inject_format_default = {
|
|
|
16548
16593
|
severity: "high",
|
|
16549
16594
|
matcher: {
|
|
16550
16595
|
type: "regex",
|
|
16551
|
-
pattern:
|
|
16596
|
+
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
16597
|
flags: "gi"
|
|
16553
16598
|
},
|
|
16554
16599
|
examples: [
|
|
@@ -16557,6 +16602,24 @@ var sql_inject_format_default = {
|
|
|
16557
16602
|
]
|
|
16558
16603
|
};
|
|
16559
16604
|
|
|
16605
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
16606
|
+
var sql_inject_interp_multiline_default = {
|
|
16607
|
+
specVersion: 1,
|
|
16608
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
16609
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
16610
|
+
category: "code_flaw",
|
|
16611
|
+
severity: "high",
|
|
16612
|
+
matcher: {
|
|
16613
|
+
type: "regex",
|
|
16614
|
+
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_])',
|
|
16615
|
+
flags: "gi"
|
|
16616
|
+
},
|
|
16617
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
16618
|
+
appliesTo: {
|
|
16619
|
+
extensions: [".rb", ".php"]
|
|
16620
|
+
}
|
|
16621
|
+
};
|
|
16622
|
+
|
|
16560
16623
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
16561
16624
|
var sql_inject_interp_default = {
|
|
16562
16625
|
specVersion: 1,
|
|
@@ -16566,7 +16629,7 @@ var sql_inject_interp_default = {
|
|
|
16566
16629
|
severity: "high",
|
|
16567
16630
|
matcher: {
|
|
16568
16631
|
type: "regex",
|
|
16569
|
-
pattern: "([\
|
|
16632
|
+
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
16633
|
flags: "gi"
|
|
16571
16634
|
},
|
|
16572
16635
|
examples: [
|
|
@@ -18294,12 +18357,13 @@ var BUNDLED_PACKS = [
|
|
|
18294
18357
|
{
|
|
18295
18358
|
packId: "code-flaws",
|
|
18296
18359
|
name: "Code Security Flaws",
|
|
18297
|
-
version: "0.1.
|
|
18360
|
+
version: "0.1.6",
|
|
18298
18361
|
rawRules: [
|
|
18299
18362
|
sql_inject_concat_default,
|
|
18300
18363
|
sql_inject_concat_dot_default,
|
|
18301
18364
|
sql_inject_format_default,
|
|
18302
18365
|
sql_inject_interp_default,
|
|
18366
|
+
sql_inject_interp_multiline_default,
|
|
18303
18367
|
cmd_inject_shell_default,
|
|
18304
18368
|
cmd_inject_exec_default,
|
|
18305
18369
|
cmd_inject_node_exec_default,
|
|
@@ -18331,6 +18395,7 @@ var BUNDLED_PACKS = [
|
|
|
18331
18395
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
18332
18396
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
18333
18397
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
18398
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
18334
18399
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
18335
18400
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
18336
18401
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -25127,7 +25192,7 @@ var SqliteFindingsRepository = class {
|
|
|
25127
25192
|
};
|
|
25128
25193
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
25129
25194
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
25130
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
25195
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
25131
25196
|
const page = sorted.slice(start, start + limit);
|
|
25132
25197
|
const lastOnPage = page.at(-1);
|
|
25133
25198
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -25221,7 +25286,7 @@ var SqliteFindingsRepository = class {
|
|
|
25221
25286
|
accumulator.add(row);
|
|
25222
25287
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
25223
25288
|
total += 1;
|
|
25224
|
-
if (!isPastCursor(row)) continue;
|
|
25289
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
25225
25290
|
if (items.length < limit) {
|
|
25226
25291
|
items.push(toInstanceDetail(row));
|
|
25227
25292
|
last = row;
|
|
@@ -25310,7 +25375,7 @@ var SqliteFindingsRepository = class {
|
|
|
25310
25375
|
}
|
|
25311
25376
|
}
|
|
25312
25377
|
sorted.sort(compareLocationOrder);
|
|
25313
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
25378
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
25314
25379
|
const page = sorted.slice(start, start + limit);
|
|
25315
25380
|
const lastOnPage = page.at(-1);
|
|
25316
25381
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -27938,6 +28003,9 @@ function pageLimit(requested, fallback) {
|
|
|
27938
28003
|
if (requested === void 0) return fallback;
|
|
27939
28004
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
27940
28005
|
}
|
|
28006
|
+
function pageOffset(requested) {
|
|
28007
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
28008
|
+
}
|
|
27941
28009
|
function encodeReuseCursor(payload) {
|
|
27942
28010
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
27943
28011
|
}
|
|
@@ -28285,7 +28353,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28285
28353
|
*/
|
|
28286
28354
|
listInventory(query = {}, now = Date.now()) {
|
|
28287
28355
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28288
|
-
const
|
|
28356
|
+
const offset = pageOffset(query.offset);
|
|
28357
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28289
28358
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
28290
28359
|
const rows = allRows(
|
|
28291
28360
|
this.db.prepare(
|
|
@@ -28299,11 +28368,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28299
28368
|
FROM secret_vault v
|
|
28300
28369
|
${where}
|
|
28301
28370
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
28302
|
-
LIMIT :limit`
|
|
28371
|
+
LIMIT :limit OFFSET :offset`
|
|
28303
28372
|
),
|
|
28304
28373
|
bindParams({
|
|
28305
28374
|
now,
|
|
28306
28375
|
limit: limit + 1,
|
|
28376
|
+
offset,
|
|
28307
28377
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
28308
28378
|
})
|
|
28309
28379
|
);
|
|
@@ -28327,7 +28397,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28327
28397
|
*/
|
|
28328
28398
|
listReuse(query = {}, now = Date.now()) {
|
|
28329
28399
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28330
|
-
const
|
|
28400
|
+
const offset = pageOffset(query.offset);
|
|
28401
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
28331
28402
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
28332
28403
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
28333
28404
|
const rows = allRows(
|
|
@@ -28342,11 +28413,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28342
28413
|
FROM secret_vault v
|
|
28343
28414
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
28344
28415
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
28345
|
-
LIMIT :limit`
|
|
28416
|
+
LIMIT :limit OFFSET :offset`
|
|
28346
28417
|
),
|
|
28347
28418
|
bindParams({
|
|
28348
28419
|
now,
|
|
28349
28420
|
limit: limit + 1,
|
|
28421
|
+
offset,
|
|
28350
28422
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
28351
28423
|
})
|
|
28352
28424
|
);
|
|
@@ -28371,7 +28443,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28371
28443
|
*/
|
|
28372
28444
|
listDerefs(query = {}) {
|
|
28373
28445
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
28374
|
-
const
|
|
28446
|
+
const offset = pageOffset(query.offset);
|
|
28447
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28375
28448
|
const conditions = [];
|
|
28376
28449
|
if (query.includeBatched !== true) {
|
|
28377
28450
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -28384,21 +28457,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
28384
28457
|
this.db.prepare(
|
|
28385
28458
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
28386
28459
|
FROM secret_vault_deref ${where}
|
|
28387
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
28460
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
28388
28461
|
),
|
|
28389
28462
|
bindParams({
|
|
28390
28463
|
limit: limit + 1,
|
|
28464
|
+
offset,
|
|
28391
28465
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
28392
28466
|
})
|
|
28393
28467
|
);
|
|
28394
28468
|
const hasMore = rows.length > limit;
|
|
28395
28469
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
28396
28470
|
const last = page[page.length - 1];
|
|
28397
|
-
const
|
|
28398
|
-
this.db
|
|
28399
|
-
|
|
28400
|
-
|
|
28471
|
+
const counts = getRow(
|
|
28472
|
+
this.db.prepare(
|
|
28473
|
+
`SELECT count(*) AS total,
|
|
28474
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
28475
|
+
FROM secret_vault_deref`
|
|
28476
|
+
)
|
|
28477
|
+
) ?? { total: 0, hidden: 0 };
|
|
28478
|
+
const includeBatched = query.includeBatched === true;
|
|
28479
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
28401
28480
|
return {
|
|
28481
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
28402
28482
|
items: page.map((r) => ({
|
|
28403
28483
|
id: r.id,
|
|
28404
28484
|
pointerId: r.pointer_id,
|
|
@@ -28423,6 +28503,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
28423
28503
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
28424
28504
|
);
|
|
28425
28505
|
}
|
|
28506
|
+
/**
|
|
28507
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
28508
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
28509
|
+
* every row.
|
|
28510
|
+
*
|
|
28511
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
28512
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
28513
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
28514
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
28515
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
28516
|
+
*
|
|
28517
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
28518
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
28519
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
28520
|
+
*
|
|
28521
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
28522
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
28523
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
28524
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
28525
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
28526
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
28527
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
28528
|
+
*/
|
|
28529
|
+
countFingerprintEpochs(currentVersion) {
|
|
28530
|
+
const row = getRow(
|
|
28531
|
+
this.db.prepare(
|
|
28532
|
+
`SELECT COUNT(*) AS total,
|
|
28533
|
+
COALESCE(
|
|
28534
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
28535
|
+
0
|
|
28536
|
+
) AS stale
|
|
28537
|
+
FROM secret_vault`
|
|
28538
|
+
),
|
|
28539
|
+
{ currentVersion }
|
|
28540
|
+
) ?? { stale: 0, total: 0 };
|
|
28541
|
+
return { stale: row.stale, total: row.total };
|
|
28542
|
+
}
|
|
28426
28543
|
};
|
|
28427
28544
|
|
|
28428
28545
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -30279,13 +30396,22 @@ var SecretVault = class {
|
|
|
30279
30396
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
30280
30397
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
30281
30398
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
30399
|
+
*
|
|
30400
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
30401
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
30402
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
30403
|
+
* than a bare success count.
|
|
30282
30404
|
*/
|
|
30283
30405
|
async refreshFingerprints(next) {
|
|
30284
30406
|
let refreshed = 0;
|
|
30407
|
+
let skipped = 0;
|
|
30285
30408
|
for (const row of this.#repo.listAll()) {
|
|
30286
30409
|
try {
|
|
30287
30410
|
const raw = await this.#openRow(row);
|
|
30288
|
-
if (raw === null)
|
|
30411
|
+
if (raw === null) {
|
|
30412
|
+
skipped += 1;
|
|
30413
|
+
continue;
|
|
30414
|
+
}
|
|
30289
30415
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
30290
30416
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
30291
30417
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -30293,10 +30419,10 @@ var SecretVault = class {
|
|
|
30293
30419
|
});
|
|
30294
30420
|
refreshed += 1;
|
|
30295
30421
|
} catch {
|
|
30296
|
-
|
|
30422
|
+
skipped += 1;
|
|
30297
30423
|
}
|
|
30298
30424
|
}
|
|
30299
|
-
return refreshed;
|
|
30425
|
+
return { refreshed, skipped };
|
|
30300
30426
|
}
|
|
30301
30427
|
/**
|
|
30302
30428
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -30813,8 +30939,25 @@ function bundledMaskingRules() {
|
|
|
30813
30939
|
return ensureBundledPacks() ? getLoadedRules() : null;
|
|
30814
30940
|
}
|
|
30815
30941
|
|
|
30942
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
30943
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
30944
|
+
function notRegularFile(path) {
|
|
30945
|
+
return `not a regular file: ${path}`;
|
|
30946
|
+
}
|
|
30947
|
+
function readRegularFile(path, maxBytes) {
|
|
30948
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
30949
|
+
try {
|
|
30950
|
+
const stat2 = fstatSync(fd);
|
|
30951
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
30952
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
30953
|
+
return readFileSync16(fd, "utf8");
|
|
30954
|
+
} finally {
|
|
30955
|
+
closeSync2(fd);
|
|
30956
|
+
}
|
|
30957
|
+
}
|
|
30958
|
+
|
|
30816
30959
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
30817
|
-
import { existsSync as existsSync9,
|
|
30960
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
30818
30961
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
30819
30962
|
function remoteWithoutCredentials(remote) {
|
|
30820
30963
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -30903,9 +31046,10 @@ function resolveGitContext(root) {
|
|
|
30903
31046
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
30904
31047
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
30905
31048
|
}
|
|
31049
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
30906
31050
|
function safeRead(path) {
|
|
30907
31051
|
try {
|
|
30908
|
-
return
|
|
31052
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
30909
31053
|
} catch {
|
|
30910
31054
|
return void 0;
|
|
30911
31055
|
}
|
|
@@ -31226,6 +31370,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
31226
31370
|
text,
|
|
31227
31371
|
filePath: context?.filePath,
|
|
31228
31372
|
eventKind: context?.eventKind,
|
|
31373
|
+
writtenRegions: context?.writtenRegions,
|
|
31229
31374
|
attribute: scanOpts?.attribute === true
|
|
31230
31375
|
}),
|
|
31231
31376
|
reply: (message) => {
|
|
@@ -31990,7 +32135,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
31990
32135
|
input.text,
|
|
31991
32136
|
{
|
|
31992
32137
|
filePath: input.metadata?.filePath,
|
|
31993
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
32138
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
32139
|
+
writtenRegions: opts2.writtenRegions
|
|
31994
32140
|
},
|
|
31995
32141
|
{
|
|
31996
32142
|
sourceTool: input.sourceTool,
|