@akasecurity/ai-tc-codex 0.9.6 → 0.9.7
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/.codex-plugin/plugin.json +1 -1
- package/package.json +5 -4
- package/scripts/apply-suppressions.js +1432 -974
- package/scripts/backfill.js +1429 -989
- package/scripts/dashboard.js +131 -10
- package/scripts/filescan.js +1458 -1009
- package/scripts/firstrun.js +1310 -904
- package/scripts/intro.js +1002 -896
- package/scripts/onboard.js +1333 -893
- package/scripts/post-tool-use.js +1358 -923
- package/scripts/pre-tool-use.js +1413 -978
- package/scripts/query.js +1315 -904
- package/scripts/reconcile.js +1320 -923
- package/scripts/remediate.js +1429 -989
- package/scripts/scan-worker.js +996 -916
- package/scripts/session-start.js +1432 -1000
- package/scripts/start-light.js +1009 -904
- package/scripts/stop.js +1069 -898
- package/scripts/user-prompt-submit.js +1416 -981
- package/skills/setup/SKILL.md +0 -17
package/scripts/reconcile.js
CHANGED
|
@@ -585,6 +585,10 @@ var SQLITE_MIGRATIONS = [
|
|
|
585
585
|
{
|
|
586
586
|
tag: "0020_secret_vault_pagination_indexes",
|
|
587
587
|
sql: "CREATE INDEX `idx_secret_vault_last_seen` ON `secret_vault` (`last_seen`,`pointer_id`);--> statement-breakpoint\nCREATE INDEX `idx_secret_vault_reuse` ON `secret_vault` (`occurrence_count`,`pointer_id`);--> statement-breakpoint\nCREATE INDEX `idx_secret_vault_deref_at` ON `secret_vault_deref` (`at`,`id`);--> statement-breakpoint\nCREATE INDEX `idx_secret_vault_deref_signal` ON `secret_vault_deref` (`at`,`id`) WHERE `reason` NOT IN ('display', 'view-render');"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
tag: "0021_finding_resolution_resolved_at_index",
|
|
591
|
+
sql: "CREATE INDEX `idx_finding_resolution_resolved_at` ON `finding_resolution` (`resolved_at`);\n"
|
|
588
592
|
}
|
|
589
593
|
];
|
|
590
594
|
|
|
@@ -15300,6 +15304,50 @@ function date4(params) {
|
|
|
15300
15304
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
15301
15305
|
config(en_default());
|
|
15302
15306
|
|
|
15307
|
+
// ../../packages/schema/src/zod/harness-map.ts
|
|
15308
|
+
var HARNESS = {
|
|
15309
|
+
ClaudeCode: "claudecode",
|
|
15310
|
+
Cursor: "cursor",
|
|
15311
|
+
Copilot: "copilot",
|
|
15312
|
+
Codex: "codex",
|
|
15313
|
+
Antigravity: "antigravity",
|
|
15314
|
+
Windsurf: "windsurf",
|
|
15315
|
+
ClaudeDesktop: "claudedesktop",
|
|
15316
|
+
ChatGpt: "chatgpt",
|
|
15317
|
+
ClaudeAi: "claudeai",
|
|
15318
|
+
Api: "api"
|
|
15319
|
+
};
|
|
15320
|
+
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
15321
|
+
var SOURCE_TOOL = {
|
|
15322
|
+
ClaudeCode: "claude-code",
|
|
15323
|
+
ClaudeDesktop: "claude-desktop",
|
|
15324
|
+
Cursor: "cursor",
|
|
15325
|
+
ChatGpt: "chatgpt",
|
|
15326
|
+
ClaudeAi: "claude-ai",
|
|
15327
|
+
Copilot: "github-copilot",
|
|
15328
|
+
Codex: "codex",
|
|
15329
|
+
Antigravity: "antigravity",
|
|
15330
|
+
// No harness counterpart, deliberately: the CLI's own captures and a capture
|
|
15331
|
+
// whose tool could not be identified both render through the read side's
|
|
15332
|
+
// miss path rather than as a harness of their own.
|
|
15333
|
+
Cli: "cli",
|
|
15334
|
+
Unknown: "unknown"
|
|
15335
|
+
};
|
|
15336
|
+
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
15337
|
+
var TOOL_TO_HARNESS = {
|
|
15338
|
+
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
15339
|
+
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
15340
|
+
[SOURCE_TOOL.Copilot]: HARNESS.Copilot,
|
|
15341
|
+
[SOURCE_TOOL.Cursor]: HARNESS.Cursor,
|
|
15342
|
+
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
15343
|
+
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
15344
|
+
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
15345
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
15346
|
+
};
|
|
15347
|
+
function harnessFromTool(tool) {
|
|
15348
|
+
return TOOL_TO_HARNESS[tool] ?? tool;
|
|
15349
|
+
}
|
|
15350
|
+
|
|
15303
15351
|
// ../../packages/schema/src/zod/finding.ts
|
|
15304
15352
|
var DetectionCategory = external_exports.enum(["pii", "financial", "secret", "phi", "code_context", "code_flaw", "custom", "config"]).meta({ id: "DetectionCategory" });
|
|
15305
15353
|
var Severity = external_exports.enum(["critical", "high", "medium", "low"]).meta({ id: "Severity" });
|
|
@@ -15322,21 +15370,22 @@ var Finding = external_exports.object({
|
|
|
15322
15370
|
}).meta({ id: "Finding" });
|
|
15323
15371
|
var DetectedFinding = Finding.meta({ id: "DetectedFinding" });
|
|
15324
15372
|
var FindingAction = external_exports.enum(["blocked", "redacted", "warned", "allowed", "quarantined", "monitored"]).meta({ id: "FindingAction" });
|
|
15325
|
-
var FindingProvider =
|
|
15326
|
-
"
|
|
15327
|
-
"
|
|
15328
|
-
"
|
|
15329
|
-
"
|
|
15330
|
-
"
|
|
15331
|
-
"
|
|
15332
|
-
"
|
|
15333
|
-
"
|
|
15334
|
-
"
|
|
15373
|
+
var FindingProvider = Harness.extract([
|
|
15374
|
+
"ClaudeCode",
|
|
15375
|
+
"ClaudeDesktop",
|
|
15376
|
+
"Cursor",
|
|
15377
|
+
"Copilot",
|
|
15378
|
+
"ChatGpt",
|
|
15379
|
+
"ClaudeAi",
|
|
15380
|
+
"Codex",
|
|
15381
|
+
"Antigravity",
|
|
15382
|
+
"Api"
|
|
15335
15383
|
]).meta({ id: "FindingProvider" });
|
|
15336
15384
|
var FindingCategory = external_exports.enum([
|
|
15337
15385
|
"secret",
|
|
15338
15386
|
"pii",
|
|
15339
15387
|
"source_code",
|
|
15388
|
+
"code_flaw",
|
|
15340
15389
|
"external_share",
|
|
15341
15390
|
"mcp_server",
|
|
15342
15391
|
"customer_data",
|
|
@@ -15516,6 +15565,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
15516
15565
|
policy: FindingPolicyRef
|
|
15517
15566
|
}).meta({ id: "FindingInstanceDetail" });
|
|
15518
15567
|
var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
|
|
15568
|
+
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
15519
15569
|
var ListFindingInstancesQuery = external_exports.object({
|
|
15520
15570
|
severity: external_exports.array(Severity).optional(),
|
|
15521
15571
|
// Rule ids, the same vocabulary the grouped list's `subtype` carries.
|
|
@@ -15535,7 +15585,7 @@ var ListFindingInstancesQuery = external_exports.object({
|
|
|
15535
15585
|
q: external_exports.string().optional(),
|
|
15536
15586
|
sessionId: external_exports.string().optional(),
|
|
15537
15587
|
from: external_exports.iso.datetime().optional(),
|
|
15538
|
-
limit: external_exports.coerce.number().int().min(1).max(
|
|
15588
|
+
limit: external_exports.coerce.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
15539
15589
|
cursor: external_exports.string().optional()
|
|
15540
15590
|
});
|
|
15541
15591
|
var ListFindingInstancesResponse = external_exports.object({
|
|
@@ -15597,33 +15647,6 @@ var ListFindingLocationsResponse = external_exports.object({
|
|
|
15597
15647
|
hasMore: external_exports.boolean()
|
|
15598
15648
|
}).meta({ id: "ListFindingLocationsResponse" });
|
|
15599
15649
|
|
|
15600
|
-
// ../../packages/schema/src/zod/harness-map.ts
|
|
15601
|
-
var Harness = external_exports.enum([
|
|
15602
|
-
"claudecode",
|
|
15603
|
-
"cursor",
|
|
15604
|
-
"copilot",
|
|
15605
|
-
"codex",
|
|
15606
|
-
"antigravity",
|
|
15607
|
-
"windsurf",
|
|
15608
|
-
"claudedesktop",
|
|
15609
|
-
"chatgpt",
|
|
15610
|
-
"claudeai",
|
|
15611
|
-
"api"
|
|
15612
|
-
]).meta({ id: "Harness" });
|
|
15613
|
-
var TOOL_TO_HARNESS = {
|
|
15614
|
-
"claude-code": "claudecode",
|
|
15615
|
-
"claude-desktop": "claudedesktop",
|
|
15616
|
-
"github-copilot": "copilot",
|
|
15617
|
-
cursor: "cursor",
|
|
15618
|
-
chatgpt: "chatgpt",
|
|
15619
|
-
codex: "codex",
|
|
15620
|
-
antigravity: "antigravity",
|
|
15621
|
-
"claude-ai": "claudeai"
|
|
15622
|
-
};
|
|
15623
|
-
function harnessFromTool(tool) {
|
|
15624
|
-
return TOOL_TO_HARNESS[tool] ?? tool;
|
|
15625
|
-
}
|
|
15626
|
-
|
|
15627
15650
|
// ../../packages/schema/src/zod/meta.ts
|
|
15628
15651
|
var InventoryObjectType = external_exports.enum(["host", "harness", "user", "skill", "hook", "mcp_server", "config_file"]).meta({ id: "InventoryObjectType" });
|
|
15629
15652
|
var AuditEventType = external_exports.enum([
|
|
@@ -16076,686 +16099,37 @@ var ActivityOverviewResponse = external_exports.object({
|
|
|
16076
16099
|
sessions: ListActivitySessionsResponse
|
|
16077
16100
|
}).meta({ id: "ActivityOverviewResponse" });
|
|
16078
16101
|
|
|
16079
|
-
// ../../packages/schema/src/zod/
|
|
16080
|
-
var
|
|
16081
|
-
var
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
filePath: external_exports.string().optional(),
|
|
16098
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
16099
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
16100
|
-
// arguments or output, which can carry the very value a finding masked
|
|
16101
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
16102
|
-
// display location ("via Bash") when no filePath exists.
|
|
16103
|
-
toolName: external_exports.string().optional(),
|
|
16104
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
16105
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
16106
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
16107
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
16108
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
16109
|
-
gitignored: external_exports.boolean().optional(),
|
|
16110
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
16111
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
16112
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
16113
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
16114
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
16115
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
16116
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
16117
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
16118
|
-
// non-authoritative path.
|
|
16119
|
-
wholeFile: external_exports.boolean().optional(),
|
|
16120
|
-
model: external_exports.string().optional(),
|
|
16121
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
16122
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
16123
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
16124
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
16125
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
16126
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
16127
|
-
correlationId: external_exports.uuid().optional(),
|
|
16128
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
16129
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
16130
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
16131
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
16132
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
16133
|
-
}).meta({ id: "EventMetadata" });
|
|
16134
|
-
var Event = external_exports.object({
|
|
16135
|
-
id: external_exports.guid(),
|
|
16136
|
-
sourceTool: SourceTool,
|
|
16137
|
-
kind: EventKind,
|
|
16138
|
-
occurredAt: external_exports.iso.datetime(),
|
|
16139
|
-
contentHash: external_exports.string(),
|
|
16140
|
-
content: external_exports.string(),
|
|
16141
|
-
metadata: EventMetadata.optional()
|
|
16142
|
-
}).meta({ id: "Event" });
|
|
16143
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
16144
|
-
var IngestBatch = external_exports.object({
|
|
16145
|
-
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
16146
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
16147
|
-
// additionally rejects any event whose contentHash the store has already
|
|
16148
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
16149
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
16150
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
16151
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
16152
|
-
// the timeline.
|
|
16153
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
16154
|
-
}).meta({ id: "IngestBatch" });
|
|
16155
|
-
|
|
16156
|
-
// ../../packages/schema/src/zod/inventory.ts
|
|
16157
|
-
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
16158
|
-
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
16159
|
-
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
16160
|
-
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
16161
|
-
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
16162
|
-
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
16163
|
-
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
16164
|
-
var HarnessId = external_exports.enum(["claudecode", "cursor", "codex", "antigravity"]).meta({ id: "HarnessId" });
|
|
16165
|
-
var AccessCounts = external_exports.object({
|
|
16166
|
-
open: external_exports.number().int().nonnegative(),
|
|
16167
|
-
approved: external_exports.number().int().nonnegative(),
|
|
16168
|
-
blocked: external_exports.number().int().nonnegative(),
|
|
16169
|
-
total: external_exports.number().int().nonnegative()
|
|
16170
|
-
}).meta({ id: "AccessCounts" });
|
|
16171
|
-
var AssetSummary = external_exports.object({
|
|
16172
|
-
id: external_exports.string(),
|
|
16173
|
-
type: AssetType,
|
|
16174
|
-
name: external_exports.string(),
|
|
16175
|
-
sub: external_exports.string(),
|
|
16176
|
-
flags: external_exports.array(Flag),
|
|
16177
|
-
/** MCP servers only — omitted for all other types. */
|
|
16178
|
-
trust: TrustLevel.optional()
|
|
16179
|
-
}).meta({ id: "AssetSummary" });
|
|
16180
|
-
var ProjectSummary = external_exports.object({
|
|
16181
|
-
id: external_exports.string(),
|
|
16182
|
-
name: external_exports.string(),
|
|
16183
|
-
repo: external_exports.string(),
|
|
16184
|
-
visibility: Visibility,
|
|
16185
|
-
language: external_exports.string(),
|
|
16186
|
-
policyDefault: AccessLevel,
|
|
16187
|
-
updatedAt: external_exports.iso.datetime(),
|
|
16188
|
-
accessCounts: AccessCounts,
|
|
16189
|
-
findingsCount: external_exports.number().int().nonnegative()
|
|
16190
|
-
}).meta({ id: "ProjectSummary" });
|
|
16191
|
-
var HarnessCategory = external_exports.object({
|
|
16192
|
-
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
16193
|
-
type: AssetType,
|
|
16194
|
-
assets: external_exports.array(AssetSummary)
|
|
16102
|
+
// ../../packages/schema/src/zod/config-inventory.ts
|
|
16103
|
+
var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
|
|
16104
|
+
var SkillScanEntry = external_exports.object({
|
|
16105
|
+
name: external_exports.string().min(1),
|
|
16106
|
+
// The identity source: a marketplace repo for plugin skills (e.g.
|
|
16107
|
+
// 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
|
|
16108
|
+
// 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
|
|
16109
|
+
// a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
|
|
16110
|
+
source: external_exports.string().min(1),
|
|
16111
|
+
scope: ConfigScope,
|
|
16112
|
+
pluginName: external_exports.string().optional(),
|
|
16113
|
+
// Volatile — rides the attribute bag, never the identity hash.
|
|
16114
|
+
version: external_exports.string().optional(),
|
|
16115
|
+
description: external_exports.string().optional(),
|
|
16116
|
+
// Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
|
|
16117
|
+
updatedAt: external_exports.iso.datetime().optional(),
|
|
16118
|
+
// Filesystem path — the promoted inventory `location` column.
|
|
16119
|
+
location: external_exports.string().optional()
|
|
16195
16120
|
});
|
|
16196
|
-
var
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
var AssetGroup = external_exports.object({
|
|
16209
|
-
/** Group key — never project (enforced at service layer). */
|
|
16210
|
-
type: AssetType,
|
|
16211
|
-
total: external_exports.number().int().nonnegative(),
|
|
16212
|
-
/**
|
|
16213
|
-
* MCP group only — omitted for all other types.
|
|
16214
|
-
* Partial: only TrustLevel keys with non-zero counts are included.
|
|
16215
|
-
* Strict: unknown keys are rejected — only TrustLevel values are valid keys.
|
|
16216
|
-
*/
|
|
16217
|
-
trustRollup: external_exports.object({
|
|
16218
|
-
"known-good": external_exports.number().int().nonnegative(),
|
|
16219
|
-
risky: external_exports.number().int().nonnegative(),
|
|
16220
|
-
unapproved: external_exports.number().int().nonnegative()
|
|
16221
|
-
}).partial().strict().optional(),
|
|
16222
|
-
/**
|
|
16223
|
-
* Partial: only Flag keys with non-zero counts are included.
|
|
16224
|
-
* Strict: unknown keys are rejected — only Flag values are valid keys.
|
|
16225
|
-
*/
|
|
16226
|
-
flagRollup: external_exports.object({
|
|
16227
|
-
update: external_exports.number().int().nonnegative(),
|
|
16228
|
-
stale: external_exports.number().int().nonnegative(),
|
|
16229
|
-
conflict: external_exports.number().int().nonnegative(),
|
|
16230
|
-
unknown: external_exports.number().int().nonnegative(),
|
|
16231
|
-
change: external_exports.number().int().nonnegative(),
|
|
16232
|
-
untracked: external_exports.number().int().nonnegative(),
|
|
16233
|
-
risk: external_exports.number().int().nonnegative(),
|
|
16234
|
-
findings: external_exports.number().int().nonnegative()
|
|
16235
|
-
}).partial().strict(),
|
|
16236
|
-
items: external_exports.array(AssetSummary)
|
|
16237
|
-
}).meta({ id: "AssetGroup" });
|
|
16238
|
-
var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
|
|
16239
|
-
var McpTool = external_exports.object({
|
|
16240
|
-
name: external_exports.string(),
|
|
16241
|
-
signature: external_exports.string(),
|
|
16242
|
-
description: external_exports.string(),
|
|
16243
|
-
write: external_exports.boolean(),
|
|
16244
|
-
/** Non-null string when tool is dangerous / blocked; null otherwise. */
|
|
16245
|
-
risk: external_exports.string().nullable()
|
|
16246
|
-
}).meta({ id: "McpTool" });
|
|
16247
|
-
var AssetFindingRef = external_exports.object({
|
|
16248
|
-
id: external_exports.string(),
|
|
16249
|
-
title: external_exports.string(),
|
|
16250
|
-
note: external_exports.string()
|
|
16251
|
-
});
|
|
16252
|
-
var AssetDetail = AssetSummary.extend({
|
|
16253
|
-
/** string | null — null when no description is available. */
|
|
16254
|
-
description: external_exports.string().nullable(),
|
|
16255
|
-
/** trustLevel | null — null for non-MCP assets. */
|
|
16256
|
-
trust: TrustLevel.nullable(),
|
|
16257
|
-
/** Type-specific raw key/values — FE renders the grid. */
|
|
16258
|
-
meta: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
16259
|
-
/** always present — object when there is an active finding, null when absent. */
|
|
16260
|
-
finding: AssetFindingRef.nullable(),
|
|
16261
|
-
/** MCP exposed-tools list — omitted for non-mcp. */
|
|
16262
|
-
tools: external_exports.array(McpTool).optional()
|
|
16263
|
-
}).meta({ id: "AssetDetail" });
|
|
16264
|
-
var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
|
|
16265
|
-
var InventoryStats = external_exports.object({
|
|
16266
|
-
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16267
|
-
attention: external_exports.number().int().nonnegative(),
|
|
16268
|
-
byType: external_exports.object({
|
|
16269
|
-
project: external_exports.number().int().nonnegative(),
|
|
16270
|
-
skill: external_exports.number().int().nonnegative(),
|
|
16271
|
-
mcp: external_exports.number().int().nonnegative(),
|
|
16272
|
-
hook: external_exports.number().int().nonnegative(),
|
|
16273
|
-
config: external_exports.number().int().nonnegative()
|
|
16274
|
-
}),
|
|
16275
|
-
harnesses: external_exports.number().int().nonnegative(),
|
|
16276
|
-
mcpTrust: external_exports.object({
|
|
16277
|
-
"known-good": external_exports.number().int().nonnegative(),
|
|
16278
|
-
risky: external_exports.number().int().nonnegative(),
|
|
16279
|
-
unapproved: external_exports.number().int().nonnegative()
|
|
16280
|
-
})
|
|
16281
|
-
}).meta({ id: "InventoryStats" });
|
|
16282
|
-
var FileSummary = external_exports.object({
|
|
16283
|
-
path: external_exports.string(),
|
|
16284
|
-
name: external_exports.string(),
|
|
16285
|
-
origin: Origin,
|
|
16286
|
-
/** Effective access (override applied). */
|
|
16287
|
-
access: AccessLevel,
|
|
16288
|
-
/** True when a file_access_override differs from the computed default. */
|
|
16289
|
-
isCustom: external_exports.boolean(),
|
|
16290
|
-
findings: external_exports.number().int().nonnegative(),
|
|
16291
|
-
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16292
|
-
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16293
|
-
/** Why the file was blocked; null when absent. */
|
|
16294
|
-
note: external_exports.string().nullable().optional()
|
|
16295
|
-
}).meta({ id: "FileSummary" });
|
|
16296
|
-
var FolderSummary = external_exports.object({
|
|
16297
|
-
name: external_exports.string(),
|
|
16298
|
-
path: external_exports.string(),
|
|
16299
|
-
/** Rollup of effective access across all descendants. */
|
|
16300
|
-
accessCounts: AccessCounts
|
|
16301
|
-
}).meta({ id: "FolderSummary" });
|
|
16302
|
-
var ProjectTreeResponse = external_exports.object({
|
|
16303
|
-
project: external_exports.object({
|
|
16304
|
-
id: external_exports.string(),
|
|
16305
|
-
repo: external_exports.string(),
|
|
16306
|
-
visibility: Visibility
|
|
16307
|
-
}),
|
|
16308
|
-
path: external_exports.string(),
|
|
16309
|
-
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16310
|
-
folders: external_exports.array(FolderSummary).optional(),
|
|
16311
|
-
files: external_exports.array(FileSummary)
|
|
16312
|
-
}).meta({ id: "ProjectTreeResponse" });
|
|
16313
|
-
var FileDetail = FileSummary.extend({
|
|
16314
|
-
project: external_exports.object({
|
|
16315
|
-
repo: external_exports.string(),
|
|
16316
|
-
visibility: Visibility,
|
|
16317
|
-
language: external_exports.string(),
|
|
16318
|
-
policyDefault: AccessLevel,
|
|
16319
|
-
updatedAt: external_exports.iso.datetime()
|
|
16320
|
-
}),
|
|
16321
|
-
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16322
|
-
}).meta({ id: "FileDetail" });
|
|
16323
|
-
var SetFileAccessBody = external_exports.object({
|
|
16324
|
-
path: external_exports.string(),
|
|
16325
|
-
access: AccessLevel
|
|
16326
|
-
}).meta({ id: "SetFileAccessBody" });
|
|
16327
|
-
var SetFileAccessResponse = external_exports.object({
|
|
16328
|
-
file: FileSummary,
|
|
16329
|
-
accessCounts: AccessCounts
|
|
16330
|
-
}).meta({ id: "SetFileAccessResponse" });
|
|
16331
|
-
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16332
|
-
var HarnessEventItem = external_exports.object({
|
|
16333
|
-
kind: HarnessEventKind,
|
|
16334
|
-
title: external_exports.string(),
|
|
16335
|
-
detail: external_exports.string(),
|
|
16336
|
-
occurredAt: external_exports.iso.datetime(),
|
|
16337
|
-
findingId: external_exports.string().nullable().optional()
|
|
16338
|
-
}).meta({ id: "HarnessEventItem" });
|
|
16339
|
-
var HarnessEventsResponse = external_exports.object({
|
|
16340
|
-
counts: external_exports.object({
|
|
16341
|
-
block: external_exports.number().int().nonnegative(),
|
|
16342
|
-
redact: external_exports.number().int().nonnegative(),
|
|
16343
|
-
warn: external_exports.number().int().nonnegative()
|
|
16344
|
-
}),
|
|
16345
|
-
items: external_exports.array(HarnessEventItem)
|
|
16346
|
-
}).meta({ id: "HarnessEventsResponse" });
|
|
16347
|
-
var RescanResponse = external_exports.object({
|
|
16348
|
-
jobId: external_exports.string(),
|
|
16349
|
-
startedAt: external_exports.iso.datetime()
|
|
16350
|
-
}).meta({ id: "RescanResponse" });
|
|
16351
|
-
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16352
|
-
var ListAssetsQuery = external_exports.object({
|
|
16353
|
-
/** Filter by one or more AssetType values; absent means all types. */
|
|
16354
|
-
type: external_exports.array(AssetType).optional(),
|
|
16355
|
-
/** Free-text search term. */
|
|
16356
|
-
q: external_exports.string().optional()
|
|
16357
|
-
});
|
|
16358
|
-
var GetProjectTreeQuery = external_exports.object({
|
|
16359
|
-
/** Subtree root path; defaults to repository root when absent. */
|
|
16360
|
-
path: external_exports.string().optional(),
|
|
16361
|
-
/** Free-text filter applied to file paths. */
|
|
16362
|
-
q: external_exports.string().optional(),
|
|
16363
|
-
/**
|
|
16364
|
-
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16365
|
-
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16366
|
-
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16367
|
-
*/
|
|
16368
|
-
filter: external_exports.enum(["blocked"]).optional()
|
|
16369
|
-
});
|
|
16370
|
-
var GetProjectFileQuery = external_exports.object({
|
|
16371
|
-
/** Repository-relative file path; absent or empty → 400. */
|
|
16372
|
-
path: external_exports.string()
|
|
16373
|
-
});
|
|
16374
|
-
var GetHarnessEventsQuery = external_exports.object({
|
|
16375
|
-
/** Maximum number of events to return. Range: 1–50; default: 7. */
|
|
16376
|
-
limit: external_exports.coerce.number().int().min(1).max(50).default(7)
|
|
16377
|
-
});
|
|
16378
|
-
|
|
16379
|
-
// ../../packages/schema/src/zod/exception.ts
|
|
16380
|
-
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
16381
|
-
var ExceptionConditions = external_exports.object({
|
|
16382
|
-
repo: external_exports.string().optional(),
|
|
16383
|
-
sourceTool: external_exports.string().optional(),
|
|
16384
|
-
provider: external_exports.string().optional()
|
|
16385
|
-
}).strict();
|
|
16386
|
-
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
16387
|
-
var DetectionException = external_exports.object({
|
|
16388
|
-
id: external_exports.guid(),
|
|
16389
|
-
ruleId: external_exports.string(),
|
|
16390
|
-
// Denormalized from the rule, for reporting — never matched on.
|
|
16391
|
-
category: DetectionCategory,
|
|
16392
|
-
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
16393
|
-
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
16394
|
-
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
16395
|
-
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
16396
|
-
// at the boundary rather than persisted.
|
|
16397
|
-
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
16398
|
-
// Version of the fingerprint key the grant was written under; a rotated key
|
|
16399
|
-
// invalidates old grants rather than silently mismatching them.
|
|
16400
|
-
keyVersion: external_exports.number().int().positive(),
|
|
16401
|
-
// maskMatch() preview of the approved value — never the raw value.
|
|
16402
|
-
maskedValue: external_exports.string(),
|
|
16403
|
-
capability: ExceptionCapability.default("suppress"),
|
|
16404
|
-
scope: ExceptionScope,
|
|
16405
|
-
expiresAt: external_exports.iso.datetime().nullable(),
|
|
16406
|
-
maxUses: external_exports.number().int().positive().nullable(),
|
|
16407
|
-
useCount: external_exports.number().int().nonnegative(),
|
|
16408
|
-
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
16409
|
-
// Mandatory: every grant carries the human reason it exists.
|
|
16410
|
-
justification: external_exports.string().min(1),
|
|
16411
|
-
conditions: ExceptionConditions.nullable(),
|
|
16412
|
-
createdBy: external_exports.string(),
|
|
16413
|
-
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
16414
|
-
createdAt: external_exports.iso.datetime(),
|
|
16415
|
-
updatedAt: external_exports.iso.datetime(),
|
|
16416
|
-
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
16417
|
-
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
16418
|
-
revokedAt: external_exports.iso.datetime().nullable(),
|
|
16419
|
-
revokedBy: external_exports.string().nullable(),
|
|
16420
|
-
revokeReason: external_exports.string().nullable()
|
|
16421
|
-
});
|
|
16422
|
-
var ExceptionBundleEntry = DetectionException.pick({
|
|
16423
|
-
id: true,
|
|
16424
|
-
ruleId: true,
|
|
16425
|
-
valueFingerprint: true,
|
|
16426
|
-
keyVersion: true,
|
|
16427
|
-
capability: true,
|
|
16428
|
-
expiresAt: true,
|
|
16429
|
-
maxUses: true,
|
|
16430
|
-
useCount: true,
|
|
16431
|
-
conditions: true
|
|
16432
|
-
});
|
|
16433
|
-
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
16434
|
-
|
|
16435
|
-
// ../../packages/schema/src/zod/rule.ts
|
|
16436
|
-
var MatcherType = external_exports.enum(["keyword", "regex", "validator"]).meta({ id: "MatcherType" });
|
|
16437
|
-
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
16438
|
-
var KeywordMatcher = external_exports.object({
|
|
16439
|
-
type: external_exports.literal("keyword"),
|
|
16440
|
-
// An empty keyword matches at every position, yielding one zero-length span
|
|
16441
|
-
// per character. Rejected here because a keyword that matches everything is
|
|
16442
|
-
// never intentional.
|
|
16443
|
-
keywords: external_exports.array(external_exports.string().min(1)).min(1),
|
|
16444
|
-
caseSensitive: external_exports.boolean().default(false)
|
|
16445
|
-
});
|
|
16446
|
-
function isValidRegex(pattern, flags) {
|
|
16447
|
-
try {
|
|
16448
|
-
new RegExp(pattern, flags);
|
|
16449
|
-
return true;
|
|
16450
|
-
} catch {
|
|
16451
|
-
return false;
|
|
16452
|
-
}
|
|
16453
|
-
}
|
|
16454
|
-
function matchesEmptyString(pattern, flags) {
|
|
16455
|
-
try {
|
|
16456
|
-
const re = new RegExp(pattern, flags.replace(/[gy]/g, ""));
|
|
16457
|
-
return re.exec("")?.[0].length === 0;
|
|
16458
|
-
} catch {
|
|
16459
|
-
return false;
|
|
16460
|
-
}
|
|
16461
|
-
}
|
|
16462
|
-
var MAX_PATTERN_LENGTH = 2e3;
|
|
16463
|
-
var RegexMatcher = external_exports.object({
|
|
16464
|
-
type: external_exports.literal("regex"),
|
|
16465
|
-
pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
|
|
16466
|
-
flags: external_exports.string().default("gi"),
|
|
16467
|
-
captureGroup: external_exports.number().int().nonnegative().optional()
|
|
16468
|
-
}).refine((v) => isValidRegex(v.pattern, v.flags), {
|
|
16469
|
-
message: "pattern/flags do not form a valid JavaScript regular expression",
|
|
16470
|
-
path: ["pattern"]
|
|
16471
|
-
}).refine((v) => v.captureGroup !== void 0 || !matchesEmptyString(v.pattern, v.flags), {
|
|
16472
|
-
message: 'a whole-match regex that can match the empty string (e.g. "\\d*", "a?", "(?:)") can hang the matcher \u2014 scope the quantifier to a captureGroup, or require at least one character',
|
|
16473
|
-
path: ["pattern"]
|
|
16474
|
-
});
|
|
16475
|
-
var ValidatorMatcher = external_exports.object({
|
|
16476
|
-
type: external_exports.literal("validator"),
|
|
16477
|
-
name: external_exports.enum(["luhn", "entropy", "ssn-checksum"]),
|
|
16478
|
-
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16479
|
-
});
|
|
16480
|
-
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher, ValidatorMatcher]).meta({ id: "Matcher" });
|
|
16481
|
-
var AppliesTo = external_exports.object({
|
|
16482
|
-
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
16483
|
-
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
16484
|
-
}).meta({ id: "AppliesTo" });
|
|
16485
|
-
var PostValidatorRef = external_exports.union([
|
|
16486
|
-
external_exports.string(),
|
|
16487
|
-
external_exports.object({
|
|
16488
|
-
name: external_exports.string(),
|
|
16489
|
-
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16490
|
-
})
|
|
16491
|
-
]).meta({ id: "PostValidatorRef" });
|
|
16492
|
-
var RequiresNearby = external_exports.object({
|
|
16493
|
-
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
16494
|
-
// an empty/blank criterion would either never fire or (for labels) match
|
|
16495
|
-
// everything.
|
|
16496
|
-
categories: external_exports.array(DetectionCategory).min(1).optional(),
|
|
16497
|
-
ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16498
|
-
labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16499
|
-
windowChars: external_exports.number().int().positive().default(160),
|
|
16500
|
-
// Optional confidence bump applied when a gated match is corroborated. Capped
|
|
16501
|
-
// small: it nudges confidence, it does not assert certainty.
|
|
16502
|
-
confidenceBoost: external_exports.number().min(0).max(0.3).optional()
|
|
16503
|
-
}).refine(
|
|
16504
|
-
(v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
|
|
16505
|
-
{ message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
|
|
16506
|
-
).meta({ id: "RequiresNearby" });
|
|
16507
|
-
var RuleFixture = external_exports.object({
|
|
16508
|
-
label: external_exports.string(),
|
|
16509
|
-
text: external_exports.string().max(5e4),
|
|
16510
|
-
shouldMatch: external_exports.boolean(),
|
|
16511
|
-
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
16512
|
-
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
16513
|
-
filePath: external_exports.string().optional(),
|
|
16514
|
-
expectedSpans: external_exports.array(external_exports.object({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
16515
|
-
}).meta({ id: "RuleFixture" });
|
|
16516
|
-
var Rule = external_exports.object({
|
|
16517
|
-
specVersion: external_exports.literal(1),
|
|
16518
|
-
// `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
|
|
16519
|
-
// the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
|
|
16520
|
-
// detection id (`namespace/packId`, decoded by splitDetectionId). A Rule.id
|
|
16521
|
-
// therefore carries no namespace and is not globally unique across publishers;
|
|
16522
|
-
// never feed one to splitDetectionId. `category` below (per-rule) is the
|
|
16523
|
-
// taxonomy axis; the pack's enforcement policy is installed_packs.policy_id.
|
|
16524
|
-
id: external_exports.string().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/),
|
|
16525
|
-
name: external_exports.string(),
|
|
16526
|
-
category: DetectionCategory,
|
|
16527
|
-
severity: Severity,
|
|
16528
|
-
matcher: Matcher,
|
|
16529
|
-
appliesTo: AppliesTo.optional(),
|
|
16530
|
-
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
16531
|
-
requiresNearby: RequiresNearby.optional(),
|
|
16532
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
16533
|
-
}).meta({ id: "Rule" });
|
|
16534
|
-
var Author = external_exports.object({
|
|
16535
|
-
name: external_exports.string(),
|
|
16536
|
-
email: external_exports.email().optional(),
|
|
16537
|
-
url: external_exports.url().optional()
|
|
16538
|
-
}).meta({ id: "Author" });
|
|
16539
|
-
var PackManifest = external_exports.object({
|
|
16540
|
-
specVersion: external_exports.literal(1),
|
|
16541
|
-
id: external_exports.string(),
|
|
16542
|
-
name: external_exports.string(),
|
|
16543
|
-
version: external_exports.string(),
|
|
16544
|
-
rules: external_exports.array(external_exports.string()),
|
|
16545
|
-
// Optional attribution/provenance — consumed by the rule marketplace.
|
|
16546
|
-
description: external_exports.string().optional(),
|
|
16547
|
-
author: Author.optional(),
|
|
16548
|
-
license: external_exports.string().optional(),
|
|
16549
|
-
sourceUrl: external_exports.url().optional()
|
|
16550
|
-
}).meta({ id: "PackManifest" });
|
|
16551
|
-
|
|
16552
|
-
// ../../packages/schema/src/zod/policy.ts
|
|
16553
|
-
var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
|
|
16554
|
-
var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
|
|
16555
|
-
var Policy = external_exports.object({
|
|
16556
|
-
id: external_exports.guid(),
|
|
16557
|
-
scope: PolicyScope,
|
|
16558
|
-
target: PolicyTarget,
|
|
16559
|
-
action: ActionTaken,
|
|
16560
|
-
enabled: external_exports.boolean().default(true),
|
|
16561
|
-
customKeywords: external_exports.array(external_exports.string()).optional(),
|
|
16562
|
-
// Display name — optional so older policy rows without name still parse.
|
|
16563
|
-
// Added for the findings API (policy.name column migration).
|
|
16564
|
-
name: external_exports.string().optional()
|
|
16565
|
-
}).meta({ id: "Policy" });
|
|
16566
|
-
var PolicyBundle = external_exports.object({
|
|
16567
|
-
version: external_exports.string(),
|
|
16568
|
-
policies: external_exports.array(Policy),
|
|
16569
|
-
// Rules from the installed marketplace packs (snapshotted by the
|
|
16570
|
-
// control plane). The plugin registers these in addition to its bundled
|
|
16571
|
-
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
16572
|
-
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
16573
|
-
rules: external_exports.array(Rule).optional(),
|
|
16574
|
-
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
16575
|
-
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
16576
|
-
// after reading the user's installed snapshot (installed_packs, enabled
|
|
16577
|
-
// packs only), which is how detection updates stay manual: new bundled
|
|
16578
|
-
// rules run only after the user applies the pack update. Absent/false keeps
|
|
16579
|
-
// the historical composition (bundled packs + rules) — older caches.
|
|
16580
|
-
rulesComplete: external_exports.boolean().optional(),
|
|
16581
|
-
// Active detection exceptions, evaluation subset only (see
|
|
16582
|
-
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
16583
|
-
// on-disk caches — that omit the field still parse; consumers read
|
|
16584
|
-
// `bundle.exceptions ?? []`.
|
|
16585
|
-
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
16586
|
-
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
16587
|
-
// from a versioned installed pack. Optional so older backends — and older
|
|
16588
|
-
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
16589
|
-
// the rule's own spec version. NOT the bundle version above — see
|
|
16590
|
-
// installedRuleset's ruleVersions for the source of truth.
|
|
16591
|
-
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
16592
|
-
customKeywords: external_exports.array(external_exports.string()),
|
|
16593
|
-
fetchedAt: external_exports.iso.datetime()
|
|
16594
|
-
}).meta({ id: "PolicyBundle" });
|
|
16595
|
-
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
16596
|
-
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
16597
|
-
var CATEGORY_PEAK_SEVERITY = {
|
|
16598
|
-
secret: "critical",
|
|
16599
|
-
financial: "critical",
|
|
16600
|
-
// core-financial/credit-card
|
|
16601
|
-
code_flaw: "critical",
|
|
16602
|
-
pii: "high",
|
|
16603
|
-
phi: "high",
|
|
16604
|
-
custom: "high",
|
|
16605
|
-
// user-defined; conservative
|
|
16606
|
-
code_context: "low",
|
|
16607
|
-
config: "low"
|
|
16608
|
-
// observe-only; floors to monitor regardless
|
|
16609
|
-
};
|
|
16610
|
-
function severityFloorPolicy(category) {
|
|
16611
|
-
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
16612
|
-
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
16613
|
-
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
16614
|
-
}
|
|
16615
|
-
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
16616
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "block"];
|
|
16617
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
16618
|
-
var BUILTIN_ORDER = KNOWN_BUILTIN_IDS;
|
|
16619
|
-
var BUILTIN_POLICY_SPECS = {
|
|
16620
|
-
monitor: {
|
|
16621
|
-
name: "Monitor",
|
|
16622
|
-
action: "log",
|
|
16623
|
-
description: "Log every match for audit. The request is allowed through untouched."
|
|
16624
|
-
},
|
|
16625
|
-
warn: {
|
|
16626
|
-
name: "Warn",
|
|
16627
|
-
action: "warn",
|
|
16628
|
-
description: "Allow the request, but warn the user inline before it is sent."
|
|
16629
|
-
},
|
|
16630
|
-
redact: {
|
|
16631
|
-
name: "Redact",
|
|
16632
|
-
action: "redact",
|
|
16633
|
-
description: "Automatically strip the matched value from the request, then continue."
|
|
16634
|
-
},
|
|
16635
|
-
block: {
|
|
16636
|
-
name: "Block",
|
|
16637
|
-
action: "block",
|
|
16638
|
-
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
16639
|
-
}
|
|
16640
|
-
};
|
|
16641
|
-
function builtinPolicyToAction(id) {
|
|
16642
|
-
return BUILTIN_POLICY_SPECS[id].action;
|
|
16643
|
-
}
|
|
16644
|
-
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
16645
|
-
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
16646
|
-
);
|
|
16647
|
-
var BUILTIN_POLICIES = Object.fromEntries(
|
|
16648
|
-
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
16649
|
-
);
|
|
16650
|
-
var DEFAULT_PACK_POLICY_ID = "monitor";
|
|
16651
|
-
function policyIdToAction(policyId) {
|
|
16652
|
-
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
16653
|
-
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
16654
|
-
return BUILTIN_POLICIES[id].action;
|
|
16655
|
-
}
|
|
16656
|
-
var UsedByItem = external_exports.object({
|
|
16657
|
-
id: external_exports.string(),
|
|
16658
|
-
name: external_exports.string(),
|
|
16659
|
-
ruleCount: external_exports.number().int().nonnegative(),
|
|
16660
|
-
enabled: external_exports.boolean()
|
|
16661
|
-
}).meta({ id: "UsedByItem" });
|
|
16662
|
-
var PolicyListItem = external_exports.object({
|
|
16663
|
-
id: external_exports.string(),
|
|
16664
|
-
kind: PolicyKind,
|
|
16665
|
-
name: external_exports.string(),
|
|
16666
|
-
enabled: external_exports.boolean(),
|
|
16667
|
-
usedByCount: external_exports.number().int().nonnegative()
|
|
16668
|
-
}).meta({ id: "PolicyListItem" });
|
|
16669
|
-
var PolicyDetail = external_exports.object({
|
|
16670
|
-
specVersion: external_exports.literal(1),
|
|
16671
|
-
id: external_exports.string(),
|
|
16672
|
-
kind: PolicyKind,
|
|
16673
|
-
name: external_exports.string(),
|
|
16674
|
-
enabled: external_exports.boolean(),
|
|
16675
|
-
description: external_exports.string(),
|
|
16676
|
-
usedBy: external_exports.array(UsedByItem)
|
|
16677
|
-
}).meta({ id: "PolicyDetail" });
|
|
16678
|
-
var PolicyStatsResponse = external_exports.object({
|
|
16679
|
-
policies: external_exports.number().int().nonnegative(),
|
|
16680
|
-
builtin: external_exports.number().int().nonnegative(),
|
|
16681
|
-
custom: external_exports.number().int().nonnegative(),
|
|
16682
|
-
detectionsGoverned: external_exports.number().int().nonnegative()
|
|
16683
|
-
}).meta({ id: "PolicyStatsResponse" });
|
|
16684
|
-
|
|
16685
|
-
// ../../packages/schema/src/zod/api.ts
|
|
16686
|
-
var LIST_QUERY_MAX_LIMIT = 200;
|
|
16687
|
-
var ListEventsQuery = external_exports.object({
|
|
16688
|
-
cursor: external_exports.string().optional(),
|
|
16689
|
-
limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
|
|
16690
|
-
sourceTool: external_exports.string().optional(),
|
|
16691
|
-
kind: external_exports.string().optional(),
|
|
16692
|
-
from: external_exports.iso.datetime().optional(),
|
|
16693
|
-
to: external_exports.iso.datetime().optional()
|
|
16694
|
-
});
|
|
16695
|
-
var ListEventsResponse = external_exports.object({
|
|
16696
|
-
items: external_exports.array(Event),
|
|
16697
|
-
nextCursor: external_exports.string().nullable()
|
|
16698
|
-
}).meta({ id: "ListEventsResponse" });
|
|
16699
|
-
var IngestResponse = external_exports.object({
|
|
16700
|
-
accepted: external_exports.number().int().nonnegative(),
|
|
16701
|
-
duplicates: external_exports.number().int().nonnegative()
|
|
16702
|
-
}).meta({ id: "IngestResponse" });
|
|
16703
|
-
var ListFindingsQuery = external_exports.object({
|
|
16704
|
-
cursor: external_exports.string().optional(),
|
|
16705
|
-
limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
|
|
16706
|
-
severity: external_exports.string().optional(),
|
|
16707
|
-
category: external_exports.string().optional(),
|
|
16708
|
-
eventId: external_exports.guid().optional()
|
|
16709
|
-
});
|
|
16710
|
-
var ListFindingsResponse = external_exports.object({
|
|
16711
|
-
items: external_exports.array(Finding),
|
|
16712
|
-
nextCursor: external_exports.string().nullable()
|
|
16713
|
-
}).meta({ id: "ListFindingsResponse" });
|
|
16714
|
-
var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
|
|
16715
|
-
var CreatePolicyRequest = Policy.omit({ id: true }).meta({
|
|
16716
|
-
id: "CreatePolicyRequest"
|
|
16717
|
-
});
|
|
16718
|
-
var UpdatePolicyRequest = Policy.partial().required({ id: true }).meta({ id: "UpdatePolicyRequest" });
|
|
16719
|
-
var RecordAuditEventResponse = external_exports.object({ accepted: external_exports.boolean() }).meta({ id: "RecordAuditEventResponse" });
|
|
16720
|
-
var ErrorResponse = external_exports.object({
|
|
16721
|
-
error: external_exports.object({
|
|
16722
|
-
code: external_exports.string(),
|
|
16723
|
-
message: external_exports.string(),
|
|
16724
|
-
details: external_exports.unknown().optional()
|
|
16725
|
-
})
|
|
16726
|
-
}).meta({ id: "ErrorResponse" });
|
|
16727
|
-
|
|
16728
|
-
// ../../packages/schema/src/zod/config-inventory.ts
|
|
16729
|
-
var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
|
|
16730
|
-
var SkillScanEntry = external_exports.object({
|
|
16731
|
-
name: external_exports.string().min(1),
|
|
16732
|
-
// The identity source: a marketplace repo for plugin skills (e.g.
|
|
16733
|
-
// 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
|
|
16734
|
-
// 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
|
|
16735
|
-
// a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
|
|
16736
|
-
source: external_exports.string().min(1),
|
|
16737
|
-
scope: ConfigScope,
|
|
16738
|
-
pluginName: external_exports.string().optional(),
|
|
16739
|
-
// Volatile — rides the attribute bag, never the identity hash.
|
|
16740
|
-
version: external_exports.string().optional(),
|
|
16741
|
-
description: external_exports.string().optional(),
|
|
16742
|
-
// Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
|
|
16743
|
-
updatedAt: external_exports.iso.datetime().optional(),
|
|
16744
|
-
// Filesystem path — the promoted inventory `location` column.
|
|
16745
|
-
location: external_exports.string().optional()
|
|
16746
|
-
});
|
|
16747
|
-
var HookScanEntry = external_exports.object({
|
|
16748
|
-
// Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
|
|
16749
|
-
// set is harness-defined and grows without a schema change.
|
|
16750
|
-
event: external_exports.string().min(1),
|
|
16751
|
-
// The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
|
|
16752
|
-
matcher: external_exports.string().optional(),
|
|
16753
|
-
command: external_exports.string().min(1),
|
|
16754
|
-
timeout: external_exports.number().optional(),
|
|
16755
|
-
scope: ConfigScope,
|
|
16756
|
-
pluginName: external_exports.string().optional(),
|
|
16757
|
-
// The settings file / hooks.json the entry came from.
|
|
16758
|
-
location: external_exports.string().optional()
|
|
16121
|
+
var HookScanEntry = external_exports.object({
|
|
16122
|
+
// Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
|
|
16123
|
+
// set is harness-defined and grows without a schema change.
|
|
16124
|
+
event: external_exports.string().min(1),
|
|
16125
|
+
// The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
|
|
16126
|
+
matcher: external_exports.string().optional(),
|
|
16127
|
+
command: external_exports.string().min(1),
|
|
16128
|
+
timeout: external_exports.number().optional(),
|
|
16129
|
+
scope: ConfigScope,
|
|
16130
|
+
pluginName: external_exports.string().optional(),
|
|
16131
|
+
// The settings file / hooks.json the entry came from.
|
|
16132
|
+
location: external_exports.string().optional()
|
|
16759
16133
|
});
|
|
16760
16134
|
var McpServerScanEntry = external_exports.object({
|
|
16761
16135
|
// The server's config key ("github", "filesystem", …) — identity, with the
|
|
@@ -16837,6 +16211,164 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
|
16837
16211
|
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16838
16212
|
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16839
16213
|
|
|
16214
|
+
// ../../packages/schema/src/zod/rule.ts
|
|
16215
|
+
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
16216
|
+
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
16217
|
+
var KeywordMatcher = external_exports.strictObject({
|
|
16218
|
+
type: external_exports.literal("keyword"),
|
|
16219
|
+
// An empty keyword matches at every position, yielding one zero-length span
|
|
16220
|
+
// per character. Rejected here because a keyword that matches everything is
|
|
16221
|
+
// never intentional.
|
|
16222
|
+
keywords: external_exports.array(external_exports.string().min(1)).min(1),
|
|
16223
|
+
caseSensitive: external_exports.boolean().default(false)
|
|
16224
|
+
});
|
|
16225
|
+
function isValidRegex(pattern, flags) {
|
|
16226
|
+
try {
|
|
16227
|
+
new RegExp(pattern, flags);
|
|
16228
|
+
return true;
|
|
16229
|
+
} catch {
|
|
16230
|
+
return false;
|
|
16231
|
+
}
|
|
16232
|
+
}
|
|
16233
|
+
function probeFlags(flags) {
|
|
16234
|
+
return flags.replace(/[gy]/g, "");
|
|
16235
|
+
}
|
|
16236
|
+
function matchesEmptyString(pattern, flags) {
|
|
16237
|
+
try {
|
|
16238
|
+
const re = new RegExp(pattern, probeFlags(flags));
|
|
16239
|
+
return re.exec("")?.[0].length === 0;
|
|
16240
|
+
} catch {
|
|
16241
|
+
return false;
|
|
16242
|
+
}
|
|
16243
|
+
}
|
|
16244
|
+
function spansWholeMatch(captureGroup) {
|
|
16245
|
+
return captureGroup === void 0 || captureGroup === 0;
|
|
16246
|
+
}
|
|
16247
|
+
function captureGroupCount(pattern, flags) {
|
|
16248
|
+
try {
|
|
16249
|
+
const probe = new RegExp(`${pattern}|`, probeFlags(flags));
|
|
16250
|
+
const result = probe.exec("");
|
|
16251
|
+
return result ? result.length - 1 : void 0;
|
|
16252
|
+
} catch {
|
|
16253
|
+
return void 0;
|
|
16254
|
+
}
|
|
16255
|
+
}
|
|
16256
|
+
var MAX_PATTERN_LENGTH = 2e3;
|
|
16257
|
+
var RegexMatcher = external_exports.strictObject({
|
|
16258
|
+
type: external_exports.literal("regex"),
|
|
16259
|
+
pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
|
|
16260
|
+
flags: external_exports.string().default("gi"),
|
|
16261
|
+
captureGroup: external_exports.number().int().nonnegative().optional()
|
|
16262
|
+
}).refine((v) => isValidRegex(v.pattern, v.flags), {
|
|
16263
|
+
message: "pattern/flags do not form a valid JavaScript regular expression",
|
|
16264
|
+
path: ["pattern"]
|
|
16265
|
+
}).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
|
|
16266
|
+
message: 'a whole-match regex that can match the empty string (e.g. "\\d*", "a?", "(?:)") can hang the matcher \u2014 scope the quantifier to a captureGroup, or require at least one character',
|
|
16267
|
+
path: ["pattern"]
|
|
16268
|
+
}).superRefine((v, ctx) => {
|
|
16269
|
+
if (v.captureGroup === void 0) return;
|
|
16270
|
+
const groups = captureGroupCount(v.pattern, v.flags);
|
|
16271
|
+
if (groups === void 0 || v.captureGroup <= groups) return;
|
|
16272
|
+
ctx.addIssue({
|
|
16273
|
+
code: "custom",
|
|
16274
|
+
path: ["captureGroup"],
|
|
16275
|
+
message: `captureGroup ${String(v.captureGroup)} is out of range \u2014 the pattern declares ${String(groups)} capture group(s), so valid values are 0-${String(groups)}. An out-of-range group never matches, which would make the rule silently never fire.`
|
|
16276
|
+
});
|
|
16277
|
+
});
|
|
16278
|
+
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
|
|
16279
|
+
var MATCHER_TYPES = MatcherType.options;
|
|
16280
|
+
var AppliesTo = external_exports.strictObject({
|
|
16281
|
+
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
16282
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
16283
|
+
}).meta({ id: "AppliesTo" });
|
|
16284
|
+
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
16285
|
+
var PostValidatorRef = external_exports.union(
|
|
16286
|
+
[
|
|
16287
|
+
PostValidatorName,
|
|
16288
|
+
external_exports.strictObject({
|
|
16289
|
+
name: PostValidatorName,
|
|
16290
|
+
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16291
|
+
})
|
|
16292
|
+
],
|
|
16293
|
+
{
|
|
16294
|
+
// A union reports one collapsed issue for every way its arms can fail, so
|
|
16295
|
+
// this has to describe the whole shape rather than just the name — it is
|
|
16296
|
+
// what an author sees for a misspelled name AND for a stray key in the
|
|
16297
|
+
// object form. The names come from the enum so the message cannot go
|
|
16298
|
+
// stale. Without it Zod says only "Invalid input", which is precisely the
|
|
16299
|
+
// no-feedback outcome this schema exists to remove.
|
|
16300
|
+
error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
|
|
16301
|
+
" or "
|
|
16302
|
+
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
16303
|
+
}
|
|
16304
|
+
).meta({ id: "PostValidatorRef" });
|
|
16305
|
+
var RequiresNearby = external_exports.strictObject({
|
|
16306
|
+
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
16307
|
+
// an empty/blank criterion would either never fire or (for labels) match
|
|
16308
|
+
// everything.
|
|
16309
|
+
categories: external_exports.array(DetectionCategory).min(1).optional(),
|
|
16310
|
+
ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16311
|
+
labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16312
|
+
windowChars: external_exports.number().int().positive().default(160),
|
|
16313
|
+
// Optional confidence bump applied when a gated match is corroborated. Capped
|
|
16314
|
+
// small: it nudges confidence, it does not assert certainty.
|
|
16315
|
+
confidenceBoost: external_exports.number().min(0).max(0.3).optional()
|
|
16316
|
+
}).refine(
|
|
16317
|
+
(v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
|
|
16318
|
+
{ message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
|
|
16319
|
+
).meta({ id: "RequiresNearby" });
|
|
16320
|
+
var RuleFixture = external_exports.strictObject({
|
|
16321
|
+
label: external_exports.string(),
|
|
16322
|
+
text: external_exports.string().max(5e4),
|
|
16323
|
+
shouldMatch: external_exports.boolean(),
|
|
16324
|
+
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
16325
|
+
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
16326
|
+
filePath: external_exports.string().optional(),
|
|
16327
|
+
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
16328
|
+
}).meta({ id: "RuleFixture" });
|
|
16329
|
+
var Rule = external_exports.strictObject({
|
|
16330
|
+
// A pinned literal over a STRICT object, and the two together decide how this
|
|
16331
|
+
// format may grow. A rule carrying a key not listed below is refused with
|
|
16332
|
+
// `unrecognized_keys`; a rule declaring `specVersion: 2` is refused with
|
|
16333
|
+
// `invalid_value`. So the only additive path is adding an OPTIONAL field here
|
|
16334
|
+
// — that keeps every rule authored before it valid — and a rule author has no
|
|
16335
|
+
// way to introduce a field of their own or to opt into a later version.
|
|
16336
|
+
// Widening the format means changing this literal and every consumer of it.
|
|
16337
|
+
specVersion: external_exports.literal(1),
|
|
16338
|
+
// `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
|
|
16339
|
+
// the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
|
|
16340
|
+
// detection id (`namespace/packId`, decoded by splitDetectionId). A Rule.id
|
|
16341
|
+
// therefore carries no namespace and is not globally unique across publishers;
|
|
16342
|
+
// never feed one to splitDetectionId. `category` below (per-rule) is the
|
|
16343
|
+
// taxonomy axis; the pack's enforcement policy is installed_packs.policy_id.
|
|
16344
|
+
id: external_exports.string().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/),
|
|
16345
|
+
name: external_exports.string(),
|
|
16346
|
+
category: DetectionCategory,
|
|
16347
|
+
severity: Severity,
|
|
16348
|
+
matcher: Matcher,
|
|
16349
|
+
appliesTo: AppliesTo.optional(),
|
|
16350
|
+
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
16351
|
+
requiresNearby: RequiresNearby.optional(),
|
|
16352
|
+
examples: external_exports.array(external_exports.string()).optional()
|
|
16353
|
+
}).meta({ id: "Rule" });
|
|
16354
|
+
var Author = external_exports.object({
|
|
16355
|
+
name: external_exports.string(),
|
|
16356
|
+
email: external_exports.email().optional(),
|
|
16357
|
+
url: external_exports.url().optional()
|
|
16358
|
+
}).meta({ id: "Author" });
|
|
16359
|
+
var PackManifest = external_exports.object({
|
|
16360
|
+
specVersion: external_exports.literal(1),
|
|
16361
|
+
id: external_exports.string(),
|
|
16362
|
+
name: external_exports.string(),
|
|
16363
|
+
version: external_exports.string(),
|
|
16364
|
+
rules: external_exports.array(external_exports.string()),
|
|
16365
|
+
// Optional attribution/provenance — consumed by the rule marketplace.
|
|
16366
|
+
description: external_exports.string().optional(),
|
|
16367
|
+
author: Author.optional(),
|
|
16368
|
+
license: external_exports.string().optional(),
|
|
16369
|
+
sourceUrl: external_exports.url().optional()
|
|
16370
|
+
}).meta({ id: "PackManifest" });
|
|
16371
|
+
|
|
16840
16372
|
// ../../packages/schema/src/zod/detection.ts
|
|
16841
16373
|
var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
|
|
16842
16374
|
var DetectionFilterEnum = external_exports.enum(["all", "library", "custom", "customized", "updates"]);
|
|
@@ -17035,6 +16567,231 @@ function buildDetectionsList(summaries, query) {
|
|
|
17035
16567
|
return { counts, items: filtered.map(summaryToDetectionListItem) };
|
|
17036
16568
|
}
|
|
17037
16569
|
|
|
16570
|
+
// ../../packages/schema/src/zod/inventory.ts
|
|
16571
|
+
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
16572
|
+
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
16573
|
+
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
16574
|
+
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
16575
|
+
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
16576
|
+
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
16577
|
+
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
16578
|
+
var HarnessId = Harness.extract(["ClaudeCode", "Cursor", "Codex", "Antigravity"]).meta({
|
|
16579
|
+
id: "HarnessId"
|
|
16580
|
+
});
|
|
16581
|
+
var AccessCounts = external_exports.object({
|
|
16582
|
+
open: external_exports.number().int().nonnegative(),
|
|
16583
|
+
approved: external_exports.number().int().nonnegative(),
|
|
16584
|
+
blocked: external_exports.number().int().nonnegative(),
|
|
16585
|
+
total: external_exports.number().int().nonnegative()
|
|
16586
|
+
}).meta({ id: "AccessCounts" });
|
|
16587
|
+
var AssetSummary = external_exports.object({
|
|
16588
|
+
id: external_exports.string(),
|
|
16589
|
+
type: AssetType,
|
|
16590
|
+
name: external_exports.string(),
|
|
16591
|
+
sub: external_exports.string(),
|
|
16592
|
+
flags: external_exports.array(Flag),
|
|
16593
|
+
/** MCP servers only — omitted for all other types. */
|
|
16594
|
+
trust: TrustLevel.optional()
|
|
16595
|
+
}).meta({ id: "AssetSummary" });
|
|
16596
|
+
var ProjectSummary = external_exports.object({
|
|
16597
|
+
id: external_exports.string(),
|
|
16598
|
+
name: external_exports.string(),
|
|
16599
|
+
repo: external_exports.string(),
|
|
16600
|
+
visibility: Visibility,
|
|
16601
|
+
language: external_exports.string(),
|
|
16602
|
+
policyDefault: AccessLevel,
|
|
16603
|
+
updatedAt: external_exports.iso.datetime(),
|
|
16604
|
+
accessCounts: AccessCounts,
|
|
16605
|
+
findingsCount: external_exports.number().int().nonnegative()
|
|
16606
|
+
}).meta({ id: "ProjectSummary" });
|
|
16607
|
+
var HarnessCategory = external_exports.object({
|
|
16608
|
+
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
16609
|
+
type: AssetType,
|
|
16610
|
+
assets: external_exports.array(AssetSummary)
|
|
16611
|
+
});
|
|
16612
|
+
var HarnessSummary = external_exports.object({
|
|
16613
|
+
id: HarnessId,
|
|
16614
|
+
label: external_exports.string(),
|
|
16615
|
+
kind: external_exports.string(),
|
|
16616
|
+
version: external_exports.string(),
|
|
16617
|
+
sessions: external_exports.number().int().nonnegative(),
|
|
16618
|
+
assetCount: external_exports.number().int().nonnegative(),
|
|
16619
|
+
flagCount: external_exports.number().int().nonnegative(),
|
|
16620
|
+
projects: external_exports.array(ProjectSummary),
|
|
16621
|
+
categories: external_exports.array(HarnessCategory)
|
|
16622
|
+
}).meta({ id: "HarnessSummary" });
|
|
16623
|
+
var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
|
|
16624
|
+
var AssetGroup = external_exports.object({
|
|
16625
|
+
/** Group key — never project (enforced at service layer). */
|
|
16626
|
+
type: AssetType,
|
|
16627
|
+
total: external_exports.number().int().nonnegative(),
|
|
16628
|
+
/**
|
|
16629
|
+
* MCP group only — omitted for all other types.
|
|
16630
|
+
* Partial: only TrustLevel keys with non-zero counts are included.
|
|
16631
|
+
* Strict: unknown keys are rejected — only TrustLevel values are valid keys.
|
|
16632
|
+
*/
|
|
16633
|
+
trustRollup: external_exports.object({
|
|
16634
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16635
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16636
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16637
|
+
}).partial().strict().optional(),
|
|
16638
|
+
/**
|
|
16639
|
+
* Partial: only Flag keys with non-zero counts are included.
|
|
16640
|
+
* Strict: unknown keys are rejected — only Flag values are valid keys.
|
|
16641
|
+
*/
|
|
16642
|
+
flagRollup: external_exports.object({
|
|
16643
|
+
update: external_exports.number().int().nonnegative(),
|
|
16644
|
+
stale: external_exports.number().int().nonnegative(),
|
|
16645
|
+
conflict: external_exports.number().int().nonnegative(),
|
|
16646
|
+
unknown: external_exports.number().int().nonnegative(),
|
|
16647
|
+
change: external_exports.number().int().nonnegative(),
|
|
16648
|
+
untracked: external_exports.number().int().nonnegative(),
|
|
16649
|
+
risk: external_exports.number().int().nonnegative(),
|
|
16650
|
+
findings: external_exports.number().int().nonnegative()
|
|
16651
|
+
}).partial().strict(),
|
|
16652
|
+
items: external_exports.array(AssetSummary)
|
|
16653
|
+
}).meta({ id: "AssetGroup" });
|
|
16654
|
+
var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
|
|
16655
|
+
var McpTool = external_exports.object({
|
|
16656
|
+
name: external_exports.string(),
|
|
16657
|
+
signature: external_exports.string(),
|
|
16658
|
+
description: external_exports.string(),
|
|
16659
|
+
write: external_exports.boolean(),
|
|
16660
|
+
/** Non-null string when tool is dangerous / blocked; null otherwise. */
|
|
16661
|
+
risk: external_exports.string().nullable()
|
|
16662
|
+
}).meta({ id: "McpTool" });
|
|
16663
|
+
var AssetFindingRef = external_exports.object({
|
|
16664
|
+
id: external_exports.string(),
|
|
16665
|
+
title: external_exports.string(),
|
|
16666
|
+
note: external_exports.string()
|
|
16667
|
+
});
|
|
16668
|
+
var AssetDetail = AssetSummary.extend({
|
|
16669
|
+
/** string | null — null when no description is available. */
|
|
16670
|
+
description: external_exports.string().nullable(),
|
|
16671
|
+
/** trustLevel | null — null for non-MCP assets. */
|
|
16672
|
+
trust: TrustLevel.nullable(),
|
|
16673
|
+
/** Type-specific raw key/values — FE renders the grid. */
|
|
16674
|
+
meta: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
16675
|
+
/** always present — object when there is an active finding, null when absent. */
|
|
16676
|
+
finding: AssetFindingRef.nullable(),
|
|
16677
|
+
/** MCP exposed-tools list — omitted for non-mcp. */
|
|
16678
|
+
tools: external_exports.array(McpTool).optional()
|
|
16679
|
+
}).meta({ id: "AssetDetail" });
|
|
16680
|
+
var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
|
|
16681
|
+
var InventoryStats = external_exports.object({
|
|
16682
|
+
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16683
|
+
attention: external_exports.number().int().nonnegative(),
|
|
16684
|
+
byType: external_exports.object({
|
|
16685
|
+
project: external_exports.number().int().nonnegative(),
|
|
16686
|
+
skill: external_exports.number().int().nonnegative(),
|
|
16687
|
+
mcp: external_exports.number().int().nonnegative(),
|
|
16688
|
+
hook: external_exports.number().int().nonnegative(),
|
|
16689
|
+
config: external_exports.number().int().nonnegative()
|
|
16690
|
+
}),
|
|
16691
|
+
harnesses: external_exports.number().int().nonnegative(),
|
|
16692
|
+
mcpTrust: external_exports.object({
|
|
16693
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16694
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16695
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16696
|
+
})
|
|
16697
|
+
}).meta({ id: "InventoryStats" });
|
|
16698
|
+
var FileSummary = external_exports.object({
|
|
16699
|
+
path: external_exports.string(),
|
|
16700
|
+
name: external_exports.string(),
|
|
16701
|
+
origin: Origin,
|
|
16702
|
+
/** Effective access (override applied). */
|
|
16703
|
+
access: AccessLevel,
|
|
16704
|
+
/** True when a file_access_override differs from the computed default. */
|
|
16705
|
+
isCustom: external_exports.boolean(),
|
|
16706
|
+
findings: external_exports.number().int().nonnegative(),
|
|
16707
|
+
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16708
|
+
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16709
|
+
/** Why the file was blocked; null when absent. */
|
|
16710
|
+
note: external_exports.string().nullable().optional()
|
|
16711
|
+
}).meta({ id: "FileSummary" });
|
|
16712
|
+
var FolderSummary = external_exports.object({
|
|
16713
|
+
name: external_exports.string(),
|
|
16714
|
+
path: external_exports.string(),
|
|
16715
|
+
/** Rollup of effective access across all descendants. */
|
|
16716
|
+
accessCounts: AccessCounts
|
|
16717
|
+
}).meta({ id: "FolderSummary" });
|
|
16718
|
+
var ProjectTreeResponse = external_exports.object({
|
|
16719
|
+
project: external_exports.object({
|
|
16720
|
+
id: external_exports.string(),
|
|
16721
|
+
repo: external_exports.string(),
|
|
16722
|
+
visibility: Visibility
|
|
16723
|
+
}),
|
|
16724
|
+
path: external_exports.string(),
|
|
16725
|
+
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16726
|
+
folders: external_exports.array(FolderSummary).optional(),
|
|
16727
|
+
files: external_exports.array(FileSummary)
|
|
16728
|
+
}).meta({ id: "ProjectTreeResponse" });
|
|
16729
|
+
var FileDetail = FileSummary.extend({
|
|
16730
|
+
project: external_exports.object({
|
|
16731
|
+
repo: external_exports.string(),
|
|
16732
|
+
visibility: Visibility,
|
|
16733
|
+
language: external_exports.string(),
|
|
16734
|
+
policyDefault: AccessLevel,
|
|
16735
|
+
updatedAt: external_exports.iso.datetime()
|
|
16736
|
+
}),
|
|
16737
|
+
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16738
|
+
}).meta({ id: "FileDetail" });
|
|
16739
|
+
var SetFileAccessBody = external_exports.object({
|
|
16740
|
+
path: external_exports.string(),
|
|
16741
|
+
access: AccessLevel
|
|
16742
|
+
}).meta({ id: "SetFileAccessBody" });
|
|
16743
|
+
var SetFileAccessResponse = external_exports.object({
|
|
16744
|
+
file: FileSummary,
|
|
16745
|
+
accessCounts: AccessCounts
|
|
16746
|
+
}).meta({ id: "SetFileAccessResponse" });
|
|
16747
|
+
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16748
|
+
var HarnessEventItem = external_exports.object({
|
|
16749
|
+
kind: HarnessEventKind,
|
|
16750
|
+
title: external_exports.string(),
|
|
16751
|
+
detail: external_exports.string(),
|
|
16752
|
+
occurredAt: external_exports.iso.datetime(),
|
|
16753
|
+
findingId: external_exports.string().nullable().optional()
|
|
16754
|
+
}).meta({ id: "HarnessEventItem" });
|
|
16755
|
+
var HarnessEventsResponse = external_exports.object({
|
|
16756
|
+
counts: external_exports.object({
|
|
16757
|
+
block: external_exports.number().int().nonnegative(),
|
|
16758
|
+
redact: external_exports.number().int().nonnegative(),
|
|
16759
|
+
warn: external_exports.number().int().nonnegative()
|
|
16760
|
+
}),
|
|
16761
|
+
items: external_exports.array(HarnessEventItem)
|
|
16762
|
+
}).meta({ id: "HarnessEventsResponse" });
|
|
16763
|
+
var RescanResponse = external_exports.object({
|
|
16764
|
+
jobId: external_exports.string(),
|
|
16765
|
+
startedAt: external_exports.iso.datetime()
|
|
16766
|
+
}).meta({ id: "RescanResponse" });
|
|
16767
|
+
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16768
|
+
var ListAssetsQuery = external_exports.object({
|
|
16769
|
+
/** Filter by one or more AssetType values; absent means all types. */
|
|
16770
|
+
type: external_exports.array(AssetType).optional(),
|
|
16771
|
+
/** Free-text search term. */
|
|
16772
|
+
q: external_exports.string().optional()
|
|
16773
|
+
});
|
|
16774
|
+
var GetProjectTreeQuery = external_exports.object({
|
|
16775
|
+
/** Subtree root path; defaults to repository root when absent. */
|
|
16776
|
+
path: external_exports.string().optional(),
|
|
16777
|
+
/** Free-text filter applied to file paths. */
|
|
16778
|
+
q: external_exports.string().optional(),
|
|
16779
|
+
/**
|
|
16780
|
+
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16781
|
+
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16782
|
+
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16783
|
+
*/
|
|
16784
|
+
filter: external_exports.enum(["blocked"]).optional()
|
|
16785
|
+
});
|
|
16786
|
+
var GetProjectFileQuery = external_exports.object({
|
|
16787
|
+
/** Repository-relative file path; absent or empty → 400. */
|
|
16788
|
+
path: external_exports.string()
|
|
16789
|
+
});
|
|
16790
|
+
var GetHarnessEventsQuery = external_exports.object({
|
|
16791
|
+
/** Maximum number of events to return. Range: 1–50; default: 7. */
|
|
16792
|
+
limit: external_exports.coerce.number().int().min(1).max(50).default(7)
|
|
16793
|
+
});
|
|
16794
|
+
|
|
17038
16795
|
// ../../packages/schema/src/zod/shares.ts
|
|
17039
16796
|
var DestinationKind = external_exports.enum(["provider", "internal", "external", "ip"]).meta({ id: "DestinationKind" });
|
|
17040
16797
|
var Transport = external_exports.enum(["https", "http", "sftp", "grpc", "smtp", "ws", "wss"]).meta({ id: "Transport" });
|
|
@@ -17241,6 +16998,127 @@ var EgressWriteSummary = external_exports.object({
|
|
|
17241
16998
|
droppedFiles: external_exports.array(external_exports.string()).default([])
|
|
17242
16999
|
}).meta({ id: "EgressWriteSummary" });
|
|
17243
17000
|
|
|
17001
|
+
// ../../packages/schema/src/zod/event.ts
|
|
17002
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
17003
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
17004
|
+
var EventMetadata = external_exports.object({
|
|
17005
|
+
sessionId: external_exports.string().optional(),
|
|
17006
|
+
repo: external_exports.string().optional(),
|
|
17007
|
+
filePath: external_exports.string().optional(),
|
|
17008
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
17009
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
17010
|
+
// arguments or output, which can carry the very value a finding masked
|
|
17011
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
17012
|
+
// display location ("via Bash") when no filePath exists.
|
|
17013
|
+
toolName: external_exports.string().optional(),
|
|
17014
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
17015
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
17016
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
17017
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
17018
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
17019
|
+
gitignored: external_exports.boolean().optional(),
|
|
17020
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
17021
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
17022
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
17023
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
17024
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
17025
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
17026
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
17027
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
17028
|
+
// non-authoritative path.
|
|
17029
|
+
wholeFile: external_exports.boolean().optional(),
|
|
17030
|
+
model: external_exports.string().optional(),
|
|
17031
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
17032
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
17033
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
17034
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
17035
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
17036
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
17037
|
+
correlationId: external_exports.uuid().optional(),
|
|
17038
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
17039
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
17040
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
17041
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
17042
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
17043
|
+
}).meta({ id: "EventMetadata" });
|
|
17044
|
+
var Event = external_exports.object({
|
|
17045
|
+
id: external_exports.guid(),
|
|
17046
|
+
sourceTool: SourceTool,
|
|
17047
|
+
kind: EventKind,
|
|
17048
|
+
occurredAt: external_exports.iso.datetime(),
|
|
17049
|
+
contentHash: external_exports.string(),
|
|
17050
|
+
content: external_exports.string(),
|
|
17051
|
+
metadata: EventMetadata.optional()
|
|
17052
|
+
}).meta({ id: "Event" });
|
|
17053
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
17054
|
+
var IngestBatch = external_exports.object({
|
|
17055
|
+
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
17056
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
17057
|
+
// additionally rejects any event whose contentHash the store has already
|
|
17058
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
17059
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
17060
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
17061
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
17062
|
+
// the timeline.
|
|
17063
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
17064
|
+
}).meta({ id: "IngestBatch" });
|
|
17065
|
+
|
|
17066
|
+
// ../../packages/schema/src/zod/exception.ts
|
|
17067
|
+
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
17068
|
+
var ExceptionConditions = external_exports.object({
|
|
17069
|
+
repo: external_exports.string().optional(),
|
|
17070
|
+
sourceTool: external_exports.string().optional(),
|
|
17071
|
+
provider: external_exports.string().optional()
|
|
17072
|
+
}).strict();
|
|
17073
|
+
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
17074
|
+
var DetectionException = external_exports.object({
|
|
17075
|
+
id: external_exports.guid(),
|
|
17076
|
+
ruleId: external_exports.string(),
|
|
17077
|
+
// Denormalized from the rule, for reporting — never matched on.
|
|
17078
|
+
category: DetectionCategory,
|
|
17079
|
+
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
17080
|
+
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
17081
|
+
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
17082
|
+
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
17083
|
+
// at the boundary rather than persisted.
|
|
17084
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17085
|
+
// Version of the fingerprint key the grant was written under; a rotated key
|
|
17086
|
+
// invalidates old grants rather than silently mismatching them.
|
|
17087
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17088
|
+
// maskMatch() preview of the approved value — never the raw value.
|
|
17089
|
+
maskedValue: external_exports.string(),
|
|
17090
|
+
capability: ExceptionCapability.default("suppress"),
|
|
17091
|
+
scope: ExceptionScope,
|
|
17092
|
+
expiresAt: external_exports.iso.datetime().nullable(),
|
|
17093
|
+
maxUses: external_exports.number().int().positive().nullable(),
|
|
17094
|
+
useCount: external_exports.number().int().nonnegative(),
|
|
17095
|
+
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
17096
|
+
// Mandatory: every grant carries the human reason it exists.
|
|
17097
|
+
justification: external_exports.string().min(1),
|
|
17098
|
+
conditions: ExceptionConditions.nullable(),
|
|
17099
|
+
createdBy: external_exports.string(),
|
|
17100
|
+
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
17101
|
+
createdAt: external_exports.iso.datetime(),
|
|
17102
|
+
updatedAt: external_exports.iso.datetime(),
|
|
17103
|
+
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
17104
|
+
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
17105
|
+
revokedAt: external_exports.iso.datetime().nullable(),
|
|
17106
|
+
revokedBy: external_exports.string().nullable(),
|
|
17107
|
+
revokeReason: external_exports.string().nullable()
|
|
17108
|
+
});
|
|
17109
|
+
var ExceptionBundleEntry = DetectionException.pick({
|
|
17110
|
+
id: true,
|
|
17111
|
+
ruleId: true,
|
|
17112
|
+
valueFingerprint: true,
|
|
17113
|
+
keyVersion: true,
|
|
17114
|
+
capability: true,
|
|
17115
|
+
expiresAt: true,
|
|
17116
|
+
maxUses: true,
|
|
17117
|
+
useCount: true,
|
|
17118
|
+
conditions: true
|
|
17119
|
+
});
|
|
17120
|
+
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
17121
|
+
|
|
17244
17122
|
// ../../packages/schema/src/zod/exception-action.ts
|
|
17245
17123
|
var confirmation = external_exports.string().optional();
|
|
17246
17124
|
var ApproveBlockedInput = external_exports.object({
|
|
@@ -17283,10 +17161,11 @@ function toApiAction(dbVal) {
|
|
|
17283
17161
|
}
|
|
17284
17162
|
function toApiCategory(dbVal) {
|
|
17285
17163
|
if (dbVal === "code_context") return "source_code";
|
|
17286
|
-
|
|
17164
|
+
const parsed = FindingCategory.safeParse(dbVal);
|
|
17165
|
+
return parsed.success ? parsed.data : "custom";
|
|
17287
17166
|
}
|
|
17288
17167
|
function toApiProvider(sourceTool) {
|
|
17289
|
-
return TOOL_TO_HARNESS[sourceTool] ??
|
|
17168
|
+
return TOOL_TO_HARNESS[sourceTool] ?? HARNESS.Api;
|
|
17290
17169
|
}
|
|
17291
17170
|
var STATUS_PRECEDENCE = ["open", "handled", "dismissed", "resolved"];
|
|
17292
17171
|
function foldGroupStatus(instanceStatuses) {
|
|
@@ -17858,6 +17737,7 @@ var ListVaultDerefsResponse = external_exports.object({
|
|
|
17858
17737
|
});
|
|
17859
17738
|
var VaultKeyCustody = external_exports.string();
|
|
17860
17739
|
var VaultInlineReveal = external_exports.enum(["masked", "full", "off"]);
|
|
17740
|
+
var VAULT_CONSENT_VERSION = 1;
|
|
17861
17741
|
var VaultConsent = external_exports.object({
|
|
17862
17742
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
17863
17743
|
version: external_exports.number().int().positive()
|
|
@@ -17865,7 +17745,14 @@ var VaultConsent = external_exports.object({
|
|
|
17865
17745
|
|
|
17866
17746
|
// ../../packages/schema/src/zod/local.ts
|
|
17867
17747
|
var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
|
|
17868
|
-
var
|
|
17748
|
+
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
17749
|
+
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
17750
|
+
var ControlPlaneConnection = external_exports.object({
|
|
17751
|
+
endpoint: external_exports.string().min(1),
|
|
17752
|
+
// Display name for the deployment, shown instead of the raw endpoint.
|
|
17753
|
+
label: external_exports.string().min(1).optional(),
|
|
17754
|
+
attachedAt: external_exports.iso.datetime()
|
|
17755
|
+
}).meta({ id: "ControlPlaneConnection" });
|
|
17869
17756
|
var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
|
|
17870
17757
|
var HistoricalAccess = external_exports.enum(["full", "session-only"]);
|
|
17871
17758
|
var ModelJudgeConsent = external_exports.object({
|
|
@@ -17874,12 +17761,10 @@ var ModelJudgeConsent = external_exports.object({
|
|
|
17874
17761
|
});
|
|
17875
17762
|
var WorkspaceSettings = external_exports.object({
|
|
17876
17763
|
specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
|
|
17877
|
-
|
|
17878
|
-
//
|
|
17879
|
-
runMode:
|
|
17880
|
-
|
|
17881
|
-
RunMode.default("standalone")
|
|
17882
|
-
),
|
|
17764
|
+
runMode: RunMode.default("standalone"),
|
|
17765
|
+
// Present only while attached; a detach clears it. Its presence is what makes
|
|
17766
|
+
// `runMode: 'attached'` mean anything — see isAttached.
|
|
17767
|
+
controlPlane: ControlPlaneConnection.optional(),
|
|
17883
17768
|
policy: SimpleDetectionPolicy.default("redact"),
|
|
17884
17769
|
// Consent for scanning pre-install surfaces; opt-in (see HistoricalAccess).
|
|
17885
17770
|
historicalAccess: HistoricalAccess.default("session-only"),
|
|
@@ -18015,6 +17900,211 @@ function toCaptureDefinitionInput(finding) {
|
|
|
18015
17900
|
};
|
|
18016
17901
|
}
|
|
18017
17902
|
|
|
17903
|
+
// ../../packages/schema/src/zod/managed.ts
|
|
17904
|
+
var MANAGED_SETTINGS_FILENAME = "managed-settings.json";
|
|
17905
|
+
var MANAGED_SETTINGS_SPEC_VERSION = 1;
|
|
17906
|
+
var ManagedSettingKey = external_exports.enum([
|
|
17907
|
+
"runMode",
|
|
17908
|
+
"historicalAccess",
|
|
17909
|
+
"vaultConsent",
|
|
17910
|
+
"vaultKeyCustody",
|
|
17911
|
+
"vaultInlineReveal",
|
|
17912
|
+
"modelJudgeConsent",
|
|
17913
|
+
"dataSharesInPlace"
|
|
17914
|
+
]).meta({ id: "ManagedSettingKey" });
|
|
17915
|
+
var ManagedSettingsValues = external_exports.object({
|
|
17916
|
+
runMode: external_exports.enum(["standalone", "attached"]).optional(),
|
|
17917
|
+
controlPlane: external_exports.object({
|
|
17918
|
+
endpoint: external_exports.string().min(1),
|
|
17919
|
+
label: external_exports.string().min(1).optional()
|
|
17920
|
+
}).optional(),
|
|
17921
|
+
historicalAccess: external_exports.enum(["full", "session-only"]).optional(),
|
|
17922
|
+
vaultConsent: external_exports.boolean().optional(),
|
|
17923
|
+
vaultKeyCustody: external_exports.enum(["file", "keychain"]).optional(),
|
|
17924
|
+
vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
|
|
17925
|
+
modelJudgeConsent: external_exports.boolean().optional(),
|
|
17926
|
+
dataSharesInPlace: external_exports.boolean().optional()
|
|
17927
|
+
}).meta({ id: "ManagedSettingsValues" });
|
|
17928
|
+
var ManagedSettings = external_exports.object({
|
|
17929
|
+
specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
|
|
17930
|
+
// Shown on every locked control, so the user can tell an administrative
|
|
17931
|
+
// decision from a bug. Absent renders as a generic "your organization".
|
|
17932
|
+
organization: external_exports.string().min(1).optional(),
|
|
17933
|
+
// What the administrator pinned.
|
|
17934
|
+
values: ManagedSettingsValues.default({}),
|
|
17935
|
+
// Which of those the user may not change. A key here with no matching value
|
|
17936
|
+
// freezes whatever the user last chose; a value with no lock is a DEFAULT
|
|
17937
|
+
// the user may still override. The two are separable on purpose.
|
|
17938
|
+
lockedFields: external_exports.array(ManagedSettingKey).default([])
|
|
17939
|
+
}).meta({ id: "ManagedSettings" });
|
|
17940
|
+
|
|
17941
|
+
// ../../packages/schema/src/zod/policy.ts
|
|
17942
|
+
var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
|
|
17943
|
+
var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
|
|
17944
|
+
var Policy = external_exports.object({
|
|
17945
|
+
id: external_exports.guid(),
|
|
17946
|
+
scope: PolicyScope,
|
|
17947
|
+
target: PolicyTarget,
|
|
17948
|
+
action: ActionTaken,
|
|
17949
|
+
enabled: external_exports.boolean().default(true),
|
|
17950
|
+
customKeywords: external_exports.array(external_exports.string()).optional(),
|
|
17951
|
+
// Display name — optional so older policy rows without name still parse.
|
|
17952
|
+
// Added for the findings API (policy.name column migration).
|
|
17953
|
+
name: external_exports.string().optional()
|
|
17954
|
+
}).meta({ id: "Policy" });
|
|
17955
|
+
var PolicyBundle = external_exports.object({
|
|
17956
|
+
version: external_exports.string(),
|
|
17957
|
+
policies: external_exports.array(Policy),
|
|
17958
|
+
// Rules from the installed marketplace packs (snapshotted by the
|
|
17959
|
+
// control plane). The plugin registers these in addition to its bundled
|
|
17960
|
+
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
17961
|
+
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
17962
|
+
rules: external_exports.array(Rule).optional(),
|
|
17963
|
+
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
17964
|
+
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
17965
|
+
// after reading the user's installed snapshot (installed_packs, enabled
|
|
17966
|
+
// packs only), which is how detection updates stay manual: new bundled
|
|
17967
|
+
// rules run only after the user applies the pack update. Absent/false keeps
|
|
17968
|
+
// the historical composition (bundled packs + rules) — older caches.
|
|
17969
|
+
rulesComplete: external_exports.boolean().optional(),
|
|
17970
|
+
// Active detection exceptions, evaluation subset only (see
|
|
17971
|
+
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
17972
|
+
// on-disk caches — that omit the field still parse; consumers read
|
|
17973
|
+
// `bundle.exceptions ?? []`.
|
|
17974
|
+
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
17975
|
+
// Rule ids whose pack is assigned a REVERSIBLE archetype (Redact & Vault).
|
|
17976
|
+
// A second axis over the same `redact` action, carried beside the policies
|
|
17977
|
+
// rather than on them: nothing writes ruleId-targeted policies to disk, so
|
|
17978
|
+
// widening Policy itself would change a persisted shape to express something
|
|
17979
|
+
// only the in-memory bundle needs. Optional so an older producer — or an
|
|
17980
|
+
// older on-disk cache — still parses; consumers read `?? []` and get the
|
|
17981
|
+
// pre-existing one-way behaviour, which is the safe direction to default.
|
|
17982
|
+
reversibleRuleIds: external_exports.array(external_exports.string()).optional(),
|
|
17983
|
+
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
17984
|
+
// from a versioned installed pack. Optional so older backends — and older
|
|
17985
|
+
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
17986
|
+
// the rule's own spec version. NOT the bundle version above — see
|
|
17987
|
+
// installedRuleset's ruleVersions for the source of truth.
|
|
17988
|
+
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
17989
|
+
customKeywords: external_exports.array(external_exports.string()),
|
|
17990
|
+
fetchedAt: external_exports.iso.datetime()
|
|
17991
|
+
}).meta({ id: "PolicyBundle" });
|
|
17992
|
+
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
17993
|
+
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
17994
|
+
var CATEGORY_PEAK_SEVERITY = {
|
|
17995
|
+
secret: "critical",
|
|
17996
|
+
financial: "critical",
|
|
17997
|
+
// core-financial/credit-card
|
|
17998
|
+
code_flaw: "critical",
|
|
17999
|
+
pii: "high",
|
|
18000
|
+
phi: "high",
|
|
18001
|
+
custom: "high",
|
|
18002
|
+
// user-defined; conservative
|
|
18003
|
+
code_context: "low",
|
|
18004
|
+
config: "low"
|
|
18005
|
+
// observe-only; floors to monitor regardless
|
|
18006
|
+
};
|
|
18007
|
+
function severityFloorPolicy(category) {
|
|
18008
|
+
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
18009
|
+
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
18010
|
+
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
18011
|
+
}
|
|
18012
|
+
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
18013
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
18014
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
18015
|
+
var BUILTIN_ORDER = KNOWN_BUILTIN_IDS;
|
|
18016
|
+
var BUILTIN_POLICY_SPECS = {
|
|
18017
|
+
monitor: {
|
|
18018
|
+
name: "Monitor",
|
|
18019
|
+
action: "log",
|
|
18020
|
+
reversible: false,
|
|
18021
|
+
description: "Log every match for audit. The request is allowed through untouched."
|
|
18022
|
+
},
|
|
18023
|
+
warn: {
|
|
18024
|
+
name: "Warn",
|
|
18025
|
+
action: "warn",
|
|
18026
|
+
reversible: false,
|
|
18027
|
+
description: "Allow the request, but warn the user inline before it is sent."
|
|
18028
|
+
},
|
|
18029
|
+
redact: {
|
|
18030
|
+
name: "Redact",
|
|
18031
|
+
action: "redact",
|
|
18032
|
+
reversible: false,
|
|
18033
|
+
description: "Strip the matched value from the request and destroy it, then continue. What was removed cannot be recovered."
|
|
18034
|
+
},
|
|
18035
|
+
vault: {
|
|
18036
|
+
name: "Redact & Vault",
|
|
18037
|
+
action: "redact",
|
|
18038
|
+
reversible: true,
|
|
18039
|
+
description: "Strip the matched value from the request and keep an encrypted, recoverable copy in the local vault, leaving a pointer in its place. Needs the vault consent granted under Settings; without it this behaves as Redact."
|
|
18040
|
+
},
|
|
18041
|
+
block: {
|
|
18042
|
+
name: "Block",
|
|
18043
|
+
action: "block",
|
|
18044
|
+
reversible: false,
|
|
18045
|
+
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
18046
|
+
}
|
|
18047
|
+
};
|
|
18048
|
+
function builtinPolicyToAction(id) {
|
|
18049
|
+
return BUILTIN_POLICY_SPECS[id].action;
|
|
18050
|
+
}
|
|
18051
|
+
var CATEGORY_EXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
18052
|
+
(id) => !BUILTIN_POLICY_SPECS[id].reversible
|
|
18053
|
+
);
|
|
18054
|
+
var CATEGORY_INEXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
18055
|
+
(id) => BUILTIN_POLICY_SPECS[id].reversible
|
|
18056
|
+
);
|
|
18057
|
+
var CategoryPolicyId = external_exports.enum(CATEGORY_EXPRESSIBLE_IDS).meta({ id: "CategoryPolicyId" });
|
|
18058
|
+
function builtinPolicyIsReversible(id) {
|
|
18059
|
+
return BUILTIN_POLICY_SPECS[id].reversible;
|
|
18060
|
+
}
|
|
18061
|
+
function policyIdIsReversible(policyId) {
|
|
18062
|
+
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
18063
|
+
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
18064
|
+
return builtinPolicyIsReversible(id);
|
|
18065
|
+
}
|
|
18066
|
+
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
18067
|
+
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
18068
|
+
);
|
|
18069
|
+
var BUILTIN_POLICIES = Object.fromEntries(
|
|
18070
|
+
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
18071
|
+
);
|
|
18072
|
+
var DEFAULT_PACK_POLICY_ID = "monitor";
|
|
18073
|
+
function policyIdToAction(policyId) {
|
|
18074
|
+
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
18075
|
+
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
18076
|
+
return BUILTIN_POLICIES[id].action;
|
|
18077
|
+
}
|
|
18078
|
+
var UsedByItem = external_exports.object({
|
|
18079
|
+
id: external_exports.string(),
|
|
18080
|
+
name: external_exports.string(),
|
|
18081
|
+
ruleCount: external_exports.number().int().nonnegative(),
|
|
18082
|
+
enabled: external_exports.boolean()
|
|
18083
|
+
}).meta({ id: "UsedByItem" });
|
|
18084
|
+
var PolicyListItem = external_exports.object({
|
|
18085
|
+
id: external_exports.string(),
|
|
18086
|
+
kind: PolicyKind,
|
|
18087
|
+
name: external_exports.string(),
|
|
18088
|
+
enabled: external_exports.boolean(),
|
|
18089
|
+
usedByCount: external_exports.number().int().nonnegative()
|
|
18090
|
+
}).meta({ id: "PolicyListItem" });
|
|
18091
|
+
var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
|
|
18092
|
+
var PolicyDetail = external_exports.object({
|
|
18093
|
+
specVersion: external_exports.literal(1),
|
|
18094
|
+
id: external_exports.string(),
|
|
18095
|
+
kind: PolicyKind,
|
|
18096
|
+
name: external_exports.string(),
|
|
18097
|
+
enabled: external_exports.boolean(),
|
|
18098
|
+
description: external_exports.string(),
|
|
18099
|
+
usedBy: external_exports.array(UsedByItem)
|
|
18100
|
+
}).meta({ id: "PolicyDetail" });
|
|
18101
|
+
var PolicyStatsResponse = external_exports.object({
|
|
18102
|
+
policies: external_exports.number().int().nonnegative(),
|
|
18103
|
+
builtin: external_exports.number().int().nonnegative(),
|
|
18104
|
+
custom: external_exports.number().int().nonnegative(),
|
|
18105
|
+
detectionsGoverned: external_exports.number().int().nonnegative()
|
|
18106
|
+
}).meta({ id: "PolicyStatsResponse" });
|
|
18107
|
+
|
|
18018
18108
|
// ../../packages/schema/src/zod/project-files.ts
|
|
18019
18109
|
var ProjectFileInput = external_exports.object({
|
|
18020
18110
|
path: external_exports.string().min(1),
|
|
@@ -18093,44 +18183,6 @@ var BatchedRemediation = external_exports.discriminatedUnion("kind", [
|
|
|
18093
18183
|
NoRemediationDecision
|
|
18094
18184
|
]);
|
|
18095
18185
|
|
|
18096
|
-
// ../../packages/schema/src/zod/rule-test.ts
|
|
18097
|
-
var TestRulesRequest = external_exports.object({
|
|
18098
|
-
rules: external_exports.array(Rule).min(1).max(100),
|
|
18099
|
-
text: external_exports.string().max(5e4).optional(),
|
|
18100
|
-
fixtures: external_exports.array(RuleFixture).max(200).optional()
|
|
18101
|
-
}).refine((v) => v.text !== void 0 || (v.fixtures?.length ?? 0) > 0, {
|
|
18102
|
-
message: "Provide `text`, `fixtures`, or both \u2014 there must be something to test"
|
|
18103
|
-
}).meta({ id: "TestRulesRequest" });
|
|
18104
|
-
var RuleTestMatch = external_exports.object({
|
|
18105
|
-
ruleId: external_exports.string(),
|
|
18106
|
-
category: DetectionCategory,
|
|
18107
|
-
severity: Severity,
|
|
18108
|
-
span: Span,
|
|
18109
|
-
confidence: external_exports.number().min(0).max(1),
|
|
18110
|
-
match: external_exports.string()
|
|
18111
|
-
}).meta({ id: "RuleTestMatch" });
|
|
18112
|
-
var FixtureResult = external_exports.object({
|
|
18113
|
-
label: external_exports.string(),
|
|
18114
|
-
shouldMatch: external_exports.boolean(),
|
|
18115
|
-
didMatch: external_exports.boolean(),
|
|
18116
|
-
passed: external_exports.boolean(),
|
|
18117
|
-
matches: external_exports.array(RuleTestMatch)
|
|
18118
|
-
}).meta({ id: "FixtureResult" });
|
|
18119
|
-
var TestRulesResponse = external_exports.object({
|
|
18120
|
-
// Present only when the request supplied `text`.
|
|
18121
|
-
adhoc: external_exports.object({ matches: external_exports.array(RuleTestMatch) }).optional(),
|
|
18122
|
-
fixtures: external_exports.array(FixtureResult),
|
|
18123
|
-
summary: external_exports.object({
|
|
18124
|
-
total: external_exports.number().int().nonnegative(),
|
|
18125
|
-
passed: external_exports.number().int().nonnegative(),
|
|
18126
|
-
failed: external_exports.number().int().nonnegative()
|
|
18127
|
-
}),
|
|
18128
|
-
// Ids of rules whose matcher type the engine cannot evaluate today (e.g.
|
|
18129
|
-
// `validator`), so they silently never match. Surfaced so an author is not
|
|
18130
|
-
// misled by a green run that actually skipped a rule.
|
|
18131
|
-
unsupportedRuleIds: external_exports.array(external_exports.string())
|
|
18132
|
-
}).meta({ id: "TestRulesResponse" });
|
|
18133
|
-
|
|
18134
18186
|
// ../../packages/schema/src/zod/security.ts
|
|
18135
18187
|
var SeveritySummaryItem = external_exports.object({
|
|
18136
18188
|
severity: Severity,
|
|
@@ -18228,10 +18280,22 @@ var TopSourcesQuery = external_exports.object({
|
|
|
18228
18280
|
// Omit for both kinds.
|
|
18229
18281
|
kind: external_exports.enum(SOURCE_KINDS).optional()
|
|
18230
18282
|
});
|
|
18231
|
-
var Provider =
|
|
18283
|
+
var Provider = Harness.extract([
|
|
18284
|
+
"ClaudeCode",
|
|
18285
|
+
"Cursor",
|
|
18286
|
+
"Codex",
|
|
18287
|
+
"Antigravity",
|
|
18288
|
+
"ClaudeAi",
|
|
18289
|
+
"ChatGpt",
|
|
18290
|
+
"Copilot",
|
|
18291
|
+
"Api"
|
|
18292
|
+
]).meta({ id: "Provider" });
|
|
18232
18293
|
var ScanCoverageProvider = external_exports.object({
|
|
18233
18294
|
provider: Provider,
|
|
18234
|
-
// Percent of that provider's traffic
|
|
18295
|
+
// Percent of that provider's traffic the shipped capture surface reaches.
|
|
18296
|
+
// A curated business fact, constant across every `range` — not a measured
|
|
18297
|
+
// per-window metric. 0 exactly when `supported` is false. See the comment
|
|
18298
|
+
// above the block for where these numbers are decided.
|
|
18235
18299
|
coverage: external_exports.number().int().min(0).max(100),
|
|
18236
18300
|
supported: external_exports.boolean()
|
|
18237
18301
|
}).meta({ id: "ScanCoverageProvider" });
|
|
@@ -18285,6 +18349,18 @@ var ApplyRecommendedActionResponse = external_exports.object({
|
|
|
18285
18349
|
var DismissRecommendedActionResponse = external_exports.object({ id: external_exports.string(), status: external_exports.literal("dismissed") }).meta({ id: "DismissRecommendedActionResponse" });
|
|
18286
18350
|
var RecommendedActionIdParam = external_exports.object({ id: external_exports.string() });
|
|
18287
18351
|
|
|
18352
|
+
// ../../packages/schema/src/zod/settings-action.ts
|
|
18353
|
+
var SaveSettingsInput = external_exports.object({
|
|
18354
|
+
historicalAccess: external_exports.string(),
|
|
18355
|
+
modelJudgeConsent: external_exports.boolean(),
|
|
18356
|
+
vaultConsent: external_exports.string(),
|
|
18357
|
+
vaultInlineReveal: external_exports.string()
|
|
18358
|
+
});
|
|
18359
|
+
var AttachInput = external_exports.object({
|
|
18360
|
+
endpoint: external_exports.string(),
|
|
18361
|
+
label: external_exports.string().optional()
|
|
18362
|
+
});
|
|
18363
|
+
|
|
18288
18364
|
// ../../packages/schema/src/zod/triage.ts
|
|
18289
18365
|
var TriageHit = external_exports.object({
|
|
18290
18366
|
ruleId: external_exports.string(),
|
|
@@ -18299,7 +18375,7 @@ var TriageHit = external_exports.object({
|
|
|
18299
18375
|
valueFingerprint: external_exports.string().optional(),
|
|
18300
18376
|
keyVersion: external_exports.number().int().nonnegative().optional()
|
|
18301
18377
|
});
|
|
18302
|
-
var TriagePolicy =
|
|
18378
|
+
var TriagePolicy = CategoryPolicyId;
|
|
18303
18379
|
var TriageCategoryRec = external_exports.object({
|
|
18304
18380
|
category: DetectionCategory,
|
|
18305
18381
|
action: TriagePolicy,
|
|
@@ -18517,8 +18593,11 @@ function chmodBestEffort(path, mode) {
|
|
|
18517
18593
|
function tightenDir(dir) {
|
|
18518
18594
|
chmodBestEffort(dir, DATA_DIR_MODE);
|
|
18519
18595
|
}
|
|
18596
|
+
function mkdirOwnerOnlySync(dir, recursive = false) {
|
|
18597
|
+
mkdirSync(dir, { recursive, mode: DATA_DIR_MODE });
|
|
18598
|
+
}
|
|
18520
18599
|
function ensureDataDirSync(dir) {
|
|
18521
|
-
|
|
18600
|
+
mkdirOwnerOnlySync(dir, true);
|
|
18522
18601
|
tightenDir(dir);
|
|
18523
18602
|
}
|
|
18524
18603
|
function dbSidecars(file2) {
|
|
@@ -18536,6 +18615,25 @@ function backupPath(file2, tag) {
|
|
|
18536
18615
|
return `${file2}.${tag}.${String(Date.now())}.${randomUUID().slice(0, 8)}.bak`;
|
|
18537
18616
|
}
|
|
18538
18617
|
var STALE_PARTIAL_MS = 5 * 6e4;
|
|
18618
|
+
var SNAPSHOT_STAGING_SUFFIX = ".partial";
|
|
18619
|
+
var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18620
|
+
var SNAPSHOT_STAGING_COPY = "copy";
|
|
18621
|
+
function createSnapshotStaging(backup) {
|
|
18622
|
+
const stage = `${backup}${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18623
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18624
|
+
mkdirOwnerOnlySync(stage);
|
|
18625
|
+
tightenDir(stage);
|
|
18626
|
+
return { stage, copy: join(stage, SNAPSHOT_STAGING_COPY) };
|
|
18627
|
+
}
|
|
18628
|
+
function idleMs(entry) {
|
|
18629
|
+
for (const candidate of [join(entry, SNAPSHOT_STAGING_COPY), entry]) {
|
|
18630
|
+
try {
|
|
18631
|
+
return Date.now() - statSync(candidate).mtimeMs;
|
|
18632
|
+
} catch {
|
|
18633
|
+
}
|
|
18634
|
+
}
|
|
18635
|
+
return null;
|
|
18636
|
+
}
|
|
18539
18637
|
function reapStalePartials(file2) {
|
|
18540
18638
|
const dir = dirname(file2);
|
|
18541
18639
|
const prefix = `${basename(file2)}.`;
|
|
@@ -18546,30 +18644,34 @@ function reapStalePartials(file2) {
|
|
|
18546
18644
|
return;
|
|
18547
18645
|
}
|
|
18548
18646
|
for (const name of entries) {
|
|
18549
|
-
if (!name.startsWith(prefix) || !name.endsWith(
|
|
18550
|
-
const
|
|
18647
|
+
if (!name.startsWith(prefix) || !name.endsWith(STAGED_NAME_SUFFIX)) continue;
|
|
18648
|
+
const staging = join(dir, name);
|
|
18551
18649
|
try {
|
|
18552
|
-
|
|
18553
|
-
|
|
18650
|
+
const idle = idleMs(staging);
|
|
18651
|
+
if (idle !== null && idle > STALE_PARTIAL_MS) {
|
|
18652
|
+
rmSync2(staging, { recursive: true, force: true });
|
|
18554
18653
|
}
|
|
18555
18654
|
} catch {
|
|
18556
18655
|
}
|
|
18557
18656
|
}
|
|
18558
18657
|
}
|
|
18559
18658
|
function snapshotStore(db, backup) {
|
|
18560
|
-
const
|
|
18659
|
+
const { stage, copy } = createSnapshotStaging(backup);
|
|
18561
18660
|
try {
|
|
18562
|
-
|
|
18563
|
-
|
|
18564
|
-
|
|
18565
|
-
renameSync2(partial2, backup);
|
|
18661
|
+
db.prepare("VACUUM INTO ?").run(copy);
|
|
18662
|
+
tightenFile(copy);
|
|
18663
|
+
renameSync2(copy, backup);
|
|
18566
18664
|
} catch (error51) {
|
|
18567
18665
|
try {
|
|
18568
|
-
rmSync2(
|
|
18666
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18569
18667
|
} catch {
|
|
18570
18668
|
}
|
|
18571
18669
|
throw error51;
|
|
18572
18670
|
}
|
|
18671
|
+
try {
|
|
18672
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18673
|
+
} catch {
|
|
18674
|
+
}
|
|
18573
18675
|
}
|
|
18574
18676
|
function moveStoreAside(file2, backup) {
|
|
18575
18677
|
const undo = [];
|
|
@@ -19297,9 +19399,10 @@ function safeParseStringArray(raw) {
|
|
|
19297
19399
|
const parsed = safeJson(raw, null);
|
|
19298
19400
|
return Array.isArray(parsed) ? parsed : [];
|
|
19299
19401
|
}
|
|
19402
|
+
var DEFAULT_HARNESS = HARNESS.ClaudeCode;
|
|
19300
19403
|
function toHarness(raw) {
|
|
19301
19404
|
const parsed = Harness.safeParse(raw);
|
|
19302
|
-
return parsed.success ? parsed.data :
|
|
19405
|
+
return parsed.success ? parsed.data : DEFAULT_HARNESS;
|
|
19303
19406
|
}
|
|
19304
19407
|
function resolveLifecycle(row, lastActivityMs, nowMs) {
|
|
19305
19408
|
if (row.status) {
|
|
@@ -19430,7 +19533,7 @@ var SqliteActivityRepository = class {
|
|
|
19430
19533
|
const params = [];
|
|
19431
19534
|
if (query.harness && query.harness.length > 0) {
|
|
19432
19535
|
conditions.push(
|
|
19433
|
-
`coalesce(json_extract(attributes, '$.harness'), '
|
|
19536
|
+
`coalesce(json_extract(attributes, '$.harness'), '${DEFAULT_HARNESS}') IN (${placeholders(query.harness.length)})`
|
|
19434
19537
|
);
|
|
19435
19538
|
params.push(...query.harness);
|
|
19436
19539
|
}
|
|
@@ -19637,13 +19740,13 @@ var SqliteActivityRepository = class {
|
|
|
19637
19740
|
* The DISTINCT harnesses that actually have sessions (optionally within a
|
|
19638
19741
|
* `started_at >= fromMs` window), so the filter can offer only the harnesses
|
|
19639
19742
|
* present rather than the full enum. Each stored value is normalized through
|
|
19640
|
-
* the SAME `toHarness` default the list uses (missing →
|
|
19641
|
-
* store of bare (harness-less) roots surfaces exactly
|
|
19743
|
+
* the SAME `toHarness` default the list uses (missing → DEFAULT_HARNESS), so
|
|
19744
|
+
* a store of bare (harness-less) roots surfaces exactly that one harness.
|
|
19642
19745
|
*/
|
|
19643
19746
|
harnessFacets(fromMs) {
|
|
19644
19747
|
const where = fromMs === void 0 ? "" : " AND started_at >= ?";
|
|
19645
19748
|
const stmt = this.db.prepare(
|
|
19646
|
-
`SELECT DISTINCT coalesce(json_extract(attributes, '$.harness'), '
|
|
19749
|
+
`SELECT DISTINCT coalesce(json_extract(attributes, '$.harness'), '${DEFAULT_HARNESS}') AS harness
|
|
19647
19750
|
FROM audit_events WHERE ${SESSION_ROOT}${where}`
|
|
19648
19751
|
);
|
|
19649
19752
|
const rows = allRows(
|
|
@@ -19857,8 +19960,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
19857
19960
|
}
|
|
19858
19961
|
// Insert one transcript-derived `llm_call` leaf. Unlike `insertAuditEvent`
|
|
19859
19962
|
// (which takes a caller-supplied random id), the id here is MINTED internally
|
|
19860
|
-
// from the natural key — `llmCallId(sessionId, messageId)` —
|
|
19861
|
-
//
|
|
19963
|
+
// from the natural key — `llmCallId(sessionId, messageId)` — derived from the
|
|
19964
|
+
// session and message alone, like the sibling local-store ids. The deterministic
|
|
19862
19965
|
// id + the UPSERT-take-MAX(output_tokens) statement make every re-read idempotent
|
|
19863
19966
|
// AND converge a streaming partial/final split across two incremental passes:
|
|
19864
19967
|
// a whole-file re-read no-ops (equal output), a lagging final replaces a
|
|
@@ -20823,6 +20926,42 @@ var SqliteFindingsRepository = class {
|
|
|
20823
20926
|
this.db = db;
|
|
20824
20927
|
}
|
|
20825
20928
|
db;
|
|
20929
|
+
/**
|
|
20930
|
+
* The newest `limit` findings, newest first.
|
|
20931
|
+
*
|
|
20932
|
+
* THE PLAN IS THE POINT HERE, and two things in the SQL below exist only to
|
|
20933
|
+
* pin it. The natural spelling — drive from `inspection_findings`, order by the
|
|
20934
|
+
* JOINED `e.started_at` — cannot push the LIMIT down, because the sort key is
|
|
20935
|
+
* not on the driving table: SQLite sorts every finding in the store through a
|
|
20936
|
+
* temp B-tree to return 500 rows. Measured at 35.0 ms on a 40,000-event corpus
|
|
20937
|
+
* against 0.9 ms for the form below, and the gap is a ratio of the store size
|
|
20938
|
+
* rather than a constant.
|
|
20939
|
+
*
|
|
20940
|
+
* What it takes to make `started_at` order come out of an index instead:
|
|
20941
|
+
*
|
|
20942
|
+
* - **`+e.event_type`** — the unary plus makes that term non-indexable, so the
|
|
20943
|
+
* planner stops choosing `idx_audit_type_t` (`event_type, started_at`). That
|
|
20944
|
+
* index cannot serve the ORDER BY: the predicate spans four event types, so
|
|
20945
|
+
* satisfying a global `started_at` order across them needs a range merge
|
|
20946
|
+
* SQLite will not do, and it sorts instead. Freed of it, the planner scans
|
|
20947
|
+
* `idx_audit_started_at` — a bare `started_at` index — in DESC order and
|
|
20948
|
+
* filters the type per row, which lets the LIMIT stop the scan early.
|
|
20949
|
+
* - **`CROSS JOIN`** — semantically identical to JOIN in SQLite, and there
|
|
20950
|
+
* purely to stop the tables being reordered. With plain JOINs the planner
|
|
20951
|
+
* drives from `f` and sorts everything again: measured at 23.6 ms, i.e. the
|
|
20952
|
+
* unary plus ALONE recovers almost none of the win. Both are needed.
|
|
20953
|
+
*
|
|
20954
|
+
* Neither is a micro-optimisation that a later reader should tidy away, and
|
|
20955
|
+
* `packages/persistence/test/performance/hot-read-query-plans.test.ts` fails if
|
|
20956
|
+
* the temp B-tree comes back.
|
|
20957
|
+
*
|
|
20958
|
+
* Degrading gracefully was the reason for `+` over `INDEXED BY`, which measured
|
|
20959
|
+
* identically (0.9 ms): `INDEXED BY` is a hard requirement, so dropping or
|
|
20960
|
+
* renaming the index turns this read into an ERROR, where `+` turns it into a
|
|
20961
|
+
* scan-and-sort — slower, still correct. The worst case for the chosen form is
|
|
20962
|
+
* a store whose recent captures carry no findings at all, where the scan walks
|
|
20963
|
+
* the whole index; that is still no worse than the full sort it replaced.
|
|
20964
|
+
*/
|
|
20826
20965
|
recentFindings(opts) {
|
|
20827
20966
|
const limit = opts?.limit ?? 50;
|
|
20828
20967
|
const rows = allRows(
|
|
@@ -20831,10 +20970,10 @@ var SqliteFindingsRepository = class {
|
|
|
20831
20970
|
f.masked_match, f.action_taken, f.confidence, e.started_at AS occurred_at,
|
|
20832
20971
|
json_extract(e.attributes, '$.source_tool') AS source_tool,
|
|
20833
20972
|
e.event_type AS kind
|
|
20834
|
-
FROM
|
|
20835
|
-
JOIN
|
|
20836
|
-
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
20837
|
-
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
20973
|
+
FROM audit_events e
|
|
20974
|
+
CROSS JOIN inspection_findings f ON f.audit_event_id = e.id
|
|
20975
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
20976
|
+
WHERE +e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
20838
20977
|
ORDER BY e.started_at DESC, f.rowid DESC
|
|
20839
20978
|
LIMIT :limit`
|
|
20840
20979
|
),
|
|
@@ -21478,7 +21617,8 @@ var SqliteInspectionDefinitionsRepository = class {
|
|
|
21478
21617
|
}
|
|
21479
21618
|
db;
|
|
21480
21619
|
insertStmt;
|
|
21481
|
-
//
|
|
21620
|
+
// Insert-if-absent; returns the content-addressed definition id. An id already
|
|
21621
|
+
// present keeps the stored row untouched — see the class doc.
|
|
21482
21622
|
upsert(input) {
|
|
21483
21623
|
const id = inspectionDefinitionId(input.ruleId, input.version);
|
|
21484
21624
|
const row = toInspectionDefinitionRow(input, id);
|
|
@@ -21622,11 +21762,23 @@ function isParseableBinaryVersion(version2) {
|
|
|
21622
21762
|
|
|
21623
21763
|
// ../../packages/persistence/src/repositories/installed-packs.ts
|
|
21624
21764
|
var DEFAULT_POLICY_ID = DEFAULT_PACK_POLICY_ID;
|
|
21765
|
+
function printableRuleId(entry) {
|
|
21766
|
+
if (typeof entry !== "object" || entry === null) return null;
|
|
21767
|
+
const candidate = entry.id;
|
|
21768
|
+
return Rule.shape.id.safeParse(candidate).success ? candidate : null;
|
|
21769
|
+
}
|
|
21770
|
+
function firstIssueReason(error51) {
|
|
21771
|
+
const issue2 = error51.issues[0];
|
|
21772
|
+
if (!issue2) return "unknown";
|
|
21773
|
+
const path = issue2.path.map((segment) => String(segment)).join(".");
|
|
21774
|
+
return path ? `${path}: ${issue2.code}` : issue2.code;
|
|
21775
|
+
}
|
|
21776
|
+
var REJECTED_RULE_DETAIL_CAP = 10;
|
|
21625
21777
|
function inventorySignature(packs2) {
|
|
21626
21778
|
return packs2.map((p) => `${p.namespace}/${p.packId}@${p.version}#${hashRules(p.rulesJson)}`).sort().join(",");
|
|
21627
21779
|
}
|
|
21628
21780
|
function hashRules(rulesJson) {
|
|
21629
|
-
return createHash2("
|
|
21781
|
+
return createHash2("sha256").update(rulesJson).digest("hex");
|
|
21630
21782
|
}
|
|
21631
21783
|
function parseVersion(v) {
|
|
21632
21784
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -21838,10 +21990,21 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21838
21990
|
* (all detection off) instead of falling back to the bundled packs. Every
|
|
21839
21991
|
* JSON-level failure therefore counts as invalid.
|
|
21840
21992
|
*/
|
|
21993
|
+
/**
|
|
21994
|
+
* ORDERED, because a rule id is unique only WITHIN a pack — the sole unique
|
|
21995
|
+
* index is (namespace, pack_id) — so two enabled packs may contribute the same
|
|
21996
|
+
* id, and the per-rule maps below are last-write-wins. Without an ORDER BY the
|
|
21997
|
+
* winner is whatever order SQLite happens to return, which makes a collision
|
|
21998
|
+
* resolve differently on two machines holding identical stores. Ordering by
|
|
21999
|
+
* (namespace, pack_id) makes the loser deterministic and therefore testable.
|
|
22000
|
+
*/
|
|
21841
22001
|
installedRuleset() {
|
|
21842
22002
|
const rows = allRows(
|
|
21843
22003
|
this.db.prepare(
|
|
21844
|
-
`SELECT enabled, policy_id AS policyId, rules_json AS rulesJson, version
|
|
22004
|
+
`SELECT enabled, policy_id AS policyId, rules_json AS rulesJson, version,
|
|
22005
|
+
namespace, pack_id AS packId
|
|
22006
|
+
FROM installed_packs
|
|
22007
|
+
ORDER BY namespace, pack_id`
|
|
21845
22008
|
)
|
|
21846
22009
|
);
|
|
21847
22010
|
const out = {
|
|
@@ -21849,22 +22012,32 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21849
22012
|
enabledPacks: 0,
|
|
21850
22013
|
rules: [],
|
|
21851
22014
|
invalidRules: 0,
|
|
22015
|
+
rejectedRules: [],
|
|
21852
22016
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
21853
|
-
ruleVersions: /* @__PURE__ */ new Map()
|
|
22017
|
+
ruleVersions: /* @__PURE__ */ new Map(),
|
|
22018
|
+
reversibleRules: /* @__PURE__ */ new Set()
|
|
22019
|
+
};
|
|
22020
|
+
const reject = (pack, ruleId, reason) => {
|
|
22021
|
+
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
22022
|
+
out.rejectedRules.push({ pack, ruleId, reason });
|
|
21854
22023
|
};
|
|
21855
22024
|
for (const row of rows) {
|
|
21856
22025
|
if (!intToBool(row.enabled)) continue;
|
|
21857
22026
|
out.enabledPacks += 1;
|
|
21858
22027
|
const action = policyIdToAction(row.policyId);
|
|
22028
|
+
const reversible = policyIdIsReversible(row.policyId);
|
|
22029
|
+
const pack = `${row.namespace}/${row.packId}`;
|
|
21859
22030
|
let raw;
|
|
21860
22031
|
try {
|
|
21861
22032
|
raw = JSON.parse(row.rulesJson);
|
|
21862
22033
|
} catch {
|
|
21863
22034
|
out.invalidRules += 1;
|
|
22035
|
+
reject(pack, null, "rules_json: malformed JSON");
|
|
21864
22036
|
continue;
|
|
21865
22037
|
}
|
|
21866
22038
|
if (!Array.isArray(raw)) {
|
|
21867
22039
|
out.invalidRules += 1;
|
|
22040
|
+
reject(pack, null, "rules_json: not an array");
|
|
21868
22041
|
continue;
|
|
21869
22042
|
}
|
|
21870
22043
|
for (const entry of raw) {
|
|
@@ -21873,7 +22046,12 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21873
22046
|
out.rules.push(parsed.data);
|
|
21874
22047
|
out.ruleActions.set(parsed.data.id, action);
|
|
21875
22048
|
out.ruleVersions.set(parsed.data.id, row.version);
|
|
21876
|
-
|
|
22049
|
+
if (reversible) out.reversibleRules.add(parsed.data.id);
|
|
22050
|
+
else out.reversibleRules.delete(parsed.data.id);
|
|
22051
|
+
} else {
|
|
22052
|
+
out.invalidRules += 1;
|
|
22053
|
+
reject(pack, printableRuleId(entry), firstIssueReason(parsed.error));
|
|
22054
|
+
}
|
|
21877
22055
|
}
|
|
21878
22056
|
}
|
|
21879
22057
|
return out;
|
|
@@ -22067,31 +22245,38 @@ var CATEGORY_ORDER = ["config", "skill", "mcp", "hook"];
|
|
|
22067
22245
|
var VALID_HARNESS_IDS = new Set(HarnessId.options);
|
|
22068
22246
|
var WORKTREE_CHECKOUT_FILTER = "(url IS NULL OR (url NOT LIKE '%/.claude/worktrees/%' AND url NOT LIKE '%\\.claude\\worktrees\\%'))";
|
|
22069
22247
|
var HARNESS_LABELS = {
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
22073
|
-
|
|
22248
|
+
[HARNESS.ClaudeCode]: "Claude Code",
|
|
22249
|
+
[HARNESS.Cursor]: "Cursor",
|
|
22250
|
+
[HARNESS.Codex]: "Codex",
|
|
22251
|
+
[HARNESS.Antigravity]: "Antigravity"
|
|
22074
22252
|
};
|
|
22075
22253
|
var HARNESS_LIVENESS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
22076
22254
|
var EMPTY_PROJECT_AGG = {
|
|
22077
22255
|
accessCounts: { open: 0, approved: 0, blocked: 0, total: 0 },
|
|
22078
22256
|
findingsCount: 0
|
|
22079
22257
|
};
|
|
22258
|
+
var stripSeparators = (value) => value.toLowerCase().replace(/[\s-]/g, "");
|
|
22259
|
+
var TITLE_NEEDLES = {
|
|
22260
|
+
ClaudeCode: stripSeparators(SOURCE_TOOL.ClaudeCode),
|
|
22261
|
+
Cursor: stripSeparators(SOURCE_TOOL.Cursor),
|
|
22262
|
+
Codex: stripSeparators(SOURCE_TOOL.Codex),
|
|
22263
|
+
Antigravity: stripSeparators(SOURCE_TOOL.Antigravity)
|
|
22264
|
+
};
|
|
22080
22265
|
function resolveHarnessId(attrs, row) {
|
|
22081
22266
|
if (attrs.provider && VALID_HARNESS_IDS.has(attrs.provider)) {
|
|
22082
22267
|
return attrs.provider;
|
|
22083
22268
|
}
|
|
22084
|
-
const t = (row.title ?? "")
|
|
22085
|
-
if (t.includes(
|
|
22086
|
-
if (t.includes(
|
|
22087
|
-
if (t.includes(
|
|
22088
|
-
if (t.includes(
|
|
22269
|
+
const t = stripSeparators(row.title ?? "");
|
|
22270
|
+
if (t.includes(TITLE_NEEDLES.ClaudeCode) || t === "claude") return HARNESS.ClaudeCode;
|
|
22271
|
+
if (t.includes(TITLE_NEEDLES.Cursor)) return HARNESS.Cursor;
|
|
22272
|
+
if (t.includes(TITLE_NEEDLES.Codex)) return HARNESS.Codex;
|
|
22273
|
+
if (t.includes(TITLE_NEEDLES.Antigravity)) return HARNESS.Antigravity;
|
|
22089
22274
|
return null;
|
|
22090
22275
|
}
|
|
22091
22276
|
function isLiveRealClaudeCode(rows) {
|
|
22092
22277
|
return rows.some((r) => {
|
|
22093
22278
|
const attrs = safeJson(r.attributes, {});
|
|
22094
|
-
return attrs.provenance !== "sample" && resolveHarnessId(attrs, r) ===
|
|
22279
|
+
return attrs.provenance !== "sample" && resolveHarnessId(attrs, r) === HARNESS.ClaudeCode;
|
|
22095
22280
|
});
|
|
22096
22281
|
}
|
|
22097
22282
|
function toAssetSummary(row) {
|
|
@@ -22359,7 +22544,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
22359
22544
|
const isRealHarness = rows.some(
|
|
22360
22545
|
(r) => safeJson(r.attributes, {}).provenance !== "sample"
|
|
22361
22546
|
);
|
|
22362
|
-
const attachConfig = isRealHarness && harnessId ===
|
|
22547
|
+
const attachConfig = isRealHarness && harnessId === HARNESS.ClaudeCode && configAssets.length > 0;
|
|
22363
22548
|
const assets = attachConfig ? [...harnessAssets, ...configAssets].sort((a, b) => a.name.localeCompare(b.name)) : harnessAssets;
|
|
22364
22549
|
if (q && assets.length === 0) continue;
|
|
22365
22550
|
const firstRow = rows[0];
|
|
@@ -23033,9 +23218,10 @@ var SqliteProjectFilesRepository = class {
|
|
|
23033
23218
|
// ../../packages/persistence/src/repositories/resolutions.ts
|
|
23034
23219
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
23035
23220
|
var SqliteResolutionsRepository = class {
|
|
23036
|
-
constructor(db, now = () => Date.now()) {
|
|
23221
|
+
constructor(db, now = () => Date.now(), newId = () => randomUUID7()) {
|
|
23037
23222
|
this.db = db;
|
|
23038
23223
|
this.now = now;
|
|
23224
|
+
this.newId = newId;
|
|
23039
23225
|
this.insertStmt = db.prepare(
|
|
23040
23226
|
`INSERT INTO finding_resolution (id, finding_key, status, method, resolved_at, evidence, created_at)
|
|
23041
23227
|
VALUES (:id, :findingKey, :status, :method, :resolvedAt, :evidence, :createdAt)`
|
|
@@ -23068,12 +23254,14 @@ var SqliteResolutionsRepository = class {
|
|
|
23068
23254
|
}
|
|
23069
23255
|
db;
|
|
23070
23256
|
now;
|
|
23257
|
+
newId;
|
|
23071
23258
|
insertStmt;
|
|
23072
23259
|
latestStmt;
|
|
23073
23260
|
openAtRestStmt;
|
|
23074
23261
|
resolvedAtRestStmt;
|
|
23075
23262
|
/**
|
|
23076
|
-
* Insert one disposition row. The repo mints the id and stamps created_at
|
|
23263
|
+
* Insert one disposition row. The repo mints the id and stamps created_at,
|
|
23264
|
+
* both through the constructor's injectable seams.
|
|
23077
23265
|
* `status`/`method` are typed AND re-parsed here against @akasecurity/schema's
|
|
23078
23266
|
* FindingStatus/ResolutionMethod, so the persisted vocabulary can never drift
|
|
23079
23267
|
* from the schema enums. NOTE for future manual-resolution writers: this is
|
|
@@ -23085,7 +23273,7 @@ var SqliteResolutionsRepository = class {
|
|
|
23085
23273
|
*/
|
|
23086
23274
|
insertResolution(r) {
|
|
23087
23275
|
this.insertStmt.run({
|
|
23088
|
-
id:
|
|
23276
|
+
id: this.newId(),
|
|
23089
23277
|
findingKey: r.findingKey,
|
|
23090
23278
|
status: FindingStatus.parse(r.status),
|
|
23091
23279
|
method: ResolutionMethod.parse(r.method),
|
|
@@ -23664,16 +23852,16 @@ var ACTION_TO_KIND = {
|
|
|
23664
23852
|
warn: "warned"
|
|
23665
23853
|
};
|
|
23666
23854
|
var ENFORCEMENT_KINDS = ["blocked", "redacted", "warned"];
|
|
23667
|
-
var SCAN_COVERAGE =
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
|
|
23672
|
-
|
|
23673
|
-
|
|
23674
|
-
|
|
23675
|
-
|
|
23676
|
-
|
|
23855
|
+
var SCAN_COVERAGE = {
|
|
23856
|
+
[HARNESS.Antigravity]: { coverage: 60, supported: true },
|
|
23857
|
+
[HARNESS.Api]: { coverage: 0, supported: false },
|
|
23858
|
+
[HARNESS.ChatGpt]: { coverage: 40, supported: true },
|
|
23859
|
+
[HARNESS.ClaudeAi]: { coverage: 40, supported: true },
|
|
23860
|
+
[HARNESS.ClaudeCode]: { coverage: 100, supported: true },
|
|
23861
|
+
[HARNESS.Codex]: { coverage: 80, supported: true },
|
|
23862
|
+
[HARNESS.Copilot]: { coverage: 0, supported: false },
|
|
23863
|
+
[HARNESS.Cursor]: { coverage: 0, supported: false }
|
|
23864
|
+
};
|
|
23677
23865
|
var GRANULARITY = {
|
|
23678
23866
|
"7d": "day",
|
|
23679
23867
|
"30d": "day",
|
|
@@ -23772,9 +23960,22 @@ var SqliteSecurityRepository = class {
|
|
|
23772
23960
|
return Promise.resolve({ total, needsRemediation, bySeverity });
|
|
23773
23961
|
}
|
|
23774
23962
|
// Range is echoed but does not change the result today — coverage is a constant
|
|
23775
|
-
// business fact (see SCAN_COVERAGE), not a measured per-window metric.
|
|
23963
|
+
// business fact (see SCAN_COVERAGE), not a measured per-window metric. Order
|
|
23964
|
+
// comes from Provider.options (the enum's declaration order), not from
|
|
23965
|
+
// SCAN_COVERAGE's own key order — deliberately, not because object literals
|
|
23966
|
+
// leave key order unspecified (ES2015 guarantees insertion order for these
|
|
23967
|
+
// non-integer string keys, so iterating SCAN_COVERAGE directly would be
|
|
23968
|
+
// reliable too). The reason is the schema comment's promise: the returned
|
|
23969
|
+
// order must mirror the generated OpenAPI enum list, which is Provider's
|
|
23970
|
+
// contract, not this table's.
|
|
23776
23971
|
scanCoverage(range) {
|
|
23777
|
-
return Promise.resolve({
|
|
23972
|
+
return Promise.resolve({
|
|
23973
|
+
range,
|
|
23974
|
+
providers: Provider.options.map((provider) => ({
|
|
23975
|
+
provider,
|
|
23976
|
+
...SCAN_COVERAGE[provider]
|
|
23977
|
+
}))
|
|
23978
|
+
});
|
|
23778
23979
|
}
|
|
23779
23980
|
enforcementActions(range) {
|
|
23780
23981
|
const lenMs = RANGE_DAYS[range] * DAY_MS4;
|
|
@@ -23832,10 +24033,10 @@ var SqliteSecurityRepository = class {
|
|
|
23832
24033
|
// count; a superseding open/redetected row means the finding is not
|
|
23833
24034
|
// remediated and is excluded, same invariant as severitySummary. Legacy
|
|
23834
24035
|
// at-rest findings with finding_key IS NULL can never have a resolution row
|
|
23835
|
-
// (the lifecycle is keyed by finding_key), so
|
|
23836
|
-
//
|
|
23837
|
-
//
|
|
23838
|
-
// mirroring this file's other methods.
|
|
24036
|
+
// (the lifecycle is keyed by finding_key), so they cannot reach the driving
|
|
24037
|
+
// set below. One raw-row query (fetch the findings with resolution activity in
|
|
24038
|
+
// the window + each one's latest resolution status/method/resolved_at) +
|
|
24039
|
+
// pure-JS filter/bucket/mean, mirroring this file's other methods.
|
|
23839
24040
|
mttrTrend(range) {
|
|
23840
24041
|
const granularity = granularityFor(range);
|
|
23841
24042
|
const bucketMs = (granularity === "day" ? 1 : 7) * DAY_MS4;
|
|
@@ -23851,29 +24052,80 @@ var SqliteSecurityRepository = class {
|
|
|
23851
24052
|
// started_at the upsert overwrites onto inspection_findings.audit_event_id.
|
|
23852
24053
|
// COALESCE onto the parent event's started_at defends against any
|
|
23853
24054
|
// legacy/edge row the backfill left null.
|
|
23854
|
-
`SELECT
|
|
24055
|
+
`SELECT DISTINCT f.finding_key AS finding_key,
|
|
24056
|
+
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at, d.severity AS severity,
|
|
23855
24057
|
latest.status AS latest_status,
|
|
23856
24058
|
latest.method AS latest_method,
|
|
23857
24059
|
latest.resolved_at AS latest_resolved_at
|
|
23858
|
-
FROM
|
|
23859
|
-
JOIN
|
|
23860
|
-
JOIN
|
|
24060
|
+
FROM finding_resolution fr
|
|
24061
|
+
CROSS JOIN inspection_findings f ON f.finding_key = fr.finding_key
|
|
24062
|
+
CROSS JOIN audit_events e ON e.id = f.audit_event_id
|
|
24063
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
23861
24064
|
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
23862
24065
|
ON latest.finding_key = f.finding_key
|
|
23863
|
-
WHERE
|
|
23864
|
-
AND e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
23865
|
-
|
|
23866
|
-
SELECT 1 FROM finding_resolution fr
|
|
23867
|
-
WHERE fr.finding_key = f.finding_key
|
|
23868
|
-
AND fr.resolved_at >= :windowStart
|
|
23869
|
-
)`
|
|
23870
|
-
// The EXISTS is a SUPERSET prefilter that bounds the scan to keys with
|
|
23871
|
-
// any resolution activity at/after the window start — a row this method
|
|
24066
|
+
WHERE fr.resolved_at >= :windowStart
|
|
24067
|
+
AND e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})`
|
|
24068
|
+
// `fr` is a SUPERSET prefilter, not the answer: a finding this method
|
|
23872
24069
|
// ultimately counts has its LATEST resolution inside the window, which
|
|
23873
|
-
// implies
|
|
23874
|
-
// latest-wins + status/method + window gate
|
|
23875
|
-
// dialect-agnostic.
|
|
23876
|
-
//
|
|
24070
|
+
// implies a resolution row at/after the window start exists, so nothing
|
|
24071
|
+
// wanted is dropped. The exact latest-wins + status/method + window gate
|
|
24072
|
+
// stays in JS below, dialect-agnostic. `f.finding_key IS NOT NULL` is
|
|
24073
|
+
// implied rather than dropped — the join key comes from
|
|
24074
|
+
// finding_resolution, whose finding_key is NOT NULL.
|
|
24075
|
+
//
|
|
24076
|
+
// IT IS THE DRIVING TABLE THAT MAKES THAT PREFILTER A BOUND, which is
|
|
24077
|
+
// the correction this replaced. Spelled as an `EXISTS` in the WHERE it
|
|
24078
|
+
// READ as a bound and was not one: SQLite drove from `audit_events` on
|
|
24079
|
+
// event_type, joined every capture event to its findings, and evaluated
|
|
24080
|
+
// the EXISTS last — bounding the RESULT and not the scan, so a 7d request
|
|
24081
|
+
// still cost the store's whole trackable history. Measured at 44.6 ms on
|
|
24082
|
+
// 50,000 events and 171.3 ms on 150,000 — linear in the STORE, and in
|
|
24083
|
+
// both cases returning rows for a window holding a fraction of it.
|
|
24084
|
+
//
|
|
24085
|
+
// Two things carry it, and they answer DIFFERENT halves — which is worth
|
|
24086
|
+
// stating precisely, because the obvious reading (both are needed for the
|
|
24087
|
+
// speed) is wrong and was measured to be wrong:
|
|
24088
|
+
//
|
|
24089
|
+
// - **`CROSS JOIN`** is the whole of the store-size fix. In SQLite the
|
|
24090
|
+
// keyword is semantically identical to JOIN and exists only to stop the
|
|
24091
|
+
// tables being reordered; with plain JOINs the planner puts `e` back on
|
|
24092
|
+
// the outside, because with no ANALYZE statistics it prices
|
|
24093
|
+
// `event_type IN (...)` as a selective probe. Reverting it alone takes
|
|
24094
|
+
// the 2k->20k flatness ratio from 1.32 to 16.87.
|
|
24095
|
+
// - **`idx_finding_resolution_resolved_at`** (migration 0021) makes
|
|
24096
|
+
// `resolved_at >= :windowStart` a range SEARCH instead of a bare
|
|
24097
|
+
// `SCAN fr` — finding_key was this table's only index before it, so the
|
|
24098
|
+
// range had none. It buys NO flatness in store size: remove it and the
|
|
24099
|
+
// ratio above does not move, because the latest-resolution derived
|
|
24100
|
+
// table already passes over the whole of finding_resolution, so this
|
|
24101
|
+
// read is O(resolutions) either way and resolutions are not the store.
|
|
24102
|
+
// What it buys is the criterion `hot-read-query-plans.test.ts` enforces
|
|
24103
|
+
// — no hot read may pass over a table with no index — and that is the
|
|
24104
|
+
// guard that goes red when it is dropped. Neither test catches the
|
|
24105
|
+
// other's defect.
|
|
24106
|
+
//
|
|
24107
|
+
// SELECT DISTINCT is a CORRECTNESS requirement of driving from `fr`, not a
|
|
24108
|
+
// tidy-up. finding_resolution is append-only, so a key that was fixed,
|
|
24109
|
+
// redetected and fixed again carries several rows inside one window and
|
|
24110
|
+
// matches once per row — and the value below is a MEAN, so a key matched
|
|
24111
|
+
// three times is a key weighted three times.
|
|
24112
|
+
//
|
|
24113
|
+
// The skew is easy to argue away and the argument is wrong, so it is worth
|
|
24114
|
+
// recording. Duplicate rows for ONE key are identical (every projected
|
|
24115
|
+
// column is per-key: `latest.*` is latest-wins, `first_detected_at` is
|
|
24116
|
+
// preserved), so sums and counts scale together and that key's own mean
|
|
24117
|
+
// does not move. What moves is a bucket holding TWO findings that duplicate
|
|
24118
|
+
// UNEQUALLY: three rows for a 5.9-day fix and one for a 1.9-day fix average
|
|
24119
|
+
// 4.9 days weighted against 3.9 unweighted. Measured, and pinned by
|
|
24120
|
+
// `security.test.ts`'s "weights a finding ONCE however many resolution rows
|
|
24121
|
+
// it has inside the window" — which needed a fixture built for it, since no
|
|
24122
|
+
// single-key case can show it.
|
|
24123
|
+
//
|
|
24124
|
+
// `finding_key` is selected to make the DISTINCT dedup by KEY rather than
|
|
24125
|
+
// by value tuple. On the other columns alone, two genuinely different
|
|
24126
|
+
// findings sharing a severity, a first-detection event and a resolution
|
|
24127
|
+
// instant — one commit fixing two secrets in one file — are one tuple, and
|
|
24128
|
+
// collapsing them would under-count in the other direction.
|
|
23877
24129
|
),
|
|
23878
24130
|
{ windowStart }
|
|
23879
24131
|
);
|
|
@@ -23931,16 +24183,47 @@ var SqliteSecurityRepository = class {
|
|
|
23931
24183
|
}
|
|
23932
24184
|
// Recently-resolved activity feed: findings whose finding_key's LATEST
|
|
23933
24185
|
// finding_resolution row is status:'resolved'/method:'fixed-at-source' —
|
|
23934
|
-
// same latest-resolution-wins
|
|
23935
|
-
//
|
|
23936
|
-
//
|
|
23937
|
-
//
|
|
23938
|
-
//
|
|
23939
|
-
//
|
|
23940
|
-
//
|
|
23941
|
-
//
|
|
23942
|
-
//
|
|
23943
|
-
//
|
|
24186
|
+
// same latest-resolution-wins derived table as severitySummary / mttrTrend
|
|
24187
|
+
// (NOT a plain JOIN, which would surface every historical resolution row for
|
|
24188
|
+
// a key rather than just its current disposition). A key whose latest row is
|
|
24189
|
+
// a superseding 'open'/'redetected' row (the same secret came back) is
|
|
24190
|
+
// excluded — it is not currently resolved. Legacy at-rest findings with
|
|
24191
|
+
// finding_key IS NULL are excluded outright (the resolution lifecycle can
|
|
24192
|
+
// never attach to them). Path comes from the finding's parent event
|
|
24193
|
+
// (event_type 'code_change', attributes.file_path) — mirrors resolutions.ts's
|
|
24194
|
+
// openAtRestStmt accessor. Ordered by resolved_at DESC, capped at `limit`.
|
|
24195
|
+
//
|
|
24196
|
+
// THE RESOLUTION SET DRIVES THIS QUERY, and that is a correctness property of
|
|
24197
|
+
// the plan rather than a preference. Written the other way round — driving
|
|
24198
|
+
// from inspection_findings/audit_events with `latest` LEFT JOINed on — SQLite
|
|
24199
|
+
// cannot use the join key: `f` is reached FROM `latest` by finding_key, so
|
|
24200
|
+
// `latest` gets probed on (rn, status, method) instead and the plan enumerates
|
|
24201
|
+
// every (code_change event x resolved key) pair before `f` can reject it. That
|
|
24202
|
+
// is a cross product, and it is quadratic in the store: measured at 10,966 ms
|
|
24203
|
+
// on a corpus of 50,000 events carrying 2,051 resolutions, against 20 rows
|
|
24204
|
+
// returned. It was invisible for as long as it was, and reported at 8 ms,
|
|
24205
|
+
// because an empty finding_resolution table makes the inner side empty and the
|
|
24206
|
+
// cross product collapses to nothing — so the shape is only observable on a
|
|
24207
|
+
// corpus that seeds resolutions.
|
|
24208
|
+
//
|
|
24209
|
+
// Driving from `latest` instead makes every step below it a unique-index or
|
|
24210
|
+
// primary-key lookup (uq_inspection_findings_key, then audit_events' own PK),
|
|
24211
|
+
// so the cost is the derived table's own — linear in resolutions, which is
|
|
24212
|
+
// what this feed is legitimately about.
|
|
24213
|
+
//
|
|
24214
|
+
// CROSS JOIN is what actually pins that, and it is load-bearing rather than
|
|
24215
|
+
// decorative: in SQLite the keyword is semantically identical to JOIN and
|
|
24216
|
+
// exists only to stop the optimizer reordering the tables. Written as plain
|
|
24217
|
+
// JOINs in this order the planner puts `e` back on the outside — it has no
|
|
24218
|
+
// ANALYZE statistics to price the alternatives with, so it takes
|
|
24219
|
+
// `event_type = 'code_change'` for a selective index probe and rebuilds the
|
|
24220
|
+
// cross product. The FROM order alone was measured to change the plan not at
|
|
24221
|
+
// all.
|
|
24222
|
+
//
|
|
24223
|
+
// The LEFT JOIN it replaced was already an inner join in effect: three
|
|
24224
|
+
// `latest.*` predicates sit in the WHERE, and each of them is false for a
|
|
24225
|
+
// null-extended row. Spelling it JOIN changes no row and stops the plan
|
|
24226
|
+
// reading as though the findings side could drive.
|
|
23944
24227
|
recentlyResolved(limit = 20) {
|
|
23945
24228
|
const rows = allRows(
|
|
23946
24229
|
this.db.prepare(
|
|
@@ -23950,17 +24233,15 @@ var SqliteSecurityRepository = class {
|
|
|
23950
24233
|
json_extract(e.attributes, '$.file_path') AS path,
|
|
23951
24234
|
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at,
|
|
23952
24235
|
latest.resolved_at AS latest_resolved_at
|
|
23953
|
-
FROM
|
|
23954
|
-
JOIN
|
|
23955
|
-
JOIN
|
|
23956
|
-
|
|
23957
|
-
|
|
23958
|
-
WHERE e.event_type = 'code_change'
|
|
23959
|
-
AND f.finding_key IS NOT NULL
|
|
23960
|
-
AND latest.status = 'resolved'
|
|
24236
|
+
FROM ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
24237
|
+
CROSS JOIN inspection_findings f ON f.finding_key = latest.finding_key
|
|
24238
|
+
CROSS JOIN audit_events e ON e.id = f.audit_event_id
|
|
24239
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
24240
|
+
WHERE latest.status = 'resolved'
|
|
23961
24241
|
AND latest.method = 'fixed-at-source'
|
|
23962
24242
|
AND latest.resolved_at IS NOT NULL
|
|
23963
|
-
|
|
24243
|
+
AND e.event_type = 'code_change'
|
|
24244
|
+
ORDER BY latest.resolved_at DESC
|
|
23964
24245
|
LIMIT :limit`
|
|
23965
24246
|
),
|
|
23966
24247
|
{ limit }
|
|
@@ -24897,6 +25178,7 @@ function openAndInitialize(file2) {
|
|
|
24897
25178
|
function openLocalDatabase(dir) {
|
|
24898
25179
|
ensureDataDirSync(dir);
|
|
24899
25180
|
const file2 = join2(dir, DB_FILENAME);
|
|
25181
|
+
reapStalePartials(file2);
|
|
24900
25182
|
const {
|
|
24901
25183
|
db,
|
|
24902
25184
|
events,
|
|
@@ -25217,11 +25499,79 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25217
25499
|
}
|
|
25218
25500
|
}
|
|
25219
25501
|
|
|
25220
|
-
// ../../packages/persistence/src/settings.ts
|
|
25502
|
+
// ../../packages/persistence/src/managed-settings.ts
|
|
25221
25503
|
import { readFileSync as readFileSync3 } from "fs";
|
|
25504
|
+
import { posix, win32 } from "path";
|
|
25505
|
+
function managedSettingsPaths(platform2 = process.platform) {
|
|
25506
|
+
if (platform2 === "darwin") {
|
|
25507
|
+
return [
|
|
25508
|
+
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
25509
|
+
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
25510
|
+
];
|
|
25511
|
+
}
|
|
25512
|
+
if (platform2 === "win32") {
|
|
25513
|
+
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
25514
|
+
}
|
|
25515
|
+
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
25516
|
+
}
|
|
25517
|
+
function readManagedSettings(paths = managedSettingsPaths()) {
|
|
25518
|
+
for (const path of paths) {
|
|
25519
|
+
let text;
|
|
25520
|
+
try {
|
|
25521
|
+
text = readFileSync3(path, "utf8");
|
|
25522
|
+
} catch {
|
|
25523
|
+
continue;
|
|
25524
|
+
}
|
|
25525
|
+
const record2 = parseJsonObject(text);
|
|
25526
|
+
if (!record2) continue;
|
|
25527
|
+
const parsed = ManagedSettings.safeParse(record2);
|
|
25528
|
+
if (parsed.success) return parsed.data;
|
|
25529
|
+
}
|
|
25530
|
+
return null;
|
|
25531
|
+
}
|
|
25532
|
+
function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ new Date()) {
|
|
25533
|
+
if (!managed) return settings;
|
|
25534
|
+
const { values } = managed;
|
|
25535
|
+
const merged = { ...settings };
|
|
25536
|
+
if (values.runMode !== void 0) merged.runMode = values.runMode;
|
|
25537
|
+
if (values.controlPlane !== void 0) {
|
|
25538
|
+
merged.controlPlane = {
|
|
25539
|
+
...values.controlPlane,
|
|
25540
|
+
// The administrator pinned WHICH deployment, not WHEN this machine
|
|
25541
|
+
// joined it. Keep the user's own attach time when the endpoint is
|
|
25542
|
+
// unchanged, so a managed machine does not appear to re-attach on every
|
|
25543
|
+
// read; stamp a fresh one when the administrator moved it.
|
|
25544
|
+
attachedAt: settings.controlPlane?.endpoint === values.controlPlane.endpoint ? settings.controlPlane.attachedAt : now().toISOString()
|
|
25545
|
+
};
|
|
25546
|
+
}
|
|
25547
|
+
if (values.historicalAccess !== void 0) merged.historicalAccess = values.historicalAccess;
|
|
25548
|
+
if (values.vaultKeyCustody !== void 0) merged.vaultKeyCustody = values.vaultKeyCustody;
|
|
25549
|
+
if (values.vaultInlineReveal !== void 0) merged.vaultInlineReveal = values.vaultInlineReveal;
|
|
25550
|
+
if (values.dataSharesInPlace !== void 0) merged.dataSharesInPlace = values.dataSharesInPlace;
|
|
25551
|
+
if (values.vaultConsent !== void 0) {
|
|
25552
|
+
merged.vaultConsent = values.vaultConsent ? (
|
|
25553
|
+
// Keep an existing valid grant so its acknowledgedAt survives; mint one
|
|
25554
|
+
// at the current version otherwise.
|
|
25555
|
+
settings.vaultConsent?.version === VAULT_CONSENT_VERSION ? settings.vaultConsent : { acknowledgedAt: now().toISOString(), version: VAULT_CONSENT_VERSION }
|
|
25556
|
+
) : void 0;
|
|
25557
|
+
}
|
|
25558
|
+
if (values.modelJudgeConsent !== void 0) {
|
|
25559
|
+
merged.modelJudgeConsent = values.modelJudgeConsent ? settings.modelJudgeConsent?.payloadVersion === MODEL_JUDGE_PAYLOAD_VERSION ? settings.modelJudgeConsent : {
|
|
25560
|
+
acknowledgedAt: now().toISOString(),
|
|
25561
|
+
payloadVersion: MODEL_JUDGE_PAYLOAD_VERSION
|
|
25562
|
+
} : void 0;
|
|
25563
|
+
}
|
|
25564
|
+
return merged;
|
|
25565
|
+
}
|
|
25566
|
+
|
|
25567
|
+
// ../../packages/persistence/src/settings.ts
|
|
25568
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25222
25569
|
import { join as join5 } from "path";
|
|
25223
25570
|
var SETTINGS_FILENAME = "settings.json";
|
|
25224
25571
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
25572
|
+
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25573
|
+
}
|
|
25574
|
+
function readUserSettings(base) {
|
|
25225
25575
|
const record2 = readJson(join5(settingsDir(base), SETTINGS_FILENAME));
|
|
25226
25576
|
if (!record2) return defaultWorkspaceSettings();
|
|
25227
25577
|
try {
|
|
@@ -25233,7 +25583,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
25233
25583
|
function readJson(file2) {
|
|
25234
25584
|
let text;
|
|
25235
25585
|
try {
|
|
25236
|
-
text =
|
|
25586
|
+
text = readFileSync4(file2, "utf8");
|
|
25237
25587
|
} catch {
|
|
25238
25588
|
return null;
|
|
25239
25589
|
}
|
|
@@ -25252,15 +25602,7 @@ import {
|
|
|
25252
25602
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25253
25603
|
import { execFileSync } from "child_process";
|
|
25254
25604
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25255
|
-
import {
|
|
25256
|
-
chmodSync as chmodSync2,
|
|
25257
|
-
mkdirSync as mkdirSync2,
|
|
25258
|
-
readFileSync as readFileSync4,
|
|
25259
|
-
renameSync as renameSync4,
|
|
25260
|
-
rmSync as rmSync4,
|
|
25261
|
-
statSync as statSync3,
|
|
25262
|
-
writeFileSync as writeFileSync3
|
|
25263
|
-
} from "fs";
|
|
25605
|
+
import { chmodSync as chmodSync2, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
25264
25606
|
import { join as join6 } from "path";
|
|
25265
25607
|
|
|
25266
25608
|
// ../../packages/persistence/src/vault/vault.ts
|
|
@@ -25356,7 +25698,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
25356
25698
|
}
|
|
25357
25699
|
|
|
25358
25700
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
25359
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
25701
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync7, realpathSync, statSync as statSync5 } from "fs";
|
|
25360
25702
|
import { homedir as homedir2 } from "os";
|
|
25361
25703
|
import { basename as basename3, join as join10 } from "path";
|
|
25362
25704
|
|
|
@@ -26064,6 +26406,10 @@ function luhnCheck(digits) {
|
|
|
26064
26406
|
// ../../packages/detections/src/engine.ts
|
|
26065
26407
|
var keywordMatcher = new KeywordMatcher2();
|
|
26066
26408
|
var regexMatcher = new RegexMatcher2();
|
|
26409
|
+
var MATCHERS = {
|
|
26410
|
+
keyword: (text, rule) => keywordMatcher.match(text, rule),
|
|
26411
|
+
regex: (text, rule) => regexMatcher.match(text, rule)
|
|
26412
|
+
};
|
|
26067
26413
|
var packs = /* @__PURE__ */ new Map();
|
|
26068
26414
|
var POST_VALIDATORS = {
|
|
26069
26415
|
entropy: (value, config2) => isHighEntropy(value, numberOption(config2, "threshold"), numberOption(config2, "minLength")),
|
|
@@ -26079,8 +26425,7 @@ function passesPostValidators(rule, value) {
|
|
|
26079
26425
|
for (const ref of validators) {
|
|
26080
26426
|
const name = typeof ref === "string" ? ref : ref.name;
|
|
26081
26427
|
const config2 = typeof ref === "string" ? void 0 : ref.config;
|
|
26082
|
-
|
|
26083
|
-
if (validate && !validate(value, config2)) return false;
|
|
26428
|
+
if (!POST_VALIDATORS[name](value, config2)) return false;
|
|
26084
26429
|
}
|
|
26085
26430
|
return true;
|
|
26086
26431
|
}
|
|
@@ -26141,14 +26486,7 @@ function scan(text, rules, context) {
|
|
|
26141
26486
|
const candidates = [];
|
|
26142
26487
|
for (const rule of ruleset) {
|
|
26143
26488
|
if (!ruleApplies(rule, extension)) continue;
|
|
26144
|
-
|
|
26145
|
-
if (rule.matcher.type === "keyword") {
|
|
26146
|
-
spans = keywordMatcher.match(text, rule);
|
|
26147
|
-
} else if (rule.matcher.type === "regex") {
|
|
26148
|
-
spans = regexMatcher.match(text, rule);
|
|
26149
|
-
} else {
|
|
26150
|
-
continue;
|
|
26151
|
-
}
|
|
26489
|
+
const spans = MATCHERS[rule.matcher.type](text, rule);
|
|
26152
26490
|
for (const span of spans) {
|
|
26153
26491
|
const rawMatch = text.slice(span.start, span.end);
|
|
26154
26492
|
if (!passesPostValidators(rule, rawMatch)) continue;
|
|
@@ -26304,6 +26642,7 @@ var CONFIG_POSTURE_RULES = [
|
|
|
26304
26642
|
];
|
|
26305
26643
|
|
|
26306
26644
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
26645
|
+
var BUDGET_MS = 100;
|
|
26307
26646
|
var EXPONENTIAL_UNITS = [
|
|
26308
26647
|
"a",
|
|
26309
26648
|
"0",
|
|
@@ -26327,6 +26666,8 @@ var EXPONENTIAL_PROBES = EXPONENTIAL_UNITS.flatMap(
|
|
|
26327
26666
|
var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map(
|
|
26328
26667
|
(unit) => unit.repeat(1e4).slice(0, 4e4) + "!"
|
|
26329
26668
|
);
|
|
26669
|
+
var CPU_CORROBORATION_SHARE = 0.2;
|
|
26670
|
+
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
26330
26671
|
|
|
26331
26672
|
// ../../rules/code-flaws/auth-jwt-no-verify.json
|
|
26332
26673
|
var auth_jwt_no_verify_default = {
|
|
@@ -28403,7 +28744,7 @@ function scanText(text, ruleVersions) {
|
|
|
28403
28744
|
}
|
|
28404
28745
|
|
|
28405
28746
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
28406
|
-
import { existsSync as existsSync6, readFileSync as
|
|
28747
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
|
|
28407
28748
|
import { basename as basename2, dirname as dirname2, isAbsolute, join as join9, sep as sep2 } from "path";
|
|
28408
28749
|
function resolveRepoIdentity(cwd) {
|
|
28409
28750
|
try {
|
|
@@ -28455,7 +28796,7 @@ function resolveGitContext(root) {
|
|
|
28455
28796
|
}
|
|
28456
28797
|
function safeRead(path) {
|
|
28457
28798
|
try {
|
|
28458
|
-
return
|
|
28799
|
+
return readFileSync6(path, "utf8");
|
|
28459
28800
|
} catch {
|
|
28460
28801
|
return void 0;
|
|
28461
28802
|
}
|
|
@@ -28500,6 +28841,11 @@ import { existsSync as existsSync7 } from "fs";
|
|
|
28500
28841
|
import { fileURLToPath } from "url";
|
|
28501
28842
|
import { Worker } from "worker_threads";
|
|
28502
28843
|
|
|
28844
|
+
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
28845
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
28846
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
28847
|
+
import { join as join11 } from "path";
|
|
28848
|
+
|
|
28503
28849
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
28504
28850
|
import { arch, hostname as hostname4, platform, release } from "os";
|
|
28505
28851
|
function resolveInventoryContext(input) {
|
|
@@ -28530,17 +28876,16 @@ function resolveInventoryContext(input) {
|
|
|
28530
28876
|
}
|
|
28531
28877
|
|
|
28532
28878
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
28533
|
-
import { mkdirSync as
|
|
28534
|
-
import { join as
|
|
28879
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
|
|
28880
|
+
import { join as join12 } from "path";
|
|
28535
28881
|
|
|
28536
28882
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
28537
28883
|
import { readdirSync as readdirSync3, realpathSync as realpathSync2 } from "fs";
|
|
28538
28884
|
import { basename as basename4, dirname as dirname3, sep as sep3 } from "path";
|
|
28539
28885
|
|
|
28540
28886
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
28541
|
-
|
|
28542
|
-
import {
|
|
28543
|
-
import { basename as basename5, join as join12 } from "path";
|
|
28887
|
+
import { existsSync as existsSync8, readdirSync as readdirSync4 } from "fs";
|
|
28888
|
+
import { basename as basename5, join as join13 } from "path";
|
|
28544
28889
|
|
|
28545
28890
|
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
28546
28891
|
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
@@ -28585,8 +28930,8 @@ import { randomUUID as randomUUID14 } from "crypto";
|
|
|
28585
28930
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
28586
28931
|
|
|
28587
28932
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
28588
|
-
import { mkdirSync as
|
|
28589
|
-
import { join as
|
|
28933
|
+
import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
28934
|
+
import { join as join14 } from "path";
|
|
28590
28935
|
|
|
28591
28936
|
// ../../packages/plugin-runtime/src/standalone-gateway.ts
|
|
28592
28937
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
@@ -28599,6 +28944,8 @@ var StandaloneDataGateway = class {
|
|
|
28599
28944
|
db;
|
|
28600
28945
|
// Kept for the fingerprint key lookup (exception.key lives beside the store).
|
|
28601
28946
|
dataDir;
|
|
28947
|
+
// One notice per gateway — see warnRulesetDiscarded.
|
|
28948
|
+
warnedRulesetDiscarded = false;
|
|
28602
28949
|
constructor(dataDir2, detections = [], meta3) {
|
|
28603
28950
|
this.db = openLocalDatabase(dataDir2);
|
|
28604
28951
|
this.dataDir = dataDir2;
|
|
@@ -28718,28 +29065,69 @@ var StandaloneDataGateway = class {
|
|
|
28718
29065
|
// - ANY invalid rule among enabled packs (all-invalid, partial corruption,
|
|
28719
29066
|
// or a single malformed entry) → undefined → bundled fallback. Serving a
|
|
28720
29067
|
// reduced "complete" set would silently drop exactly the corrupted rules
|
|
28721
|
-
// with no fallback
|
|
28722
|
-
// never loses coverage
|
|
28723
|
-
//
|
|
28724
|
-
//
|
|
29068
|
+
// with no fallback. The bundled packs are a superset of AKA's OWN packs,
|
|
29069
|
+
// so falling back never loses coverage there — but they contain no
|
|
29070
|
+
// pulled or custom pack, so for those this trades a partial ruleset for
|
|
29071
|
+
// none of them plus the loss of every pack's per-detection enforcement
|
|
29072
|
+
// action. That is deliberate (a store this machine cannot fully validate
|
|
29073
|
+
// is not authoritative), and it is why the cost of REJECTING a rule
|
|
29074
|
+
// matters: `Rule` is strict, so one unrecognized key in one custom rule
|
|
29075
|
+
// reaches this branch, not just a genuinely malformed or foreign store.
|
|
29076
|
+
// `installed-packs.test.ts` pins that per-rule counting;
|
|
28725
29077
|
// - enabled packs that produce ZERO rules with no invalids (e.g. every
|
|
28726
29078
|
// enabled pack's rules_json is `[]`) → undefined → bundled fallback: an
|
|
28727
29079
|
// enabled pack contributing nothing is untrustworthy, not a real
|
|
28728
29080
|
// "detect nothing" (that is expressed by disabling packs, handled above);
|
|
28729
29081
|
// - otherwise → the enabled packs' validated rules, marked complete.
|
|
29082
|
+
/**
|
|
29083
|
+
* The discard above is the one ruleset decision this gateway reaches on its
|
|
29084
|
+
* own, and it is the most expensive one here: ONE rejected entry costs the
|
|
29085
|
+
* user every custom rule and every per-detection enforcement action, replaced
|
|
29086
|
+
* by bundled packs that contain neither. Nothing else reports it — a hook is a
|
|
29087
|
+
* short-lived process whose stderr is the only channel it has — so name what
|
|
29088
|
+
* was rejected and where the rest of the list lives.
|
|
29089
|
+
*
|
|
29090
|
+
* Unlike a quarantine verdict this caches nothing: the rejection is re-derived
|
|
29091
|
+
* from the store on every run, so the recovery is to fix or reinstall the pack,
|
|
29092
|
+
* and no line here may offer a command that clears a stored verdict.
|
|
29093
|
+
*
|
|
29094
|
+
* Written at most once per gateway — a second getPolicyBundle() in the same
|
|
29095
|
+
* process would re-report the same finding.
|
|
29096
|
+
*/
|
|
29097
|
+
warnRulesetDiscarded(snapshot) {
|
|
29098
|
+
if (this.warnedRulesetDiscarded) return;
|
|
29099
|
+
this.warnedRulesetDiscarded = true;
|
|
29100
|
+
const listed = snapshot.rejectedRules.map((r) => `${r.pack}${r.ruleId === null ? "" : ` "${r.ruleId}"`} (${r.reason})`).join(", ");
|
|
29101
|
+
const undisclosed = snapshot.invalidRules - snapshot.rejectedRules.length;
|
|
29102
|
+
const more = undisclosed > 0 ? `, and ${String(undisclosed)} more` : "";
|
|
29103
|
+
process.stderr.write(
|
|
29104
|
+
`[aka] installed ruleset not used: ${String(snapshot.invalidRules)} rule(s) under enabled packs failed validation, so scanning fell back to the bundled packs and no custom rule or per-detection action is enforced \u2014 rejected: ${listed}${more}; review them with \`aka detections\`
|
|
29105
|
+
`
|
|
29106
|
+
);
|
|
29107
|
+
}
|
|
28730
29108
|
installedScanRules() {
|
|
28731
29109
|
try {
|
|
28732
29110
|
const snapshot = this.db.installedPacks.installedRuleset();
|
|
28733
29111
|
if (snapshot.installedPacks === 0) return void 0;
|
|
28734
29112
|
if (snapshot.enabledPacks === 0) {
|
|
28735
|
-
return {
|
|
29113
|
+
return {
|
|
29114
|
+
rules: [],
|
|
29115
|
+
ruleActions: /* @__PURE__ */ new Map(),
|
|
29116
|
+
ruleVersions: /* @__PURE__ */ new Map(),
|
|
29117
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
29118
|
+
complete: true
|
|
29119
|
+
};
|
|
29120
|
+
}
|
|
29121
|
+
if (snapshot.invalidRules > 0) {
|
|
29122
|
+
this.warnRulesetDiscarded(snapshot);
|
|
29123
|
+
return void 0;
|
|
28736
29124
|
}
|
|
28737
|
-
if (snapshot.invalidRules > 0) return void 0;
|
|
28738
29125
|
if (snapshot.rules.length === 0) return void 0;
|
|
28739
29126
|
return {
|
|
28740
29127
|
rules: snapshot.rules,
|
|
28741
29128
|
ruleActions: snapshot.ruleActions,
|
|
28742
29129
|
ruleVersions: snapshot.ruleVersions,
|
|
29130
|
+
reversibleRules: snapshot.reversibleRules,
|
|
28743
29131
|
complete: true
|
|
28744
29132
|
};
|
|
28745
29133
|
} catch {
|
|
@@ -28767,6 +29155,11 @@ var StandaloneDataGateway = class {
|
|
|
28767
29155
|
return {
|
|
28768
29156
|
version: "local",
|
|
28769
29157
|
policies: [...policies, ...rulePolicies],
|
|
29158
|
+
// The reversibility half of each pack's assignment. Emitted only under the
|
|
29159
|
+
// authoritative installed snapshot, exactly like rulePolicies above: the
|
|
29160
|
+
// bundled-packs fallback carries no per-pack assignment, so it carries no
|
|
29161
|
+
// reversibility either and every redaction there stays one-way.
|
|
29162
|
+
reversibleRuleIds: installed ? [...installed.reversibleRules] : [],
|
|
28770
29163
|
rules: installed ? installed.rules : [],
|
|
28771
29164
|
...installed ? { rulesComplete: true } : {},
|
|
28772
29165
|
...installed ? { ruleVersions: Object.fromEntries(installed.ruleVersions) } : {},
|
|
@@ -28785,29 +29178,32 @@ var StandaloneDataGateway = class {
|
|
|
28785
29178
|
return this.db.exceptions.recordBlocked(entry);
|
|
28786
29179
|
}
|
|
28787
29180
|
// Retention sweep over TERMINAL exception rows (revoked / expired / budget
|
|
28788
|
-
// exhausted) —
|
|
28789
|
-
//
|
|
29181
|
+
// exhausted) — local-store maintenance, invoked from SessionStart through the
|
|
29182
|
+
// LocalStoreMaintenance capability rather than the DataGateway port. Active
|
|
29183
|
+
// grants are never touched.
|
|
28790
29184
|
sweepTerminalExceptions(retentionMs) {
|
|
28791
29185
|
return this.db.exceptions.sweepTerminal(retentionMs);
|
|
28792
29186
|
}
|
|
28793
|
-
// The warn-era enforcement cap
|
|
28794
|
-
//
|
|
28795
|
-
// of block/redact rows capped to
|
|
28796
|
-
// already-capped one).
|
|
29187
|
+
// The warn-era enforcement cap — local-store maintenance, invoked from
|
|
29188
|
+
// SessionStart through the LocalStoreMaintenance capability rather than
|
|
29189
|
+
// the DataGateway port. Returns the number of block/redact rows capped to
|
|
29190
|
+
// warn (0 for a redact-policy store or an already-capped one).
|
|
28797
29191
|
capWarnEraEnforcement(policyMode) {
|
|
28798
29192
|
const { capped } = capWarnEraEnforcementOnce(this.db, policyMode, this.dataDir);
|
|
28799
29193
|
return { capped };
|
|
28800
29194
|
}
|
|
28801
29195
|
// One project-file scan → the local project_file tree (one transaction inside
|
|
28802
|
-
// the LocalDatabase, fail-open there). Like the sweep above, this is
|
|
28803
|
-
//
|
|
29196
|
+
// the LocalDatabase, fail-open there). Like the sweep above, this is reached
|
|
29197
|
+
// through the LocalStoreMaintenance capability rather than the DataGateway
|
|
29198
|
+
// port: the file tree is a local-store read model.
|
|
28804
29199
|
recordProjectFiles(projectId, scan2) {
|
|
28805
29200
|
this.db.recordProjectFiles(projectId, scan2);
|
|
28806
29201
|
return Promise.resolve();
|
|
28807
29202
|
}
|
|
28808
29203
|
// Fold ghost source_project rows minted by the pre-worktree-fix resolver
|
|
28809
|
-
// (checkout-path identities) into the repo's canonical row.
|
|
28810
|
-
//
|
|
29204
|
+
// (checkout-path identities) into the repo's canonical row. Local-store
|
|
29205
|
+
// maintenance, invoked from SessionStart through the LocalStoreMaintenance
|
|
29206
|
+
// capability. Fail-open in the store.
|
|
28811
29207
|
reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot) {
|
|
28812
29208
|
this.db.reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot);
|
|
28813
29209
|
return Promise.resolve();
|
|
@@ -28818,10 +29214,10 @@ var StandaloneDataGateway = class {
|
|
|
28818
29214
|
* executing the plugin generation they started with (Claude Code caches
|
|
28819
29215
|
* plugin versions), and the write gate makes their installed-pack writes
|
|
28820
29216
|
* silent no-ops — this is the one-line nudge telling the user WHY, and that
|
|
28821
|
-
* a restart picks the newer plugin up.
|
|
28822
|
-
* SessionStart
|
|
28823
|
-
* null (no notice), and
|
|
28824
|
-
* never fire it.
|
|
29217
|
+
* a restart picks the newer plugin up. Local-store maintenance, invoked
|
|
29218
|
+
* from SessionStart through the LocalStoreMaintenance capability rather
|
|
29219
|
+
* than the DataGateway port. Fail-open: any error → null (no notice), and
|
|
29220
|
+
* unparseable versions compare equal so garbage can never fire it.
|
|
28825
29221
|
*/
|
|
28826
29222
|
staleBinaryNotice(currentVersion) {
|
|
28827
29223
|
try {
|
|
@@ -28899,7 +29295,8 @@ var StandaloneDataGateway = class {
|
|
|
28899
29295
|
|
|
28900
29296
|
// ../../packages/plugin-runtime/src/resolve.ts
|
|
28901
29297
|
var standaloneGatewayFactory = (config2, meta3) => new StandaloneDataGateway(config2.dataDir, bundledDetections(), meta3);
|
|
28902
|
-
|
|
29298
|
+
var defaultGatewayFactory = standaloneGatewayFactory;
|
|
29299
|
+
function resolveDataGateway(config2, meta3, gatewayFactory = defaultGatewayFactory) {
|
|
28903
29300
|
return gatewayFactory(config2, meta3);
|
|
28904
29301
|
}
|
|
28905
29302
|
|
|
@@ -28912,15 +29309,15 @@ import { createHash as createHash5 } from "crypto";
|
|
|
28912
29309
|
import {
|
|
28913
29310
|
closeSync as closeSync2,
|
|
28914
29311
|
fstatSync,
|
|
28915
|
-
mkdirSync as
|
|
29312
|
+
mkdirSync as mkdirSync4,
|
|
28916
29313
|
openSync as openSync2,
|
|
28917
|
-
readFileSync as
|
|
29314
|
+
readFileSync as readFileSync10,
|
|
28918
29315
|
readSync,
|
|
28919
29316
|
writeFileSync as writeFileSync7
|
|
28920
29317
|
} from "fs";
|
|
28921
|
-
import { join as
|
|
29318
|
+
import { join as join15 } from "path";
|
|
28922
29319
|
function offsetsDir(dataDir2) {
|
|
28923
|
-
return
|
|
29320
|
+
return join15(dataDir2, "usage-offsets");
|
|
28924
29321
|
}
|
|
28925
29322
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
28926
29323
|
function safeSessionId(sessionId) {
|
|
@@ -28930,11 +29327,11 @@ function safeSessionId(sessionId) {
|
|
|
28930
29327
|
return createHash5("sha256").update(sessionId).digest("hex");
|
|
28931
29328
|
}
|
|
28932
29329
|
function offsetPath(dataDir2, sessionId) {
|
|
28933
|
-
return
|
|
29330
|
+
return join15(offsetsDir(dataDir2), safeSessionId(sessionId));
|
|
28934
29331
|
}
|
|
28935
29332
|
function readOffset(dataDir2, sessionId) {
|
|
28936
29333
|
try {
|
|
28937
|
-
const raw =
|
|
29334
|
+
const raw = readFileSync10(offsetPath(dataDir2, sessionId), "utf8");
|
|
28938
29335
|
const parsed = JSON.parse(raw);
|
|
28939
29336
|
if (typeof parsed === "object" && parsed !== null) {
|
|
28940
29337
|
const rec = parsed;
|
|
@@ -28948,7 +29345,7 @@ function readOffset(dataDir2, sessionId) {
|
|
|
28948
29345
|
}
|
|
28949
29346
|
function writeOffset(dataDir2, sessionId, value) {
|
|
28950
29347
|
try {
|
|
28951
|
-
|
|
29348
|
+
mkdirSync4(offsetsDir(dataDir2), { recursive: true, mode: DATA_DIR_MODE });
|
|
28952
29349
|
const payload = value.lastPromptId !== void 0 ? { offset: value.offset, lastPromptId: value.lastPromptId } : { offset: value.offset };
|
|
28953
29350
|
writeFileSync7(offsetPath(dataDir2, sessionId), JSON.stringify(payload), {
|
|
28954
29351
|
mode: DATA_FILE_MODE
|
|
@@ -28992,9 +29389,9 @@ function readTail(transcriptPath, startOffset) {
|
|
|
28992
29389
|
}
|
|
28993
29390
|
|
|
28994
29391
|
// src/history/transcripts.ts
|
|
28995
|
-
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5, readFileSync as
|
|
29392
|
+
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5, readFileSync as readFileSync11, readSync as readSync2, statSync as statSync7 } from "fs";
|
|
28996
29393
|
import { homedir as homedir3 } from "os";
|
|
28997
|
-
import { join as
|
|
29394
|
+
import { join as join16 } from "path";
|
|
28998
29395
|
function isRecord(value) {
|
|
28999
29396
|
return typeof value === "object" && value !== null;
|
|
29000
29397
|
}
|
|
@@ -29195,7 +29592,7 @@ async function reconcileSession(gateway, sessionId, records, opts = {}) {
|
|
|
29195
29592
|
if (anchor === void 0) return { llmCalls: 0, skipped: 0, lastPromptId };
|
|
29196
29593
|
const ctx = resolveInventoryContext({
|
|
29197
29594
|
cwd: anchor.cwd ?? NO_PROJECT_CWD,
|
|
29198
|
-
tool:
|
|
29595
|
+
tool: SOURCE_TOOL.Codex,
|
|
29199
29596
|
harnessVersion: anchor.version,
|
|
29200
29597
|
// Descriptive only (never hashed, never forks the harness dimension) —
|
|
29201
29598
|
// distinguishes e.g. 'codex_desktop' (Codex inside the ChatGPT desktop
|
|
@@ -29316,7 +29713,7 @@ function buildSessionRoot(sessionId, ctx, resolved, anchor, provider) {
|
|
|
29316
29713
|
if (anchor.version !== void 0) attributes.harness_version = anchor.version;
|
|
29317
29714
|
if (anchor.originator !== void 0) attributes.harness_interface = anchor.originator;
|
|
29318
29715
|
attributes.provider = provider;
|
|
29319
|
-
attributes.harness = harnessFromTool(
|
|
29716
|
+
attributes.harness = harnessFromTool(SOURCE_TOOL.Codex);
|
|
29320
29717
|
if (anchor.cwd !== void 0) attributes.cwd = anchor.cwd;
|
|
29321
29718
|
if (anchor.version !== void 0) attributes.version = anchor.version;
|
|
29322
29719
|
const hostName = ctx.host?.attributes.host_name;
|