@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/statusline.js
CHANGED
|
@@ -493,10 +493,10 @@ var require_ignore = __commonJS({
|
|
|
493
493
|
|
|
494
494
|
// ../../packages/plugin-sdk/src/config.ts
|
|
495
495
|
import { existsSync as existsSync4 } from "fs";
|
|
496
|
-
import { join as
|
|
496
|
+
import { join as join7 } from "path";
|
|
497
497
|
|
|
498
498
|
// ../../packages/persistence/src/database.ts
|
|
499
|
-
import { randomUUID as
|
|
499
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
500
500
|
import { existsSync, renameSync as renameSync2, rmSync as rmSync2 } from "fs";
|
|
501
501
|
import { join, sep } from "path";
|
|
502
502
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -562,6 +562,22 @@ var SQLITE_MIGRATIONS = [
|
|
|
562
562
|
{
|
|
563
563
|
tag: "0014_drop_legacy_events_findings",
|
|
564
564
|
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"
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
tag: "0015_busy_vengeance",
|
|
568
|
+
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`);"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
tag: "0016_breezy_zodiak",
|
|
572
|
+
sql: "ALTER TABLE `exceptions` ADD `capability` text DEFAULT 'suppress' NOT NULL;"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
tag: "0017_rainy_kat_farrell",
|
|
576
|
+
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`);"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
tag: "0018_serious_tana_nile",
|
|
580
|
+
sql: "ALTER TABLE `secret_vault` ADD `format_version` integer DEFAULT 2 NOT NULL;"
|
|
565
581
|
}
|
|
566
582
|
];
|
|
567
583
|
|
|
@@ -16218,6 +16234,7 @@ var ExceptionConditions = external_exports.object({
|
|
|
16218
16234
|
sourceTool: external_exports.string().optional(),
|
|
16219
16235
|
provider: external_exports.string().optional()
|
|
16220
16236
|
}).strict();
|
|
16237
|
+
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
16221
16238
|
var DetectionException = external_exports.object({
|
|
16222
16239
|
id: external_exports.guid(),
|
|
16223
16240
|
ruleId: external_exports.string(),
|
|
@@ -16234,6 +16251,7 @@ var DetectionException = external_exports.object({
|
|
|
16234
16251
|
keyVersion: external_exports.number().int().positive(),
|
|
16235
16252
|
// maskMatch() preview of the approved value — never the raw value.
|
|
16236
16253
|
maskedValue: external_exports.string(),
|
|
16254
|
+
capability: ExceptionCapability.default("suppress"),
|
|
16237
16255
|
scope: ExceptionScope,
|
|
16238
16256
|
expiresAt: external_exports.iso.datetime().nullable(),
|
|
16239
16257
|
maxUses: external_exports.number().int().positive().nullable(),
|
|
@@ -16257,6 +16275,7 @@ var ExceptionBundleEntry = DetectionException.pick({
|
|
|
16257
16275
|
ruleId: true,
|
|
16258
16276
|
valueFingerprint: true,
|
|
16259
16277
|
keyVersion: true,
|
|
16278
|
+
capability: true,
|
|
16260
16279
|
expiresAt: true,
|
|
16261
16280
|
maxUses: true,
|
|
16262
16281
|
useCount: true,
|
|
@@ -17361,8 +17380,117 @@ var PatchInstalledPackRequest = external_exports.object({
|
|
|
17361
17380
|
message: "At least one field must be provided"
|
|
17362
17381
|
}).meta({ id: "PatchInstalledPackRequest" });
|
|
17363
17382
|
|
|
17383
|
+
// ../../packages/schema/src/zod/vault.ts
|
|
17384
|
+
var POINTER_FORMAT_VERSION = 2;
|
|
17385
|
+
var CATEGORY_ALTERNATION = DetectionCategory.options.join("|");
|
|
17386
|
+
var POINTER_TOKEN_PATTERN = new RegExp(
|
|
17387
|
+
`\\[\\[aka:(?:${CATEGORY_ALTERNATION}):[A-Z2-7]{2,7}\\.[A-Z2-7]{26}\\.[A-Z2-7]{16}\\]\\]`
|
|
17388
|
+
);
|
|
17389
|
+
var POINTER_TOKEN_ANCHORED = new RegExp(`^${POINTER_TOKEN_PATTERN.source}$`);
|
|
17390
|
+
var PointerToken = external_exports.string().regex(POINTER_TOKEN_ANCHORED);
|
|
17391
|
+
var ParsedPointer = external_exports.object({
|
|
17392
|
+
category: DetectionCategory,
|
|
17393
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17394
|
+
pointerId: external_exports.string(),
|
|
17395
|
+
tag: external_exports.string()
|
|
17396
|
+
});
|
|
17397
|
+
var VaultEntry = external_exports.object({
|
|
17398
|
+
pointerId: external_exports.string(),
|
|
17399
|
+
// The keyed HMAC of the raw value under `exception.key`, and the epoch it was
|
|
17400
|
+
// derived under. This is what a reveal-to-model grant matches on, and it rotates
|
|
17401
|
+
// independently of the vault encryption key below.
|
|
17402
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17403
|
+
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
17404
|
+
// The vault-key epoch this row's ciphertext was sealed under.
|
|
17405
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17406
|
+
// Fixed at first mint and never updated: the same value detected later under a
|
|
17407
|
+
// different rule's category keeps the category it was minted with, so one
|
|
17408
|
+
// value always produces exactly one wire token.
|
|
17409
|
+
category: DetectionCategory,
|
|
17410
|
+
ruleId: external_exports.string(),
|
|
17411
|
+
// Partial-reveal preview for badges and listings. Never the raw value.
|
|
17412
|
+
maskedMatch: external_exports.string(),
|
|
17413
|
+
provider: external_exports.string().optional(),
|
|
17414
|
+
ciphertext: external_exports.string(),
|
|
17415
|
+
nonce: external_exports.string(),
|
|
17416
|
+
authTag: external_exports.string(),
|
|
17417
|
+
// How many times this value has been detected on this machine — the reuse
|
|
17418
|
+
// signal the vault dashboard reads. Distinct from VaultDeref.pointerCount.
|
|
17419
|
+
occurrenceCount: external_exports.number().int().nonnegative(),
|
|
17420
|
+
firstSeen: external_exports.string(),
|
|
17421
|
+
lastSeen: external_exports.string()
|
|
17422
|
+
});
|
|
17423
|
+
var PointerDescriptor = external_exports.object({
|
|
17424
|
+
category: DetectionCategory,
|
|
17425
|
+
provider: external_exports.string().optional(),
|
|
17426
|
+
maskedMatch: external_exports.string(),
|
|
17427
|
+
occurrences: external_exports.number().int().nonnegative(),
|
|
17428
|
+
firstSeen: external_exports.string(),
|
|
17429
|
+
lastSeen: external_exports.string()
|
|
17430
|
+
});
|
|
17431
|
+
var PointerIdentity = external_exports.object({
|
|
17432
|
+
ruleId: external_exports.string(),
|
|
17433
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17434
|
+
fingerprintKeyVersion: external_exports.number().int().positive()
|
|
17435
|
+
});
|
|
17436
|
+
var DetokenizeTarget = external_exports.enum(["human", "model"]);
|
|
17437
|
+
var VaultDerefReason = external_exports.enum([
|
|
17438
|
+
"display",
|
|
17439
|
+
"explicit-reveal",
|
|
17440
|
+
"view-render",
|
|
17441
|
+
"model-input",
|
|
17442
|
+
"remediation",
|
|
17443
|
+
"purge"
|
|
17444
|
+
]);
|
|
17445
|
+
var VaultDerefOutcome = external_exports.enum(["revealed", "refused", "unavailable"]);
|
|
17446
|
+
var VaultDeref = external_exports.object({
|
|
17447
|
+
id: external_exports.guid(),
|
|
17448
|
+
pointerId: external_exports.string(),
|
|
17449
|
+
at: external_exports.string(),
|
|
17450
|
+
target: DetokenizeTarget,
|
|
17451
|
+
reason: VaultDerefReason,
|
|
17452
|
+
outcome: VaultDerefOutcome,
|
|
17453
|
+
// Present only on a model-target crossing that a reveal grant authorized.
|
|
17454
|
+
grantId: external_exports.string().optional(),
|
|
17455
|
+
// How many pointers ONE batched render resolved. 1 for unbatched rows. Named
|
|
17456
|
+
// apart from VaultEntry.occurrenceCount, which counts detections of a value.
|
|
17457
|
+
pointerCount: external_exports.number().int().positive().default(1)
|
|
17458
|
+
});
|
|
17459
|
+
var VaultSightingKind = external_exports.enum([
|
|
17460
|
+
"prompt",
|
|
17461
|
+
"tool-input",
|
|
17462
|
+
"tool-output",
|
|
17463
|
+
"file",
|
|
17464
|
+
"transcript"
|
|
17465
|
+
]);
|
|
17466
|
+
var VaultSighting = external_exports.object({
|
|
17467
|
+
location: external_exports.string(),
|
|
17468
|
+
kind: VaultSightingKind,
|
|
17469
|
+
firstSeen: external_exports.string(),
|
|
17470
|
+
lastSeen: external_exports.string()
|
|
17471
|
+
});
|
|
17472
|
+
var VaultInventoryEntry = external_exports.object({
|
|
17473
|
+
pointerId: external_exports.string(),
|
|
17474
|
+
category: DetectionCategory,
|
|
17475
|
+
provider: external_exports.string().optional(),
|
|
17476
|
+
maskedMatch: external_exports.string(),
|
|
17477
|
+
occurrences: external_exports.number().int().nonnegative(),
|
|
17478
|
+
firstSeen: external_exports.string(),
|
|
17479
|
+
lastSeen: external_exports.string(),
|
|
17480
|
+
// The active reveal-to-model grant covering this value, when one exists —
|
|
17481
|
+
// the inventory badges it, the row links to revocation.
|
|
17482
|
+
revealGrantId: external_exports.string().nullable(),
|
|
17483
|
+
sightings: external_exports.array(VaultSighting)
|
|
17484
|
+
});
|
|
17485
|
+
var VaultKeyCustody = external_exports.string();
|
|
17486
|
+
var VaultInlineReveal = external_exports.enum(["masked", "full", "off"]);
|
|
17487
|
+
var VaultConsent = external_exports.object({
|
|
17488
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
17489
|
+
version: external_exports.number().int().positive()
|
|
17490
|
+
});
|
|
17491
|
+
|
|
17364
17492
|
// ../../packages/schema/src/zod/local.ts
|
|
17365
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
17493
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
|
|
17366
17494
|
var RunMode = external_exports.enum(["standalone"]);
|
|
17367
17495
|
var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
|
|
17368
17496
|
var HistoricalAccess = external_exports.enum(["full", "session-only"]);
|
|
@@ -17384,6 +17512,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
17384
17512
|
// In-place egress extraction on the scan paths; disable to stop all Data
|
|
17385
17513
|
// Shares writes.
|
|
17386
17514
|
dataSharesInPlace: external_exports.boolean().default(true),
|
|
17515
|
+
// Consent to keep a RECOVERABLE encrypted copy of detected values in the local
|
|
17516
|
+
// vault, instead of destroying them. Absent by default: this is a custody
|
|
17517
|
+
// change from one-way redaction, so it is never an assumed grant on upgrade.
|
|
17518
|
+
// Revoking stops future vaulting; it does not erase what is already stored —
|
|
17519
|
+
// purging the vault is the eraser.
|
|
17520
|
+
vaultConsent: VaultConsent.optional(),
|
|
17521
|
+
// Where the vault master key lives.
|
|
17522
|
+
vaultKeyCustody: VaultKeyCustody.default("file"),
|
|
17523
|
+
// How a pointer renders in assistant prose on screen (see VaultInlineReveal).
|
|
17524
|
+
vaultInlineReveal: VaultInlineReveal.default("masked"),
|
|
17387
17525
|
// Absent until /aka:setup completes; its presence is what "onboarded" means.
|
|
17388
17526
|
onboardedAt: external_exports.iso.datetime().optional(),
|
|
17389
17527
|
// Records that the user consented to sending findings to the model API for
|
|
@@ -19781,6 +19919,9 @@ var AmbiguousExceptionIdError = class extends Error {
|
|
|
19781
19919
|
var ACTIVE_PREDICATE = `revoked_at IS NULL
|
|
19782
19920
|
AND (expires_at IS NULL OR expires_at > :now)
|
|
19783
19921
|
AND (max_uses IS NULL OR use_count < max_uses)`;
|
|
19922
|
+
var ACTIVE_REVEAL_GRANT_PREDICATE = `capability = 'reveal_to_model'
|
|
19923
|
+
AND conditions IS NULL
|
|
19924
|
+
AND ${ACTIVE_PREDICATE}`;
|
|
19784
19925
|
var SqliteExceptionsRepository = class {
|
|
19785
19926
|
constructor(db) {
|
|
19786
19927
|
this.db = db;
|
|
@@ -19872,11 +20013,11 @@ var SqliteExceptionsRepository = class {
|
|
|
19872
20013
|
this.db.prepare(
|
|
19873
20014
|
`INSERT INTO exceptions (
|
|
19874
20015
|
id, rule_id, category, value_fingerprint, key_version, masked_value,
|
|
19875
|
-
scope, expires_at, max_uses, use_count, last_used_at,
|
|
19876
|
-
conditions, created_by, created_via, created_at, updated_at
|
|
20016
|
+
capability, scope, expires_at, max_uses, use_count, last_used_at,
|
|
20017
|
+
justification, conditions, created_by, created_via, created_at, updated_at
|
|
19877
20018
|
) VALUES (
|
|
19878
20019
|
:id, :ruleId, :category, :valueFingerprint, :keyVersion, :maskedValue,
|
|
19879
|
-
:scope, :expiresAt, :maxUses, 0, NULL, :justification,
|
|
20020
|
+
:capability, :scope, :expiresAt, :maxUses, 0, NULL, :justification,
|
|
19880
20021
|
:conditions, :createdBy, :createdVia, :now, :now
|
|
19881
20022
|
)`
|
|
19882
20023
|
).run({
|
|
@@ -19886,6 +20027,7 @@ var SqliteExceptionsRepository = class {
|
|
|
19886
20027
|
valueFingerprint: input.valueFingerprint,
|
|
19887
20028
|
keyVersion: input.keyVersion,
|
|
19888
20029
|
maskedValue: input.maskedValue,
|
|
20030
|
+
capability: input.capability ?? "suppress",
|
|
19889
20031
|
scope: input.scope,
|
|
19890
20032
|
expiresAt: input.expiresAt === null ? null : isoToEpochMillis(input.expiresAt),
|
|
19891
20033
|
maxUses: input.maxUses,
|
|
@@ -19979,6 +20121,7 @@ var SqliteExceptionsRepository = class {
|
|
|
19979
20121
|
ruleId: row.rule_id,
|
|
19980
20122
|
valueFingerprint: row.value_fingerprint,
|
|
19981
20123
|
keyVersion: row.key_version,
|
|
20124
|
+
capability: row.capability,
|
|
19982
20125
|
expiresAt: row.expires_at === null ? null : epochMillisToIso(row.expires_at),
|
|
19983
20126
|
maxUses: row.max_uses,
|
|
19984
20127
|
useCount: row.use_count,
|
|
@@ -20033,6 +20176,35 @@ var SqliteExceptionsRepository = class {
|
|
|
20033
20176
|
}))
|
|
20034
20177
|
);
|
|
20035
20178
|
}
|
|
20179
|
+
/**
|
|
20180
|
+
* The active reveal-to-model grant for a vaulted value's identity, or null.
|
|
20181
|
+
* Matching is exact on (ruleId, valueFingerprint, keyVersion) — the same key
|
|
20182
|
+
* suppression uses — plus the capability: a suppression grant must never
|
|
20183
|
+
* authorize a reveal. Read-only: the caller does NOT consume here, because a
|
|
20184
|
+
* revealed value re-enters the detection scan immediately afterward and the
|
|
20185
|
+
* suppression match there claims the use — one crossing, one use.
|
|
20186
|
+
*
|
|
20187
|
+
* A grant with `conditions` NEVER matches here: the reveal path does not yet
|
|
20188
|
+
* evaluate conditions, and a narrowing clause that is ignored would WIDEN the
|
|
20189
|
+
* grant instead. Fail closed until reveal-side condition evaluation exists.
|
|
20190
|
+
*/
|
|
20191
|
+
activeRevealGrant(ruleId, valueFingerprint, keyVersion, now = Date.now()) {
|
|
20192
|
+
try {
|
|
20193
|
+
const row = getRow(
|
|
20194
|
+
this.db.prepare(
|
|
20195
|
+
`SELECT id FROM exceptions
|
|
20196
|
+
WHERE rule_id = :ruleId AND value_fingerprint = :valueFingerprint
|
|
20197
|
+
AND key_version = :keyVersion
|
|
20198
|
+
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
20199
|
+
LIMIT 1`
|
|
20200
|
+
),
|
|
20201
|
+
{ ruleId, valueFingerprint, keyVersion, now }
|
|
20202
|
+
);
|
|
20203
|
+
return Promise.resolve(row ?? null);
|
|
20204
|
+
} catch (err) {
|
|
20205
|
+
return Promise.reject(err instanceof Error ? err : new Error(String(err)));
|
|
20206
|
+
}
|
|
20207
|
+
}
|
|
20036
20208
|
/**
|
|
20037
20209
|
* Retention sweep: delete TERMINAL rows (revoked, expired, or use-budget
|
|
20038
20210
|
* exhausted) whose last transition is older than the retention window.
|
|
@@ -20060,6 +20232,7 @@ function parseExceptionRow(row) {
|
|
|
20060
20232
|
valueFingerprint: row.value_fingerprint,
|
|
20061
20233
|
keyVersion: row.key_version,
|
|
20062
20234
|
maskedValue: row.masked_value,
|
|
20235
|
+
capability: row.capability,
|
|
20063
20236
|
scope: row.scope,
|
|
20064
20237
|
expiresAt: row.expires_at === null ? null : epochMillisToIso(row.expires_at),
|
|
20065
20238
|
maxUses: row.max_uses,
|
|
@@ -22225,6 +22398,287 @@ var SqliteScanLedgerRepository = class {
|
|
|
22225
22398
|
}
|
|
22226
22399
|
};
|
|
22227
22400
|
|
|
22401
|
+
// ../../packages/persistence/src/repositories/secret-vault.ts
|
|
22402
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
22403
|
+
var SELECT_COLUMNS = `
|
|
22404
|
+
pointer_id AS pointerId,
|
|
22405
|
+
value_fingerprint AS valueFingerprint,
|
|
22406
|
+
fingerprint_key_version AS fingerprintKeyVersion,
|
|
22407
|
+
key_version AS keyVersion,
|
|
22408
|
+
format_version AS formatVersion,
|
|
22409
|
+
category,
|
|
22410
|
+
rule_id AS ruleId,
|
|
22411
|
+
masked_match AS maskedMatch,
|
|
22412
|
+
provider,
|
|
22413
|
+
ciphertext,
|
|
22414
|
+
nonce,
|
|
22415
|
+
auth_tag AS authTag,
|
|
22416
|
+
occurrence_count AS occurrenceCount,
|
|
22417
|
+
first_seen AS firstSeen,
|
|
22418
|
+
last_seen AS lastSeen`;
|
|
22419
|
+
function toRow(raw) {
|
|
22420
|
+
const { provider, ...rest } = raw;
|
|
22421
|
+
return provider === null ? rest : { ...rest, provider };
|
|
22422
|
+
}
|
|
22423
|
+
var SqliteSecretVaultRepository = class {
|
|
22424
|
+
constructor(db) {
|
|
22425
|
+
this.db = db;
|
|
22426
|
+
this.insertStmt = db.prepare(
|
|
22427
|
+
`INSERT INTO secret_vault (
|
|
22428
|
+
pointer_id, value_fingerprint, fingerprint_key_version, key_version,
|
|
22429
|
+
format_version, category, rule_id, masked_match, provider,
|
|
22430
|
+
ciphertext, nonce, auth_tag,
|
|
22431
|
+
occurrence_count, first_seen, last_seen
|
|
22432
|
+
) VALUES (
|
|
22433
|
+
:pointerId, :valueFingerprint, :fingerprintKeyVersion, :keyVersion,
|
|
22434
|
+
:formatVersion, :category, :ruleId, :maskedMatch, :provider,
|
|
22435
|
+
:ciphertext, :nonce, :authTag,
|
|
22436
|
+
1, :now, :now
|
|
22437
|
+
)`
|
|
22438
|
+
);
|
|
22439
|
+
this.bumpStmt = db.prepare(
|
|
22440
|
+
`UPDATE secret_vault
|
|
22441
|
+
SET occurrence_count = occurrence_count + 1, last_seen = :now
|
|
22442
|
+
WHERE value_fingerprint = :valueFingerprint`
|
|
22443
|
+
);
|
|
22444
|
+
this.byPointerStmt = db.prepare(
|
|
22445
|
+
`SELECT ${SELECT_COLUMNS} FROM secret_vault WHERE pointer_id = :pointerId`
|
|
22446
|
+
);
|
|
22447
|
+
this.byFingerprintStmt = db.prepare(
|
|
22448
|
+
`SELECT ${SELECT_COLUMNS} FROM secret_vault WHERE value_fingerprint = :valueFingerprint`
|
|
22449
|
+
);
|
|
22450
|
+
this.listStmt = db.prepare(`SELECT ${SELECT_COLUMNS} FROM secret_vault ORDER BY first_seen`);
|
|
22451
|
+
this.replaceCiphertextStmt = db.prepare(
|
|
22452
|
+
`UPDATE secret_vault
|
|
22453
|
+
SET key_version = :keyVersion, ciphertext = :ciphertext, nonce = :nonce, auth_tag = :authTag
|
|
22454
|
+
WHERE pointer_id = :pointerId`
|
|
22455
|
+
);
|
|
22456
|
+
this.refreshFingerprintStmt = db.prepare(
|
|
22457
|
+
`UPDATE secret_vault
|
|
22458
|
+
SET value_fingerprint = :valueFingerprint, fingerprint_key_version = :fingerprintKeyVersion
|
|
22459
|
+
WHERE pointer_id = :pointerId`
|
|
22460
|
+
);
|
|
22461
|
+
this.derefStmt = db.prepare(
|
|
22462
|
+
`INSERT INTO secret_vault_deref (id, pointer_id, at, target, reason, outcome, grant_id, pointer_count)
|
|
22463
|
+
VALUES (:id, :pointerId, :at, :target, :reason, :outcome, :grantId, :pointerCount)`
|
|
22464
|
+
);
|
|
22465
|
+
}
|
|
22466
|
+
db;
|
|
22467
|
+
insertStmt;
|
|
22468
|
+
bumpStmt;
|
|
22469
|
+
byPointerStmt;
|
|
22470
|
+
byFingerprintStmt;
|
|
22471
|
+
listStmt;
|
|
22472
|
+
replaceCiphertextStmt;
|
|
22473
|
+
refreshFingerprintStmt;
|
|
22474
|
+
derefStmt;
|
|
22475
|
+
/**
|
|
22476
|
+
* Vault a value, or record another sighting of one already vaulted. Keyed on
|
|
22477
|
+
* `valueFingerprint`, never on the caller's pointer id: a value seen again
|
|
22478
|
+
* bumps `occurrence_count` and `last_seen` and comes back with its ORIGINAL
|
|
22479
|
+
* pointer, category and ciphertext, so the same secret always resolves to one
|
|
22480
|
+
* wire token. `minted` is true only when this call created the row.
|
|
22481
|
+
*
|
|
22482
|
+
* The read-then-write runs in one IMMEDIATE transaction so two concurrent
|
|
22483
|
+
* writers cannot both decide they are minting.
|
|
22484
|
+
*/
|
|
22485
|
+
upsert(input, now) {
|
|
22486
|
+
let minted = false;
|
|
22487
|
+
withTransaction(
|
|
22488
|
+
this.db,
|
|
22489
|
+
() => {
|
|
22490
|
+
const existing = getRow(this.byFingerprintStmt, {
|
|
22491
|
+
valueFingerprint: input.valueFingerprint
|
|
22492
|
+
});
|
|
22493
|
+
if (existing === void 0) {
|
|
22494
|
+
this.insertStmt.run(
|
|
22495
|
+
bindParams({
|
|
22496
|
+
pointerId: input.pointerId,
|
|
22497
|
+
valueFingerprint: input.valueFingerprint,
|
|
22498
|
+
fingerprintKeyVersion: input.fingerprintKeyVersion,
|
|
22499
|
+
keyVersion: input.keyVersion,
|
|
22500
|
+
formatVersion: input.formatVersion ?? POINTER_FORMAT_VERSION,
|
|
22501
|
+
category: input.category,
|
|
22502
|
+
ruleId: input.ruleId,
|
|
22503
|
+
maskedMatch: input.maskedMatch,
|
|
22504
|
+
provider: input.provider,
|
|
22505
|
+
ciphertext: input.ciphertext,
|
|
22506
|
+
nonce: input.nonce,
|
|
22507
|
+
authTag: input.authTag,
|
|
22508
|
+
now
|
|
22509
|
+
})
|
|
22510
|
+
);
|
|
22511
|
+
minted = true;
|
|
22512
|
+
return;
|
|
22513
|
+
}
|
|
22514
|
+
this.bumpStmt.run({ valueFingerprint: input.valueFingerprint, now });
|
|
22515
|
+
},
|
|
22516
|
+
"IMMEDIATE"
|
|
22517
|
+
);
|
|
22518
|
+
const row = getRow(this.byFingerprintStmt, {
|
|
22519
|
+
valueFingerprint: input.valueFingerprint
|
|
22520
|
+
});
|
|
22521
|
+
if (row === void 0) throw new Error("vault: row vanished immediately after write");
|
|
22522
|
+
return { row: toRow(row), minted };
|
|
22523
|
+
}
|
|
22524
|
+
byPointerId(pointerId) {
|
|
22525
|
+
const raw = getRow(this.byPointerStmt, { pointerId });
|
|
22526
|
+
return raw === void 0 ? null : toRow(raw);
|
|
22527
|
+
}
|
|
22528
|
+
byValueFingerprint(fingerprint) {
|
|
22529
|
+
const raw = getRow(this.byFingerprintStmt, { valueFingerprint: fingerprint });
|
|
22530
|
+
return raw === void 0 ? null : toRow(raw);
|
|
22531
|
+
}
|
|
22532
|
+
/** Append one audit row. Carries no raw value and no ciphertext, by shape. */
|
|
22533
|
+
recordDeref(entry) {
|
|
22534
|
+
this.derefStmt.run(
|
|
22535
|
+
bindParams({
|
|
22536
|
+
id: entry.id,
|
|
22537
|
+
pointerId: entry.pointerId,
|
|
22538
|
+
at: entry.at,
|
|
22539
|
+
target: entry.target,
|
|
22540
|
+
reason: entry.reason,
|
|
22541
|
+
outcome: entry.outcome,
|
|
22542
|
+
grantId: entry.grantId,
|
|
22543
|
+
pointerCount: entry.pointerCount ?? 1
|
|
22544
|
+
})
|
|
22545
|
+
);
|
|
22546
|
+
}
|
|
22547
|
+
listAll() {
|
|
22548
|
+
return allRows(this.listStmt).map(toRow);
|
|
22549
|
+
}
|
|
22550
|
+
/** Re-seal an entry under a new key epoch, leaving its identity untouched. */
|
|
22551
|
+
replaceCiphertext(pointerId, next) {
|
|
22552
|
+
this.replaceCiphertextStmt.run({ pointerId, ...next });
|
|
22553
|
+
}
|
|
22554
|
+
/** Re-derive an entry's fingerprint under a new fingerprint-key epoch. */
|
|
22555
|
+
refreshFingerprint(pointerId, next) {
|
|
22556
|
+
this.refreshFingerprintStmt.run({ pointerId, ...next });
|
|
22557
|
+
}
|
|
22558
|
+
/**
|
|
22559
|
+
* Destroy every vaulted value and report how many were destroyed. The deref
|
|
22560
|
+
* audit is left alone on purpose — see the table note above.
|
|
22561
|
+
*/
|
|
22562
|
+
purgeAll() {
|
|
22563
|
+
let destroyed = 0;
|
|
22564
|
+
withTransaction(
|
|
22565
|
+
this.db,
|
|
22566
|
+
() => {
|
|
22567
|
+
destroyed = this.countEntries();
|
|
22568
|
+
this.db.exec("DELETE FROM secret_vault");
|
|
22569
|
+
},
|
|
22570
|
+
"IMMEDIATE"
|
|
22571
|
+
);
|
|
22572
|
+
return destroyed;
|
|
22573
|
+
}
|
|
22574
|
+
/**
|
|
22575
|
+
* Record (or re-stamp) one place a pointer has been written. One row per
|
|
22576
|
+
* (pointer, location); a re-sighting bumps last_seen. Best-effort bookkeeping
|
|
22577
|
+
* on hook paths — a failure must never affect the rewrite that triggered it,
|
|
22578
|
+
* so callers wrap this, not the other way around.
|
|
22579
|
+
*/
|
|
22580
|
+
recordSighting(entry, now) {
|
|
22581
|
+
this.db.prepare(
|
|
22582
|
+
`INSERT INTO secret_vault_sighting (id, pointer_id, location, kind, first_seen, last_seen)
|
|
22583
|
+
VALUES (:id, :pointerId, :location, :kind, :now, :now)
|
|
22584
|
+
ON CONFLICT (pointer_id, location) DO UPDATE SET last_seen = :now`
|
|
22585
|
+
).run({
|
|
22586
|
+
id: randomUUID7(),
|
|
22587
|
+
pointerId: entry.pointerId,
|
|
22588
|
+
location: entry.location,
|
|
22589
|
+
kind: entry.kind,
|
|
22590
|
+
now
|
|
22591
|
+
});
|
|
22592
|
+
}
|
|
22593
|
+
listSightings(pointerId) {
|
|
22594
|
+
const rows = allRows(
|
|
22595
|
+
this.db.prepare(
|
|
22596
|
+
`SELECT location, kind, first_seen, last_seen FROM secret_vault_sighting
|
|
22597
|
+
WHERE pointer_id = :pointerId ORDER BY last_seen DESC`
|
|
22598
|
+
),
|
|
22599
|
+
{ pointerId }
|
|
22600
|
+
);
|
|
22601
|
+
return rows.map((r) => ({
|
|
22602
|
+
location: r.location,
|
|
22603
|
+
kind: r.kind,
|
|
22604
|
+
firstSeen: new Date(r.first_seen).toISOString(),
|
|
22605
|
+
lastSeen: new Date(r.last_seen).toISOString()
|
|
22606
|
+
}));
|
|
22607
|
+
}
|
|
22608
|
+
/**
|
|
22609
|
+
* The dashboard inventory: every vaulted value's descriptor data joined with
|
|
22610
|
+
* its sightings and the active reveal-to-model grant when one exists.
|
|
22611
|
+
* Raw-free by construction — neither the fingerprint nor the ciphertext
|
|
22612
|
+
* columns are selected.
|
|
22613
|
+
*/
|
|
22614
|
+
listInventory(now = Date.now()) {
|
|
22615
|
+
const rows = allRows(
|
|
22616
|
+
this.db.prepare(
|
|
22617
|
+
`SELECT v.pointer_id, v.category, v.rule_id, v.masked_match, v.provider,
|
|
22618
|
+
v.occurrence_count, v.first_seen, v.last_seen,
|
|
22619
|
+
(SELECT e.id FROM exceptions e
|
|
22620
|
+
WHERE e.rule_id = v.rule_id
|
|
22621
|
+
AND e.value_fingerprint = v.value_fingerprint
|
|
22622
|
+
AND e.key_version = v.fingerprint_key_version
|
|
22623
|
+
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
22624
|
+
LIMIT 1) AS grant_id
|
|
22625
|
+
FROM secret_vault v
|
|
22626
|
+
ORDER BY v.last_seen DESC`
|
|
22627
|
+
),
|
|
22628
|
+
{ now }
|
|
22629
|
+
);
|
|
22630
|
+
return rows.map((r) => ({
|
|
22631
|
+
pointerId: r.pointer_id,
|
|
22632
|
+
category: r.category,
|
|
22633
|
+
...r.provider === null ? {} : { provider: r.provider },
|
|
22634
|
+
maskedMatch: r.masked_match,
|
|
22635
|
+
occurrences: r.occurrence_count,
|
|
22636
|
+
firstSeen: new Date(r.first_seen).toISOString(),
|
|
22637
|
+
lastSeen: new Date(r.last_seen).toISOString(),
|
|
22638
|
+
revealGrantId: r.grant_id,
|
|
22639
|
+
sightings: this.listSightings(r.pointer_id)
|
|
22640
|
+
}));
|
|
22641
|
+
}
|
|
22642
|
+
/**
|
|
22643
|
+
* The de-reference trail, newest first. By default the batched, high-volume
|
|
22644
|
+
* reasons (display, view-render) are hidden and counted instead — the rows
|
|
22645
|
+
* that matter as a signal are the model crossings, and burying them under
|
|
22646
|
+
* render noise would defeat the audit's purpose.
|
|
22647
|
+
*/
|
|
22648
|
+
listDerefs(opts) {
|
|
22649
|
+
const limit = opts?.limit ?? 200;
|
|
22650
|
+
const where = opts?.includeBatched === true ? "" : `WHERE reason NOT IN ('display', 'view-render')`;
|
|
22651
|
+
const rows = allRows(
|
|
22652
|
+
this.db.prepare(
|
|
22653
|
+
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
22654
|
+
FROM secret_vault_deref ${where}
|
|
22655
|
+
ORDER BY at DESC, rowid DESC LIMIT :limit`
|
|
22656
|
+
),
|
|
22657
|
+
{ limit }
|
|
22658
|
+
);
|
|
22659
|
+
const hiddenBatched = opts?.includeBatched === true ? 0 : countScalar(
|
|
22660
|
+
this.db,
|
|
22661
|
+
`SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
|
|
22662
|
+
);
|
|
22663
|
+
return {
|
|
22664
|
+
rows: rows.map((r) => ({
|
|
22665
|
+
id: r.id,
|
|
22666
|
+
pointerId: r.pointer_id,
|
|
22667
|
+
at: new Date(r.at).toISOString(),
|
|
22668
|
+
target: r.target,
|
|
22669
|
+
reason: r.reason,
|
|
22670
|
+
outcome: r.outcome,
|
|
22671
|
+
...r.grant_id === null ? {} : { grantId: r.grant_id },
|
|
22672
|
+
pointerCount: r.pointer_count
|
|
22673
|
+
})),
|
|
22674
|
+
hiddenBatched
|
|
22675
|
+
};
|
|
22676
|
+
}
|
|
22677
|
+
countEntries() {
|
|
22678
|
+
return countScalar(this.db, "SELECT COUNT(*) AS n FROM secret_vault");
|
|
22679
|
+
}
|
|
22680
|
+
};
|
|
22681
|
+
|
|
22228
22682
|
// ../../packages/persistence/src/repositories/security.ts
|
|
22229
22683
|
var DAY_MS4 = 864e5;
|
|
22230
22684
|
var SEVERITIES = ["critical", "high", "medium", "low"];
|
|
@@ -22570,7 +23024,7 @@ var SqliteSecurityRepository = class {
|
|
|
22570
23024
|
};
|
|
22571
23025
|
|
|
22572
23026
|
// ../../packages/persistence/src/repositories/shares.ts
|
|
22573
|
-
import { randomUUID as
|
|
23027
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
22574
23028
|
var MAX_EGRESS_CALL_SITES_PER_PROJECT = 5e3;
|
|
22575
23029
|
var IN_CHUNK = 500;
|
|
22576
23030
|
var KIND_ORDER = ["provider", "internal", "external", "ip"];
|
|
@@ -22826,7 +23280,7 @@ var SqliteSharesRepository = class {
|
|
|
22826
23280
|
(id, destination_id, host, decision, created_at, updated_at)
|
|
22827
23281
|
VALUES (:id, :destinationId, :host, :decision, :now, :now)`
|
|
22828
23282
|
).run({
|
|
22829
|
-
id:
|
|
23283
|
+
id: randomUUID8(),
|
|
22830
23284
|
destinationId,
|
|
22831
23285
|
host: dest.host,
|
|
22832
23286
|
decision,
|
|
@@ -22975,7 +23429,7 @@ var SqliteSharesRepository = class {
|
|
|
22975
23429
|
let destinationId = destIds.get(hit.host);
|
|
22976
23430
|
if (destinationId === void 0) {
|
|
22977
23431
|
destStmt.run({
|
|
22978
|
-
id:
|
|
23432
|
+
id: randomUUID8(),
|
|
22979
23433
|
kind: hit.kind,
|
|
22980
23434
|
name: hit.name,
|
|
22981
23435
|
host: hit.host,
|
|
@@ -22991,7 +23445,7 @@ var SqliteSharesRepository = class {
|
|
|
22991
23445
|
let endpointId = endpointIds.get(endpointKey);
|
|
22992
23446
|
if (endpointId === void 0) {
|
|
22993
23447
|
endpointStmt.run({
|
|
22994
|
-
id:
|
|
23448
|
+
id: randomUUID8(),
|
|
22995
23449
|
destinationId,
|
|
22996
23450
|
method: hit.method,
|
|
22997
23451
|
transport: hit.transport,
|
|
@@ -23004,7 +23458,7 @@ var SqliteSharesRepository = class {
|
|
|
23004
23458
|
endpointIds.set(endpointKey, endpointId);
|
|
23005
23459
|
}
|
|
23006
23460
|
siteStmt.run({
|
|
23007
|
-
id:
|
|
23461
|
+
id: randomUUID8(),
|
|
23008
23462
|
endpointId,
|
|
23009
23463
|
project: input.project,
|
|
23010
23464
|
projectKey: input.projectKey,
|
|
@@ -23420,6 +23874,7 @@ function openAndInitialize(file2) {
|
|
|
23420
23874
|
policies,
|
|
23421
23875
|
installedPacks,
|
|
23422
23876
|
scanLedger: new SqliteScanLedgerRepository(db),
|
|
23877
|
+
secretVault: new SqliteSecretVaultRepository(db),
|
|
23423
23878
|
exceptions: new SqliteExceptionsRepository(db),
|
|
23424
23879
|
resolutions: new SqliteResolutionsRepository(db),
|
|
23425
23880
|
ruleProbeCache: new SqliteRuleProbeCacheRepository(db),
|
|
@@ -23455,6 +23910,7 @@ function openLocalDatabase(dir) {
|
|
|
23455
23910
|
policies,
|
|
23456
23911
|
installedPacks,
|
|
23457
23912
|
scanLedger,
|
|
23913
|
+
secretVault,
|
|
23458
23914
|
exceptions,
|
|
23459
23915
|
resolutions,
|
|
23460
23916
|
ruleProbeCache,
|
|
@@ -23563,7 +24019,7 @@ function openLocalDatabase(dir) {
|
|
|
23563
24019
|
const definitionId = definitionIds.get(`${finding.ruleId}@${finding.version}`);
|
|
23564
24020
|
if (!definitionId) continue;
|
|
23565
24021
|
inspectionFindings.insertFinding({
|
|
23566
|
-
id:
|
|
24022
|
+
id: randomUUID9(),
|
|
23567
24023
|
auditEventId: record2.scanEvent.id,
|
|
23568
24024
|
inspectionDefinitionId: definitionId,
|
|
23569
24025
|
span: finding.span,
|
|
@@ -23640,6 +24096,7 @@ function openLocalDatabase(dir) {
|
|
|
23640
24096
|
policies,
|
|
23641
24097
|
installedPacks,
|
|
23642
24098
|
scanLedger,
|
|
24099
|
+
secretVault,
|
|
23643
24100
|
exceptions,
|
|
23644
24101
|
resolutions,
|
|
23645
24102
|
ruleProbeCache,
|
|
@@ -23772,16 +24229,42 @@ function readJson(file2) {
|
|
|
23772
24229
|
return parseJsonObject(text) ?? null;
|
|
23773
24230
|
}
|
|
23774
24231
|
|
|
23775
|
-
// ../../packages/persistence/src/
|
|
23776
|
-
import {
|
|
24232
|
+
// ../../packages/persistence/src/vault/crypto.ts
|
|
24233
|
+
import {
|
|
24234
|
+
createCipheriv,
|
|
24235
|
+
createDecipheriv,
|
|
24236
|
+
createHmac as createHmac2,
|
|
24237
|
+
hkdfSync,
|
|
24238
|
+
timingSafeEqual
|
|
24239
|
+
} from "crypto";
|
|
24240
|
+
|
|
24241
|
+
// ../../packages/persistence/src/vault/key-provider.ts
|
|
24242
|
+
import { execFileSync } from "child_process";
|
|
24243
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
24244
|
+
import {
|
|
24245
|
+
chmodSync as chmodSync2,
|
|
24246
|
+
mkdirSync as mkdirSync2,
|
|
24247
|
+
readFileSync as readFileSync3,
|
|
24248
|
+
renameSync as renameSync4,
|
|
24249
|
+
rmSync as rmSync3,
|
|
24250
|
+
statSync,
|
|
24251
|
+
writeFileSync as writeFileSync2
|
|
24252
|
+
} from "fs";
|
|
23777
24253
|
import { join as join5 } from "path";
|
|
24254
|
+
|
|
24255
|
+
// ../../packages/persistence/src/vault/vault.ts
|
|
24256
|
+
import { randomBytes as randomBytes3, randomUUID as randomUUID10 } from "crypto";
|
|
24257
|
+
|
|
24258
|
+
// ../../packages/persistence/src/warn-era-cap.ts
|
|
24259
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
24260
|
+
import { join as join6 } from "path";
|
|
23778
24261
|
var MARKER = "warn-era-capped";
|
|
23779
24262
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
23780
24263
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
23781
|
-
const marker =
|
|
24264
|
+
const marker = join6(dataDir2, MARKER);
|
|
23782
24265
|
if (existsSync3(marker)) return { capped: 0, skipped: "already-run" };
|
|
23783
24266
|
const capped = db.policies.capCategoryActions();
|
|
23784
|
-
|
|
24267
|
+
writeFileSync3(marker, `${new Date(Date.now()).toISOString()}
|
|
23785
24268
|
`, { mode: DATA_FILE_MODE });
|
|
23786
24269
|
return { capped };
|
|
23787
24270
|
}
|
|
@@ -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/hooks/shared.ts
|
|
@@ -27037,8 +27520,8 @@ function renderStatusBar(s, opts = {}) {
|
|
|
27037
27520
|
const score = `${dot} health ${paint.bold(String(s.score))}${paint.dim("/100")}`;
|
|
27038
27521
|
const tally = `${paint.dim("unreviewed")} ${paint.critical(sq)}${String(u.critical)} ${paint.high(sq)}${String(u.high)} ${paint.medium(sq)}${String(u.medium)} ${paint.low(sq)}${String(u.low)}`;
|
|
27039
27522
|
const flag = s.openFindings > 0 ? paint.critical("\u2691") : paint.dim("\u2691");
|
|
27040
|
-
const
|
|
27041
|
-
return `${paint.brand("\u25B8\u25B8 AKA")}${sep5}${score}${sep5}${tally}${sep5}${
|
|
27523
|
+
const open2 = `${flag} ${String(s.openFindings)} open findings`;
|
|
27524
|
+
return `${paint.brand("\u25B8\u25B8 AKA")}${sep5}${score}${sep5}${tally}${sep5}${open2}`;
|
|
27042
27525
|
}
|
|
27043
27526
|
function renderStatusLine(summary) {
|
|
27044
27527
|
return renderStatusBar(findingStatus(summary), { color: true });
|