@akasecurity/ai-tc-codex 0.9.14 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/scripts/intro.js CHANGED
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  mod
33
33
  ));
34
34
 
35
- // ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
35
+ // ../../node_modules/.pnpm/ignore@7.0.10/node_modules/ignore/index.js
36
36
  var require_ignore = __commonJS({
37
- "../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js"(exports, module) {
37
+ "../../node_modules/.pnpm/ignore@7.0.10/node_modules/ignore/index.js"(exports, module) {
38
38
  "use strict";
39
39
  function makeArray(subject) {
40
40
  return Array.isArray(subject) ? subject : [subject];
@@ -429,6 +429,13 @@ var require_ignore = __commonJS({
429
429
  }
430
430
  };
431
431
  var WILDCARD = "[^\\/]*";
432
+ var separatorAfter = (run, at) => {
433
+ let separator = EMPTY;
434
+ for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
435
+ separator += run[index].single;
436
+ }
437
+ return separator;
438
+ };
432
439
  var pinWildcards = (source) => {
433
440
  if (source.indexOf(WILDCARD) < 0) {
434
441
  return source;
@@ -498,7 +505,7 @@ var require_ignore = __commonJS({
498
505
  out += token.single;
499
506
  return;
500
507
  }
501
- out += at === lastWildcard ? WILDCARD : `(?:(?!${run[at + 1].single})[^\\/])*`;
508
+ out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
502
509
  });
503
510
  run = [];
504
511
  };
@@ -23041,7 +23048,29 @@ var StorePosturePlugin = external_exports.object({
23041
23048
  */
23042
23049
  policyBundleVersion: external_exports.string().max(200).nullable(),
23043
23050
  /** Epoch millis, on the CLIENT clock, of that fetch. */
23044
- policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
23051
+ policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
23052
+ /**
23053
+ * The newest version the host's own install record holds for this plugin —
23054
+ * what is on disk. After an update it leads `version` (the running copy) by
23055
+ * one launch. Null when no usable version can be read: no install record
23056
+ * (a plugin run from a checkout), no entry with a valid version, or every
23057
+ * such entry names an `installPath` that no longer exists; OPTIONAL, not
23058
+ * required, so a build that predates the member keeps getting its 200.
23059
+ * Bounded like `version`.
23060
+ */
23061
+ installedVersion: external_exports.string().max(64).nullable().optional(),
23062
+ /**
23063
+ * The local-store schema version this running build migrates a store to:
23064
+ * the number of store migrations it carries, the count it stamps into
23065
+ * `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
23066
+ * usually describes a store a newer build migrated. It is a hint, not a
23067
+ * verdict: the stamp is write-only, so a store whose count ran past this
23068
+ * build's while this build knows every migration in its ledger reads above
23069
+ * it too, which is why describeStoreSkew decides skew on ledger tags and
23070
+ * never on the count. OPTIONAL for the same reason as `installedVersion`;
23071
+ * bounded like `schemaVersion`.
23072
+ */
23073
+ buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
23045
23074
  }).meta({ id: "StorePosturePlugin" });
23046
23075
  var StorePostureSnapshot = external_exports.object({
23047
23076
  deviceId: external_exports.guid(),
@@ -24020,10 +24049,15 @@ var ParsedPointer = external_exports.object({
24020
24049
  });
24021
24050
  var VaultEntry = external_exports.object({
24022
24051
  pointerId: external_exports.string(),
24023
- // The keyed HMAC of the raw value under `exception.key`, and the epoch it was
24024
- // derived under. This is what a reveal-to-model grant matches on, and it rotates
24025
- // independently of the vault encryption key below.
24052
+ // The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
24053
+ // was derived under. The vault's own dedupe key: a value and its invisibly
24054
+ // padded twin are two rows. It rotates independently of the vault encryption
24055
+ // key below. Never matched against an exception or grant.
24026
24056
  valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
24057
+ // The same HMAC over the raw with invisible padding removed: the identity a
24058
+ // reveal-to-model grant and every exception match on. Shared by a value and
24059
+ // its padded twin.
24060
+ valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
24027
24061
  fingerprintKeyVersion: external_exports.number().int().positive(),
24028
24062
  // The vault-key epoch this row's ciphertext was sealed under.
24029
24063
  keyVersion: external_exports.number().int().positive(),
@@ -24465,10 +24499,18 @@ var SeveritySummaryItem = external_exports.object({
24465
24499
  count: external_exports.number().int().nonnegative(),
24466
24500
  // Resolution-aware breakdown (optional, additive). Populated once findings
24467
24501
  // carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
24468
- // = still open with no in-flight enforcement (needs remediation). Absent on the
24469
- // legacy count-only response until the resolution feature lands.
24502
+ // = still open with no in-flight enforcement (needs remediation); `dismissed`
24503
+ // = closed by a human judgement rather than a fix — visible, but not counted as
24504
+ // needing remediation. The three are disjoint. Absent on the legacy count-only
24505
+ // response until the resolution feature lands.
24470
24506
  caught: external_exports.number().int().nonnegative().optional(),
24471
- openAtRest: external_exports.number().int().nonnegative().optional()
24507
+ openAtRest: external_exports.number().int().nonnegative().optional(),
24508
+ dismissed: external_exports.number().int().nonnegative().optional(),
24509
+ // The two halves of `caught`, for a reader that wants them apart: `handled` =
24510
+ // in-flight findings an enforcement action already contained; `resolved` =
24511
+ // at-rest findings closed out by fixing them. `handled + resolved === caught`.
24512
+ handled: external_exports.number().int().nonnegative().optional(),
24513
+ resolved: external_exports.number().int().nonnegative().optional()
24472
24514
  }).meta({ id: "SeveritySummaryItem" });
24473
24515
  var SeveritySummaryResponse = external_exports.object({
24474
24516
  // Sum of bySeverity[].count.
@@ -24476,6 +24518,9 @@ var SeveritySummaryResponse = external_exports.object({
24476
24518
  // Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
24477
24519
  // additive — absent on the legacy response until the resolution feature lands.
24478
24520
  needsRemediation: external_exports.number().int().nonnegative().optional(),
24521
+ // Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
24522
+ // needsRemediation, and kept visible here so an accepted risk is not erased.
24523
+ dismissed: external_exports.number().int().nonnegative().optional(),
24479
24524
  // All four severity levels are always present (count may be 0).
24480
24525
  bySeverity: external_exports.array(SeveritySummaryItem)
24481
24526
  }).meta({ id: "SeveritySummaryResponse" });
@@ -25785,6 +25830,10 @@ function escapeRegExp2(value) {
25785
25830
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
25786
25831
  }
25787
25832
 
25833
+ // ../../packages/detections/src/format-chars.ts
25834
+ var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
25835
+ var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
25836
+
25788
25837
  // ../../packages/detections/src/regex-cache.ts
25789
25838
  var singles = /* @__PURE__ */ new WeakMap();
25790
25839
  var keywordLists = /* @__PURE__ */ new WeakMap();
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  mod
33
33
  ));
34
34
 
35
- // ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
35
+ // ../../node_modules/.pnpm/ignore@7.0.10/node_modules/ignore/index.js
36
36
  var require_ignore = __commonJS({
37
- "../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js"(exports, module) {
37
+ "../../node_modules/.pnpm/ignore@7.0.10/node_modules/ignore/index.js"(exports, module) {
38
38
  "use strict";
39
39
  function makeArray(subject) {
40
40
  return Array.isArray(subject) ? subject : [subject];
@@ -429,6 +429,13 @@ var require_ignore = __commonJS({
429
429
  }
430
430
  };
431
431
  var WILDCARD = "[^\\/]*";
432
+ var separatorAfter = (run, at) => {
433
+ let separator = EMPTY;
434
+ for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
435
+ separator += run[index].single;
436
+ }
437
+ return separator;
438
+ };
432
439
  var pinWildcards = (source) => {
433
440
  if (source.indexOf(WILDCARD) < 0) {
434
441
  return source;
@@ -498,7 +505,7 @@ var require_ignore = __commonJS({
498
505
  out += token.single;
499
506
  return;
500
507
  }
501
- out += at === lastWildcard ? WILDCARD : `(?:(?!${run[at + 1].single})[^\\/])*`;
508
+ out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
502
509
  });
503
510
  run = [];
504
511
  };
@@ -995,6 +1002,10 @@ var SQLITE_MIGRATIONS = [
995
1002
  {
996
1003
  tag: "0035_share_destination_provider_id",
997
1004
  sql: "ALTER TABLE `share_destination` ADD `provider_id` text;"
1005
+ },
1006
+ {
1007
+ tag: "0036_secret_vault_identity_fingerprint",
1008
+ sql: "ALTER TABLE `secret_vault` ADD `value_identity_fingerprint` text DEFAULT '' NOT NULL;--> statement-breakpoint\nUPDATE `secret_vault` SET `value_identity_fingerprint` = `value_fingerprint`;\n"
998
1009
  }
999
1010
  ];
1000
1011
 
@@ -23371,7 +23382,29 @@ var StorePosturePlugin = external_exports.object({
23371
23382
  */
23372
23383
  policyBundleVersion: external_exports.string().max(200).nullable(),
23373
23384
  /** Epoch millis, on the CLIENT clock, of that fetch. */
23374
- policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
23385
+ policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
23386
+ /**
23387
+ * The newest version the host's own install record holds for this plugin —
23388
+ * what is on disk. After an update it leads `version` (the running copy) by
23389
+ * one launch. Null when no usable version can be read: no install record
23390
+ * (a plugin run from a checkout), no entry with a valid version, or every
23391
+ * such entry names an `installPath` that no longer exists; OPTIONAL, not
23392
+ * required, so a build that predates the member keeps getting its 200.
23393
+ * Bounded like `version`.
23394
+ */
23395
+ installedVersion: external_exports.string().max(64).nullable().optional(),
23396
+ /**
23397
+ * The local-store schema version this running build migrates a store to:
23398
+ * the number of store migrations it carries, the count it stamps into
23399
+ * `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
23400
+ * usually describes a store a newer build migrated. It is a hint, not a
23401
+ * verdict: the stamp is write-only, so a store whose count ran past this
23402
+ * build's while this build knows every migration in its ledger reads above
23403
+ * it too, which is why describeStoreSkew decides skew on ledger tags and
23404
+ * never on the count. OPTIONAL for the same reason as `installedVersion`;
23405
+ * bounded like `schemaVersion`.
23406
+ */
23407
+ buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
23375
23408
  }).meta({ id: "StorePosturePlugin" });
23376
23409
  var StorePostureSnapshot = external_exports.object({
23377
23410
  deviceId: external_exports.guid(),
@@ -24932,10 +24965,15 @@ var ParsedPointer = external_exports.object({
24932
24965
  });
24933
24966
  var VaultEntry = external_exports.object({
24934
24967
  pointerId: external_exports.string(),
24935
- // The keyed HMAC of the raw value under `exception.key`, and the epoch it was
24936
- // derived under. This is what a reveal-to-model grant matches on, and it rotates
24937
- // independently of the vault encryption key below.
24968
+ // The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
24969
+ // was derived under. The vault's own dedupe key: a value and its invisibly
24970
+ // padded twin are two rows. It rotates independently of the vault encryption
24971
+ // key below. Never matched against an exception or grant.
24938
24972
  valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
24973
+ // The same HMAC over the raw with invisible padding removed: the identity a
24974
+ // reveal-to-model grant and every exception match on. Shared by a value and
24975
+ // its padded twin.
24976
+ valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
24939
24977
  fingerprintKeyVersion: external_exports.number().int().positive(),
24940
24978
  // The vault-key epoch this row's ciphertext was sealed under.
24941
24979
  keyVersion: external_exports.number().int().positive(),
@@ -25515,10 +25553,18 @@ var SeveritySummaryItem = external_exports.object({
25515
25553
  count: external_exports.number().int().nonnegative(),
25516
25554
  // Resolution-aware breakdown (optional, additive). Populated once findings
25517
25555
  // carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
25518
- // = still open with no in-flight enforcement (needs remediation). Absent on the
25519
- // legacy count-only response until the resolution feature lands.
25556
+ // = still open with no in-flight enforcement (needs remediation); `dismissed`
25557
+ // = closed by a human judgement rather than a fix — visible, but not counted as
25558
+ // needing remediation. The three are disjoint. Absent on the legacy count-only
25559
+ // response until the resolution feature lands.
25520
25560
  caught: external_exports.number().int().nonnegative().optional(),
25521
- openAtRest: external_exports.number().int().nonnegative().optional()
25561
+ openAtRest: external_exports.number().int().nonnegative().optional(),
25562
+ dismissed: external_exports.number().int().nonnegative().optional(),
25563
+ // The two halves of `caught`, for a reader that wants them apart: `handled` =
25564
+ // in-flight findings an enforcement action already contained; `resolved` =
25565
+ // at-rest findings closed out by fixing them. `handled + resolved === caught`.
25566
+ handled: external_exports.number().int().nonnegative().optional(),
25567
+ resolved: external_exports.number().int().nonnegative().optional()
25522
25568
  }).meta({ id: "SeveritySummaryItem" });
25523
25569
  var SeveritySummaryResponse = external_exports.object({
25524
25570
  // Sum of bySeverity[].count.
@@ -25526,6 +25572,9 @@ var SeveritySummaryResponse = external_exports.object({
25526
25572
  // Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
25527
25573
  // additive — absent on the legacy response until the resolution feature lands.
25528
25574
  needsRemediation: external_exports.number().int().nonnegative().optional(),
25575
+ // Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
25576
+ // needsRemediation, and kept visible here so an accepted risk is not erased.
25577
+ dismissed: external_exports.number().int().nonnegative().optional(),
25529
25578
  // All four severity levels are always present (count may be 0).
25530
25579
  bySeverity: external_exports.array(SeveritySummaryItem)
25531
25580
  }).meta({ id: "SeveritySummaryResponse" });
@@ -32483,7 +32532,10 @@ var SqliteResolutionsRepository = class {
32483
32532
  * Insert many dispositions as ONE transaction — all of them or none.
32484
32533
  *
32485
32534
  * A dashboard dismissal closes every open finding of a rule, which is one
32486
- * write per key; run loose, a fault partway leaves half a rule closed with
32535
+ * write per key. It reaches this through
32536
+ * `LocalDatabase.dismissOpenFindingsForRule`, which calls it inside the
32537
+ * transaction that selected the keys, so there it runs as a SAVEPOINT of
32538
+ * that transaction. Run loose, a fault partway leaves half a rule closed with
32487
32539
  * nothing recording that the other half was meant to be. The caller then has
32488
32540
  * no way to tell a partial run from a complete one, because the card it
32489
32541
  * refreshes into just shows a smaller number either way.
@@ -32703,6 +32755,7 @@ function toSighting(row) {
32703
32755
  var SELECT_COLUMNS = `
32704
32756
  pointer_id AS pointerId,
32705
32757
  value_fingerprint AS valueFingerprint,
32758
+ value_identity_fingerprint AS valueIdentityFingerprint,
32706
32759
  fingerprint_key_version AS fingerprintKeyVersion,
32707
32760
  key_version AS keyVersion,
32708
32761
  format_version AS formatVersion,
@@ -32727,13 +32780,13 @@ var SqliteSecretVaultRepository = class {
32727
32780
  this.db = db;
32728
32781
  this.insertStmt = db.prepare(
32729
32782
  `INSERT INTO secret_vault (
32730
- pointer_id, value_fingerprint, fingerprint_key_version, key_version,
32731
- format_version, category, rule_id, masked_match, provider,
32783
+ pointer_id, value_fingerprint, value_identity_fingerprint,
32784
+ fingerprint_key_version, key_version, format_version, category, rule_id, masked_match, provider,
32732
32785
  ciphertext, nonce, auth_tag,
32733
32786
  user_authorized, occurrence_count, first_seen, last_seen
32734
32787
  ) VALUES (
32735
- :pointerId, :valueFingerprint, :fingerprintKeyVersion, :keyVersion,
32736
- :formatVersion, :category, :ruleId, :maskedMatch, :provider,
32788
+ :pointerId, :valueFingerprint, :valueIdentityFingerprint,
32789
+ :fingerprintKeyVersion, :keyVersion, :formatVersion, :category, :ruleId, :maskedMatch, :provider,
32737
32790
  :ciphertext, :nonce, :authTag,
32738
32791
  :userAuthorized, 1, :now, :now
32739
32792
  )`
@@ -32758,7 +32811,13 @@ var SqliteSecretVaultRepository = class {
32758
32811
  );
32759
32812
  this.refreshFingerprintStmt = db.prepare(
32760
32813
  `UPDATE secret_vault
32761
- SET value_fingerprint = :valueFingerprint, fingerprint_key_version = :fingerprintKeyVersion
32814
+ SET value_fingerprint = :valueFingerprint,
32815
+ value_identity_fingerprint = :valueIdentityFingerprint,
32816
+ fingerprint_key_version = :fingerprintKeyVersion
32817
+ WHERE pointer_id = :pointerId`
32818
+ );
32819
+ this.setIdentityStmt = db.prepare(
32820
+ `UPDATE secret_vault SET value_identity_fingerprint = :valueIdentityFingerprint
32762
32821
  WHERE pointer_id = :pointerId`
32763
32822
  );
32764
32823
  this.deleteByPointerStmt = db.prepare(`DELETE FROM secret_vault WHERE pointer_id = :pointerId`);
@@ -32775,6 +32834,7 @@ var SqliteSecretVaultRepository = class {
32775
32834
  listStmt;
32776
32835
  replaceCiphertextStmt;
32777
32836
  refreshFingerprintStmt;
32837
+ setIdentityStmt;
32778
32838
  deleteByPointerStmt;
32779
32839
  derefStmt;
32780
32840
  /**
@@ -32805,6 +32865,7 @@ var SqliteSecretVaultRepository = class {
32805
32865
  bindParams({
32806
32866
  pointerId: input2.pointerId,
32807
32867
  valueFingerprint: input2.valueFingerprint,
32868
+ valueIdentityFingerprint: input2.valueIdentityFingerprint,
32808
32869
  fingerprintKeyVersion: input2.fingerprintKeyVersion,
32809
32870
  keyVersion: input2.keyVersion,
32810
32871
  formatVersion: input2.formatVersion ?? POINTER_FORMAT_VERSION,
@@ -32866,7 +32927,15 @@ var SqliteSecretVaultRepository = class {
32866
32927
  replaceCiphertext(pointerId, next) {
32867
32928
  this.replaceCiphertextStmt.run({ pointerId, ...next });
32868
32929
  }
32869
- /** Re-derive an entry's fingerprint under a new fingerprint-key epoch. */
32930
+ /**
32931
+ * Correct an entry's identity fingerprint in place, leaving its exact
32932
+ * fingerprint and key epoch alone. For a row whose identity column still holds
32933
+ * the exact value copied in by the migration that added it.
32934
+ */
32935
+ setIdentityFingerprint(pointerId, valueIdentityFingerprint) {
32936
+ this.setIdentityStmt.run({ pointerId, valueIdentityFingerprint });
32937
+ }
32938
+ /** Re-derive an entry's fingerprints under a new fingerprint-key epoch. */
32870
32939
  refreshFingerprint(pointerId, next) {
32871
32940
  this.refreshFingerprintStmt.run({ pointerId, ...next });
32872
32941
  }
@@ -32997,7 +33066,7 @@ var SqliteSecretVaultRepository = class {
32997
33066
  `SELECT ${INVENTORY_COLUMNS},
32998
33067
  (SELECT e.id FROM exceptions e
32999
33068
  WHERE e.rule_id = v.rule_id
33000
- AND e.value_fingerprint = v.value_fingerprint
33069
+ AND e.value_fingerprint = v.value_identity_fingerprint
33001
33070
  AND e.key_version = v.fingerprint_key_version
33002
33071
  AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
33003
33072
  LIMIT 1) AS grant_id
@@ -33040,7 +33109,7 @@ var SqliteSecretVaultRepository = class {
33040
33109
  `SELECT ${INVENTORY_COLUMNS},
33041
33110
  (SELECT e.id FROM exceptions e
33042
33111
  WHERE e.rule_id = v.rule_id
33043
- AND e.value_fingerprint = v.value_fingerprint
33112
+ AND e.value_fingerprint = v.value_identity_fingerprint
33044
33113
  AND e.key_version = v.fingerprint_key_version
33045
33114
  AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
33046
33115
  LIMIT 1) AS grant_id
@@ -33144,6 +33213,18 @@ var OPEN_AT_REST_FINDINGS_SQL = `FROM inspection_findings f
33144
33213
  OR latest.status IS NULL
33145
33214
  OR latest.status NOT IN ('resolved', 'dismissed')
33146
33215
  )`;
33216
+ function selectOpenFindingKeysForRule(db, ruleId) {
33217
+ const rows = allRows(
33218
+ db.prepare(
33219
+ `SELECT DISTINCT f.finding_key AS finding_key
33220
+ ${OPEN_AT_REST_FINDINGS_SQL}
33221
+ AND d.rule_id = :ruleId
33222
+ AND f.finding_key IS NOT NULL`
33223
+ ),
33224
+ { ruleId }
33225
+ );
33226
+ return rows.map((r) => r.finding_key);
33227
+ }
33147
33228
  var SEVERITIES = ["critical", "high", "medium", "low"];
33148
33229
  var ACTION_TO_KIND = {
33149
33230
  block: "blocked",
@@ -33200,16 +33281,16 @@ var SqliteSecurityRepository = class {
33200
33281
  // findings are caught only once their latest disposition is resolved,
33201
33282
  // otherwise they are open-at-rest.
33202
33283
  //
33203
- // NOTE for future manual-resolution writers: only latest status
33204
- // 'resolved' counts as caught above. When acknowledged/dismissed/
33205
- // false-positive manual dispositions land, this must keep filtering by
33206
- // status/method — 'acknowledged' is accepted risk, not a fix, and must NOT
33207
- // be bucketed as caught alongside 'resolved'.
33284
+ // Only latest status 'resolved' counts as caught above. 'dismissed' is its
33285
+ // own bucket: a judgement rather than a fix, so it is neither caught nor
33286
+ // needing remediation, and stays countable. A further manual disposition
33287
+ // (acknowledged, false-positive) must be placed deliberately — 'acknowledged'
33288
+ // is accepted risk, not a fix, and must NOT be bucketed as caught.
33208
33289
  //
33209
33290
  // Legacy at-rest findings from pre-branch scans carry finding_key = NULL —
33210
33291
  // the resolution lifecycle is keyed by finding_key, so it can never attach a
33211
33292
  // disposition to (or clear) one of these on re-scan. They are excluded from
33212
- // both caught and openAtRest (untracked, not "needs remediation forever"),
33293
+ // all three buckets (untracked, not "needs remediation forever"),
33213
33294
  // but still counted in total/count below — this keeps this predicate
33214
33295
  // consistent with SqliteResolutionsRepository.openAtRestKeysForPath, which
33215
33296
  // already filters `finding_key IS NOT NULL`.
@@ -33232,12 +33313,25 @@ var SqliteSecurityRepository = class {
33232
33313
  WHEN latest.status = 'resolved' THEN 1
33233
33314
  ELSE 0
33234
33315
  END) AS caught,
33316
+ SUM(CASE WHEN e.event_type != 'code_change' THEN 1 ELSE 0 END) AS handled,
33317
+ SUM(CASE
33318
+ WHEN e.event_type = 'code_change'
33319
+ AND f.finding_key IS NOT NULL
33320
+ AND latest.status = 'resolved' THEN 1
33321
+ ELSE 0
33322
+ END) AS resolved,
33235
33323
  SUM(CASE
33236
33324
  WHEN e.event_type = 'code_change'
33237
33325
  AND f.finding_key IS NOT NULL
33238
- AND (latest.status IS NULL OR latest.status != 'resolved') THEN 1
33326
+ AND (latest.status IS NULL
33327
+ OR latest.status NOT IN ('resolved', 'dismissed')) THEN 1
33328
+ ELSE 0
33329
+ END) AS open_at_rest,
33330
+ SUM(CASE
33331
+ WHEN e.event_type = 'code_change'
33332
+ AND latest.status = 'dismissed' THEN 1
33239
33333
  ELSE 0
33240
- END) AS open_at_rest
33334
+ END) AS dismissed
33241
33335
  FROM inspection_findings f
33242
33336
  JOIN audit_events e INDEXED BY idx_audit_capture_rollup ON e.id = f.audit_event_id
33243
33337
  JOIN inspection_definitions d ON d.id = f.inspection_definition_id
@@ -33252,11 +33346,15 @@ var SqliteSecurityRepository = class {
33252
33346
  severity,
33253
33347
  count: byRow.get(severity)?.count ?? 0,
33254
33348
  caught: byRow.get(severity)?.caught ?? 0,
33255
- openAtRest: byRow.get(severity)?.open_at_rest ?? 0
33349
+ handled: byRow.get(severity)?.handled ?? 0,
33350
+ resolved: byRow.get(severity)?.resolved ?? 0,
33351
+ openAtRest: byRow.get(severity)?.open_at_rest ?? 0,
33352
+ dismissed: byRow.get(severity)?.dismissed ?? 0
33256
33353
  }));
33257
33354
  const total = bySeverity.reduce((sum, s) => sum + s.count, 0);
33258
33355
  const needsRemediation = bySeverity.reduce((sum, s) => sum + s.openAtRest, 0);
33259
- return Promise.resolve({ total, needsRemediation, bySeverity });
33356
+ const dismissed = bySeverity.reduce((sum, s) => sum + s.dismissed, 0);
33357
+ return Promise.resolve({ total, needsRemediation, dismissed, bySeverity });
33260
33358
  }
33261
33359
  // Range is echoed but does not change the result today — coverage is a constant
33262
33360
  // business fact (see SCAN_COVERAGE), not a measured per-window metric. Order
@@ -33573,10 +33671,10 @@ var SqliteSecurityRepository = class {
33573
33671
  * machine, and the second reported "no recommendations" over live exposure.
33574
33672
  *
33575
33673
  * `open` mirrors `deriveFindingStatus` — at-rest, minus resolved and dismissed —
33576
- * so a row's count is exactly what `?status=open&type=<rule>` returns. Note that
33577
- * is NOT `severitySummary`'s `openAtRest`, which keeps dismissed findings (a
33578
- * dismissal is a judgement, not a remediation) and drops untracked legacy rows.
33579
- * The two answer different questions and only this one has to match a link.
33674
+ * so a row's count is exactly what `?status=open&type=<rule>` returns. It
33675
+ * differs from `severitySummary`'s `openAtRest` only in including untracked
33676
+ * legacy rows, which that bucket leaves out; dismissed is excluded from both.
33677
+ * Only this one has to match a link.
33580
33678
  *
33581
33679
  * Aggregated in SQL: the result is O(distinct rule × category × severity), so a
33582
33680
  * whole-store scope costs a grouped scan rather than a row per finding.
@@ -33604,6 +33702,8 @@ var SqliteSecurityRepository = class {
33604
33702
  /**
33605
33703
  * The distinct `finding_key`s behind ONE rule's {@link recommendationInputs}
33606
33704
  * tally — what a dashboard dismissal of that row writes a disposition for.
33705
+ * The dismissal itself does not call this: it reads the same set through
33706
+ * {@link selectOpenFindingKeysForRule}, inside its own write transaction.
33607
33707
  *
33608
33708
  * It shares {@link OPEN_AT_REST_FINDINGS_SQL} with the count rather than
33609
33709
  * restating the predicate, because a dismissal has to act on exactly the set
@@ -33620,16 +33720,7 @@ var SqliteSecurityRepository = class {
33620
33720
  * this set SMALLER than the tally, never larger.
33621
33721
  */
33622
33722
  openFindingKeysForRule(ruleId) {
33623
- const rows = allRows(
33624
- this.db.prepare(
33625
- `SELECT DISTINCT f.finding_key AS finding_key
33626
- ${OPEN_AT_REST_FINDINGS_SQL}
33627
- AND d.rule_id = :ruleId
33628
- AND f.finding_key IS NOT NULL`
33629
- ),
33630
- { ruleId }
33631
- );
33632
- return Promise.resolve(rows.map((r) => r.finding_key));
33723
+ return Promise.resolve(selectOpenFindingKeysForRule(this.db, ruleId));
33633
33724
  }
33634
33725
  // Findings whose parent event occurred in [fromMs, toMs), with the parent's
33635
33726
  // epoch-millis timestamp. started_at is an INTEGER column, so the bounds stay
@@ -34675,6 +34766,31 @@ function openLocalDatabase(dir, options = {}) {
34675
34766
  );
34676
34767
  });
34677
34768
  }
34769
+ function dismissOpenFindingsForRule(ruleId, disposition) {
34770
+ let dismissed = 0;
34771
+ withTransaction(
34772
+ db,
34773
+ () => {
34774
+ const keys = selectOpenFindingKeysForRule(db, ruleId);
34775
+ resolutions.insertResolutions(
34776
+ keys.map((findingKey) => ({
34777
+ findingKey,
34778
+ status: "dismissed",
34779
+ method: disposition.method,
34780
+ resolvedAt: disposition.resolvedAt,
34781
+ evidence: disposition.evidence
34782
+ }))
34783
+ );
34784
+ dismissed = keys.length;
34785
+ },
34786
+ // IMMEDIATE takes the write lock at BEGIN, before the select, which is
34787
+ // what keeps a concurrent resolve out of the gap. It also makes waiting
34788
+ // on a busy writer an ordinary busy_timeout wait rather than a
34789
+ // read-to-write upgrade SQLite refuses to retry.
34790
+ "IMMEDIATE"
34791
+ );
34792
+ return dismissed;
34793
+ }
34678
34794
  function recordCapture(event, detected) {
34679
34795
  failOpenTransaction(db, () => {
34680
34796
  const sessionId = event.metadata?.sessionId;
@@ -34858,6 +34974,7 @@ function openLocalDatabase(dir, options = {}) {
34858
34974
  inspectionDefinitions,
34859
34975
  inspectionFindings,
34860
34976
  recordCapture,
34977
+ dismissOpenFindingsForRule,
34861
34978
  markCaptureDelivered,
34862
34979
  markCaptureOwed,
34863
34980
  markAuditEventsDelivered,
@@ -35625,6 +35742,10 @@ function escapeRegExp2(value) {
35625
35742
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
35626
35743
  }
35627
35744
 
35745
+ // ../../packages/detections/src/format-chars.ts
35746
+ var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
35747
+ var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
35748
+
35628
35749
  // ../../packages/detections/src/regex-cache.ts
35629
35750
  var singles = /* @__PURE__ */ new WeakMap();
35630
35751
  var keywordLists = /* @__PURE__ */ new WeakMap();