@akasecurity/ai-tc-antigravity 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.
@@ -8783,7 +8783,11 @@ var ListFindingTypesQuery = object({
8783
8783
  // and so is not bounded by what any page happens to hold.
8784
8784
  includeId: string2().optional(),
8785
8785
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8786
- cursor: string2().optional()
8786
+ cursor: string2().optional(),
8787
+ // A row position to read from, for jumping to a page instead of stepping to
8788
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8789
+ // from wherever it lands.
8790
+ offset: coerce_exports.number().int().min(0).optional()
8787
8791
  });
8788
8792
  var ListFindingTypesResponse = object({
8789
8793
  totals: object({
@@ -8864,7 +8868,11 @@ var ListFindingInstancesQuery = object({
8864
8868
  sessionId: string2().optional(),
8865
8869
  from: iso_exports.datetime().optional(),
8866
8870
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8867
- cursor: string2().optional()
8871
+ cursor: string2().optional(),
8872
+ // A row position to read from, for jumping to a page instead of stepping to
8873
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8874
+ // from wherever it lands.
8875
+ offset: coerce_exports.number().int().min(0).optional()
8868
8876
  });
8869
8877
  var ListFindingInstancesResponse = object({
8870
8878
  // Instances matching the filters across the whole scope, not just this
@@ -8936,7 +8944,11 @@ var ListFindingLocationsQuery = object({
8936
8944
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8937
8945
  includeId: string2().optional(),
8938
8946
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8939
- cursor: string2().optional()
8947
+ cursor: string2().optional(),
8948
+ // A row position to read from, for jumping to a page instead of stepping to
8949
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8950
+ // from wherever it lands.
8951
+ offset: coerce_exports.number().int().min(0).optional()
8940
8952
  });
8941
8953
  var ListFindingLocationsResponse = object({
8942
8954
  totals: object({
@@ -11573,7 +11585,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11573
11585
  var ListVaultInventoryQuery = object({
11574
11586
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11575
11587
  // Opaque; names the last row of the page just served.
11576
- cursor: string2().optional()
11588
+ cursor: string2().optional(),
11589
+ // A row position to read from, for jumping to a page instead of stepping to
11590
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11591
+ // from wherever it lands.
11592
+ offset: coerce_exports.number().int().min(0).optional()
11577
11593
  });
11578
11594
  var ListVaultInventoryResponse = object({
11579
11595
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11585,7 +11601,11 @@ var ListVaultInventoryResponse = object({
11585
11601
  });
11586
11602
  var ListVaultReuseQuery = object({
11587
11603
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11588
- cursor: string2().optional()
11604
+ cursor: string2().optional(),
11605
+ // A row position to read from, for jumping to a page instead of stepping to
11606
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11607
+ // from wherever it lands.
11608
+ offset: coerce_exports.number().int().min(0).optional()
11589
11609
  });
11590
11610
  var ListVaultReuseResponse = object({
11591
11611
  // Reused values across the whole store — the number the section's claim
@@ -11601,9 +11621,15 @@ var ListVaultDerefsQuery = object({
11601
11621
  // over a Server Action, which preserves the type, never as a URL param.
11602
11622
  includeBatched: boolean2().optional(),
11603
11623
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11604
- cursor: string2().optional()
11624
+ cursor: string2().optional(),
11625
+ // A row position to read from, for jumping to a page instead of stepping to
11626
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11627
+ // from wherever it lands.
11628
+ offset: coerce_exports.number().int().min(0).optional()
11605
11629
  });
11606
11630
  var ListVaultDerefsResponse = object({
11631
+ // Rows this filter selects across the whole trail, not just this page.
11632
+ totals: object({ derefs: number2().int().nonnegative() }),
11607
11633
  items: array(VaultDeref),
11608
11634
  nextCursor: string2().nullable(),
11609
11635
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -15120,6 +15146,21 @@ function registerPack(pack) {
15120
15146
  function getLoadedRules() {
15121
15147
  return [...packs.values()].flatMap((p) => p.rules);
15122
15148
  }
15149
+ function outsideWrittenRegions(candidates, context) {
15150
+ const regions = context?.writtenRegions;
15151
+ if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
15152
+ return candidates.filter((c) => {
15153
+ if (c.rule.category !== "code_flaw") return true;
15154
+ const { start, end } = c.match.span;
15155
+ return !regions.some(
15156
+ (r) => r.start <= start && end <= r.end && ruleApplies(
15157
+ c.rule,
15158
+ r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
15159
+ "code_change"
15160
+ )
15161
+ );
15162
+ });
15163
+ }
15123
15164
  function spansOverlap(a, b) {
15124
15165
  return a.start < b.end && a.end > b.start;
15125
15166
  }
@@ -15307,17 +15348,20 @@ function scanEncoded(text, ruleset, context) {
15307
15348
  function scanText(text, ruleset, context) {
15308
15349
  const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
15309
15350
  const normalization = normalizeFormatChars(text);
15310
- const originalCandidates = buildCandidates(text, ruleset, extension, context?.eventKind);
15351
+ const originalCandidates = outsideWrittenRegions(
15352
+ buildCandidates(text, ruleset, extension, context?.eventKind),
15353
+ context
15354
+ );
15311
15355
  if (!normalization) return gate(originalCandidates, text, void 0);
15312
15356
  const pooledOriginal = originalCandidates.map(
15313
15357
  (candidate) => withNormalizedSpan(candidate, normalization)
15314
15358
  );
15315
- const normalizedCandidates = buildCandidates(
15316
- normalization.normalized,
15317
- ruleset,
15318
- extension,
15319
- context?.eventKind
15320
- ).map((candidate) => mapCandidateToOriginal(candidate, normalization, text));
15359
+ const normalizedCandidates = outsideWrittenRegions(
15360
+ buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
15361
+ (candidate) => mapCandidateToOriginal(candidate, normalization, text)
15362
+ ),
15363
+ context
15364
+ );
15321
15365
  const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
15322
15366
  return mergeOverlappingSameRule(findings, text);
15323
15367
  }
@@ -15378,6 +15422,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
15378
15422
  "code-flaws/sql-inject-concat-dot",
15379
15423
  "code-flaws/sql-inject-format",
15380
15424
  "code-flaws/sql-inject-interp",
15425
+ "code-flaws/sql-inject-interp-multiline",
15381
15426
  "code-flaws/ssrf-user-url",
15382
15427
  "code-flaws/xss-dangerously-set",
15383
15428
  "code-flaws/xss-inner-html",
@@ -16616,7 +16661,7 @@ var sql_inject_concat_dot_default = {
16616
16661
  severity: "high",
16617
16662
  matcher: {
16618
16663
  type: "regex",
16619
- pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
16664
+ 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*\\.",
16620
16665
  flags: "gi"
16621
16666
  },
16622
16667
  appliesTo: {
@@ -16634,7 +16679,7 @@ var sql_inject_concat_default = {
16634
16679
  severity: "high",
16635
16680
  matcher: {
16636
16681
  type: "regex",
16637
- 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*\\+`,
16682
+ 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*\\+",
16638
16683
  flags: "gi"
16639
16684
  },
16640
16685
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -16649,7 +16694,7 @@ var sql_inject_format_default = {
16649
16694
  severity: "high",
16650
16695
  matcher: {
16651
16696
  type: "regex",
16652
- 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]+\\})`,
16697
+ 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]+\\})",
16653
16698
  flags: "gi"
16654
16699
  },
16655
16700
  examples: [
@@ -16658,6 +16703,24 @@ var sql_inject_format_default = {
16658
16703
  ]
16659
16704
  };
16660
16705
 
16706
+ // ../../rules/code-flaws/sql-inject-interp-multiline.json
16707
+ var sql_inject_interp_multiline_default = {
16708
+ specVersion: 1,
16709
+ id: "code-flaws/sql-inject-interp-multiline",
16710
+ name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
16711
+ category: "code_flaw",
16712
+ severity: "high",
16713
+ matcher: {
16714
+ type: "regex",
16715
+ 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_])',
16716
+ flags: "gi"
16717
+ },
16718
+ examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
16719
+ appliesTo: {
16720
+ extensions: [".rb", ".php"]
16721
+ }
16722
+ };
16723
+
16661
16724
  // ../../rules/code-flaws/sql-inject-interp.json
16662
16725
  var sql_inject_interp_default = {
16663
16726
  specVersion: 1,
@@ -16667,7 +16730,7 @@ var sql_inject_interp_default = {
16667
16730
  severity: "high",
16668
16731
  matcher: {
16669
16732
  type: "regex",
16670
- pattern: "([\"'`])\\s*\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])|(?<=^|\\n)[ \\t]*(?:select|insert|update|delete|where)\\s[^\\n]*?(?:#\\{|\\$[a-z_])",
16733
+ 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_])',
16671
16734
  flags: "gi"
16672
16735
  },
16673
16736
  examples: [
@@ -18395,12 +18458,13 @@ var BUNDLED_PACKS = [
18395
18458
  {
18396
18459
  packId: "code-flaws",
18397
18460
  name: "Code Security Flaws",
18398
- version: "0.1.3",
18461
+ version: "0.1.6",
18399
18462
  rawRules: [
18400
18463
  sql_inject_concat_default,
18401
18464
  sql_inject_concat_dot_default,
18402
18465
  sql_inject_format_default,
18403
18466
  sql_inject_interp_default,
18467
+ sql_inject_interp_multiline_default,
18404
18468
  cmd_inject_shell_default,
18405
18469
  cmd_inject_exec_default,
18406
18470
  cmd_inject_node_exec_default,
@@ -18432,6 +18496,7 @@ var BUNDLED_PACKS = [
18432
18496
  "code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
18433
18497
  "code-flaws/sql-inject-format": "SQL injection (format string)",
18434
18498
  "code-flaws/sql-inject-interp": "SQL injection (interpolation)",
18499
+ "code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
18435
18500
  "code-flaws/cmd-inject-shell": "Command injection (shell)",
18436
18501
  "code-flaws/cmd-inject-exec": "Command injection (Java exec)",
18437
18502
  "code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
@@ -25228,7 +25293,7 @@ var SqliteFindingsRepository = class {
25228
25293
  };
25229
25294
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
25230
25295
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
25231
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
25296
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
25232
25297
  const page = sorted.slice(start, start + limit);
25233
25298
  const lastOnPage = page.at(-1);
25234
25299
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -25322,7 +25387,7 @@ var SqliteFindingsRepository = class {
25322
25387
  accumulator.add(row);
25323
25388
  if (!matchesInstanceFilters(row, opts)) continue;
25324
25389
  total += 1;
25325
- if (!isPastCursor(row)) continue;
25390
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
25326
25391
  if (items.length < limit) {
25327
25392
  items.push(toInstanceDetail(row));
25328
25393
  last = row;
@@ -25411,7 +25476,7 @@ var SqliteFindingsRepository = class {
25411
25476
  }
25412
25477
  }
25413
25478
  sorted.sort(compareLocationOrder);
25414
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
25479
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
25415
25480
  const page = sorted.slice(start, start + limit);
25416
25481
  const lastOnPage = page.at(-1);
25417
25482
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -28039,6 +28104,9 @@ function pageLimit(requested, fallback) {
28039
28104
  if (requested === void 0) return fallback;
28040
28105
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
28041
28106
  }
28107
+ function pageOffset(requested) {
28108
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
28109
+ }
28042
28110
  function encodeReuseCursor(payload) {
28043
28111
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
28044
28112
  }
@@ -28386,7 +28454,8 @@ var SqliteSecretVaultRepository = class {
28386
28454
  */
28387
28455
  listInventory(query = {}, now = Date.now()) {
28388
28456
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28389
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28457
+ const offset = pageOffset(query.offset);
28458
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28390
28459
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
28391
28460
  const rows = allRows(
28392
28461
  this.db.prepare(
@@ -28400,11 +28469,12 @@ var SqliteSecretVaultRepository = class {
28400
28469
  FROM secret_vault v
28401
28470
  ${where}
28402
28471
  ORDER BY v.last_seen DESC, v.pointer_id DESC
28403
- LIMIT :limit`
28472
+ LIMIT :limit OFFSET :offset`
28404
28473
  ),
28405
28474
  bindParams({
28406
28475
  now,
28407
28476
  limit: limit + 1,
28477
+ offset,
28408
28478
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
28409
28479
  })
28410
28480
  );
@@ -28428,7 +28498,8 @@ var SqliteSecretVaultRepository = class {
28428
28498
  */
28429
28499
  listReuse(query = {}, now = Date.now()) {
28430
28500
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28431
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
28501
+ const offset = pageOffset(query.offset);
28502
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
28432
28503
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
28433
28504
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
28434
28505
  const rows = allRows(
@@ -28443,11 +28514,12 @@ var SqliteSecretVaultRepository = class {
28443
28514
  FROM secret_vault v
28444
28515
  WHERE ${REUSED_PREDICATE} ${after}
28445
28516
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
28446
- LIMIT :limit`
28517
+ LIMIT :limit OFFSET :offset`
28447
28518
  ),
28448
28519
  bindParams({
28449
28520
  now,
28450
28521
  limit: limit + 1,
28522
+ offset,
28451
28523
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
28452
28524
  })
28453
28525
  );
@@ -28472,7 +28544,8 @@ var SqliteSecretVaultRepository = class {
28472
28544
  */
28473
28545
  listDerefs(query = {}) {
28474
28546
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
28475
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28547
+ const offset = pageOffset(query.offset);
28548
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28476
28549
  const conditions = [];
28477
28550
  if (query.includeBatched !== true) {
28478
28551
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -28485,21 +28558,28 @@ var SqliteSecretVaultRepository = class {
28485
28558
  this.db.prepare(
28486
28559
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
28487
28560
  FROM secret_vault_deref ${where}
28488
- ORDER BY at DESC, id DESC LIMIT :limit`
28561
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
28489
28562
  ),
28490
28563
  bindParams({
28491
28564
  limit: limit + 1,
28565
+ offset,
28492
28566
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
28493
28567
  })
28494
28568
  );
28495
28569
  const hasMore = rows.length > limit;
28496
28570
  const page = hasMore ? rows.slice(0, limit) : rows;
28497
28571
  const last = page[page.length - 1];
28498
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28499
- this.db,
28500
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
28501
- );
28572
+ const counts = getRow(
28573
+ this.db.prepare(
28574
+ `SELECT count(*) AS total,
28575
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
28576
+ FROM secret_vault_deref`
28577
+ )
28578
+ ) ?? { total: 0, hidden: 0 };
28579
+ const includeBatched = query.includeBatched === true;
28580
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
28502
28581
  return {
28582
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
28503
28583
  items: page.map((r) => ({
28504
28584
  id: r.id,
28505
28585
  pointerId: r.pointer_id,
@@ -28524,6 +28604,43 @@ var SqliteSecretVaultRepository = class {
28524
28604
  `SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
28525
28605
  );
28526
28606
  }
28607
+ /**
28608
+ * Every entry held, and how many of them are NOT under `currentVersion` — the
28609
+ * standing record of a fingerprint-key rotation whose re-key did not reach
28610
+ * every row.
28611
+ *
28612
+ * This is the durable form of what `SecretVault.refreshFingerprints` reports
28613
+ * once. That count is an event, gone the moment it is printed; this is the
28614
+ * condition, and it stays true until some later rotation re-keys the rows. It
28615
+ * is therefore the one that can answer "is a shortfall still outstanding?" —
28616
+ * including for a rotation run from the CLI, which no dashboard render saw.
28617
+ *
28618
+ * `<>` rather than `<`: a row ahead of the current version is equally
28619
+ * unmatchable, and that is reachable — a key file restored from a backup, or
28620
+ * replaced after being lost, leaves rows stamped higher than the key is.
28621
+ *
28622
+ * Both numbers come from ONE statement, which is why this returns a pair
28623
+ * instead of offering two counts to call. Read separately, a purge landing
28624
+ * between them hands back a `stale` counted over rows the later `total` no
28625
+ * longer includes, and a disclosure built from that pair states a fraction
28626
+ * true of no state of the table — "1 of 0 stored values", or a negative
28627
+ * remainder. Same reasoning as `purgeVault`'s count, which comes from the
28628
+ * delete rather than from a `countEntries` standing beside it.
28629
+ */
28630
+ countFingerprintEpochs(currentVersion) {
28631
+ const row = getRow(
28632
+ this.db.prepare(
28633
+ `SELECT COUNT(*) AS total,
28634
+ COALESCE(
28635
+ SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
28636
+ 0
28637
+ ) AS stale
28638
+ FROM secret_vault`
28639
+ ),
28640
+ { currentVersion }
28641
+ ) ?? { stale: 0, total: 0 };
28642
+ return { stale: row.stale, total: row.total };
28643
+ }
28527
28644
  };
28528
28645
 
28529
28646
  // ../../packages/persistence/src/repositories/security.ts
@@ -30333,13 +30450,22 @@ var SecretVault = class {
30333
30450
  * fingerprint collides with a row already refreshed, is skipped rather than
30334
30451
  * aborting the pass — one damaged entry must not strand the re-key of every
30335
30452
  * other. A skipped row keeps resolving under its old fingerprint epoch.
30453
+ *
30454
+ * Every skip is COUNTED, because best-effort and silent are different things:
30455
+ * the loss above is invisible at the moment it happens and only shows up later
30456
+ * as a duplicate pointer, so the pass owes its caller a denominator rather
30457
+ * than a bare success count.
30336
30458
  */
30337
30459
  async refreshFingerprints(next) {
30338
30460
  let refreshed = 0;
30461
+ let skipped = 0;
30339
30462
  for (const row of this.#repo.listAll()) {
30340
30463
  try {
30341
30464
  const raw = await this.#openRow(row);
30342
- if (raw === null) continue;
30465
+ if (raw === null) {
30466
+ skipped += 1;
30467
+ continue;
30468
+ }
30343
30469
  this.#repo.refreshFingerprint(row.pointerId, {
30344
30470
  valueFingerprint: exactFingerprintValue(next, raw),
30345
30471
  valueIdentityFingerprint: fingerprintValue(next, raw),
@@ -30347,10 +30473,10 @@ var SecretVault = class {
30347
30473
  });
30348
30474
  refreshed += 1;
30349
30475
  } catch {
30350
- continue;
30476
+ skipped += 1;
30351
30477
  }
30352
30478
  }
30353
- return refreshed;
30479
+ return { refreshed, skipped };
30354
30480
  }
30355
30481
  /**
30356
30482
  * Destroy every entry, making all outstanding pointers permanently
@@ -30929,8 +31055,25 @@ function scanText2(text, ruleVersions, options = {}) {
30929
31055
  }
30930
31056
  }
30931
31057
 
31058
+ // ../../packages/plugin-sdk/src/regular-file.ts
31059
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
31060
+ function notRegularFile(path) {
31061
+ return `not a regular file: ${path}`;
31062
+ }
31063
+ function readRegularFile(path, maxBytes) {
31064
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
31065
+ try {
31066
+ const stat2 = fstatSync(fd);
31067
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
31068
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
31069
+ return readFileSync16(fd, "utf8");
31070
+ } finally {
31071
+ closeSync2(fd);
31072
+ }
31073
+ }
31074
+
30932
31075
  // ../../packages/plugin-sdk/src/repo.ts
30933
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
31076
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30934
31077
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30935
31078
  function remoteWithoutCredentials(remote) {
30936
31079
  const withoutInfo = withoutUserinfo(remote);
@@ -31034,9 +31177,10 @@ function resolveGitContext(root) {
31034
31177
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
31035
31178
  return { configPath: join24(commonGitDir, "config"), headRoot };
31036
31179
  }
31180
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
31037
31181
  function safeRead(path) {
31038
31182
  try {
31039
- return readFileSync16(path, "utf8");
31183
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
31040
31184
  } catch {
31041
31185
  return void 0;
31042
31186
  }
@@ -31357,6 +31501,7 @@ function createIsolatedScanner(data, opts = {}) {
31357
31501
  text,
31358
31502
  filePath: context?.filePath,
31359
31503
  eventKind: context?.eventKind,
31504
+ writtenRegions: context?.writtenRegions,
31360
31505
  attribute: scanOpts?.attribute === true
31361
31506
  }),
31362
31507
  reply: (message) => {
@@ -32131,7 +32276,8 @@ function createPluginRuntime(gateway, settings, opts) {
32131
32276
  input.text,
32132
32277
  {
32133
32278
  filePath: input.metadata?.filePath,
32134
- eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
32279
+ eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
32280
+ writtenRegions: opts2.writtenRegions
32135
32281
  },
32136
32282
  {
32137
32283
  sourceTool: input.sourceTool,
@@ -35792,7 +35938,7 @@ import { dirname as dirname11 } from "path";
35792
35938
  var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
35793
35939
 
35794
35940
  // src/history/transcripts.ts
35795
- import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync25, readSync, statSync as statSync10 } from "fs";
35941
+ import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync3, readFileSync as readFileSync25, readSync, statSync as statSync10 } from "fs";
35796
35942
  import { homedir as homedir3 } from "os";
35797
35943
  import { join as join39 } from "path";
35798
35944
  function transcriptsDir(home) {
@@ -36183,10 +36329,10 @@ function pluginBuild() {
36183
36329
  // src/history/tail.ts
36184
36330
  import { createHash as createHash13 } from "crypto";
36185
36331
  import {
36186
- closeSync as closeSync3,
36187
- fstatSync,
36332
+ closeSync as closeSync4,
36333
+ fstatSync as fstatSync2,
36188
36334
  mkdirSync as mkdirSync2,
36189
- openSync as openSync3,
36335
+ openSync as openSync4,
36190
36336
  readFileSync as readFileSync26,
36191
36337
  readSync as readSync2,
36192
36338
  writeFileSync as writeFileSync7