@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.
@@ -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 = buildCandidates(text, ruleset, extension, context?.eventKind);
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 = buildCandidates(
15310
- normalization.normalized,
15311
- ruleset,
15312
- extension,
15313
- context?.eventKind
15314
- ).map((candidate) => mapCandidateToOriginal(candidate, normalization, text));
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: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
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: `(["'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?=))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?["']\\s*\\+`,
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: `(["'\`])\\s*(?=((?:select\\b(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b)|\\1)[^\\n])*?\\bfrom\\b)|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))\\2(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b)|\\1)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|(["'\`])\\s*(?=((?:(?!\\3)[^\\n])*?\\bwhere\\b(?:(?!\\bwhere\\b|\\3)[^\\n])*?=))\\4(?:(?!\\bwhere\\b|\\3)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|(?<=^|\\n)[ \\t]*(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))\\5(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?(?:=\\s*['"]?\\s*(?:%[sd]|\\{[^{}\\n]+\\})|[#$]\\{[^{}\\n]+\\})`,
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: "([\"'`])\\s*\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])|(?<=^|\\n)[ \\t]*(?:select|insert|update|delete|where)\\s[^\\n]*?(?:#\\{|\\$[a-z_])",
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.3",
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 cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
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 cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
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 cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
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 hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28393
- this.db,
28394
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
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) continue;
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
- continue;
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
@@ -30808,8 +30934,25 @@ function bundledMaskingRules() {
30808
30934
  return ensureBundledPacks() ? getLoadedRules() : null;
30809
30935
  }
30810
30936
 
30937
+ // ../../packages/plugin-sdk/src/regular-file.ts
30938
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
30939
+ function notRegularFile(path) {
30940
+ return `not a regular file: ${path}`;
30941
+ }
30942
+ function readRegularFile(path, maxBytes) {
30943
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
30944
+ try {
30945
+ const stat2 = fstatSync(fd);
30946
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
30947
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
30948
+ return readFileSync16(fd, "utf8");
30949
+ } finally {
30950
+ closeSync2(fd);
30951
+ }
30952
+ }
30953
+
30811
30954
  // ../../packages/plugin-sdk/src/repo.ts
30812
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
30955
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30813
30956
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30814
30957
  function remoteWithoutCredentials(remote) {
30815
30958
  const withoutInfo = withoutUserinfo(remote);
@@ -30898,9 +31041,10 @@ function resolveGitContext(root) {
30898
31041
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30899
31042
  return { configPath: join24(commonGitDir, "config"), headRoot };
30900
31043
  }
31044
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
30901
31045
  function safeRead(path) {
30902
31046
  try {
30903
- return readFileSync16(path, "utf8");
31047
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
30904
31048
  } catch {
30905
31049
  return void 0;
30906
31050
  }
@@ -31221,6 +31365,7 @@ function createIsolatedScanner(data, opts = {}) {
31221
31365
  text,
31222
31366
  filePath: context?.filePath,
31223
31367
  eventKind: context?.eventKind,
31368
+ writtenRegions: context?.writtenRegions,
31224
31369
  attribute: scanOpts?.attribute === true
31225
31370
  }),
31226
31371
  reply: (message) => {
@@ -31958,7 +32103,8 @@ function createPluginRuntime(gateway, settings, opts) {
31958
32103
  input.text,
31959
32104
  {
31960
32105
  filePath: input.metadata?.filePath,
31961
- eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
32106
+ eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
32107
+ writtenRegions: opts2.writtenRegions
31962
32108
  },
31963
32109
  {
31964
32110
  sourceTool: input.sourceTool,