@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
@@ -20508,7 +20534,7 @@ var SqliteFindingsRepository = class {
20508
20534
  };
20509
20535
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
20510
20536
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
20511
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
20537
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
20512
20538
  const page = sorted.slice(start, start + limit);
20513
20539
  const lastOnPage = page.at(-1);
20514
20540
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -20602,7 +20628,7 @@ var SqliteFindingsRepository = class {
20602
20628
  accumulator.add(row);
20603
20629
  if (!matchesInstanceFilters(row, opts)) continue;
20604
20630
  total += 1;
20605
- if (!isPastCursor(row)) continue;
20631
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
20606
20632
  if (items.length < limit) {
20607
20633
  items.push(toInstanceDetail(row));
20608
20634
  last = row;
@@ -20691,7 +20717,7 @@ var SqliteFindingsRepository = class {
20691
20717
  }
20692
20718
  }
20693
20719
  sorted.sort(compareLocationOrder);
20694
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
20720
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
20695
20721
  const page = sorted.slice(start, start + limit);
20696
20722
  const lastOnPage = page.at(-1);
20697
20723
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -23319,6 +23345,9 @@ function pageLimit(requested, fallback) {
23319
23345
  if (requested === void 0) return fallback;
23320
23346
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
23321
23347
  }
23348
+ function pageOffset(requested) {
23349
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
23350
+ }
23322
23351
  function encodeReuseCursor(payload) {
23323
23352
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
23324
23353
  }
@@ -23666,7 +23695,8 @@ var SqliteSecretVaultRepository = class {
23666
23695
  */
23667
23696
  listInventory(query = {}, now = Date.now()) {
23668
23697
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23669
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23698
+ const offset = pageOffset(query.offset);
23699
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23670
23700
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
23671
23701
  const rows = allRows(
23672
23702
  this.db.prepare(
@@ -23680,11 +23710,12 @@ var SqliteSecretVaultRepository = class {
23680
23710
  FROM secret_vault v
23681
23711
  ${where}
23682
23712
  ORDER BY v.last_seen DESC, v.pointer_id DESC
23683
- LIMIT :limit`
23713
+ LIMIT :limit OFFSET :offset`
23684
23714
  ),
23685
23715
  bindParams({
23686
23716
  now,
23687
23717
  limit: limit + 1,
23718
+ offset,
23688
23719
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
23689
23720
  })
23690
23721
  );
@@ -23708,7 +23739,8 @@ var SqliteSecretVaultRepository = class {
23708
23739
  */
23709
23740
  listReuse(query = {}, now = Date.now()) {
23710
23741
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23711
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
23742
+ const offset = pageOffset(query.offset);
23743
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
23712
23744
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
23713
23745
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
23714
23746
  const rows = allRows(
@@ -23723,11 +23755,12 @@ var SqliteSecretVaultRepository = class {
23723
23755
  FROM secret_vault v
23724
23756
  WHERE ${REUSED_PREDICATE} ${after}
23725
23757
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
23726
- LIMIT :limit`
23758
+ LIMIT :limit OFFSET :offset`
23727
23759
  ),
23728
23760
  bindParams({
23729
23761
  now,
23730
23762
  limit: limit + 1,
23763
+ offset,
23731
23764
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
23732
23765
  })
23733
23766
  );
@@ -23752,7 +23785,8 @@ var SqliteSecretVaultRepository = class {
23752
23785
  */
23753
23786
  listDerefs(query = {}) {
23754
23787
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
23755
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23788
+ const offset = pageOffset(query.offset);
23789
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23756
23790
  const conditions = [];
23757
23791
  if (query.includeBatched !== true) {
23758
23792
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -23765,21 +23799,28 @@ var SqliteSecretVaultRepository = class {
23765
23799
  this.db.prepare(
23766
23800
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
23767
23801
  FROM secret_vault_deref ${where}
23768
- ORDER BY at DESC, id DESC LIMIT :limit`
23802
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
23769
23803
  ),
23770
23804
  bindParams({
23771
23805
  limit: limit + 1,
23806
+ offset,
23772
23807
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
23773
23808
  })
23774
23809
  );
23775
23810
  const hasMore = rows.length > limit;
23776
23811
  const page = hasMore ? rows.slice(0, limit) : rows;
23777
23812
  const last = page[page.length - 1];
23778
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
23779
- this.db,
23780
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
23781
- );
23813
+ const counts = getRow(
23814
+ this.db.prepare(
23815
+ `SELECT count(*) AS total,
23816
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
23817
+ FROM secret_vault_deref`
23818
+ )
23819
+ ) ?? { total: 0, hidden: 0 };
23820
+ const includeBatched = query.includeBatched === true;
23821
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
23782
23822
  return {
23823
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
23783
23824
  items: page.map((r) => ({
23784
23825
  id: r.id,
23785
23826
  pointerId: r.pointer_id,
@@ -23804,6 +23845,43 @@ var SqliteSecretVaultRepository = class {
23804
23845
  `SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
23805
23846
  );
23806
23847
  }
23848
+ /**
23849
+ * Every entry held, and how many of them are NOT under `currentVersion` — the
23850
+ * standing record of a fingerprint-key rotation whose re-key did not reach
23851
+ * every row.
23852
+ *
23853
+ * This is the durable form of what `SecretVault.refreshFingerprints` reports
23854
+ * once. That count is an event, gone the moment it is printed; this is the
23855
+ * condition, and it stays true until some later rotation re-keys the rows. It
23856
+ * is therefore the one that can answer "is a shortfall still outstanding?" —
23857
+ * including for a rotation run from the CLI, which no dashboard render saw.
23858
+ *
23859
+ * `<>` rather than `<`: a row ahead of the current version is equally
23860
+ * unmatchable, and that is reachable — a key file restored from a backup, or
23861
+ * replaced after being lost, leaves rows stamped higher than the key is.
23862
+ *
23863
+ * Both numbers come from ONE statement, which is why this returns a pair
23864
+ * instead of offering two counts to call. Read separately, a purge landing
23865
+ * between them hands back a `stale` counted over rows the later `total` no
23866
+ * longer includes, and a disclosure built from that pair states a fraction
23867
+ * true of no state of the table — "1 of 0 stored values", or a negative
23868
+ * remainder. Same reasoning as `purgeVault`'s count, which comes from the
23869
+ * delete rather than from a `countEntries` standing beside it.
23870
+ */
23871
+ countFingerprintEpochs(currentVersion) {
23872
+ const row = getRow(
23873
+ this.db.prepare(
23874
+ `SELECT COUNT(*) AS total,
23875
+ COALESCE(
23876
+ SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
23877
+ 0
23878
+ ) AS stale
23879
+ FROM secret_vault`
23880
+ ),
23881
+ { currentVersion }
23882
+ ) ?? { stale: 0, total: 0 };
23883
+ return { stale: row.stale, total: row.total };
23884
+ }
23807
23885
  };
23808
23886
 
23809
23887
  // ../../packages/persistence/src/repositories/security.ts
@@ -25660,13 +25738,22 @@ var SecretVault = class {
25660
25738
  * fingerprint collides with a row already refreshed, is skipped rather than
25661
25739
  * aborting the pass — one damaged entry must not strand the re-key of every
25662
25740
  * other. A skipped row keeps resolving under its old fingerprint epoch.
25741
+ *
25742
+ * Every skip is COUNTED, because best-effort and silent are different things:
25743
+ * the loss above is invisible at the moment it happens and only shows up later
25744
+ * as a duplicate pointer, so the pass owes its caller a denominator rather
25745
+ * than a bare success count.
25663
25746
  */
25664
25747
  async refreshFingerprints(next) {
25665
25748
  let refreshed = 0;
25749
+ let skipped = 0;
25666
25750
  for (const row of this.#repo.listAll()) {
25667
25751
  try {
25668
25752
  const raw = await this.#openRow(row);
25669
- if (raw === null) continue;
25753
+ if (raw === null) {
25754
+ skipped += 1;
25755
+ continue;
25756
+ }
25670
25757
  this.#repo.refreshFingerprint(row.pointerId, {
25671
25758
  valueFingerprint: exactFingerprintValue(next, raw),
25672
25759
  valueIdentityFingerprint: fingerprintValue(next, raw),
@@ -25674,10 +25761,10 @@ var SecretVault = class {
25674
25761
  });
25675
25762
  refreshed += 1;
25676
25763
  } catch {
25677
- continue;
25764
+ skipped += 1;
25678
25765
  }
25679
25766
  }
25680
- return refreshed;
25767
+ return { refreshed, skipped };
25681
25768
  }
25682
25769
  /**
25683
25770
  * Destroy every entry, making all outstanding pointers permanently
@@ -27016,6 +27103,21 @@ function registerPack(pack) {
27016
27103
  function getLoadedRules() {
27017
27104
  return [...packs.values()].flatMap((p) => p.rules);
27018
27105
  }
27106
+ function outsideWrittenRegions(candidates, context) {
27107
+ const regions = context?.writtenRegions;
27108
+ if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
27109
+ return candidates.filter((c) => {
27110
+ if (c.rule.category !== "code_flaw") return true;
27111
+ const { start, end } = c.match.span;
27112
+ return !regions.some(
27113
+ (r) => r.start <= start && end <= r.end && ruleApplies(
27114
+ c.rule,
27115
+ r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
27116
+ "code_change"
27117
+ )
27118
+ );
27119
+ });
27120
+ }
27019
27121
  function spansOverlap(a, b) {
27020
27122
  return a.start < b.end && a.end > b.start;
27021
27123
  }
@@ -27203,17 +27305,20 @@ function scanEncoded(text2, ruleset, context) {
27203
27305
  function scanText(text2, ruleset, context) {
27204
27306
  const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
27205
27307
  const normalization = normalizeFormatChars(text2);
27206
- const originalCandidates = buildCandidates(text2, ruleset, extension, context?.eventKind);
27308
+ const originalCandidates = outsideWrittenRegions(
27309
+ buildCandidates(text2, ruleset, extension, context?.eventKind),
27310
+ context
27311
+ );
27207
27312
  if (!normalization) return gate(originalCandidates, text2, void 0);
27208
27313
  const pooledOriginal = originalCandidates.map(
27209
27314
  (candidate) => withNormalizedSpan(candidate, normalization)
27210
27315
  );
27211
- const normalizedCandidates = buildCandidates(
27212
- normalization.normalized,
27213
- ruleset,
27214
- extension,
27215
- context?.eventKind
27216
- ).map((candidate) => mapCandidateToOriginal(candidate, normalization, text2));
27316
+ const normalizedCandidates = outsideWrittenRegions(
27317
+ buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
27318
+ (candidate) => mapCandidateToOriginal(candidate, normalization, text2)
27319
+ ),
27320
+ context
27321
+ );
27217
27322
  const findings = gate([...pooledOriginal, ...normalizedCandidates], text2, normalization);
27218
27323
  return mergeOverlappingSameRule(findings, text2);
27219
27324
  }
@@ -27274,6 +27379,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
27274
27379
  "code-flaws/sql-inject-concat-dot",
27275
27380
  "code-flaws/sql-inject-format",
27276
27381
  "code-flaws/sql-inject-interp",
27382
+ "code-flaws/sql-inject-interp-multiline",
27277
27383
  "code-flaws/ssrf-user-url",
27278
27384
  "code-flaws/xss-dangerously-set",
27279
27385
  "code-flaws/xss-inner-html",
@@ -28412,7 +28518,7 @@ var sql_inject_concat_dot_default = {
28412
28518
  severity: "high",
28413
28519
  matcher: {
28414
28520
  type: "regex",
28415
- pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
28521
+ 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*\\.",
28416
28522
  flags: "gi"
28417
28523
  },
28418
28524
  appliesTo: {
@@ -28430,7 +28536,7 @@ var sql_inject_concat_default = {
28430
28536
  severity: "high",
28431
28537
  matcher: {
28432
28538
  type: "regex",
28433
- 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*\\+`,
28539
+ 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*\\+",
28434
28540
  flags: "gi"
28435
28541
  },
28436
28542
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -28445,7 +28551,7 @@ var sql_inject_format_default = {
28445
28551
  severity: "high",
28446
28552
  matcher: {
28447
28553
  type: "regex",
28448
- 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]+\\})`,
28554
+ 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]+\\})",
28449
28555
  flags: "gi"
28450
28556
  },
28451
28557
  examples: [
@@ -28454,6 +28560,24 @@ var sql_inject_format_default = {
28454
28560
  ]
28455
28561
  };
28456
28562
 
28563
+ // ../../rules/code-flaws/sql-inject-interp-multiline.json
28564
+ var sql_inject_interp_multiline_default = {
28565
+ specVersion: 1,
28566
+ id: "code-flaws/sql-inject-interp-multiline",
28567
+ name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
28568
+ category: "code_flaw",
28569
+ severity: "high",
28570
+ matcher: {
28571
+ type: "regex",
28572
+ 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_])',
28573
+ flags: "gi"
28574
+ },
28575
+ examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
28576
+ appliesTo: {
28577
+ extensions: [".rb", ".php"]
28578
+ }
28579
+ };
28580
+
28457
28581
  // ../../rules/code-flaws/sql-inject-interp.json
28458
28582
  var sql_inject_interp_default = {
28459
28583
  specVersion: 1,
@@ -28463,7 +28587,7 @@ var sql_inject_interp_default = {
28463
28587
  severity: "high",
28464
28588
  matcher: {
28465
28589
  type: "regex",
28466
- pattern: "([\"'`])\\s*\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])|(?<=^|\\n)[ \\t]*(?:select|insert|update|delete|where)\\s[^\\n]*?(?:#\\{|\\$[a-z_])",
28590
+ 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_])',
28467
28591
  flags: "gi"
28468
28592
  },
28469
28593
  examples: [
@@ -30191,12 +30315,13 @@ var BUNDLED_PACKS = [
30191
30315
  {
30192
30316
  packId: "code-flaws",
30193
30317
  name: "Code Security Flaws",
30194
- version: "0.1.3",
30318
+ version: "0.1.6",
30195
30319
  rawRules: [
30196
30320
  sql_inject_concat_default,
30197
30321
  sql_inject_concat_dot_default,
30198
30322
  sql_inject_format_default,
30199
30323
  sql_inject_interp_default,
30324
+ sql_inject_interp_multiline_default,
30200
30325
  cmd_inject_shell_default,
30201
30326
  cmd_inject_exec_default,
30202
30327
  cmd_inject_node_exec_default,
@@ -30228,6 +30353,7 @@ var BUNDLED_PACKS = [
30228
30353
  "code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
30229
30354
  "code-flaws/sql-inject-format": "SQL injection (format string)",
30230
30355
  "code-flaws/sql-inject-interp": "SQL injection (interpolation)",
30356
+ "code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
30231
30357
  "code-flaws/cmd-inject-shell": "Command injection (shell)",
30232
30358
  "code-flaws/cmd-inject-exec": "Command injection (Java exec)",
30233
30359
  "code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
@@ -30907,8 +31033,25 @@ function bundledMaskingRules() {
30907
31033
  return ensureBundledPacks() ? getLoadedRules() : null;
30908
31034
  }
30909
31035
 
31036
+ // ../../packages/plugin-sdk/src/regular-file.ts
31037
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
31038
+ function notRegularFile(path) {
31039
+ return `not a regular file: ${path}`;
31040
+ }
31041
+ function readRegularFile(path, maxBytes) {
31042
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
31043
+ try {
31044
+ const stat2 = fstatSync(fd);
31045
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
31046
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
31047
+ return readFileSync16(fd, "utf8");
31048
+ } finally {
31049
+ closeSync2(fd);
31050
+ }
31051
+ }
31052
+
30910
31053
  // ../../packages/plugin-sdk/src/repo.ts
30911
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
31054
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30912
31055
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30913
31056
  function remoteWithoutCredentials(remote) {
30914
31057
  const withoutInfo = withoutUserinfo(remote);
@@ -30997,9 +31140,10 @@ function resolveGitContext(root) {
30997
31140
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30998
31141
  return { configPath: join24(commonGitDir, "config"), headRoot };
30999
31142
  }
31143
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
31000
31144
  function safeRead(path) {
31001
31145
  try {
31002
- return readFileSync16(path, "utf8");
31146
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
31003
31147
  } catch {
31004
31148
  return void 0;
31005
31149
  }
@@ -31320,6 +31464,7 @@ function createIsolatedScanner(data, opts = {}) {
31320
31464
  text: text2,
31321
31465
  filePath: context?.filePath,
31322
31466
  eventKind: context?.eventKind,
31467
+ writtenRegions: context?.writtenRegions,
31323
31468
  attribute: scanOpts?.attribute === true
31324
31469
  }),
31325
31470
  reply: (message) => {
@@ -32133,7 +32278,8 @@ function createPluginRuntime(gateway, settings, opts) {
32133
32278
  input.text,
32134
32279
  {
32135
32280
  filePath: input.metadata?.filePath,
32136
- eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
32281
+ eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
32282
+ writtenRegions: opts2.writtenRegions
32137
32283
  },
32138
32284
  {
32139
32285
  sourceTool: input.sourceTool,
@@ -35565,21 +35711,21 @@ function resolveCodexHome(env, home = homedir3()) {
35565
35711
 
35566
35712
  // ../../packages/plugin-sdk/src/account/observation-log.ts
35567
35713
  import { createHash as createHash13 } from "crypto";
35568
- import { closeSync as closeSync2, constants, fstatSync, mkdirSync as mkdirSync2, openSync as openSync2, readSync, writeSync } from "fs";
35714
+ import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync2, mkdirSync as mkdirSync2, openSync as openSync3, readSync, writeSync } from "fs";
35569
35715
  import { join as join35 } from "path";
35570
35716
  var SESSION_LOG_CAP_BYTES = 16 * 1024 * 1024;
35571
35717
  var SESSION_LOG_TAIL_BYTES = 64 * 1024;
35572
35718
  var NEWLINE = 10;
35573
35719
  var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
35574
35720
  function sessionLogOpenFlags(noFollow) {
35575
- return constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | (noFollow ?? 0);
35721
+ return constants2.O_WRONLY | constants2.O_APPEND | constants2.O_CREAT | (noFollow ?? 0);
35576
35722
  }
35577
35723
  var SESSION_LOG_OPEN_FLAGS = sessionLogOpenFlags(
35578
- constants.O_NOFOLLOW
35724
+ constants2.O_NOFOLLOW
35579
35725
  );
35580
35726
  function closeQuietly2(fd) {
35581
35727
  try {
35582
- closeSync2(fd);
35728
+ closeSync3(fd);
35583
35729
  } catch {
35584
35730
  }
35585
35731
  }
@@ -35602,8 +35748,8 @@ function appendObservation(stateDir, sessionId, observation, capBytes = SESSION_
35602
35748
  let fd;
35603
35749
  try {
35604
35750
  mkdirSync2(stateDir, { recursive: true, mode: DATA_DIR_MODE });
35605
- fd = openSync2(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
35606
- if (fstatSync(fd).size + Buffer.byteLength(line) > capBytes) return false;
35751
+ fd = openSync3(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
35752
+ if (fstatSync2(fd).size + Buffer.byteLength(line) > capBytes) return false;
35607
35753
  writeSync(fd, line);
35608
35754
  return true;
35609
35755
  } catch {
@@ -35633,12 +35779,12 @@ function parseLines(buffer, base) {
35633
35779
  function readRange(path, from, capBytes) {
35634
35780
  let fd;
35635
35781
  try {
35636
- fd = openSync2(path, "r");
35782
+ fd = openSync3(path, "r");
35637
35783
  } catch {
35638
35784
  return void 0;
35639
35785
  }
35640
35786
  try {
35641
- const size = fstatSync(fd).size;
35787
+ const size = fstatSync2(fd).size;
35642
35788
  const length = Math.max(0, Math.min(size, capBytes) - from);
35643
35789
  const buffer = Buffer.alloc(length);
35644
35790
  let filled = 0;
@@ -35685,7 +35831,7 @@ function classifyObservation(observation) {
35685
35831
  }
35686
35832
 
35687
35833
  // ../../packages/plugin-sdk/src/account/codex-head.ts
35688
- import { closeSync as closeSync3, openSync as openSync3, readSync as readSync2 } from "fs";
35834
+ import { closeSync as closeSync4, openSync as openSync4, readSync as readSync2 } from "fs";
35689
35835
  var CODEX_HEAD_READ_BYTES = 64 * 1024;
35690
35836
  var CODEX_HEAD_MAX_BYTES = 1024 * 1024;
35691
35837
  var NEWLINE2 = 10;
@@ -35718,7 +35864,7 @@ function parseHead(line) {
35718
35864
  function readCodexHead(rolloutPath) {
35719
35865
  let fd;
35720
35866
  try {
35721
- fd = openSync3(rolloutPath, "r");
35867
+ fd = openSync4(rolloutPath, "r");
35722
35868
  } catch (error2) {
35723
35869
  return isNotFound(error2) ? "pending" : void 0;
35724
35870
  }
@@ -35743,14 +35889,14 @@ function readCodexHead(rolloutPath) {
35743
35889
  return void 0;
35744
35890
  } finally {
35745
35891
  try {
35746
- closeSync3(fd);
35892
+ closeSync4(fd);
35747
35893
  } catch {
35748
35894
  }
35749
35895
  }
35750
35896
  }
35751
35897
 
35752
35898
  // ../../packages/plugin-sdk/src/account/codex-login.ts
35753
- import { closeSync as closeSync4, constants as constants2, fstatSync as fstatSync2, lstatSync as lstatSync6, openSync as openSync4, readSync as readSync3 } from "fs";
35899
+ import { closeSync as closeSync5, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync5, readSync as readSync3 } from "fs";
35754
35900
  import { join as join36 } from "path";
35755
35901
  var CODEX_AUTH_MAX_BYTES = 64 * 1024;
35756
35902
  var CODEX_ID_TOKEN_MAX_CHARS = 16 * 1024;
@@ -35783,8 +35929,8 @@ var DROPPED = new Set(CODEX_DROPPED_FIELDS);
35783
35929
  var PRESENCE = new Set(CODEX_PRESENCE_FIELDS);
35784
35930
  var BASE64URL = /^[A-Za-z0-9_-]+$/;
35785
35931
  var UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
35786
- var NOFOLLOW = constants2.O_NOFOLLOW ?? 0;
35787
- var READ_FLAGS = constants2.O_RDONLY | NOFOLLOW;
35932
+ var NOFOLLOW = constants3.O_NOFOLLOW ?? 0;
35933
+ var READ_FLAGS = constants3.O_RDONLY | NOFOLLOW;
35788
35934
  var ABSENT = { status: "absent" };
35789
35935
  var MODE = { status: "mode" };
35790
35936
  var MALFORMED = { status: "malformed" };
@@ -35906,12 +36052,12 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
35906
36052
  let fd;
35907
36053
  try {
35908
36054
  if (platform === "win32" && lstatSync6(path).isSymbolicLink()) return MALFORMED;
35909
- fd = openSync4(path, openFlags);
36055
+ fd = openSync5(path, openFlags);
35910
36056
  } catch (error2) {
35911
36057
  return isNotFound2(error2) ? ABSENT : MALFORMED;
35912
36058
  }
35913
36059
  try {
35914
- const stat2 = fstatSync2(fd);
36060
+ const stat2 = fstatSync3(fd);
35915
36061
  if (!stat2.isFile() || stat2.size > CODEX_AUTH_MAX_BYTES) return MALFORMED;
35916
36062
  if (platform !== "win32" && (stat2.uid !== process.getuid?.() || (stat2.mode & 18) !== 0)) {
35917
36063
  return MALFORMED;
@@ -35923,7 +36069,7 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
35923
36069
  return MALFORMED;
35924
36070
  } finally {
35925
36071
  try {
35926
- closeSync4(fd);
36072
+ closeSync5(fd);
35927
36073
  } catch {
35928
36074
  }
35929
36075
  }