@akasecurity/ai-tc-codex 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
@@ -15129,6 +15155,21 @@ function registerPack(pack) {
15129
15155
  function getLoadedRules() {
15130
15156
  return [...packs.values()].flatMap((p) => p.rules);
15131
15157
  }
15158
+ function outsideWrittenRegions(candidates, context) {
15159
+ const regions = context?.writtenRegions;
15160
+ if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
15161
+ return candidates.filter((c) => {
15162
+ if (c.rule.category !== "code_flaw") return true;
15163
+ const { start, end } = c.match.span;
15164
+ return !regions.some(
15165
+ (r) => r.start <= start && end <= r.end && ruleApplies(
15166
+ c.rule,
15167
+ r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
15168
+ "code_change"
15169
+ )
15170
+ );
15171
+ });
15172
+ }
15132
15173
  function spansOverlap(a, b) {
15133
15174
  return a.start < b.end && a.end > b.start;
15134
15175
  }
@@ -15316,17 +15357,20 @@ function scanEncoded(text2, ruleset, context) {
15316
15357
  function scanText(text2, ruleset, context) {
15317
15358
  const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
15318
15359
  const normalization = normalizeFormatChars(text2);
15319
- const originalCandidates = buildCandidates(text2, ruleset, extension, context?.eventKind);
15360
+ const originalCandidates = outsideWrittenRegions(
15361
+ buildCandidates(text2, ruleset, extension, context?.eventKind),
15362
+ context
15363
+ );
15320
15364
  if (!normalization) return gate(originalCandidates, text2, void 0);
15321
15365
  const pooledOriginal = originalCandidates.map(
15322
15366
  (candidate) => withNormalizedSpan(candidate, normalization)
15323
15367
  );
15324
- const normalizedCandidates = buildCandidates(
15325
- normalization.normalized,
15326
- ruleset,
15327
- extension,
15328
- context?.eventKind
15329
- ).map((candidate) => mapCandidateToOriginal(candidate, normalization, text2));
15368
+ const normalizedCandidates = outsideWrittenRegions(
15369
+ buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
15370
+ (candidate) => mapCandidateToOriginal(candidate, normalization, text2)
15371
+ ),
15372
+ context
15373
+ );
15330
15374
  const findings = gate([...pooledOriginal, ...normalizedCandidates], text2, normalization);
15331
15375
  return mergeOverlappingSameRule(findings, text2);
15332
15376
  }
@@ -15387,6 +15431,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
15387
15431
  "code-flaws/sql-inject-concat-dot",
15388
15432
  "code-flaws/sql-inject-format",
15389
15433
  "code-flaws/sql-inject-interp",
15434
+ "code-flaws/sql-inject-interp-multiline",
15390
15435
  "code-flaws/ssrf-user-url",
15391
15436
  "code-flaws/xss-dangerously-set",
15392
15437
  "code-flaws/xss-inner-html",
@@ -16525,7 +16570,7 @@ var sql_inject_concat_dot_default = {
16525
16570
  severity: "high",
16526
16571
  matcher: {
16527
16572
  type: "regex",
16528
- pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
16573
+ pattern: "([\"'])(?=((?:(?!\\1)[^\\n])*?\\b(?:select\\b(?:(?!\\1|\\bselect\\b)[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?!\\1)['\"%]|between\\b)))))\\2(?:(?!\\1(?:(?!\\1)[^\\n])*?\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?[\"']\\s*\\.",
16529
16574
  flags: "gi"
16530
16575
  },
16531
16576
  appliesTo: {
@@ -16543,7 +16588,7 @@ var sql_inject_concat_default = {
16543
16588
  severity: "high",
16544
16589
  matcher: {
16545
16590
  type: "regex",
16546
- 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*\\+`,
16591
+ pattern: "([\"'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?!\\1)['\"%]|between\\b))))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?[\"']\\s*\\+",
16547
16592
  flags: "gi"
16548
16593
  },
16549
16594
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -16558,7 +16603,7 @@ var sql_inject_format_default = {
16558
16603
  severity: "high",
16559
16604
  matcher: {
16560
16605
  type: "regex",
16561
- 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]+\\})`,
16606
+ pattern: "([\"'`])\\s*(?=((?:select\\b(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b)|\\1)[^\\n])*?\\bfrom\\b)|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))\\2(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b)|\\1)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|([\"'`])\\s*(?=((?:(?!\\3)[^\\n])*?\\bwhere\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?=(?!\\3)['\"%])|between\\b))))\\4(?:(?!\\bwhere\\b|\\3)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|(?<=^|\\n)[ \\t]*(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))\\5(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))[^\\n])*?(?:=\\s*['\"]?\\s*(?:%[sd]|\\{[^{}\\n]+\\})|[#$]\\{[^{}\\n]+\\})",
16562
16607
  flags: "gi"
16563
16608
  },
16564
16609
  examples: [
@@ -16567,6 +16612,24 @@ var sql_inject_format_default = {
16567
16612
  ]
16568
16613
  };
16569
16614
 
16615
+ // ../../rules/code-flaws/sql-inject-interp-multiline.json
16616
+ var sql_inject_interp_multiline_default = {
16617
+ specVersion: 1,
16618
+ id: "code-flaws/sql-inject-interp-multiline",
16619
+ name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
16620
+ category: "code_flaw",
16621
+ severity: "high",
16622
+ matcher: {
16623
+ type: "regex",
16624
+ 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_])',
16625
+ flags: "gi"
16626
+ },
16627
+ examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
16628
+ appliesTo: {
16629
+ extensions: [".rb", ".php"]
16630
+ }
16631
+ };
16632
+
16570
16633
  // ../../rules/code-flaws/sql-inject-interp.json
16571
16634
  var sql_inject_interp_default = {
16572
16635
  specVersion: 1,
@@ -16576,7 +16639,7 @@ var sql_inject_interp_default = {
16576
16639
  severity: "high",
16577
16640
  matcher: {
16578
16641
  type: "regex",
16579
- pattern: "([\"'`])\\s*\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])|(?<=^|\\n)[ \\t]*(?:select|insert|update|delete|where)\\s[^\\n]*?(?:#\\{|\\$[a-z_])",
16642
+ pattern: '(?<![\\w\'"`})\\]])(["\'`])[ \\t]*(?=(?:select\\b(?:#\\{(?:[^{}\\n]|\\{(?:[^{}\\n]|\\{[^{}\\n]{0,100}\\}){0,100}\\}){0,200}\\}|\\{\\$[^}\\n]{0,200}\\}|\\\\(?!\\1[ \\t]*(?:select|insert|update|delete|where)\\b).|(?!\\1)(?!#\\{|\\{\\$|\\\\)[\\s\\S]){0,1000}?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+\\w+)\\s+){0,2}(?:into\\b|[\\w.`]+\\s*\\()|update\\s+(?:(?:low_priority|ignore|or\\s+\\w+)\\s+){0,2}(?:only\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?(?:\\s*,\\s*(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?){0,7}(?:(?:\\s+\\w+){0,2}\\s+join\\b(?:(?!\\bset\\b)(?!\\1)[^\\n]){1,300})?\\s+set(?:\\s+|(?=`))(?:(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+\\s*=|#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;),]|\\n|$|(?:where|order|limit)\\b)))|delete\\s+(?:(?:low_priority|quick|ignore)\\s+){0,3}(?:from\\b|[\\w.`]+(?:\\s*,\\s*[\\w.`]+)*\\s+from\\s+[\\w.`]+(?:\\s+(?:as\\s+)?\\w+)?\\s+(?:(?:inner|cross|(?:left|right)(?:\\s+outer)?)\\s+)?(?:join|using|where)\\b)|where\\s+(?:(?:not\\s+)?(?:\\(\\s*)*(?:#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;)]|\\n|$|(?:and|or|order|group|limit)\\b)))|(?:not\\s+)?exists\\s*\\(|(?:not\\s+)?(?:\\(\\s*)*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?(?:\\s*,\\s*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?){0,4}\\s*(?:\\)\\s*)?(?:[=<>!~@|&:%^*/+-]+|\\b(?:is|in|not|i?like|regexp|rlike|similar\\s+to|glob|between|against|match|exists|and|or)\\b))))\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])',
16580
16643
  flags: "gi"
16581
16644
  },
16582
16645
  examples: [
@@ -18304,12 +18367,13 @@ var BUNDLED_PACKS = [
18304
18367
  {
18305
18368
  packId: "code-flaws",
18306
18369
  name: "Code Security Flaws",
18307
- version: "0.1.3",
18370
+ version: "0.1.6",
18308
18371
  rawRules: [
18309
18372
  sql_inject_concat_default,
18310
18373
  sql_inject_concat_dot_default,
18311
18374
  sql_inject_format_default,
18312
18375
  sql_inject_interp_default,
18376
+ sql_inject_interp_multiline_default,
18313
18377
  cmd_inject_shell_default,
18314
18378
  cmd_inject_exec_default,
18315
18379
  cmd_inject_node_exec_default,
@@ -18341,6 +18405,7 @@ var BUNDLED_PACKS = [
18341
18405
  "code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
18342
18406
  "code-flaws/sql-inject-format": "SQL injection (format string)",
18343
18407
  "code-flaws/sql-inject-interp": "SQL injection (interpolation)",
18408
+ "code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
18344
18409
  "code-flaws/cmd-inject-shell": "Command injection (shell)",
18345
18410
  "code-flaws/cmd-inject-exec": "Command injection (Java exec)",
18346
18411
  "code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
@@ -25146,7 +25211,7 @@ var SqliteFindingsRepository = class {
25146
25211
  };
25147
25212
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
25148
25213
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
25149
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
25214
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
25150
25215
  const page = sorted.slice(start, start + limit);
25151
25216
  const lastOnPage = page.at(-1);
25152
25217
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -25240,7 +25305,7 @@ var SqliteFindingsRepository = class {
25240
25305
  accumulator.add(row);
25241
25306
  if (!matchesInstanceFilters(row, opts)) continue;
25242
25307
  total += 1;
25243
- if (!isPastCursor(row)) continue;
25308
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
25244
25309
  if (items.length < limit) {
25245
25310
  items.push(toInstanceDetail(row));
25246
25311
  last = row;
@@ -25329,7 +25394,7 @@ var SqliteFindingsRepository = class {
25329
25394
  }
25330
25395
  }
25331
25396
  sorted.sort(compareLocationOrder);
25332
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
25397
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
25333
25398
  const page = sorted.slice(start, start + limit);
25334
25399
  const lastOnPage = page.at(-1);
25335
25400
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -27957,6 +28022,9 @@ function pageLimit(requested, fallback) {
27957
28022
  if (requested === void 0) return fallback;
27958
28023
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
27959
28024
  }
28025
+ function pageOffset(requested) {
28026
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
28027
+ }
27960
28028
  function encodeReuseCursor(payload) {
27961
28029
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
27962
28030
  }
@@ -28304,7 +28372,8 @@ var SqliteSecretVaultRepository = class {
28304
28372
  */
28305
28373
  listInventory(query = {}, now = Date.now()) {
28306
28374
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28307
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28375
+ const offset = pageOffset(query.offset);
28376
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28308
28377
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
28309
28378
  const rows = allRows(
28310
28379
  this.db.prepare(
@@ -28318,11 +28387,12 @@ var SqliteSecretVaultRepository = class {
28318
28387
  FROM secret_vault v
28319
28388
  ${where}
28320
28389
  ORDER BY v.last_seen DESC, v.pointer_id DESC
28321
- LIMIT :limit`
28390
+ LIMIT :limit OFFSET :offset`
28322
28391
  ),
28323
28392
  bindParams({
28324
28393
  now,
28325
28394
  limit: limit + 1,
28395
+ offset,
28326
28396
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
28327
28397
  })
28328
28398
  );
@@ -28346,7 +28416,8 @@ var SqliteSecretVaultRepository = class {
28346
28416
  */
28347
28417
  listReuse(query = {}, now = Date.now()) {
28348
28418
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28349
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
28419
+ const offset = pageOffset(query.offset);
28420
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
28350
28421
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
28351
28422
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
28352
28423
  const rows = allRows(
@@ -28361,11 +28432,12 @@ var SqliteSecretVaultRepository = class {
28361
28432
  FROM secret_vault v
28362
28433
  WHERE ${REUSED_PREDICATE} ${after}
28363
28434
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
28364
- LIMIT :limit`
28435
+ LIMIT :limit OFFSET :offset`
28365
28436
  ),
28366
28437
  bindParams({
28367
28438
  now,
28368
28439
  limit: limit + 1,
28440
+ offset,
28369
28441
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
28370
28442
  })
28371
28443
  );
@@ -28390,7 +28462,8 @@ var SqliteSecretVaultRepository = class {
28390
28462
  */
28391
28463
  listDerefs(query = {}) {
28392
28464
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
28393
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28465
+ const offset = pageOffset(query.offset);
28466
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28394
28467
  const conditions = [];
28395
28468
  if (query.includeBatched !== true) {
28396
28469
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -28403,21 +28476,28 @@ var SqliteSecretVaultRepository = class {
28403
28476
  this.db.prepare(
28404
28477
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
28405
28478
  FROM secret_vault_deref ${where}
28406
- ORDER BY at DESC, id DESC LIMIT :limit`
28479
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
28407
28480
  ),
28408
28481
  bindParams({
28409
28482
  limit: limit + 1,
28483
+ offset,
28410
28484
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
28411
28485
  })
28412
28486
  );
28413
28487
  const hasMore = rows.length > limit;
28414
28488
  const page = hasMore ? rows.slice(0, limit) : rows;
28415
28489
  const last = page[page.length - 1];
28416
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28417
- this.db,
28418
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
28419
- );
28490
+ const counts = getRow(
28491
+ this.db.prepare(
28492
+ `SELECT count(*) AS total,
28493
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
28494
+ FROM secret_vault_deref`
28495
+ )
28496
+ ) ?? { total: 0, hidden: 0 };
28497
+ const includeBatched = query.includeBatched === true;
28498
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
28420
28499
  return {
28500
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
28421
28501
  items: page.map((r) => ({
28422
28502
  id: r.id,
28423
28503
  pointerId: r.pointer_id,
@@ -28442,6 +28522,43 @@ var SqliteSecretVaultRepository = class {
28442
28522
  `SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
28443
28523
  );
28444
28524
  }
28525
+ /**
28526
+ * Every entry held, and how many of them are NOT under `currentVersion` — the
28527
+ * standing record of a fingerprint-key rotation whose re-key did not reach
28528
+ * every row.
28529
+ *
28530
+ * This is the durable form of what `SecretVault.refreshFingerprints` reports
28531
+ * once. That count is an event, gone the moment it is printed; this is the
28532
+ * condition, and it stays true until some later rotation re-keys the rows. It
28533
+ * is therefore the one that can answer "is a shortfall still outstanding?" —
28534
+ * including for a rotation run from the CLI, which no dashboard render saw.
28535
+ *
28536
+ * `<>` rather than `<`: a row ahead of the current version is equally
28537
+ * unmatchable, and that is reachable — a key file restored from a backup, or
28538
+ * replaced after being lost, leaves rows stamped higher than the key is.
28539
+ *
28540
+ * Both numbers come from ONE statement, which is why this returns a pair
28541
+ * instead of offering two counts to call. Read separately, a purge landing
28542
+ * between them hands back a `stale` counted over rows the later `total` no
28543
+ * longer includes, and a disclosure built from that pair states a fraction
28544
+ * true of no state of the table — "1 of 0 stored values", or a negative
28545
+ * remainder. Same reasoning as `purgeVault`'s count, which comes from the
28546
+ * delete rather than from a `countEntries` standing beside it.
28547
+ */
28548
+ countFingerprintEpochs(currentVersion) {
28549
+ const row = getRow(
28550
+ this.db.prepare(
28551
+ `SELECT COUNT(*) AS total,
28552
+ COALESCE(
28553
+ SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
28554
+ 0
28555
+ ) AS stale
28556
+ FROM secret_vault`
28557
+ ),
28558
+ { currentVersion }
28559
+ ) ?? { stale: 0, total: 0 };
28560
+ return { stale: row.stale, total: row.total };
28561
+ }
28445
28562
  };
28446
28563
 
28447
28564
  // ../../packages/persistence/src/repositories/security.ts
@@ -30298,13 +30415,22 @@ var SecretVault = class {
30298
30415
  * fingerprint collides with a row already refreshed, is skipped rather than
30299
30416
  * aborting the pass — one damaged entry must not strand the re-key of every
30300
30417
  * other. A skipped row keeps resolving under its old fingerprint epoch.
30418
+ *
30419
+ * Every skip is COUNTED, because best-effort and silent are different things:
30420
+ * the loss above is invisible at the moment it happens and only shows up later
30421
+ * as a duplicate pointer, so the pass owes its caller a denominator rather
30422
+ * than a bare success count.
30301
30423
  */
30302
30424
  async refreshFingerprints(next) {
30303
30425
  let refreshed = 0;
30426
+ let skipped = 0;
30304
30427
  for (const row of this.#repo.listAll()) {
30305
30428
  try {
30306
30429
  const raw = await this.#openRow(row);
30307
- if (raw === null) continue;
30430
+ if (raw === null) {
30431
+ skipped += 1;
30432
+ continue;
30433
+ }
30308
30434
  this.#repo.refreshFingerprint(row.pointerId, {
30309
30435
  valueFingerprint: exactFingerprintValue(next, raw),
30310
30436
  valueIdentityFingerprint: fingerprintValue(next, raw),
@@ -30312,10 +30438,10 @@ var SecretVault = class {
30312
30438
  });
30313
30439
  refreshed += 1;
30314
30440
  } catch {
30315
- continue;
30441
+ skipped += 1;
30316
30442
  }
30317
30443
  }
30318
- return refreshed;
30444
+ return { refreshed, skipped };
30319
30445
  }
30320
30446
  /**
30321
30447
  * Destroy every entry, making all outstanding pointers permanently
@@ -30832,8 +30958,25 @@ function bundledMaskingRules() {
30832
30958
  return ensureBundledPacks() ? getLoadedRules() : null;
30833
30959
  }
30834
30960
 
30961
+ // ../../packages/plugin-sdk/src/regular-file.ts
30962
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
30963
+ function notRegularFile(path) {
30964
+ return `not a regular file: ${path}`;
30965
+ }
30966
+ function readRegularFile(path, maxBytes) {
30967
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
30968
+ try {
30969
+ const stat2 = fstatSync(fd);
30970
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
30971
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
30972
+ return readFileSync16(fd, "utf8");
30973
+ } finally {
30974
+ closeSync2(fd);
30975
+ }
30976
+ }
30977
+
30835
30978
  // ../../packages/plugin-sdk/src/repo.ts
30836
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
30979
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30837
30980
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30838
30981
  function remoteWithoutCredentials(remote) {
30839
30982
  const withoutInfo = withoutUserinfo(remote);
@@ -30922,9 +31065,10 @@ function resolveGitContext(root) {
30922
31065
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30923
31066
  return { configPath: join24(commonGitDir, "config"), headRoot };
30924
31067
  }
31068
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
30925
31069
  function safeRead(path) {
30926
31070
  try {
30927
- return readFileSync16(path, "utf8");
31071
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
30928
31072
  } catch {
30929
31073
  return void 0;
30930
31074
  }
@@ -31245,6 +31389,7 @@ function createIsolatedScanner(data, opts = {}) {
31245
31389
  text: text2,
31246
31390
  filePath: context?.filePath,
31247
31391
  eventKind: context?.eventKind,
31392
+ writtenRegions: context?.writtenRegions,
31248
31393
  attribute: scanOpts?.attribute === true
31249
31394
  }),
31250
31395
  reply: (message) => {
@@ -31582,10 +31727,10 @@ function isPositiveSafeInteger(value) {
31582
31727
 
31583
31728
  // ../../packages/plugin-sdk/src/model-governance.ts
31584
31729
  import {
31585
- closeSync as closeSync2,
31586
- fstatSync,
31730
+ closeSync as closeSync3,
31731
+ fstatSync as fstatSync2,
31587
31732
  mkdirSync as mkdirSync2,
31588
- openSync as openSync2,
31733
+ openSync as openSync3,
31589
31734
  readFileSync as readFileSync18,
31590
31735
  readSync,
31591
31736
  writeFileSync as writeFileSync5
@@ -31620,9 +31765,9 @@ function readSessionModel(dataDir2, sessionId) {
31620
31765
  }
31621
31766
  var TAIL_BYTES = 256 * 1024;
31622
31767
  function readTail(path) {
31623
- const fd = openSync2(path, "r");
31768
+ const fd = openSync3(path, "r");
31624
31769
  try {
31625
- const { size } = fstatSync(fd);
31770
+ const { size } = fstatSync2(fd);
31626
31771
  if (size <= TAIL_BYTES) return { text: readFileSync18(fd, "utf8"), truncated: false };
31627
31772
  const buffer = Buffer.allocUnsafe(TAIL_BYTES);
31628
31773
  let filled = 0;
@@ -31633,7 +31778,7 @@ function readTail(path) {
31633
31778
  }
31634
31779
  return { text: buffer.subarray(0, filled).toString("utf8"), truncated: true };
31635
31780
  } finally {
31636
- closeSync2(fd);
31781
+ closeSync3(fd);
31637
31782
  }
31638
31783
  }
31639
31784
  function modelFromTranscriptTail(transcriptPath, fromRecord) {
@@ -32225,7 +32370,8 @@ function createPluginRuntime(gateway, settings, opts) {
32225
32370
  input.text,
32226
32371
  {
32227
32372
  filePath: input.metadata?.filePath,
32228
- eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
32373
+ eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
32374
+ writtenRegions: opts2.writtenRegions
32229
32375
  },
32230
32376
  {
32231
32377
  sourceTool: input.sourceTool,
@@ -35712,21 +35858,21 @@ function resolveCodexHome(env, home = homedir3()) {
35712
35858
 
35713
35859
  // ../../packages/plugin-sdk/src/account/observation-log.ts
35714
35860
  import { createHash as createHash13 } from "crypto";
35715
- import { closeSync as closeSync3, constants, fstatSync as fstatSync2, mkdirSync as mkdirSync4, openSync as openSync3, readSync as readSync2, writeSync } from "fs";
35861
+ import { closeSync as closeSync4, constants as constants2, fstatSync as fstatSync3, mkdirSync as mkdirSync4, openSync as openSync4, readSync as readSync2, writeSync } from "fs";
35716
35862
  import { join as join37 } from "path";
35717
35863
  var SESSION_LOG_CAP_BYTES = 16 * 1024 * 1024;
35718
35864
  var SESSION_LOG_TAIL_BYTES = 64 * 1024;
35719
35865
  var NEWLINE = 10;
35720
35866
  var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
35721
35867
  function sessionLogOpenFlags(noFollow) {
35722
- return constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | (noFollow ?? 0);
35868
+ return constants2.O_WRONLY | constants2.O_APPEND | constants2.O_CREAT | (noFollow ?? 0);
35723
35869
  }
35724
35870
  var SESSION_LOG_OPEN_FLAGS = sessionLogOpenFlags(
35725
- constants.O_NOFOLLOW
35871
+ constants2.O_NOFOLLOW
35726
35872
  );
35727
35873
  function closeQuietly2(fd) {
35728
35874
  try {
35729
- closeSync3(fd);
35875
+ closeSync4(fd);
35730
35876
  } catch {
35731
35877
  }
35732
35878
  }
@@ -35749,8 +35895,8 @@ function appendObservation(stateDir, sessionId, observation, capBytes = SESSION_
35749
35895
  let fd;
35750
35896
  try {
35751
35897
  mkdirSync4(stateDir, { recursive: true, mode: DATA_DIR_MODE });
35752
- fd = openSync3(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
35753
- if (fstatSync2(fd).size + Buffer.byteLength(line) > capBytes) return false;
35898
+ fd = openSync4(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
35899
+ if (fstatSync3(fd).size + Buffer.byteLength(line) > capBytes) return false;
35754
35900
  writeSync(fd, line);
35755
35901
  return true;
35756
35902
  } catch {
@@ -35780,12 +35926,12 @@ function parseLines(buffer, base) {
35780
35926
  function readRange(path, from, capBytes) {
35781
35927
  let fd;
35782
35928
  try {
35783
- fd = openSync3(path, "r");
35929
+ fd = openSync4(path, "r");
35784
35930
  } catch {
35785
35931
  return void 0;
35786
35932
  }
35787
35933
  try {
35788
- const size = fstatSync2(fd).size;
35934
+ const size = fstatSync3(fd).size;
35789
35935
  const length = Math.max(0, Math.min(size, capBytes) - from);
35790
35936
  const buffer = Buffer.alloc(length);
35791
35937
  let filled = 0;
@@ -35832,7 +35978,7 @@ function classifyObservation(observation) {
35832
35978
  }
35833
35979
 
35834
35980
  // ../../packages/plugin-sdk/src/account/codex-head.ts
35835
- import { closeSync as closeSync4, openSync as openSync4, readSync as readSync3 } from "fs";
35981
+ import { closeSync as closeSync5, openSync as openSync5, readSync as readSync3 } from "fs";
35836
35982
  var CODEX_HEAD_READ_BYTES = 64 * 1024;
35837
35983
  var CODEX_HEAD_MAX_BYTES = 1024 * 1024;
35838
35984
  var NEWLINE2 = 10;
@@ -35865,7 +36011,7 @@ function parseHead(line) {
35865
36011
  function readCodexHead(rolloutPath) {
35866
36012
  let fd;
35867
36013
  try {
35868
- fd = openSync4(rolloutPath, "r");
36014
+ fd = openSync5(rolloutPath, "r");
35869
36015
  } catch (error2) {
35870
36016
  return isNotFound(error2) ? "pending" : void 0;
35871
36017
  }
@@ -35890,14 +36036,14 @@ function readCodexHead(rolloutPath) {
35890
36036
  return void 0;
35891
36037
  } finally {
35892
36038
  try {
35893
- closeSync4(fd);
36039
+ closeSync5(fd);
35894
36040
  } catch {
35895
36041
  }
35896
36042
  }
35897
36043
  }
35898
36044
 
35899
36045
  // ../../packages/plugin-sdk/src/account/codex-login.ts
35900
- import { closeSync as closeSync5, constants as constants2, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync5, readSync as readSync4 } from "fs";
36046
+ import { closeSync as closeSync6, constants as constants3, fstatSync as fstatSync4, lstatSync as lstatSync6, openSync as openSync6, readSync as readSync4 } from "fs";
35901
36047
  import { join as join38 } from "path";
35902
36048
  var CODEX_AUTH_MAX_BYTES = 64 * 1024;
35903
36049
  var CODEX_ID_TOKEN_MAX_CHARS = 16 * 1024;
@@ -35930,8 +36076,8 @@ var DROPPED = new Set(CODEX_DROPPED_FIELDS);
35930
36076
  var PRESENCE = new Set(CODEX_PRESENCE_FIELDS);
35931
36077
  var BASE64URL = /^[A-Za-z0-9_-]+$/;
35932
36078
  var UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
35933
- var NOFOLLOW = constants2.O_NOFOLLOW ?? 0;
35934
- var READ_FLAGS = constants2.O_RDONLY | NOFOLLOW;
36079
+ var NOFOLLOW = constants3.O_NOFOLLOW ?? 0;
36080
+ var READ_FLAGS = constants3.O_RDONLY | NOFOLLOW;
35935
36081
  var ABSENT = { status: "absent" };
35936
36082
  var MODE = { status: "mode" };
35937
36083
  var MALFORMED = { status: "malformed" };
@@ -36053,12 +36199,12 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
36053
36199
  let fd;
36054
36200
  try {
36055
36201
  if (platform === "win32" && lstatSync6(path).isSymbolicLink()) return MALFORMED;
36056
- fd = openSync5(path, openFlags);
36202
+ fd = openSync6(path, openFlags);
36057
36203
  } catch (error2) {
36058
36204
  return isNotFound2(error2) ? ABSENT : MALFORMED;
36059
36205
  }
36060
36206
  try {
36061
- const stat2 = fstatSync3(fd);
36207
+ const stat2 = fstatSync4(fd);
36062
36208
  if (!stat2.isFile() || stat2.size > CODEX_AUTH_MAX_BYTES) return MALFORMED;
36063
36209
  if (platform !== "win32" && (stat2.uid !== process.getuid?.() || (stat2.mode & 18) !== 0)) {
36064
36210
  return MALFORMED;
@@ -36070,7 +36216,7 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
36070
36216
  return MALFORMED;
36071
36217
  } finally {
36072
36218
  try {
36073
- closeSync5(fd);
36219
+ closeSync6(fd);
36074
36220
  } catch {
36075
36221
  }
36076
36222
  }