@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/pre-tool-use.js
CHANGED
|
@@ -8777,7 +8777,11 @@ var ListFindingTypesQuery = object({
|
|
|
8777
8777
|
// and so is not bounded by what any page happens to hold.
|
|
8778
8778
|
includeId: string2().optional(),
|
|
8779
8779
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8780
|
-
cursor: string2().optional()
|
|
8780
|
+
cursor: string2().optional(),
|
|
8781
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8782
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8783
|
+
// from wherever it lands.
|
|
8784
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8781
8785
|
});
|
|
8782
8786
|
var ListFindingTypesResponse = object({
|
|
8783
8787
|
totals: object({
|
|
@@ -8858,7 +8862,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8858
8862
|
sessionId: string2().optional(),
|
|
8859
8863
|
from: iso_exports.datetime().optional(),
|
|
8860
8864
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8861
|
-
cursor: string2().optional()
|
|
8865
|
+
cursor: string2().optional(),
|
|
8866
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8867
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8868
|
+
// from wherever it lands.
|
|
8869
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8862
8870
|
});
|
|
8863
8871
|
var ListFindingInstancesResponse = object({
|
|
8864
8872
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8930,7 +8938,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8930
8938
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8931
8939
|
includeId: string2().optional(),
|
|
8932
8940
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8933
|
-
cursor: string2().optional()
|
|
8941
|
+
cursor: string2().optional(),
|
|
8942
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8943
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8944
|
+
// from wherever it lands.
|
|
8945
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8934
8946
|
});
|
|
8935
8947
|
var ListFindingLocationsResponse = object({
|
|
8936
8948
|
totals: object({
|
|
@@ -11567,7 +11579,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11567
11579
|
var ListVaultInventoryQuery = object({
|
|
11568
11580
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11569
11581
|
// Opaque; names the last row of the page just served.
|
|
11570
|
-
cursor: string2().optional()
|
|
11582
|
+
cursor: string2().optional(),
|
|
11583
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11584
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11585
|
+
// from wherever it lands.
|
|
11586
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11571
11587
|
});
|
|
11572
11588
|
var ListVaultInventoryResponse = object({
|
|
11573
11589
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11579,7 +11595,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11579
11595
|
});
|
|
11580
11596
|
var ListVaultReuseQuery = object({
|
|
11581
11597
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11582
|
-
cursor: string2().optional()
|
|
11598
|
+
cursor: string2().optional(),
|
|
11599
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11600
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11601
|
+
// from wherever it lands.
|
|
11602
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11583
11603
|
});
|
|
11584
11604
|
var ListVaultReuseResponse = object({
|
|
11585
11605
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11595,9 +11615,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11595
11615
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11596
11616
|
includeBatched: boolean2().optional(),
|
|
11597
11617
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11598
|
-
cursor: string2().optional()
|
|
11618
|
+
cursor: string2().optional(),
|
|
11619
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11620
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11621
|
+
// from wherever it lands.
|
|
11622
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11599
11623
|
});
|
|
11600
11624
|
var ListVaultDerefsResponse = object({
|
|
11625
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11626
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11601
11627
|
items: array(VaultDeref),
|
|
11602
11628
|
nextCursor: string2().nullable(),
|
|
11603
11629
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -15114,6 +15140,21 @@ function registerPack(pack) {
|
|
|
15114
15140
|
function getLoadedRules() {
|
|
15115
15141
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
15116
15142
|
}
|
|
15143
|
+
function outsideWrittenRegions(candidates, context) {
|
|
15144
|
+
const regions = context?.writtenRegions;
|
|
15145
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
15146
|
+
return candidates.filter((c) => {
|
|
15147
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
15148
|
+
const { start, end } = c.match.span;
|
|
15149
|
+
return !regions.some(
|
|
15150
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
15151
|
+
c.rule,
|
|
15152
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
15153
|
+
"code_change"
|
|
15154
|
+
)
|
|
15155
|
+
);
|
|
15156
|
+
});
|
|
15157
|
+
}
|
|
15117
15158
|
function spansOverlap(a, b) {
|
|
15118
15159
|
return a.start < b.end && a.end > b.start;
|
|
15119
15160
|
}
|
|
@@ -15301,17 +15342,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
15301
15342
|
function scanText(text, ruleset, context) {
|
|
15302
15343
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
15303
15344
|
const normalization = normalizeFormatChars(text);
|
|
15304
|
-
const originalCandidates =
|
|
15345
|
+
const originalCandidates = outsideWrittenRegions(
|
|
15346
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
15347
|
+
context
|
|
15348
|
+
);
|
|
15305
15349
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
15306
15350
|
const pooledOriginal = originalCandidates.map(
|
|
15307
15351
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
15308
15352
|
);
|
|
15309
|
-
const normalizedCandidates =
|
|
15310
|
-
normalization.normalized,
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
context
|
|
15314
|
-
)
|
|
15353
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
15354
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
15355
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
15356
|
+
),
|
|
15357
|
+
context
|
|
15358
|
+
);
|
|
15315
15359
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
15316
15360
|
return mergeOverlappingSameRule(findings, text);
|
|
15317
15361
|
}
|
|
@@ -15372,6 +15416,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
15372
15416
|
"code-flaws/sql-inject-concat-dot",
|
|
15373
15417
|
"code-flaws/sql-inject-format",
|
|
15374
15418
|
"code-flaws/sql-inject-interp",
|
|
15419
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
15375
15420
|
"code-flaws/ssrf-user-url",
|
|
15376
15421
|
"code-flaws/xss-dangerously-set",
|
|
15377
15422
|
"code-flaws/xss-inner-html",
|
|
@@ -16510,7 +16555,7 @@ var sql_inject_concat_dot_default = {
|
|
|
16510
16555
|
severity: "high",
|
|
16511
16556
|
matcher: {
|
|
16512
16557
|
type: "regex",
|
|
16513
|
-
pattern:
|
|
16558
|
+
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*\\.",
|
|
16514
16559
|
flags: "gi"
|
|
16515
16560
|
},
|
|
16516
16561
|
appliesTo: {
|
|
@@ -16528,7 +16573,7 @@ var sql_inject_concat_default = {
|
|
|
16528
16573
|
severity: "high",
|
|
16529
16574
|
matcher: {
|
|
16530
16575
|
type: "regex",
|
|
16531
|
-
pattern:
|
|
16576
|
+
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*\\+",
|
|
16532
16577
|
flags: "gi"
|
|
16533
16578
|
},
|
|
16534
16579
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -16543,7 +16588,7 @@ var sql_inject_format_default = {
|
|
|
16543
16588
|
severity: "high",
|
|
16544
16589
|
matcher: {
|
|
16545
16590
|
type: "regex",
|
|
16546
|
-
pattern:
|
|
16591
|
+
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]+\\})",
|
|
16547
16592
|
flags: "gi"
|
|
16548
16593
|
},
|
|
16549
16594
|
examples: [
|
|
@@ -16552,6 +16597,24 @@ var sql_inject_format_default = {
|
|
|
16552
16597
|
]
|
|
16553
16598
|
};
|
|
16554
16599
|
|
|
16600
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
16601
|
+
var sql_inject_interp_multiline_default = {
|
|
16602
|
+
specVersion: 1,
|
|
16603
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
16604
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
16605
|
+
category: "code_flaw",
|
|
16606
|
+
severity: "high",
|
|
16607
|
+
matcher: {
|
|
16608
|
+
type: "regex",
|
|
16609
|
+
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_])',
|
|
16610
|
+
flags: "gi"
|
|
16611
|
+
},
|
|
16612
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
16613
|
+
appliesTo: {
|
|
16614
|
+
extensions: [".rb", ".php"]
|
|
16615
|
+
}
|
|
16616
|
+
};
|
|
16617
|
+
|
|
16555
16618
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
16556
16619
|
var sql_inject_interp_default = {
|
|
16557
16620
|
specVersion: 1,
|
|
@@ -16561,7 +16624,7 @@ var sql_inject_interp_default = {
|
|
|
16561
16624
|
severity: "high",
|
|
16562
16625
|
matcher: {
|
|
16563
16626
|
type: "regex",
|
|
16564
|
-
pattern: "([\
|
|
16627
|
+
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_])',
|
|
16565
16628
|
flags: "gi"
|
|
16566
16629
|
},
|
|
16567
16630
|
examples: [
|
|
@@ -18289,12 +18352,13 @@ var BUNDLED_PACKS = [
|
|
|
18289
18352
|
{
|
|
18290
18353
|
packId: "code-flaws",
|
|
18291
18354
|
name: "Code Security Flaws",
|
|
18292
|
-
version: "0.1.
|
|
18355
|
+
version: "0.1.6",
|
|
18293
18356
|
rawRules: [
|
|
18294
18357
|
sql_inject_concat_default,
|
|
18295
18358
|
sql_inject_concat_dot_default,
|
|
18296
18359
|
sql_inject_format_default,
|
|
18297
18360
|
sql_inject_interp_default,
|
|
18361
|
+
sql_inject_interp_multiline_default,
|
|
18298
18362
|
cmd_inject_shell_default,
|
|
18299
18363
|
cmd_inject_exec_default,
|
|
18300
18364
|
cmd_inject_node_exec_default,
|
|
@@ -18326,6 +18390,7 @@ var BUNDLED_PACKS = [
|
|
|
18326
18390
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
18327
18391
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
18328
18392
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
18393
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
18329
18394
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
18330
18395
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
18331
18396
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -25122,7 +25187,7 @@ var SqliteFindingsRepository = class {
|
|
|
25122
25187
|
};
|
|
25123
25188
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
25124
25189
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
25125
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
25190
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
25126
25191
|
const page = sorted.slice(start, start + limit);
|
|
25127
25192
|
const lastOnPage = page.at(-1);
|
|
25128
25193
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -25216,7 +25281,7 @@ var SqliteFindingsRepository = class {
|
|
|
25216
25281
|
accumulator.add(row);
|
|
25217
25282
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
25218
25283
|
total += 1;
|
|
25219
|
-
if (!isPastCursor(row)) continue;
|
|
25284
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
25220
25285
|
if (items.length < limit) {
|
|
25221
25286
|
items.push(toInstanceDetail(row));
|
|
25222
25287
|
last = row;
|
|
@@ -25305,7 +25370,7 @@ var SqliteFindingsRepository = class {
|
|
|
25305
25370
|
}
|
|
25306
25371
|
}
|
|
25307
25372
|
sorted.sort(compareLocationOrder);
|
|
25308
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
25373
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
25309
25374
|
const page = sorted.slice(start, start + limit);
|
|
25310
25375
|
const lastOnPage = page.at(-1);
|
|
25311
25376
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -27933,6 +27998,9 @@ function pageLimit(requested, fallback) {
|
|
|
27933
27998
|
if (requested === void 0) return fallback;
|
|
27934
27999
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
27935
28000
|
}
|
|
28001
|
+
function pageOffset(requested) {
|
|
28002
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
28003
|
+
}
|
|
27936
28004
|
function encodeReuseCursor(payload) {
|
|
27937
28005
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
27938
28006
|
}
|
|
@@ -28280,7 +28348,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28280
28348
|
*/
|
|
28281
28349
|
listInventory(query = {}, now = Date.now()) {
|
|
28282
28350
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28283
|
-
const
|
|
28351
|
+
const offset = pageOffset(query.offset);
|
|
28352
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28284
28353
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
28285
28354
|
const rows = allRows(
|
|
28286
28355
|
this.db.prepare(
|
|
@@ -28294,11 +28363,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28294
28363
|
FROM secret_vault v
|
|
28295
28364
|
${where}
|
|
28296
28365
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
28297
|
-
LIMIT :limit`
|
|
28366
|
+
LIMIT :limit OFFSET :offset`
|
|
28298
28367
|
),
|
|
28299
28368
|
bindParams({
|
|
28300
28369
|
now,
|
|
28301
28370
|
limit: limit + 1,
|
|
28371
|
+
offset,
|
|
28302
28372
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
28303
28373
|
})
|
|
28304
28374
|
);
|
|
@@ -28322,7 +28392,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28322
28392
|
*/
|
|
28323
28393
|
listReuse(query = {}, now = Date.now()) {
|
|
28324
28394
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28325
|
-
const
|
|
28395
|
+
const offset = pageOffset(query.offset);
|
|
28396
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
28326
28397
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
28327
28398
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
28328
28399
|
const rows = allRows(
|
|
@@ -28337,11 +28408,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28337
28408
|
FROM secret_vault v
|
|
28338
28409
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
28339
28410
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
28340
|
-
LIMIT :limit`
|
|
28411
|
+
LIMIT :limit OFFSET :offset`
|
|
28341
28412
|
),
|
|
28342
28413
|
bindParams({
|
|
28343
28414
|
now,
|
|
28344
28415
|
limit: limit + 1,
|
|
28416
|
+
offset,
|
|
28345
28417
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
28346
28418
|
})
|
|
28347
28419
|
);
|
|
@@ -28366,7 +28438,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28366
28438
|
*/
|
|
28367
28439
|
listDerefs(query = {}) {
|
|
28368
28440
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
28369
|
-
const
|
|
28441
|
+
const offset = pageOffset(query.offset);
|
|
28442
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28370
28443
|
const conditions = [];
|
|
28371
28444
|
if (query.includeBatched !== true) {
|
|
28372
28445
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -28379,21 +28452,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
28379
28452
|
this.db.prepare(
|
|
28380
28453
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
28381
28454
|
FROM secret_vault_deref ${where}
|
|
28382
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
28455
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
28383
28456
|
),
|
|
28384
28457
|
bindParams({
|
|
28385
28458
|
limit: limit + 1,
|
|
28459
|
+
offset,
|
|
28386
28460
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
28387
28461
|
})
|
|
28388
28462
|
);
|
|
28389
28463
|
const hasMore = rows.length > limit;
|
|
28390
28464
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
28391
28465
|
const last = page[page.length - 1];
|
|
28392
|
-
const
|
|
28393
|
-
this.db
|
|
28394
|
-
|
|
28395
|
-
|
|
28466
|
+
const counts = getRow(
|
|
28467
|
+
this.db.prepare(
|
|
28468
|
+
`SELECT count(*) AS total,
|
|
28469
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
28470
|
+
FROM secret_vault_deref`
|
|
28471
|
+
)
|
|
28472
|
+
) ?? { total: 0, hidden: 0 };
|
|
28473
|
+
const includeBatched = query.includeBatched === true;
|
|
28474
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
28396
28475
|
return {
|
|
28476
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
28397
28477
|
items: page.map((r) => ({
|
|
28398
28478
|
id: r.id,
|
|
28399
28479
|
pointerId: r.pointer_id,
|
|
@@ -28418,6 +28498,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
28418
28498
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
28419
28499
|
);
|
|
28420
28500
|
}
|
|
28501
|
+
/**
|
|
28502
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
28503
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
28504
|
+
* every row.
|
|
28505
|
+
*
|
|
28506
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
28507
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
28508
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
28509
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
28510
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
28511
|
+
*
|
|
28512
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
28513
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
28514
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
28515
|
+
*
|
|
28516
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
28517
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
28518
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
28519
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
28520
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
28521
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
28522
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
28523
|
+
*/
|
|
28524
|
+
countFingerprintEpochs(currentVersion) {
|
|
28525
|
+
const row = getRow(
|
|
28526
|
+
this.db.prepare(
|
|
28527
|
+
`SELECT COUNT(*) AS total,
|
|
28528
|
+
COALESCE(
|
|
28529
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
28530
|
+
0
|
|
28531
|
+
) AS stale
|
|
28532
|
+
FROM secret_vault`
|
|
28533
|
+
),
|
|
28534
|
+
{ currentVersion }
|
|
28535
|
+
) ?? { stale: 0, total: 0 };
|
|
28536
|
+
return { stale: row.stale, total: row.total };
|
|
28537
|
+
}
|
|
28421
28538
|
};
|
|
28422
28539
|
|
|
28423
28540
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -30274,13 +30391,22 @@ var SecretVault = class {
|
|
|
30274
30391
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
30275
30392
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
30276
30393
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
30394
|
+
*
|
|
30395
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
30396
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
30397
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
30398
|
+
* than a bare success count.
|
|
30277
30399
|
*/
|
|
30278
30400
|
async refreshFingerprints(next) {
|
|
30279
30401
|
let refreshed = 0;
|
|
30402
|
+
let skipped = 0;
|
|
30280
30403
|
for (const row of this.#repo.listAll()) {
|
|
30281
30404
|
try {
|
|
30282
30405
|
const raw = await this.#openRow(row);
|
|
30283
|
-
if (raw === null)
|
|
30406
|
+
if (raw === null) {
|
|
30407
|
+
skipped += 1;
|
|
30408
|
+
continue;
|
|
30409
|
+
}
|
|
30284
30410
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
30285
30411
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
30286
30412
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -30288,10 +30414,10 @@ var SecretVault = class {
|
|
|
30288
30414
|
});
|
|
30289
30415
|
refreshed += 1;
|
|
30290
30416
|
} catch {
|
|
30291
|
-
|
|
30417
|
+
skipped += 1;
|
|
30292
30418
|
}
|
|
30293
30419
|
}
|
|
30294
|
-
return refreshed;
|
|
30420
|
+
return { refreshed, skipped };
|
|
30295
30421
|
}
|
|
30296
30422
|
/**
|
|
30297
30423
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -30805,8 +30931,25 @@ function bundledMaskingRules() {
|
|
|
30805
30931
|
return ensureBundledPacks() ? getLoadedRules() : null;
|
|
30806
30932
|
}
|
|
30807
30933
|
|
|
30934
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
30935
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
30936
|
+
function notRegularFile(path) {
|
|
30937
|
+
return `not a regular file: ${path}`;
|
|
30938
|
+
}
|
|
30939
|
+
function readRegularFile(path, maxBytes) {
|
|
30940
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
30941
|
+
try {
|
|
30942
|
+
const stat2 = fstatSync(fd);
|
|
30943
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
30944
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
30945
|
+
return readFileSync16(fd, "utf8");
|
|
30946
|
+
} finally {
|
|
30947
|
+
closeSync2(fd);
|
|
30948
|
+
}
|
|
30949
|
+
}
|
|
30950
|
+
|
|
30808
30951
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
30809
|
-
import { existsSync as existsSync9,
|
|
30952
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
30810
30953
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
30811
30954
|
function remoteWithoutCredentials(remote) {
|
|
30812
30955
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -30895,9 +31038,10 @@ function resolveGitContext(root) {
|
|
|
30895
31038
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
30896
31039
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
30897
31040
|
}
|
|
31041
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
30898
31042
|
function safeRead(path) {
|
|
30899
31043
|
try {
|
|
30900
|
-
return
|
|
31044
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
30901
31045
|
} catch {
|
|
30902
31046
|
return void 0;
|
|
30903
31047
|
}
|
|
@@ -31218,6 +31362,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
31218
31362
|
text,
|
|
31219
31363
|
filePath: context?.filePath,
|
|
31220
31364
|
eventKind: context?.eventKind,
|
|
31365
|
+
writtenRegions: context?.writtenRegions,
|
|
31221
31366
|
attribute: scanOpts?.attribute === true
|
|
31222
31367
|
}),
|
|
31223
31368
|
reply: (message) => {
|
|
@@ -31955,7 +32100,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
31955
32100
|
input.text,
|
|
31956
32101
|
{
|
|
31957
32102
|
filePath: input.metadata?.filePath,
|
|
31958
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
32103
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
32104
|
+
writtenRegions: opts2.writtenRegions
|
|
31959
32105
|
},
|
|
31960
32106
|
{
|
|
31961
32107
|
sourceTool: input.sourceTool,
|
package/scripts/scan-worker.js
CHANGED
|
@@ -8329,7 +8329,11 @@ var ListFindingTypesQuery = object({
|
|
|
8329
8329
|
// and so is not bounded by what any page happens to hold.
|
|
8330
8330
|
includeId: string2().optional(),
|
|
8331
8331
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8332
|
-
cursor: string2().optional()
|
|
8332
|
+
cursor: string2().optional(),
|
|
8333
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8334
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8335
|
+
// from wherever it lands.
|
|
8336
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8333
8337
|
});
|
|
8334
8338
|
var ListFindingTypesResponse = object({
|
|
8335
8339
|
totals: object({
|
|
@@ -8409,7 +8413,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8409
8413
|
sessionId: string2().optional(),
|
|
8410
8414
|
from: iso_exports.datetime().optional(),
|
|
8411
8415
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8412
|
-
cursor: string2().optional()
|
|
8416
|
+
cursor: string2().optional(),
|
|
8417
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8418
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8419
|
+
// from wherever it lands.
|
|
8420
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8413
8421
|
});
|
|
8414
8422
|
var ListFindingInstancesResponse = object({
|
|
8415
8423
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8480,7 +8488,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8480
8488
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8481
8489
|
includeId: string2().optional(),
|
|
8482
8490
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8483
|
-
cursor: string2().optional()
|
|
8491
|
+
cursor: string2().optional(),
|
|
8492
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8493
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8494
|
+
// from wherever it lands.
|
|
8495
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8484
8496
|
});
|
|
8485
8497
|
var ListFindingLocationsResponse = object({
|
|
8486
8498
|
totals: object({
|
|
@@ -10877,7 +10889,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
10877
10889
|
var ListVaultInventoryQuery = object({
|
|
10878
10890
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
10879
10891
|
// Opaque; names the last row of the page just served.
|
|
10880
|
-
cursor: string2().optional()
|
|
10892
|
+
cursor: string2().optional(),
|
|
10893
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
10894
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
10895
|
+
// from wherever it lands.
|
|
10896
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
10881
10897
|
});
|
|
10882
10898
|
var ListVaultInventoryResponse = object({
|
|
10883
10899
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -10889,7 +10905,11 @@ var ListVaultInventoryResponse = object({
|
|
|
10889
10905
|
});
|
|
10890
10906
|
var ListVaultReuseQuery = object({
|
|
10891
10907
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
10892
|
-
cursor: string2().optional()
|
|
10908
|
+
cursor: string2().optional(),
|
|
10909
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
10910
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
10911
|
+
// from wherever it lands.
|
|
10912
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
10893
10913
|
});
|
|
10894
10914
|
var ListVaultReuseResponse = object({
|
|
10895
10915
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -10905,9 +10925,15 @@ var ListVaultDerefsQuery = object({
|
|
|
10905
10925
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
10906
10926
|
includeBatched: boolean2().optional(),
|
|
10907
10927
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
10908
|
-
cursor: string2().optional()
|
|
10928
|
+
cursor: string2().optional(),
|
|
10929
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
10930
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
10931
|
+
// from wherever it lands.
|
|
10932
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
10909
10933
|
});
|
|
10910
10934
|
var ListVaultDerefsResponse = object({
|
|
10935
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
10936
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
10911
10937
|
items: array(VaultDeref),
|
|
10912
10938
|
nextCursor: string2().nullable(),
|
|
10913
10939
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -13495,6 +13521,21 @@ function passesPostValidators(rule, value) {
|
|
|
13495
13521
|
function getLoadedRules() {
|
|
13496
13522
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
13497
13523
|
}
|
|
13524
|
+
function outsideWrittenRegions(candidates, context) {
|
|
13525
|
+
const regions = context?.writtenRegions;
|
|
13526
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
13527
|
+
return candidates.filter((c) => {
|
|
13528
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
13529
|
+
const { start, end } = c.match.span;
|
|
13530
|
+
return !regions.some(
|
|
13531
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
13532
|
+
c.rule,
|
|
13533
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
13534
|
+
"code_change"
|
|
13535
|
+
)
|
|
13536
|
+
);
|
|
13537
|
+
});
|
|
13538
|
+
}
|
|
13498
13539
|
function spansOverlap(a, b) {
|
|
13499
13540
|
return a.start < b.end && a.end > b.start;
|
|
13500
13541
|
}
|
|
@@ -13682,17 +13723,20 @@ function scanEncoded(text, ruleset2, context) {
|
|
|
13682
13723
|
function scanText(text, ruleset2, context) {
|
|
13683
13724
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
13684
13725
|
const normalization = normalizeFormatChars(text);
|
|
13685
|
-
const originalCandidates =
|
|
13726
|
+
const originalCandidates = outsideWrittenRegions(
|
|
13727
|
+
buildCandidates(text, ruleset2, extension, context?.eventKind),
|
|
13728
|
+
context
|
|
13729
|
+
);
|
|
13686
13730
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
13687
13731
|
const pooledOriginal = originalCandidates.map(
|
|
13688
13732
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
13689
13733
|
);
|
|
13690
|
-
const normalizedCandidates =
|
|
13691
|
-
normalization.normalized,
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
context
|
|
13695
|
-
)
|
|
13734
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
13735
|
+
buildCandidates(normalization.normalized, ruleset2, extension, context?.eventKind).map(
|
|
13736
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
13737
|
+
),
|
|
13738
|
+
context
|
|
13739
|
+
);
|
|
13696
13740
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
13697
13741
|
return mergeOverlappingSameRule(findings, text);
|
|
13698
13742
|
}
|
|
@@ -14015,6 +14059,21 @@ var ruleset = [...verified, ...unverified];
|
|
|
14015
14059
|
function post(message) {
|
|
14016
14060
|
port.postMessage(message);
|
|
14017
14061
|
}
|
|
14062
|
+
var MAX_REGIONS = 64;
|
|
14063
|
+
function validRegions(value, length) {
|
|
14064
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > MAX_REGIONS) return void 0;
|
|
14065
|
+
let previousEnd = 0;
|
|
14066
|
+
for (const region of value) {
|
|
14067
|
+
if (typeof region !== "object" || region === null) return void 0;
|
|
14068
|
+
const { start, end, filePath } = region;
|
|
14069
|
+
if (filePath !== void 0 && typeof filePath !== "string") return void 0;
|
|
14070
|
+
if (typeof start !== "number" || typeof end !== "number") return void 0;
|
|
14071
|
+
if (!Number.isInteger(start) || !Number.isInteger(end)) return void 0;
|
|
14072
|
+
if (start < previousEnd || start >= end || end > length) return void 0;
|
|
14073
|
+
previousEnd = end;
|
|
14074
|
+
}
|
|
14075
|
+
return value;
|
|
14076
|
+
}
|
|
14018
14077
|
port.on("message", (job) => {
|
|
14019
14078
|
try {
|
|
14020
14079
|
if (job.kind === "probe") {
|
|
@@ -14030,7 +14089,8 @@ port.on("message", (job) => {
|
|
|
14030
14089
|
});
|
|
14031
14090
|
return;
|
|
14032
14091
|
}
|
|
14033
|
-
const
|
|
14092
|
+
const writtenRegions = validRegions(job.writtenRegions, job.text.length);
|
|
14093
|
+
const context = job.filePath === void 0 && job.eventKind === void 0 && writtenRegions === void 0 ? void 0 : { filePath: job.filePath, eventKind: job.eventKind, writtenRegions };
|
|
14034
14094
|
if (job.attribute) {
|
|
14035
14095
|
for (const [index, rule] of unverified.entries()) {
|
|
14036
14096
|
post({ kind: "progress", index });
|