@akasecurity/ai-tc-claude-code 0.9.3 → 0.9.4
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/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/commands/setup.md +123 -35
- package/hooks/hooks.json +11 -0
- package/package.json +4 -4
- package/scripts/apply-suppressions.js +581 -69
- package/scripts/backfill.js +1954 -147
- package/scripts/filescan.js +602 -76
- package/scripts/firstrun.js +517 -34
- package/scripts/intro.js +176 -20
- package/scripts/message-display.js +28945 -0
- package/scripts/onboard.js +542 -30
- package/scripts/post-tool-use.js +1943 -139
- package/scripts/pre-tool-use.js +2114 -163
- package/scripts/query.js +522 -35
- package/scripts/reconcile.js +2082 -242
- package/scripts/remediate.js +1872 -104
- package/scripts/session-start.js +680 -112
- package/scripts/start-light.js +174 -18
- package/scripts/statusline.js +517 -34
- package/scripts/stop.js +185 -29
- package/scripts/user-prompt-submit.js +1910 -152
package/scripts/firstrun.js
CHANGED
|
@@ -492,7 +492,7 @@ var require_ignore = __commonJS({
|
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
// ../../packages/persistence/src/database.ts
|
|
495
|
-
import { randomUUID as
|
|
495
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
496
496
|
import { existsSync, renameSync as renameSync2, rmSync as rmSync2 } from "fs";
|
|
497
497
|
import { join, sep } from "path";
|
|
498
498
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -558,6 +558,22 @@ var SQLITE_MIGRATIONS = [
|
|
|
558
558
|
{
|
|
559
559
|
tag: "0014_drop_legacy_events_findings",
|
|
560
560
|
sql: "-- Custom migration: drops the frozen legacy `events`/`findings` tables\n-- (superseded by audit_events/inspection_definitions/inspection_findings) and\n-- replaces them with read-only views of the same name.\n--\n-- persistence's migrations.ts applies this migration ONLY once the batched\n-- history backfill (see runLegacyHistoryBackfill) has fully drained both\n-- tables, and only after copying the live file aside \u2014 see\n-- backupBeforeLegacyDrop in packages/persistence/src/migrations.ts. A store\n-- still mid-copy keeps its real tables and this migration stays pending.\n--\n-- The views exist for skew: the `aka` CLI and the Claude Code plugin update\n-- independently against one shared store, so an older, already-installed\n-- binary can open a store a newer binary already dropped these tables on.\n-- Every already-shipped repository constructor prepares its SQL eagerly at\n-- open time, so a bare \"table not found\" would fail the WHOLE open, not just\n-- a findings-specific read \u2014 these views keep `prepare()` succeeding so an\n-- old binary's unrelated features keep working; its own reads stay truthful,\n-- and its rare (already fail-open) writes fail at run time instead.\n--\n-- The 0009/0010 expression indexes existed only over the legacy `events`\n-- table; DROP TABLE below would remove them implicitly, but they are\n-- dropped explicitly first so the intent reads clearly. IF EXISTS so a store\n-- that reached here with an index missing out of band (an adopted-tag store\n-- whose physical index was never built) does not throw a deterministic \"no\n-- such index\" out of the fail-open drop path.\nDROP INDEX IF EXISTS `idx_events_code_change_path`;\n--> statement-breakpoint\nDROP INDEX IF EXISTS `idx_events_session_id`;\n--> statement-breakpoint\n-- `findings.event_id` references `events.id` \u2014 drop the child first.\nDROP TABLE `findings`;\n--> statement-breakpoint\nDROP TABLE `events`;\n--> statement-breakpoint\n-- Legacy `events` shape, projected from audit_events: `kind`/`occurred_at`/\n-- `source_tool` become real columns again (source_tool round-trips through\n-- the attributes bag, the only place a capture-typed audit row keeps it);\n-- `metadata` is reconstructed as the old camelCase JSON object from the new\n-- snake_case attributes bag, with `root_session_id` folded back in as\n-- `sessionId` (the one legacy metadata key that became a column, never an\n-- attribute, on the new table). Constrained to the four capture kinds so\n-- structural rows (session/run/tool_call/llm_call/source_lookup/config_scan)\n-- never leak into a legacy reader's result set \u2014 the old `events` table\n-- never held them either.\nCREATE VIEW `events` AS\nSELECT\n id,\n json_extract(attributes, '$.source_tool') AS source_tool,\n event_type AS kind,\n started_at AS occurred_at,\n content_hash,\n content,\n -- Plugin-local bookkeeping column that `ensureSyncedAtColumn` adds to the\n -- real `events` table at open time. A pre-cutover binary runs that probe on\n -- EVERY open; without this projection its `columnNames('events')` check\n -- misses `synced_at` and issues `ALTER TABLE events ADD COLUMN` against this\n -- view, which SQLite rejects (\"Cannot add a column to a view\") \u2014 a hard,\n -- non-fail-open crash of the whole open, the exact skew failure these views\n -- exist to prevent. Projecting it (always NULL; no reader consumes it)\n -- short-circuits that ALTER.\n NULL AS synced_at,\n json_object(\n 'sessionId', root_session_id,\n 'repo', json_extract(attributes, '$.repo'),\n 'filePath', json_extract(attributes, '$.file_path'),\n 'toolName', json_extract(attributes, '$.tool_name'),\n 'gitignored', json_extract(attributes, '$.gitignored'),\n 'wholeFile', json_extract(attributes, '$.whole_file'),\n 'model', json_extract(attributes, '$.model'),\n 'turnIndex', json_extract(attributes, '$.turn_index'),\n 'correlationId', json_extract(attributes, '$.correlation_id'),\n 'traceId', json_extract(attributes, '$.trace_id'),\n 'exceptionIds', json_extract(attributes, '$.exception_ids')\n ) AS metadata\nFROM audit_events\nWHERE event_type IN ('prompt', 'response', 'code_change', 'tool_use');\n--> statement-breakpoint\n-- A plain single-row INSERT (the old writer's shape \u2014 no ON CONFLICT) is\n-- accepted by prepare() against a view once an INSTEAD OF INSERT trigger\n-- exists, so it fails at run time instead of at open \u2014 landing in the same\n-- fail-open path the caller already wraps its write in.\nCREATE TRIGGER `trg_events_ro`\nINSTEAD OF INSERT ON `events`\nBEGIN SELECT RAISE(ABORT, 'events is read-only; write to audit_events instead'); END;\n--> statement-breakpoint\n-- Legacy `findings` shape: rule_id/category/severity come from the joined\n-- inspection_definitions row (the legacy table inlined them per-row; the\n-- generalized schema normalizes them out into the shared definition). A view\n-- has no rowid of its own, so the underlying table's rowid is re-exposed\n-- explicitly under that name \u2014 a legacy reader ordering by `f.rowid` would\n-- otherwise fail to resolve the column at all. Joined to audit_events for the\n-- same four-capture-kind constraint as the events view above (a finding\n-- attached to a tool_call/config_scan row never existed in the legacy table\n-- either \u2014 see the persistence findings repository's identical predicate).\nCREATE VIEW `findings` AS\nSELECT\n f.id AS id,\n f.rowid AS rowid,\n f.audit_event_id AS event_id,\n d.rule_id AS rule_id,\n d.category AS category,\n d.severity AS severity,\n f.span_start AS span_start,\n f.span_end AS span_end,\n f.masked_match AS masked_match,\n f.action_taken AS action_taken,\n f.confidence AS confidence,\n f.finding_key AS finding_key,\n f.first_detected_at AS first_detected_at\nFROM inspection_findings f\nJOIN audit_events e ON e.id = f.audit_event_id\nJOIN inspection_definitions d ON d.id = f.inspection_definition_id\nWHERE e.event_type IN ('prompt', 'response', 'code_change', 'tool_use');\n--> statement-breakpoint\n-- Defense in depth only: SQLite refuses to plan ANY upsert against a view\n-- (\"cannot UPSERT a view\") no matter what trigger exists, so this can never\n-- rescue the real legacy writer, which always used\n-- `ON CONFLICT (finding_key) DO UPDATE` \u2014 that statement still fails at\n-- prepare() on an old binary, same as it would with no trigger at all. This\n-- only covers a plain-INSERT shape, should one ever exist.\nCREATE TRIGGER `trg_findings_ro`\nINSTEAD OF INSERT ON `findings`\nBEGIN SELECT RAISE(ABORT, 'findings is read-only; write to inspection_findings instead'); END;\n"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
tag: "0015_busy_vengeance",
|
|
564
|
+
sql: "CREATE TABLE `secret_vault` (\n `pointer_id` text PRIMARY KEY NOT NULL,\n `value_fingerprint` text NOT NULL,\n `fingerprint_key_version` integer NOT NULL,\n `key_version` integer NOT NULL,\n `category` text NOT NULL,\n `rule_id` text NOT NULL,\n `masked_match` text NOT NULL,\n `provider` text,\n `ciphertext` text NOT NULL,\n `nonce` text NOT NULL,\n `auth_tag` text NOT NULL,\n `occurrence_count` integer DEFAULT 1 NOT NULL,\n `first_seen` integer NOT NULL,\n `last_seen` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX `uq_secret_vault_value` ON `secret_vault` (`value_fingerprint`);--> statement-breakpoint\nCREATE TABLE `secret_vault_deref` (\n `id` text PRIMARY KEY NOT NULL,\n `pointer_id` text NOT NULL,\n `at` integer NOT NULL,\n `target` text NOT NULL,\n `reason` text NOT NULL,\n `outcome` text NOT NULL,\n `grant_id` text,\n `pointer_count` integer DEFAULT 1 NOT NULL\n);\n--> statement-breakpoint\nCREATE INDEX `idx_secret_vault_deref_pointer` ON `secret_vault_deref` (`pointer_id`);--> statement-breakpoint\nCREATE INDEX `idx_secret_vault_deref_reason_at` ON `secret_vault_deref` (`reason`,`at`);"
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
tag: "0016_breezy_zodiak",
|
|
568
|
+
sql: "ALTER TABLE `exceptions` ADD `capability` text DEFAULT 'suppress' NOT NULL;"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
tag: "0017_rainy_kat_farrell",
|
|
572
|
+
sql: "CREATE TABLE `secret_vault_sighting` (\n `id` text PRIMARY KEY NOT NULL,\n `pointer_id` text NOT NULL,\n `location` text NOT NULL,\n `kind` text NOT NULL,\n `first_seen` integer NOT NULL,\n `last_seen` integer NOT NULL\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX `uq_secret_vault_sighting` ON `secret_vault_sighting` (`pointer_id`,`location`);"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
tag: "0018_serious_tana_nile",
|
|
576
|
+
sql: "ALTER TABLE `secret_vault` ADD `format_version` integer DEFAULT 2 NOT NULL;"
|
|
561
577
|
}
|
|
562
578
|
];
|
|
563
579
|
|
|
@@ -16214,6 +16230,7 @@ var ExceptionConditions = external_exports.object({
|
|
|
16214
16230
|
sourceTool: external_exports.string().optional(),
|
|
16215
16231
|
provider: external_exports.string().optional()
|
|
16216
16232
|
}).strict();
|
|
16233
|
+
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
16217
16234
|
var DetectionException = external_exports.object({
|
|
16218
16235
|
id: external_exports.guid(),
|
|
16219
16236
|
ruleId: external_exports.string(),
|
|
@@ -16230,6 +16247,7 @@ var DetectionException = external_exports.object({
|
|
|
16230
16247
|
keyVersion: external_exports.number().int().positive(),
|
|
16231
16248
|
// maskMatch() preview of the approved value — never the raw value.
|
|
16232
16249
|
maskedValue: external_exports.string(),
|
|
16250
|
+
capability: ExceptionCapability.default("suppress"),
|
|
16233
16251
|
scope: ExceptionScope,
|
|
16234
16252
|
expiresAt: external_exports.iso.datetime().nullable(),
|
|
16235
16253
|
maxUses: external_exports.number().int().positive().nullable(),
|
|
@@ -16253,6 +16271,7 @@ var ExceptionBundleEntry = DetectionException.pick({
|
|
|
16253
16271
|
ruleId: true,
|
|
16254
16272
|
valueFingerprint: true,
|
|
16255
16273
|
keyVersion: true,
|
|
16274
|
+
capability: true,
|
|
16256
16275
|
expiresAt: true,
|
|
16257
16276
|
maxUses: true,
|
|
16258
16277
|
useCount: true,
|
|
@@ -17357,8 +17376,117 @@ var PatchInstalledPackRequest = external_exports.object({
|
|
|
17357
17376
|
message: "At least one field must be provided"
|
|
17358
17377
|
}).meta({ id: "PatchInstalledPackRequest" });
|
|
17359
17378
|
|
|
17379
|
+
// ../../packages/schema/src/zod/vault.ts
|
|
17380
|
+
var POINTER_FORMAT_VERSION = 2;
|
|
17381
|
+
var CATEGORY_ALTERNATION = DetectionCategory.options.join("|");
|
|
17382
|
+
var POINTER_TOKEN_PATTERN = new RegExp(
|
|
17383
|
+
`\\[\\[aka:(?:${CATEGORY_ALTERNATION}):[A-Z2-7]{2,7}\\.[A-Z2-7]{26}\\.[A-Z2-7]{16}\\]\\]`
|
|
17384
|
+
);
|
|
17385
|
+
var POINTER_TOKEN_ANCHORED = new RegExp(`^${POINTER_TOKEN_PATTERN.source}$`);
|
|
17386
|
+
var PointerToken = external_exports.string().regex(POINTER_TOKEN_ANCHORED);
|
|
17387
|
+
var ParsedPointer = external_exports.object({
|
|
17388
|
+
category: DetectionCategory,
|
|
17389
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17390
|
+
pointerId: external_exports.string(),
|
|
17391
|
+
tag: external_exports.string()
|
|
17392
|
+
});
|
|
17393
|
+
var VaultEntry = external_exports.object({
|
|
17394
|
+
pointerId: external_exports.string(),
|
|
17395
|
+
// The keyed HMAC of the raw value under `exception.key`, and the epoch it was
|
|
17396
|
+
// derived under. This is what a reveal-to-model grant matches on, and it rotates
|
|
17397
|
+
// independently of the vault encryption key below.
|
|
17398
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17399
|
+
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
17400
|
+
// The vault-key epoch this row's ciphertext was sealed under.
|
|
17401
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17402
|
+
// Fixed at first mint and never updated: the same value detected later under a
|
|
17403
|
+
// different rule's category keeps the category it was minted with, so one
|
|
17404
|
+
// value always produces exactly one wire token.
|
|
17405
|
+
category: DetectionCategory,
|
|
17406
|
+
ruleId: external_exports.string(),
|
|
17407
|
+
// Partial-reveal preview for badges and listings. Never the raw value.
|
|
17408
|
+
maskedMatch: external_exports.string(),
|
|
17409
|
+
provider: external_exports.string().optional(),
|
|
17410
|
+
ciphertext: external_exports.string(),
|
|
17411
|
+
nonce: external_exports.string(),
|
|
17412
|
+
authTag: external_exports.string(),
|
|
17413
|
+
// How many times this value has been detected on this machine — the reuse
|
|
17414
|
+
// signal the vault dashboard reads. Distinct from VaultDeref.pointerCount.
|
|
17415
|
+
occurrenceCount: external_exports.number().int().nonnegative(),
|
|
17416
|
+
firstSeen: external_exports.string(),
|
|
17417
|
+
lastSeen: external_exports.string()
|
|
17418
|
+
});
|
|
17419
|
+
var PointerDescriptor = external_exports.object({
|
|
17420
|
+
category: DetectionCategory,
|
|
17421
|
+
provider: external_exports.string().optional(),
|
|
17422
|
+
maskedMatch: external_exports.string(),
|
|
17423
|
+
occurrences: external_exports.number().int().nonnegative(),
|
|
17424
|
+
firstSeen: external_exports.string(),
|
|
17425
|
+
lastSeen: external_exports.string()
|
|
17426
|
+
});
|
|
17427
|
+
var PointerIdentity = external_exports.object({
|
|
17428
|
+
ruleId: external_exports.string(),
|
|
17429
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17430
|
+
fingerprintKeyVersion: external_exports.number().int().positive()
|
|
17431
|
+
});
|
|
17432
|
+
var DetokenizeTarget = external_exports.enum(["human", "model"]);
|
|
17433
|
+
var VaultDerefReason = external_exports.enum([
|
|
17434
|
+
"display",
|
|
17435
|
+
"explicit-reveal",
|
|
17436
|
+
"view-render",
|
|
17437
|
+
"model-input",
|
|
17438
|
+
"remediation",
|
|
17439
|
+
"purge"
|
|
17440
|
+
]);
|
|
17441
|
+
var VaultDerefOutcome = external_exports.enum(["revealed", "refused", "unavailable"]);
|
|
17442
|
+
var VaultDeref = external_exports.object({
|
|
17443
|
+
id: external_exports.guid(),
|
|
17444
|
+
pointerId: external_exports.string(),
|
|
17445
|
+
at: external_exports.string(),
|
|
17446
|
+
target: DetokenizeTarget,
|
|
17447
|
+
reason: VaultDerefReason,
|
|
17448
|
+
outcome: VaultDerefOutcome,
|
|
17449
|
+
// Present only on a model-target crossing that a reveal grant authorized.
|
|
17450
|
+
grantId: external_exports.string().optional(),
|
|
17451
|
+
// How many pointers ONE batched render resolved. 1 for unbatched rows. Named
|
|
17452
|
+
// apart from VaultEntry.occurrenceCount, which counts detections of a value.
|
|
17453
|
+
pointerCount: external_exports.number().int().positive().default(1)
|
|
17454
|
+
});
|
|
17455
|
+
var VaultSightingKind = external_exports.enum([
|
|
17456
|
+
"prompt",
|
|
17457
|
+
"tool-input",
|
|
17458
|
+
"tool-output",
|
|
17459
|
+
"file",
|
|
17460
|
+
"transcript"
|
|
17461
|
+
]);
|
|
17462
|
+
var VaultSighting = external_exports.object({
|
|
17463
|
+
location: external_exports.string(),
|
|
17464
|
+
kind: VaultSightingKind,
|
|
17465
|
+
firstSeen: external_exports.string(),
|
|
17466
|
+
lastSeen: external_exports.string()
|
|
17467
|
+
});
|
|
17468
|
+
var VaultInventoryEntry = external_exports.object({
|
|
17469
|
+
pointerId: external_exports.string(),
|
|
17470
|
+
category: DetectionCategory,
|
|
17471
|
+
provider: external_exports.string().optional(),
|
|
17472
|
+
maskedMatch: external_exports.string(),
|
|
17473
|
+
occurrences: external_exports.number().int().nonnegative(),
|
|
17474
|
+
firstSeen: external_exports.string(),
|
|
17475
|
+
lastSeen: external_exports.string(),
|
|
17476
|
+
// The active reveal-to-model grant covering this value, when one exists —
|
|
17477
|
+
// the inventory badges it, the row links to revocation.
|
|
17478
|
+
revealGrantId: external_exports.string().nullable(),
|
|
17479
|
+
sightings: external_exports.array(VaultSighting)
|
|
17480
|
+
});
|
|
17481
|
+
var VaultKeyCustody = external_exports.string();
|
|
17482
|
+
var VaultInlineReveal = external_exports.enum(["masked", "full", "off"]);
|
|
17483
|
+
var VaultConsent = external_exports.object({
|
|
17484
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
17485
|
+
version: external_exports.number().int().positive()
|
|
17486
|
+
});
|
|
17487
|
+
|
|
17360
17488
|
// ../../packages/schema/src/zod/local.ts
|
|
17361
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
17489
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
|
|
17362
17490
|
var RunMode = external_exports.enum(["standalone"]);
|
|
17363
17491
|
var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
|
|
17364
17492
|
var HistoricalAccess = external_exports.enum(["full", "session-only"]);
|
|
@@ -17380,6 +17508,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
17380
17508
|
// In-place egress extraction on the scan paths; disable to stop all Data
|
|
17381
17509
|
// Shares writes.
|
|
17382
17510
|
dataSharesInPlace: external_exports.boolean().default(true),
|
|
17511
|
+
// Consent to keep a RECOVERABLE encrypted copy of detected values in the local
|
|
17512
|
+
// vault, instead of destroying them. Absent by default: this is a custody
|
|
17513
|
+
// change from one-way redaction, so it is never an assumed grant on upgrade.
|
|
17514
|
+
// Revoking stops future vaulting; it does not erase what is already stored —
|
|
17515
|
+
// purging the vault is the eraser.
|
|
17516
|
+
vaultConsent: VaultConsent.optional(),
|
|
17517
|
+
// Where the vault master key lives.
|
|
17518
|
+
vaultKeyCustody: VaultKeyCustody.default("file"),
|
|
17519
|
+
// How a pointer renders in assistant prose on screen (see VaultInlineReveal).
|
|
17520
|
+
vaultInlineReveal: VaultInlineReveal.default("masked"),
|
|
17383
17521
|
// Absent until /aka:setup completes; its presence is what "onboarded" means.
|
|
17384
17522
|
onboardedAt: external_exports.iso.datetime().optional(),
|
|
17385
17523
|
// Records that the user consented to sending findings to the model API for
|
|
@@ -19777,6 +19915,9 @@ var AmbiguousExceptionIdError = class extends Error {
|
|
|
19777
19915
|
var ACTIVE_PREDICATE = `revoked_at IS NULL
|
|
19778
19916
|
AND (expires_at IS NULL OR expires_at > :now)
|
|
19779
19917
|
AND (max_uses IS NULL OR use_count < max_uses)`;
|
|
19918
|
+
var ACTIVE_REVEAL_GRANT_PREDICATE = `capability = 'reveal_to_model'
|
|
19919
|
+
AND conditions IS NULL
|
|
19920
|
+
AND ${ACTIVE_PREDICATE}`;
|
|
19780
19921
|
var SqliteExceptionsRepository = class {
|
|
19781
19922
|
constructor(db) {
|
|
19782
19923
|
this.db = db;
|
|
@@ -19868,11 +20009,11 @@ var SqliteExceptionsRepository = class {
|
|
|
19868
20009
|
this.db.prepare(
|
|
19869
20010
|
`INSERT INTO exceptions (
|
|
19870
20011
|
id, rule_id, category, value_fingerprint, key_version, masked_value,
|
|
19871
|
-
scope, expires_at, max_uses, use_count, last_used_at,
|
|
19872
|
-
conditions, created_by, created_via, created_at, updated_at
|
|
20012
|
+
capability, scope, expires_at, max_uses, use_count, last_used_at,
|
|
20013
|
+
justification, conditions, created_by, created_via, created_at, updated_at
|
|
19873
20014
|
) VALUES (
|
|
19874
20015
|
:id, :ruleId, :category, :valueFingerprint, :keyVersion, :maskedValue,
|
|
19875
|
-
:scope, :expiresAt, :maxUses, 0, NULL, :justification,
|
|
20016
|
+
:capability, :scope, :expiresAt, :maxUses, 0, NULL, :justification,
|
|
19876
20017
|
:conditions, :createdBy, :createdVia, :now, :now
|
|
19877
20018
|
)`
|
|
19878
20019
|
).run({
|
|
@@ -19882,6 +20023,7 @@ var SqliteExceptionsRepository = class {
|
|
|
19882
20023
|
valueFingerprint: input.valueFingerprint,
|
|
19883
20024
|
keyVersion: input.keyVersion,
|
|
19884
20025
|
maskedValue: input.maskedValue,
|
|
20026
|
+
capability: input.capability ?? "suppress",
|
|
19885
20027
|
scope: input.scope,
|
|
19886
20028
|
expiresAt: input.expiresAt === null ? null : isoToEpochMillis(input.expiresAt),
|
|
19887
20029
|
maxUses: input.maxUses,
|
|
@@ -19975,6 +20117,7 @@ var SqliteExceptionsRepository = class {
|
|
|
19975
20117
|
ruleId: row.rule_id,
|
|
19976
20118
|
valueFingerprint: row.value_fingerprint,
|
|
19977
20119
|
keyVersion: row.key_version,
|
|
20120
|
+
capability: row.capability,
|
|
19978
20121
|
expiresAt: row.expires_at === null ? null : epochMillisToIso(row.expires_at),
|
|
19979
20122
|
maxUses: row.max_uses,
|
|
19980
20123
|
useCount: row.use_count,
|
|
@@ -20029,6 +20172,35 @@ var SqliteExceptionsRepository = class {
|
|
|
20029
20172
|
}))
|
|
20030
20173
|
);
|
|
20031
20174
|
}
|
|
20175
|
+
/**
|
|
20176
|
+
* The active reveal-to-model grant for a vaulted value's identity, or null.
|
|
20177
|
+
* Matching is exact on (ruleId, valueFingerprint, keyVersion) — the same key
|
|
20178
|
+
* suppression uses — plus the capability: a suppression grant must never
|
|
20179
|
+
* authorize a reveal. Read-only: the caller does NOT consume here, because a
|
|
20180
|
+
* revealed value re-enters the detection scan immediately afterward and the
|
|
20181
|
+
* suppression match there claims the use — one crossing, one use.
|
|
20182
|
+
*
|
|
20183
|
+
* A grant with `conditions` NEVER matches here: the reveal path does not yet
|
|
20184
|
+
* evaluate conditions, and a narrowing clause that is ignored would WIDEN the
|
|
20185
|
+
* grant instead. Fail closed until reveal-side condition evaluation exists.
|
|
20186
|
+
*/
|
|
20187
|
+
activeRevealGrant(ruleId, valueFingerprint, keyVersion, now = Date.now()) {
|
|
20188
|
+
try {
|
|
20189
|
+
const row = getRow(
|
|
20190
|
+
this.db.prepare(
|
|
20191
|
+
`SELECT id FROM exceptions
|
|
20192
|
+
WHERE rule_id = :ruleId AND value_fingerprint = :valueFingerprint
|
|
20193
|
+
AND key_version = :keyVersion
|
|
20194
|
+
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
20195
|
+
LIMIT 1`
|
|
20196
|
+
),
|
|
20197
|
+
{ ruleId, valueFingerprint, keyVersion, now }
|
|
20198
|
+
);
|
|
20199
|
+
return Promise.resolve(row ?? null);
|
|
20200
|
+
} catch (err) {
|
|
20201
|
+
return Promise.reject(err instanceof Error ? err : new Error(String(err)));
|
|
20202
|
+
}
|
|
20203
|
+
}
|
|
20032
20204
|
/**
|
|
20033
20205
|
* Retention sweep: delete TERMINAL rows (revoked, expired, or use-budget
|
|
20034
20206
|
* exhausted) whose last transition is older than the retention window.
|
|
@@ -20056,6 +20228,7 @@ function parseExceptionRow(row) {
|
|
|
20056
20228
|
valueFingerprint: row.value_fingerprint,
|
|
20057
20229
|
keyVersion: row.key_version,
|
|
20058
20230
|
maskedValue: row.masked_value,
|
|
20231
|
+
capability: row.capability,
|
|
20059
20232
|
scope: row.scope,
|
|
20060
20233
|
expiresAt: row.expires_at === null ? null : epochMillisToIso(row.expires_at),
|
|
20061
20234
|
maxUses: row.max_uses,
|
|
@@ -22221,6 +22394,287 @@ var SqliteScanLedgerRepository = class {
|
|
|
22221
22394
|
}
|
|
22222
22395
|
};
|
|
22223
22396
|
|
|
22397
|
+
// ../../packages/persistence/src/repositories/secret-vault.ts
|
|
22398
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
22399
|
+
var SELECT_COLUMNS = `
|
|
22400
|
+
pointer_id AS pointerId,
|
|
22401
|
+
value_fingerprint AS valueFingerprint,
|
|
22402
|
+
fingerprint_key_version AS fingerprintKeyVersion,
|
|
22403
|
+
key_version AS keyVersion,
|
|
22404
|
+
format_version AS formatVersion,
|
|
22405
|
+
category,
|
|
22406
|
+
rule_id AS ruleId,
|
|
22407
|
+
masked_match AS maskedMatch,
|
|
22408
|
+
provider,
|
|
22409
|
+
ciphertext,
|
|
22410
|
+
nonce,
|
|
22411
|
+
auth_tag AS authTag,
|
|
22412
|
+
occurrence_count AS occurrenceCount,
|
|
22413
|
+
first_seen AS firstSeen,
|
|
22414
|
+
last_seen AS lastSeen`;
|
|
22415
|
+
function toRow(raw) {
|
|
22416
|
+
const { provider, ...rest } = raw;
|
|
22417
|
+
return provider === null ? rest : { ...rest, provider };
|
|
22418
|
+
}
|
|
22419
|
+
var SqliteSecretVaultRepository = class {
|
|
22420
|
+
constructor(db) {
|
|
22421
|
+
this.db = db;
|
|
22422
|
+
this.insertStmt = db.prepare(
|
|
22423
|
+
`INSERT INTO secret_vault (
|
|
22424
|
+
pointer_id, value_fingerprint, fingerprint_key_version, key_version,
|
|
22425
|
+
format_version, category, rule_id, masked_match, provider,
|
|
22426
|
+
ciphertext, nonce, auth_tag,
|
|
22427
|
+
occurrence_count, first_seen, last_seen
|
|
22428
|
+
) VALUES (
|
|
22429
|
+
:pointerId, :valueFingerprint, :fingerprintKeyVersion, :keyVersion,
|
|
22430
|
+
:formatVersion, :category, :ruleId, :maskedMatch, :provider,
|
|
22431
|
+
:ciphertext, :nonce, :authTag,
|
|
22432
|
+
1, :now, :now
|
|
22433
|
+
)`
|
|
22434
|
+
);
|
|
22435
|
+
this.bumpStmt = db.prepare(
|
|
22436
|
+
`UPDATE secret_vault
|
|
22437
|
+
SET occurrence_count = occurrence_count + 1, last_seen = :now
|
|
22438
|
+
WHERE value_fingerprint = :valueFingerprint`
|
|
22439
|
+
);
|
|
22440
|
+
this.byPointerStmt = db.prepare(
|
|
22441
|
+
`SELECT ${SELECT_COLUMNS} FROM secret_vault WHERE pointer_id = :pointerId`
|
|
22442
|
+
);
|
|
22443
|
+
this.byFingerprintStmt = db.prepare(
|
|
22444
|
+
`SELECT ${SELECT_COLUMNS} FROM secret_vault WHERE value_fingerprint = :valueFingerprint`
|
|
22445
|
+
);
|
|
22446
|
+
this.listStmt = db.prepare(`SELECT ${SELECT_COLUMNS} FROM secret_vault ORDER BY first_seen`);
|
|
22447
|
+
this.replaceCiphertextStmt = db.prepare(
|
|
22448
|
+
`UPDATE secret_vault
|
|
22449
|
+
SET key_version = :keyVersion, ciphertext = :ciphertext, nonce = :nonce, auth_tag = :authTag
|
|
22450
|
+
WHERE pointer_id = :pointerId`
|
|
22451
|
+
);
|
|
22452
|
+
this.refreshFingerprintStmt = db.prepare(
|
|
22453
|
+
`UPDATE secret_vault
|
|
22454
|
+
SET value_fingerprint = :valueFingerprint, fingerprint_key_version = :fingerprintKeyVersion
|
|
22455
|
+
WHERE pointer_id = :pointerId`
|
|
22456
|
+
);
|
|
22457
|
+
this.derefStmt = db.prepare(
|
|
22458
|
+
`INSERT INTO secret_vault_deref (id, pointer_id, at, target, reason, outcome, grant_id, pointer_count)
|
|
22459
|
+
VALUES (:id, :pointerId, :at, :target, :reason, :outcome, :grantId, :pointerCount)`
|
|
22460
|
+
);
|
|
22461
|
+
}
|
|
22462
|
+
db;
|
|
22463
|
+
insertStmt;
|
|
22464
|
+
bumpStmt;
|
|
22465
|
+
byPointerStmt;
|
|
22466
|
+
byFingerprintStmt;
|
|
22467
|
+
listStmt;
|
|
22468
|
+
replaceCiphertextStmt;
|
|
22469
|
+
refreshFingerprintStmt;
|
|
22470
|
+
derefStmt;
|
|
22471
|
+
/**
|
|
22472
|
+
* Vault a value, or record another sighting of one already vaulted. Keyed on
|
|
22473
|
+
* `valueFingerprint`, never on the caller's pointer id: a value seen again
|
|
22474
|
+
* bumps `occurrence_count` and `last_seen` and comes back with its ORIGINAL
|
|
22475
|
+
* pointer, category and ciphertext, so the same secret always resolves to one
|
|
22476
|
+
* wire token. `minted` is true only when this call created the row.
|
|
22477
|
+
*
|
|
22478
|
+
* The read-then-write runs in one IMMEDIATE transaction so two concurrent
|
|
22479
|
+
* writers cannot both decide they are minting.
|
|
22480
|
+
*/
|
|
22481
|
+
upsert(input, now) {
|
|
22482
|
+
let minted = false;
|
|
22483
|
+
withTransaction(
|
|
22484
|
+
this.db,
|
|
22485
|
+
() => {
|
|
22486
|
+
const existing = getRow(this.byFingerprintStmt, {
|
|
22487
|
+
valueFingerprint: input.valueFingerprint
|
|
22488
|
+
});
|
|
22489
|
+
if (existing === void 0) {
|
|
22490
|
+
this.insertStmt.run(
|
|
22491
|
+
bindParams({
|
|
22492
|
+
pointerId: input.pointerId,
|
|
22493
|
+
valueFingerprint: input.valueFingerprint,
|
|
22494
|
+
fingerprintKeyVersion: input.fingerprintKeyVersion,
|
|
22495
|
+
keyVersion: input.keyVersion,
|
|
22496
|
+
formatVersion: input.formatVersion ?? POINTER_FORMAT_VERSION,
|
|
22497
|
+
category: input.category,
|
|
22498
|
+
ruleId: input.ruleId,
|
|
22499
|
+
maskedMatch: input.maskedMatch,
|
|
22500
|
+
provider: input.provider,
|
|
22501
|
+
ciphertext: input.ciphertext,
|
|
22502
|
+
nonce: input.nonce,
|
|
22503
|
+
authTag: input.authTag,
|
|
22504
|
+
now
|
|
22505
|
+
})
|
|
22506
|
+
);
|
|
22507
|
+
minted = true;
|
|
22508
|
+
return;
|
|
22509
|
+
}
|
|
22510
|
+
this.bumpStmt.run({ valueFingerprint: input.valueFingerprint, now });
|
|
22511
|
+
},
|
|
22512
|
+
"IMMEDIATE"
|
|
22513
|
+
);
|
|
22514
|
+
const row = getRow(this.byFingerprintStmt, {
|
|
22515
|
+
valueFingerprint: input.valueFingerprint
|
|
22516
|
+
});
|
|
22517
|
+
if (row === void 0) throw new Error("vault: row vanished immediately after write");
|
|
22518
|
+
return { row: toRow(row), minted };
|
|
22519
|
+
}
|
|
22520
|
+
byPointerId(pointerId) {
|
|
22521
|
+
const raw = getRow(this.byPointerStmt, { pointerId });
|
|
22522
|
+
return raw === void 0 ? null : toRow(raw);
|
|
22523
|
+
}
|
|
22524
|
+
byValueFingerprint(fingerprint) {
|
|
22525
|
+
const raw = getRow(this.byFingerprintStmt, { valueFingerprint: fingerprint });
|
|
22526
|
+
return raw === void 0 ? null : toRow(raw);
|
|
22527
|
+
}
|
|
22528
|
+
/** Append one audit row. Carries no raw value and no ciphertext, by shape. */
|
|
22529
|
+
recordDeref(entry) {
|
|
22530
|
+
this.derefStmt.run(
|
|
22531
|
+
bindParams({
|
|
22532
|
+
id: entry.id,
|
|
22533
|
+
pointerId: entry.pointerId,
|
|
22534
|
+
at: entry.at,
|
|
22535
|
+
target: entry.target,
|
|
22536
|
+
reason: entry.reason,
|
|
22537
|
+
outcome: entry.outcome,
|
|
22538
|
+
grantId: entry.grantId,
|
|
22539
|
+
pointerCount: entry.pointerCount ?? 1
|
|
22540
|
+
})
|
|
22541
|
+
);
|
|
22542
|
+
}
|
|
22543
|
+
listAll() {
|
|
22544
|
+
return allRows(this.listStmt).map(toRow);
|
|
22545
|
+
}
|
|
22546
|
+
/** Re-seal an entry under a new key epoch, leaving its identity untouched. */
|
|
22547
|
+
replaceCiphertext(pointerId, next) {
|
|
22548
|
+
this.replaceCiphertextStmt.run({ pointerId, ...next });
|
|
22549
|
+
}
|
|
22550
|
+
/** Re-derive an entry's fingerprint under a new fingerprint-key epoch. */
|
|
22551
|
+
refreshFingerprint(pointerId, next) {
|
|
22552
|
+
this.refreshFingerprintStmt.run({ pointerId, ...next });
|
|
22553
|
+
}
|
|
22554
|
+
/**
|
|
22555
|
+
* Destroy every vaulted value and report how many were destroyed. The deref
|
|
22556
|
+
* audit is left alone on purpose — see the table note above.
|
|
22557
|
+
*/
|
|
22558
|
+
purgeAll() {
|
|
22559
|
+
let destroyed = 0;
|
|
22560
|
+
withTransaction(
|
|
22561
|
+
this.db,
|
|
22562
|
+
() => {
|
|
22563
|
+
destroyed = this.countEntries();
|
|
22564
|
+
this.db.exec("DELETE FROM secret_vault");
|
|
22565
|
+
},
|
|
22566
|
+
"IMMEDIATE"
|
|
22567
|
+
);
|
|
22568
|
+
return destroyed;
|
|
22569
|
+
}
|
|
22570
|
+
/**
|
|
22571
|
+
* Record (or re-stamp) one place a pointer has been written. One row per
|
|
22572
|
+
* (pointer, location); a re-sighting bumps last_seen. Best-effort bookkeeping
|
|
22573
|
+
* on hook paths — a failure must never affect the rewrite that triggered it,
|
|
22574
|
+
* so callers wrap this, not the other way around.
|
|
22575
|
+
*/
|
|
22576
|
+
recordSighting(entry, now) {
|
|
22577
|
+
this.db.prepare(
|
|
22578
|
+
`INSERT INTO secret_vault_sighting (id, pointer_id, location, kind, first_seen, last_seen)
|
|
22579
|
+
VALUES (:id, :pointerId, :location, :kind, :now, :now)
|
|
22580
|
+
ON CONFLICT (pointer_id, location) DO UPDATE SET last_seen = :now`
|
|
22581
|
+
).run({
|
|
22582
|
+
id: randomUUID7(),
|
|
22583
|
+
pointerId: entry.pointerId,
|
|
22584
|
+
location: entry.location,
|
|
22585
|
+
kind: entry.kind,
|
|
22586
|
+
now
|
|
22587
|
+
});
|
|
22588
|
+
}
|
|
22589
|
+
listSightings(pointerId) {
|
|
22590
|
+
const rows = allRows(
|
|
22591
|
+
this.db.prepare(
|
|
22592
|
+
`SELECT location, kind, first_seen, last_seen FROM secret_vault_sighting
|
|
22593
|
+
WHERE pointer_id = :pointerId ORDER BY last_seen DESC`
|
|
22594
|
+
),
|
|
22595
|
+
{ pointerId }
|
|
22596
|
+
);
|
|
22597
|
+
return rows.map((r) => ({
|
|
22598
|
+
location: r.location,
|
|
22599
|
+
kind: r.kind,
|
|
22600
|
+
firstSeen: new Date(r.first_seen).toISOString(),
|
|
22601
|
+
lastSeen: new Date(r.last_seen).toISOString()
|
|
22602
|
+
}));
|
|
22603
|
+
}
|
|
22604
|
+
/**
|
|
22605
|
+
* The dashboard inventory: every vaulted value's descriptor data joined with
|
|
22606
|
+
* its sightings and the active reveal-to-model grant when one exists.
|
|
22607
|
+
* Raw-free by construction — neither the fingerprint nor the ciphertext
|
|
22608
|
+
* columns are selected.
|
|
22609
|
+
*/
|
|
22610
|
+
listInventory(now = Date.now()) {
|
|
22611
|
+
const rows = allRows(
|
|
22612
|
+
this.db.prepare(
|
|
22613
|
+
`SELECT v.pointer_id, v.category, v.rule_id, v.masked_match, v.provider,
|
|
22614
|
+
v.occurrence_count, v.first_seen, v.last_seen,
|
|
22615
|
+
(SELECT e.id FROM exceptions e
|
|
22616
|
+
WHERE e.rule_id = v.rule_id
|
|
22617
|
+
AND e.value_fingerprint = v.value_fingerprint
|
|
22618
|
+
AND e.key_version = v.fingerprint_key_version
|
|
22619
|
+
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
22620
|
+
LIMIT 1) AS grant_id
|
|
22621
|
+
FROM secret_vault v
|
|
22622
|
+
ORDER BY v.last_seen DESC`
|
|
22623
|
+
),
|
|
22624
|
+
{ now }
|
|
22625
|
+
);
|
|
22626
|
+
return rows.map((r) => ({
|
|
22627
|
+
pointerId: r.pointer_id,
|
|
22628
|
+
category: r.category,
|
|
22629
|
+
...r.provider === null ? {} : { provider: r.provider },
|
|
22630
|
+
maskedMatch: r.masked_match,
|
|
22631
|
+
occurrences: r.occurrence_count,
|
|
22632
|
+
firstSeen: new Date(r.first_seen).toISOString(),
|
|
22633
|
+
lastSeen: new Date(r.last_seen).toISOString(),
|
|
22634
|
+
revealGrantId: r.grant_id,
|
|
22635
|
+
sightings: this.listSightings(r.pointer_id)
|
|
22636
|
+
}));
|
|
22637
|
+
}
|
|
22638
|
+
/**
|
|
22639
|
+
* The de-reference trail, newest first. By default the batched, high-volume
|
|
22640
|
+
* reasons (display, view-render) are hidden and counted instead — the rows
|
|
22641
|
+
* that matter as a signal are the model crossings, and burying them under
|
|
22642
|
+
* render noise would defeat the audit's purpose.
|
|
22643
|
+
*/
|
|
22644
|
+
listDerefs(opts) {
|
|
22645
|
+
const limit = opts?.limit ?? 200;
|
|
22646
|
+
const where = opts?.includeBatched === true ? "" : `WHERE reason NOT IN ('display', 'view-render')`;
|
|
22647
|
+
const rows = allRows(
|
|
22648
|
+
this.db.prepare(
|
|
22649
|
+
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
22650
|
+
FROM secret_vault_deref ${where}
|
|
22651
|
+
ORDER BY at DESC, rowid DESC LIMIT :limit`
|
|
22652
|
+
),
|
|
22653
|
+
{ limit }
|
|
22654
|
+
);
|
|
22655
|
+
const hiddenBatched = opts?.includeBatched === true ? 0 : countScalar(
|
|
22656
|
+
this.db,
|
|
22657
|
+
`SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
|
|
22658
|
+
);
|
|
22659
|
+
return {
|
|
22660
|
+
rows: rows.map((r) => ({
|
|
22661
|
+
id: r.id,
|
|
22662
|
+
pointerId: r.pointer_id,
|
|
22663
|
+
at: new Date(r.at).toISOString(),
|
|
22664
|
+
target: r.target,
|
|
22665
|
+
reason: r.reason,
|
|
22666
|
+
outcome: r.outcome,
|
|
22667
|
+
...r.grant_id === null ? {} : { grantId: r.grant_id },
|
|
22668
|
+
pointerCount: r.pointer_count
|
|
22669
|
+
})),
|
|
22670
|
+
hiddenBatched
|
|
22671
|
+
};
|
|
22672
|
+
}
|
|
22673
|
+
countEntries() {
|
|
22674
|
+
return countScalar(this.db, "SELECT COUNT(*) AS n FROM secret_vault");
|
|
22675
|
+
}
|
|
22676
|
+
};
|
|
22677
|
+
|
|
22224
22678
|
// ../../packages/persistence/src/repositories/security.ts
|
|
22225
22679
|
var DAY_MS4 = 864e5;
|
|
22226
22680
|
var SEVERITIES = ["critical", "high", "medium", "low"];
|
|
@@ -22566,7 +23020,7 @@ var SqliteSecurityRepository = class {
|
|
|
22566
23020
|
};
|
|
22567
23021
|
|
|
22568
23022
|
// ../../packages/persistence/src/repositories/shares.ts
|
|
22569
|
-
import { randomUUID as
|
|
23023
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
22570
23024
|
var MAX_EGRESS_CALL_SITES_PER_PROJECT = 5e3;
|
|
22571
23025
|
var IN_CHUNK = 500;
|
|
22572
23026
|
var KIND_ORDER = ["provider", "internal", "external", "ip"];
|
|
@@ -22822,7 +23276,7 @@ var SqliteSharesRepository = class {
|
|
|
22822
23276
|
(id, destination_id, host, decision, created_at, updated_at)
|
|
22823
23277
|
VALUES (:id, :destinationId, :host, :decision, :now, :now)`
|
|
22824
23278
|
).run({
|
|
22825
|
-
id:
|
|
23279
|
+
id: randomUUID8(),
|
|
22826
23280
|
destinationId,
|
|
22827
23281
|
host: dest.host,
|
|
22828
23282
|
decision,
|
|
@@ -22971,7 +23425,7 @@ var SqliteSharesRepository = class {
|
|
|
22971
23425
|
let destinationId = destIds.get(hit.host);
|
|
22972
23426
|
if (destinationId === void 0) {
|
|
22973
23427
|
destStmt.run({
|
|
22974
|
-
id:
|
|
23428
|
+
id: randomUUID8(),
|
|
22975
23429
|
kind: hit.kind,
|
|
22976
23430
|
name: hit.name,
|
|
22977
23431
|
host: hit.host,
|
|
@@ -22987,7 +23441,7 @@ var SqliteSharesRepository = class {
|
|
|
22987
23441
|
let endpointId = endpointIds.get(endpointKey);
|
|
22988
23442
|
if (endpointId === void 0) {
|
|
22989
23443
|
endpointStmt.run({
|
|
22990
|
-
id:
|
|
23444
|
+
id: randomUUID8(),
|
|
22991
23445
|
destinationId,
|
|
22992
23446
|
method: hit.method,
|
|
22993
23447
|
transport: hit.transport,
|
|
@@ -23000,7 +23454,7 @@ var SqliteSharesRepository = class {
|
|
|
23000
23454
|
endpointIds.set(endpointKey, endpointId);
|
|
23001
23455
|
}
|
|
23002
23456
|
siteStmt.run({
|
|
23003
|
-
id:
|
|
23457
|
+
id: randomUUID8(),
|
|
23004
23458
|
endpointId,
|
|
23005
23459
|
project: input.project,
|
|
23006
23460
|
projectKey: input.projectKey,
|
|
@@ -23416,6 +23870,7 @@ function openAndInitialize(file2) {
|
|
|
23416
23870
|
policies,
|
|
23417
23871
|
installedPacks,
|
|
23418
23872
|
scanLedger: new SqliteScanLedgerRepository(db),
|
|
23873
|
+
secretVault: new SqliteSecretVaultRepository(db),
|
|
23419
23874
|
exceptions: new SqliteExceptionsRepository(db),
|
|
23420
23875
|
resolutions: new SqliteResolutionsRepository(db),
|
|
23421
23876
|
ruleProbeCache: new SqliteRuleProbeCacheRepository(db),
|
|
@@ -23451,6 +23906,7 @@ function openLocalDatabase(dir) {
|
|
|
23451
23906
|
policies,
|
|
23452
23907
|
installedPacks,
|
|
23453
23908
|
scanLedger,
|
|
23909
|
+
secretVault,
|
|
23454
23910
|
exceptions,
|
|
23455
23911
|
resolutions,
|
|
23456
23912
|
ruleProbeCache,
|
|
@@ -23559,7 +24015,7 @@ function openLocalDatabase(dir) {
|
|
|
23559
24015
|
const definitionId = definitionIds.get(`${finding.ruleId}@${finding.version}`);
|
|
23560
24016
|
if (!definitionId) continue;
|
|
23561
24017
|
inspectionFindings.insertFinding({
|
|
23562
|
-
id:
|
|
24018
|
+
id: randomUUID9(),
|
|
23563
24019
|
auditEventId: record2.scanEvent.id,
|
|
23564
24020
|
inspectionDefinitionId: definitionId,
|
|
23565
24021
|
span: finding.span,
|
|
@@ -23636,6 +24092,7 @@ function openLocalDatabase(dir) {
|
|
|
23636
24092
|
policies,
|
|
23637
24093
|
installedPacks,
|
|
23638
24094
|
scanLedger,
|
|
24095
|
+
secretVault,
|
|
23639
24096
|
exceptions,
|
|
23640
24097
|
resolutions,
|
|
23641
24098
|
ruleProbeCache,
|
|
@@ -23768,23 +24225,49 @@ function readJson(file2) {
|
|
|
23768
24225
|
return parseJsonObject(text) ?? null;
|
|
23769
24226
|
}
|
|
23770
24227
|
|
|
23771
|
-
// ../../packages/persistence/src/
|
|
23772
|
-
import {
|
|
24228
|
+
// ../../packages/persistence/src/vault/crypto.ts
|
|
24229
|
+
import {
|
|
24230
|
+
createCipheriv,
|
|
24231
|
+
createDecipheriv,
|
|
24232
|
+
createHmac as createHmac2,
|
|
24233
|
+
hkdfSync,
|
|
24234
|
+
timingSafeEqual
|
|
24235
|
+
} from "crypto";
|
|
24236
|
+
|
|
24237
|
+
// ../../packages/persistence/src/vault/key-provider.ts
|
|
24238
|
+
import { execFileSync } from "child_process";
|
|
24239
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
24240
|
+
import {
|
|
24241
|
+
chmodSync as chmodSync2,
|
|
24242
|
+
mkdirSync as mkdirSync2,
|
|
24243
|
+
readFileSync as readFileSync3,
|
|
24244
|
+
renameSync as renameSync4,
|
|
24245
|
+
rmSync as rmSync3,
|
|
24246
|
+
statSync,
|
|
24247
|
+
writeFileSync as writeFileSync2
|
|
24248
|
+
} from "fs";
|
|
23773
24249
|
import { join as join5 } from "path";
|
|
24250
|
+
|
|
24251
|
+
// ../../packages/persistence/src/vault/vault.ts
|
|
24252
|
+
import { randomBytes as randomBytes3, randomUUID as randomUUID10 } from "crypto";
|
|
24253
|
+
|
|
24254
|
+
// ../../packages/persistence/src/warn-era-cap.ts
|
|
24255
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
24256
|
+
import { join as join6 } from "path";
|
|
23774
24257
|
var MARKER = "warn-era-capped";
|
|
23775
24258
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
23776
24259
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
23777
|
-
const marker =
|
|
24260
|
+
const marker = join6(dataDir2, MARKER);
|
|
23778
24261
|
if (existsSync3(marker)) return { capped: 0, skipped: "already-run" };
|
|
23779
24262
|
const capped = db.policies.capCategoryActions();
|
|
23780
|
-
|
|
24263
|
+
writeFileSync3(marker, `${new Date(Date.now()).toISOString()}
|
|
23781
24264
|
`, { mode: DATA_FILE_MODE });
|
|
23782
24265
|
return { capped };
|
|
23783
24266
|
}
|
|
23784
24267
|
|
|
23785
24268
|
// ../../packages/plugin-sdk/src/config.ts
|
|
23786
24269
|
import { existsSync as existsSync4 } from "fs";
|
|
23787
|
-
import { join as
|
|
24270
|
+
import { join as join7 } from "path";
|
|
23788
24271
|
|
|
23789
24272
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
23790
24273
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -23838,7 +24321,7 @@ function resolveProvider() {
|
|
|
23838
24321
|
function loadConfig(base = defaultDataDir()) {
|
|
23839
24322
|
try {
|
|
23840
24323
|
ensureLayoutDirSync(base);
|
|
23841
|
-
const settingsFile =
|
|
24324
|
+
const settingsFile = join7(settingsDir(base), "settings.json");
|
|
23842
24325
|
if (existsSync4(settingsFile)) tightenFile(settingsFile);
|
|
23843
24326
|
} catch {
|
|
23844
24327
|
}
|
|
@@ -23862,9 +24345,9 @@ function resolveProviderSafe() {
|
|
|
23862
24345
|
}
|
|
23863
24346
|
|
|
23864
24347
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
23865
|
-
import { readdirSync, readFileSync as
|
|
24348
|
+
import { readdirSync, readFileSync as readFileSync5, realpathSync, statSync as statSync3 } from "fs";
|
|
23866
24349
|
import { homedir as homedir2 } from "os";
|
|
23867
|
-
import { basename as basename2, join as
|
|
24350
|
+
import { basename as basename2, join as join9 } from "path";
|
|
23868
24351
|
|
|
23869
24352
|
// ../../packages/detections/src/egress/registry.ts
|
|
23870
24353
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -26600,18 +27083,18 @@ function bundledDetections() {
|
|
|
26600
27083
|
}
|
|
26601
27084
|
|
|
26602
27085
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
26603
|
-
import { existsSync as existsSync5, readFileSync as
|
|
26604
|
-
import { basename, dirname, isAbsolute, join as
|
|
27086
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
|
|
27087
|
+
import { basename, dirname, isAbsolute, join as join8, sep as sep2 } from "path";
|
|
26605
27088
|
|
|
26606
27089
|
// ../../packages/plugin-sdk/src/events.ts
|
|
26607
|
-
import { createHash as createHash4, randomUUID as
|
|
27090
|
+
import { createHash as createHash4, randomUUID as randomUUID11 } from "crypto";
|
|
26608
27091
|
|
|
26609
27092
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
26610
27093
|
import { arch, hostname as hostname3, platform, release } from "os";
|
|
26611
27094
|
|
|
26612
27095
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
26613
|
-
import { mkdirSync as
|
|
26614
|
-
import { join as
|
|
27096
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
27097
|
+
import { join as join10 } from "path";
|
|
26615
27098
|
|
|
26616
27099
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
26617
27100
|
import { readdirSync as readdirSync2, realpathSync as realpathSync2 } from "fs";
|
|
@@ -26619,21 +27102,21 @@ import { basename as basename3, dirname as dirname2, sep as sep3 } from "path";
|
|
|
26619
27102
|
|
|
26620
27103
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
26621
27104
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
26622
|
-
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as
|
|
26623
|
-
import { basename as basename4, join as
|
|
27105
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync7 } from "fs";
|
|
27106
|
+
import { basename as basename4, join as join11, relative, sep as sep4 } from "path";
|
|
26624
27107
|
|
|
26625
27108
|
// ../../packages/plugin-sdk/src/runtime.ts
|
|
26626
|
-
import { randomUUID as
|
|
27109
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
26627
27110
|
|
|
26628
27111
|
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
26629
27112
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
26630
27113
|
|
|
26631
27114
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
26632
|
-
import { mkdirSync as
|
|
26633
|
-
import { join as
|
|
27115
|
+
import { mkdirSync as mkdirSync4, statSync as statSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
27116
|
+
import { join as join12 } from "path";
|
|
26634
27117
|
|
|
26635
27118
|
// ../../packages/plugin-runtime/src/standalone-gateway.ts
|
|
26636
|
-
import { randomUUID as
|
|
27119
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
26637
27120
|
|
|
26638
27121
|
// ../../packages/plugin-runtime/src/recorder.ts
|
|
26639
27122
|
var PLUGIN_RECORDER_BINARY = "plugin";
|
|
@@ -26795,7 +27278,7 @@ var StandaloneDataGateway = class {
|
|
|
26795
27278
|
const customKeywords = [...new Set(policies.flatMap((p) => p.customKeywords ?? []))];
|
|
26796
27279
|
const installed = this.installedScanRules();
|
|
26797
27280
|
const rulePolicies = installed ? [...installed.ruleActions].map(([ruleId, action]) => ({
|
|
26798
|
-
id:
|
|
27281
|
+
id: randomUUID13(),
|
|
26799
27282
|
scope: "global",
|
|
26800
27283
|
target: { ruleId },
|
|
26801
27284
|
action,
|
|
@@ -26948,7 +27431,7 @@ function resolveDataGateway(config2, meta3, gatewayFactory = standaloneGatewayFa
|
|
|
26948
27431
|
}
|
|
26949
27432
|
|
|
26950
27433
|
// ../../packages/plugin-runtime/src/handle-session-start.ts
|
|
26951
|
-
import { randomUUID as
|
|
27434
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
26952
27435
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
26953
27436
|
|
|
26954
27437
|
// src/command-registry.ts
|
|
@@ -27272,10 +27755,10 @@ async function runFirstRunFailOpen(deps) {
|
|
|
27272
27755
|
}
|
|
27273
27756
|
|
|
27274
27757
|
// src/posture.ts
|
|
27275
|
-
async function readPostureBlock(
|
|
27758
|
+
async function readPostureBlock(open2) {
|
|
27276
27759
|
let db;
|
|
27277
27760
|
try {
|
|
27278
|
-
db =
|
|
27761
|
+
db = open2();
|
|
27279
27762
|
const policies = await db.policies.readPolicies();
|
|
27280
27763
|
return renderPosture(
|
|
27281
27764
|
policies.map((p) => ({
|