@akasecurity/ai-tc-antigravity 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/package.json +5 -4
- package/plugin.json +1 -1
- package/scripts/apply-suppressions.js +1432 -976
- 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 +1069 -898
- package/scripts/pre-invocation.js +1430 -998
- 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/start-light.js +1009 -904
- package/scripts/stop.js +1069 -898
- package/skills/setup/SKILL.md +22 -16
package/scripts/backfill.js
CHANGED
|
@@ -588,6 +588,10 @@ var SQLITE_MIGRATIONS = [
|
|
|
588
588
|
{
|
|
589
589
|
tag: "0020_secret_vault_pagination_indexes",
|
|
590
590
|
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');"
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
tag: "0021_finding_resolution_resolved_at_index",
|
|
594
|
+
sql: "CREATE INDEX `idx_finding_resolution_resolved_at` ON `finding_resolution` (`resolved_at`);\n"
|
|
591
595
|
}
|
|
592
596
|
];
|
|
593
597
|
|
|
@@ -15303,6 +15307,50 @@ function date4(params) {
|
|
|
15303
15307
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
15304
15308
|
config(en_default());
|
|
15305
15309
|
|
|
15310
|
+
// ../../packages/schema/src/zod/harness-map.ts
|
|
15311
|
+
var HARNESS = {
|
|
15312
|
+
ClaudeCode: "claudecode",
|
|
15313
|
+
Cursor: "cursor",
|
|
15314
|
+
Copilot: "copilot",
|
|
15315
|
+
Codex: "codex",
|
|
15316
|
+
Antigravity: "antigravity",
|
|
15317
|
+
Windsurf: "windsurf",
|
|
15318
|
+
ClaudeDesktop: "claudedesktop",
|
|
15319
|
+
ChatGpt: "chatgpt",
|
|
15320
|
+
ClaudeAi: "claudeai",
|
|
15321
|
+
Api: "api"
|
|
15322
|
+
};
|
|
15323
|
+
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
15324
|
+
var SOURCE_TOOL = {
|
|
15325
|
+
ClaudeCode: "claude-code",
|
|
15326
|
+
ClaudeDesktop: "claude-desktop",
|
|
15327
|
+
Cursor: "cursor",
|
|
15328
|
+
ChatGpt: "chatgpt",
|
|
15329
|
+
ClaudeAi: "claude-ai",
|
|
15330
|
+
Copilot: "github-copilot",
|
|
15331
|
+
Codex: "codex",
|
|
15332
|
+
Antigravity: "antigravity",
|
|
15333
|
+
// No harness counterpart, deliberately: the CLI's own captures and a capture
|
|
15334
|
+
// whose tool could not be identified both render through the read side's
|
|
15335
|
+
// miss path rather than as a harness of their own.
|
|
15336
|
+
Cli: "cli",
|
|
15337
|
+
Unknown: "unknown"
|
|
15338
|
+
};
|
|
15339
|
+
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
15340
|
+
var TOOL_TO_HARNESS = {
|
|
15341
|
+
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
15342
|
+
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
15343
|
+
[SOURCE_TOOL.Copilot]: HARNESS.Copilot,
|
|
15344
|
+
[SOURCE_TOOL.Cursor]: HARNESS.Cursor,
|
|
15345
|
+
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
15346
|
+
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
15347
|
+
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
15348
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
15349
|
+
};
|
|
15350
|
+
function harnessFromTool(tool) {
|
|
15351
|
+
return TOOL_TO_HARNESS[tool] ?? tool;
|
|
15352
|
+
}
|
|
15353
|
+
|
|
15306
15354
|
// ../../packages/schema/src/zod/finding.ts
|
|
15307
15355
|
var DetectionCategory = external_exports.enum(["pii", "financial", "secret", "phi", "code_context", "code_flaw", "custom", "config"]).meta({ id: "DetectionCategory" });
|
|
15308
15356
|
var Severity = external_exports.enum(["critical", "high", "medium", "low"]).meta({ id: "Severity" });
|
|
@@ -15325,21 +15373,22 @@ var Finding = external_exports.object({
|
|
|
15325
15373
|
}).meta({ id: "Finding" });
|
|
15326
15374
|
var DetectedFinding = Finding.meta({ id: "DetectedFinding" });
|
|
15327
15375
|
var FindingAction = external_exports.enum(["blocked", "redacted", "warned", "allowed", "quarantined", "monitored"]).meta({ id: "FindingAction" });
|
|
15328
|
-
var FindingProvider =
|
|
15329
|
-
"
|
|
15330
|
-
"
|
|
15331
|
-
"
|
|
15332
|
-
"
|
|
15333
|
-
"
|
|
15334
|
-
"
|
|
15335
|
-
"
|
|
15336
|
-
"
|
|
15337
|
-
"
|
|
15376
|
+
var FindingProvider = Harness.extract([
|
|
15377
|
+
"ClaudeCode",
|
|
15378
|
+
"ClaudeDesktop",
|
|
15379
|
+
"Cursor",
|
|
15380
|
+
"Copilot",
|
|
15381
|
+
"ChatGpt",
|
|
15382
|
+
"ClaudeAi",
|
|
15383
|
+
"Codex",
|
|
15384
|
+
"Antigravity",
|
|
15385
|
+
"Api"
|
|
15338
15386
|
]).meta({ id: "FindingProvider" });
|
|
15339
15387
|
var FindingCategory = external_exports.enum([
|
|
15340
15388
|
"secret",
|
|
15341
15389
|
"pii",
|
|
15342
15390
|
"source_code",
|
|
15391
|
+
"code_flaw",
|
|
15343
15392
|
"external_share",
|
|
15344
15393
|
"mcp_server",
|
|
15345
15394
|
"customer_data",
|
|
@@ -15519,6 +15568,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
15519
15568
|
policy: FindingPolicyRef
|
|
15520
15569
|
}).meta({ id: "FindingInstanceDetail" });
|
|
15521
15570
|
var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
|
|
15571
|
+
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
15522
15572
|
var ListFindingInstancesQuery = external_exports.object({
|
|
15523
15573
|
severity: external_exports.array(Severity).optional(),
|
|
15524
15574
|
// Rule ids, the same vocabulary the grouped list's `subtype` carries.
|
|
@@ -15538,7 +15588,7 @@ var ListFindingInstancesQuery = external_exports.object({
|
|
|
15538
15588
|
q: external_exports.string().optional(),
|
|
15539
15589
|
sessionId: external_exports.string().optional(),
|
|
15540
15590
|
from: external_exports.iso.datetime().optional(),
|
|
15541
|
-
limit: external_exports.coerce.number().int().min(1).max(
|
|
15591
|
+
limit: external_exports.coerce.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
15542
15592
|
cursor: external_exports.string().optional()
|
|
15543
15593
|
});
|
|
15544
15594
|
var ListFindingInstancesResponse = external_exports.object({
|
|
@@ -15600,33 +15650,6 @@ var ListFindingLocationsResponse = external_exports.object({
|
|
|
15600
15650
|
hasMore: external_exports.boolean()
|
|
15601
15651
|
}).meta({ id: "ListFindingLocationsResponse" });
|
|
15602
15652
|
|
|
15603
|
-
// ../../packages/schema/src/zod/harness-map.ts
|
|
15604
|
-
var Harness = external_exports.enum([
|
|
15605
|
-
"claudecode",
|
|
15606
|
-
"cursor",
|
|
15607
|
-
"copilot",
|
|
15608
|
-
"codex",
|
|
15609
|
-
"antigravity",
|
|
15610
|
-
"windsurf",
|
|
15611
|
-
"claudedesktop",
|
|
15612
|
-
"chatgpt",
|
|
15613
|
-
"claudeai",
|
|
15614
|
-
"api"
|
|
15615
|
-
]).meta({ id: "Harness" });
|
|
15616
|
-
var TOOL_TO_HARNESS = {
|
|
15617
|
-
"claude-code": "claudecode",
|
|
15618
|
-
"claude-desktop": "claudedesktop",
|
|
15619
|
-
"github-copilot": "copilot",
|
|
15620
|
-
cursor: "cursor",
|
|
15621
|
-
chatgpt: "chatgpt",
|
|
15622
|
-
codex: "codex",
|
|
15623
|
-
antigravity: "antigravity",
|
|
15624
|
-
"claude-ai": "claudeai"
|
|
15625
|
-
};
|
|
15626
|
-
function harnessFromTool(tool) {
|
|
15627
|
-
return TOOL_TO_HARNESS[tool] ?? tool;
|
|
15628
|
-
}
|
|
15629
|
-
|
|
15630
15653
|
// ../../packages/schema/src/zod/meta.ts
|
|
15631
15654
|
var InventoryObjectType = external_exports.enum(["host", "harness", "user", "skill", "hook", "mcp_server", "config_file"]).meta({ id: "InventoryObjectType" });
|
|
15632
15655
|
var AuditEventType = external_exports.enum([
|
|
@@ -16079,686 +16102,37 @@ var ActivityOverviewResponse = external_exports.object({
|
|
|
16079
16102
|
sessions: ListActivitySessionsResponse
|
|
16080
16103
|
}).meta({ id: "ActivityOverviewResponse" });
|
|
16081
16104
|
|
|
16082
|
-
// ../../packages/schema/src/zod/
|
|
16083
|
-
var
|
|
16084
|
-
var
|
|
16085
|
-
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
filePath: external_exports.string().optional(),
|
|
16101
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
16102
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
16103
|
-
// arguments or output, which can carry the very value a finding masked
|
|
16104
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
16105
|
-
// display location ("via Bash") when no filePath exists.
|
|
16106
|
-
toolName: external_exports.string().optional(),
|
|
16107
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
16108
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
16109
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
16110
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
16111
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
16112
|
-
gitignored: external_exports.boolean().optional(),
|
|
16113
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
16114
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
16115
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
16116
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
16117
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
16118
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
16119
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
16120
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
16121
|
-
// non-authoritative path.
|
|
16122
|
-
wholeFile: external_exports.boolean().optional(),
|
|
16123
|
-
model: external_exports.string().optional(),
|
|
16124
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
16125
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
16126
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
16127
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
16128
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
16129
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
16130
|
-
correlationId: external_exports.uuid().optional(),
|
|
16131
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
16132
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
16133
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
16134
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
16135
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
16136
|
-
}).meta({ id: "EventMetadata" });
|
|
16137
|
-
var Event = external_exports.object({
|
|
16138
|
-
id: external_exports.guid(),
|
|
16139
|
-
sourceTool: SourceTool,
|
|
16140
|
-
kind: EventKind,
|
|
16141
|
-
occurredAt: external_exports.iso.datetime(),
|
|
16142
|
-
contentHash: external_exports.string(),
|
|
16143
|
-
content: external_exports.string(),
|
|
16144
|
-
metadata: EventMetadata.optional()
|
|
16145
|
-
}).meta({ id: "Event" });
|
|
16146
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
16147
|
-
var IngestBatch = external_exports.object({
|
|
16148
|
-
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
16149
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
16150
|
-
// additionally rejects any event whose contentHash the store has already
|
|
16151
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
16152
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
16153
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
16154
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
16155
|
-
// the timeline.
|
|
16156
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
16157
|
-
}).meta({ id: "IngestBatch" });
|
|
16158
|
-
|
|
16159
|
-
// ../../packages/schema/src/zod/inventory.ts
|
|
16160
|
-
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
16161
|
-
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
16162
|
-
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
16163
|
-
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
16164
|
-
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
16165
|
-
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
16166
|
-
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
16167
|
-
var HarnessId = external_exports.enum(["claudecode", "cursor", "codex", "antigravity"]).meta({ id: "HarnessId" });
|
|
16168
|
-
var AccessCounts = external_exports.object({
|
|
16169
|
-
open: external_exports.number().int().nonnegative(),
|
|
16170
|
-
approved: external_exports.number().int().nonnegative(),
|
|
16171
|
-
blocked: external_exports.number().int().nonnegative(),
|
|
16172
|
-
total: external_exports.number().int().nonnegative()
|
|
16173
|
-
}).meta({ id: "AccessCounts" });
|
|
16174
|
-
var AssetSummary = external_exports.object({
|
|
16175
|
-
id: external_exports.string(),
|
|
16176
|
-
type: AssetType,
|
|
16177
|
-
name: external_exports.string(),
|
|
16178
|
-
sub: external_exports.string(),
|
|
16179
|
-
flags: external_exports.array(Flag),
|
|
16180
|
-
/** MCP servers only — omitted for all other types. */
|
|
16181
|
-
trust: TrustLevel.optional()
|
|
16182
|
-
}).meta({ id: "AssetSummary" });
|
|
16183
|
-
var ProjectSummary = external_exports.object({
|
|
16184
|
-
id: external_exports.string(),
|
|
16185
|
-
name: external_exports.string(),
|
|
16186
|
-
repo: external_exports.string(),
|
|
16187
|
-
visibility: Visibility,
|
|
16188
|
-
language: external_exports.string(),
|
|
16189
|
-
policyDefault: AccessLevel,
|
|
16190
|
-
updatedAt: external_exports.iso.datetime(),
|
|
16191
|
-
accessCounts: AccessCounts,
|
|
16192
|
-
findingsCount: external_exports.number().int().nonnegative()
|
|
16193
|
-
}).meta({ id: "ProjectSummary" });
|
|
16194
|
-
var HarnessCategory = external_exports.object({
|
|
16195
|
-
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
16196
|
-
type: AssetType,
|
|
16197
|
-
assets: external_exports.array(AssetSummary)
|
|
16105
|
+
// ../../packages/schema/src/zod/config-inventory.ts
|
|
16106
|
+
var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
|
|
16107
|
+
var SkillScanEntry = external_exports.object({
|
|
16108
|
+
name: external_exports.string().min(1),
|
|
16109
|
+
// The identity source: a marketplace repo for plugin skills (e.g.
|
|
16110
|
+
// 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
|
|
16111
|
+
// 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
|
|
16112
|
+
// a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
|
|
16113
|
+
source: external_exports.string().min(1),
|
|
16114
|
+
scope: ConfigScope,
|
|
16115
|
+
pluginName: external_exports.string().optional(),
|
|
16116
|
+
// Volatile — rides the attribute bag, never the identity hash.
|
|
16117
|
+
version: external_exports.string().optional(),
|
|
16118
|
+
description: external_exports.string().optional(),
|
|
16119
|
+
// Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
|
|
16120
|
+
updatedAt: external_exports.iso.datetime().optional(),
|
|
16121
|
+
// Filesystem path — the promoted inventory `location` column.
|
|
16122
|
+
location: external_exports.string().optional()
|
|
16198
16123
|
});
|
|
16199
|
-
var
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
var AssetGroup = external_exports.object({
|
|
16212
|
-
/** Group key — never project (enforced at service layer). */
|
|
16213
|
-
type: AssetType,
|
|
16214
|
-
total: external_exports.number().int().nonnegative(),
|
|
16215
|
-
/**
|
|
16216
|
-
* MCP group only — omitted for all other types.
|
|
16217
|
-
* Partial: only TrustLevel keys with non-zero counts are included.
|
|
16218
|
-
* Strict: unknown keys are rejected — only TrustLevel values are valid keys.
|
|
16219
|
-
*/
|
|
16220
|
-
trustRollup: external_exports.object({
|
|
16221
|
-
"known-good": external_exports.number().int().nonnegative(),
|
|
16222
|
-
risky: external_exports.number().int().nonnegative(),
|
|
16223
|
-
unapproved: external_exports.number().int().nonnegative()
|
|
16224
|
-
}).partial().strict().optional(),
|
|
16225
|
-
/**
|
|
16226
|
-
* Partial: only Flag keys with non-zero counts are included.
|
|
16227
|
-
* Strict: unknown keys are rejected — only Flag values are valid keys.
|
|
16228
|
-
*/
|
|
16229
|
-
flagRollup: external_exports.object({
|
|
16230
|
-
update: external_exports.number().int().nonnegative(),
|
|
16231
|
-
stale: external_exports.number().int().nonnegative(),
|
|
16232
|
-
conflict: external_exports.number().int().nonnegative(),
|
|
16233
|
-
unknown: external_exports.number().int().nonnegative(),
|
|
16234
|
-
change: external_exports.number().int().nonnegative(),
|
|
16235
|
-
untracked: external_exports.number().int().nonnegative(),
|
|
16236
|
-
risk: external_exports.number().int().nonnegative(),
|
|
16237
|
-
findings: external_exports.number().int().nonnegative()
|
|
16238
|
-
}).partial().strict(),
|
|
16239
|
-
items: external_exports.array(AssetSummary)
|
|
16240
|
-
}).meta({ id: "AssetGroup" });
|
|
16241
|
-
var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
|
|
16242
|
-
var McpTool = external_exports.object({
|
|
16243
|
-
name: external_exports.string(),
|
|
16244
|
-
signature: external_exports.string(),
|
|
16245
|
-
description: external_exports.string(),
|
|
16246
|
-
write: external_exports.boolean(),
|
|
16247
|
-
/** Non-null string when tool is dangerous / blocked; null otherwise. */
|
|
16248
|
-
risk: external_exports.string().nullable()
|
|
16249
|
-
}).meta({ id: "McpTool" });
|
|
16250
|
-
var AssetFindingRef = external_exports.object({
|
|
16251
|
-
id: external_exports.string(),
|
|
16252
|
-
title: external_exports.string(),
|
|
16253
|
-
note: external_exports.string()
|
|
16254
|
-
});
|
|
16255
|
-
var AssetDetail = AssetSummary.extend({
|
|
16256
|
-
/** string | null — null when no description is available. */
|
|
16257
|
-
description: external_exports.string().nullable(),
|
|
16258
|
-
/** trustLevel | null — null for non-MCP assets. */
|
|
16259
|
-
trust: TrustLevel.nullable(),
|
|
16260
|
-
/** Type-specific raw key/values — FE renders the grid. */
|
|
16261
|
-
meta: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
16262
|
-
/** always present — object when there is an active finding, null when absent. */
|
|
16263
|
-
finding: AssetFindingRef.nullable(),
|
|
16264
|
-
/** MCP exposed-tools list — omitted for non-mcp. */
|
|
16265
|
-
tools: external_exports.array(McpTool).optional()
|
|
16266
|
-
}).meta({ id: "AssetDetail" });
|
|
16267
|
-
var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
|
|
16268
|
-
var InventoryStats = external_exports.object({
|
|
16269
|
-
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16270
|
-
attention: external_exports.number().int().nonnegative(),
|
|
16271
|
-
byType: external_exports.object({
|
|
16272
|
-
project: external_exports.number().int().nonnegative(),
|
|
16273
|
-
skill: external_exports.number().int().nonnegative(),
|
|
16274
|
-
mcp: external_exports.number().int().nonnegative(),
|
|
16275
|
-
hook: external_exports.number().int().nonnegative(),
|
|
16276
|
-
config: external_exports.number().int().nonnegative()
|
|
16277
|
-
}),
|
|
16278
|
-
harnesses: external_exports.number().int().nonnegative(),
|
|
16279
|
-
mcpTrust: external_exports.object({
|
|
16280
|
-
"known-good": external_exports.number().int().nonnegative(),
|
|
16281
|
-
risky: external_exports.number().int().nonnegative(),
|
|
16282
|
-
unapproved: external_exports.number().int().nonnegative()
|
|
16283
|
-
})
|
|
16284
|
-
}).meta({ id: "InventoryStats" });
|
|
16285
|
-
var FileSummary = external_exports.object({
|
|
16286
|
-
path: external_exports.string(),
|
|
16287
|
-
name: external_exports.string(),
|
|
16288
|
-
origin: Origin,
|
|
16289
|
-
/** Effective access (override applied). */
|
|
16290
|
-
access: AccessLevel,
|
|
16291
|
-
/** True when a file_access_override differs from the computed default. */
|
|
16292
|
-
isCustom: external_exports.boolean(),
|
|
16293
|
-
findings: external_exports.number().int().nonnegative(),
|
|
16294
|
-
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16295
|
-
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16296
|
-
/** Why the file was blocked; null when absent. */
|
|
16297
|
-
note: external_exports.string().nullable().optional()
|
|
16298
|
-
}).meta({ id: "FileSummary" });
|
|
16299
|
-
var FolderSummary = external_exports.object({
|
|
16300
|
-
name: external_exports.string(),
|
|
16301
|
-
path: external_exports.string(),
|
|
16302
|
-
/** Rollup of effective access across all descendants. */
|
|
16303
|
-
accessCounts: AccessCounts
|
|
16304
|
-
}).meta({ id: "FolderSummary" });
|
|
16305
|
-
var ProjectTreeResponse = external_exports.object({
|
|
16306
|
-
project: external_exports.object({
|
|
16307
|
-
id: external_exports.string(),
|
|
16308
|
-
repo: external_exports.string(),
|
|
16309
|
-
visibility: Visibility
|
|
16310
|
-
}),
|
|
16311
|
-
path: external_exports.string(),
|
|
16312
|
-
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16313
|
-
folders: external_exports.array(FolderSummary).optional(),
|
|
16314
|
-
files: external_exports.array(FileSummary)
|
|
16315
|
-
}).meta({ id: "ProjectTreeResponse" });
|
|
16316
|
-
var FileDetail = FileSummary.extend({
|
|
16317
|
-
project: external_exports.object({
|
|
16318
|
-
repo: external_exports.string(),
|
|
16319
|
-
visibility: Visibility,
|
|
16320
|
-
language: external_exports.string(),
|
|
16321
|
-
policyDefault: AccessLevel,
|
|
16322
|
-
updatedAt: external_exports.iso.datetime()
|
|
16323
|
-
}),
|
|
16324
|
-
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16325
|
-
}).meta({ id: "FileDetail" });
|
|
16326
|
-
var SetFileAccessBody = external_exports.object({
|
|
16327
|
-
path: external_exports.string(),
|
|
16328
|
-
access: AccessLevel
|
|
16329
|
-
}).meta({ id: "SetFileAccessBody" });
|
|
16330
|
-
var SetFileAccessResponse = external_exports.object({
|
|
16331
|
-
file: FileSummary,
|
|
16332
|
-
accessCounts: AccessCounts
|
|
16333
|
-
}).meta({ id: "SetFileAccessResponse" });
|
|
16334
|
-
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16335
|
-
var HarnessEventItem = external_exports.object({
|
|
16336
|
-
kind: HarnessEventKind,
|
|
16337
|
-
title: external_exports.string(),
|
|
16338
|
-
detail: external_exports.string(),
|
|
16339
|
-
occurredAt: external_exports.iso.datetime(),
|
|
16340
|
-
findingId: external_exports.string().nullable().optional()
|
|
16341
|
-
}).meta({ id: "HarnessEventItem" });
|
|
16342
|
-
var HarnessEventsResponse = external_exports.object({
|
|
16343
|
-
counts: external_exports.object({
|
|
16344
|
-
block: external_exports.number().int().nonnegative(),
|
|
16345
|
-
redact: external_exports.number().int().nonnegative(),
|
|
16346
|
-
warn: external_exports.number().int().nonnegative()
|
|
16347
|
-
}),
|
|
16348
|
-
items: external_exports.array(HarnessEventItem)
|
|
16349
|
-
}).meta({ id: "HarnessEventsResponse" });
|
|
16350
|
-
var RescanResponse = external_exports.object({
|
|
16351
|
-
jobId: external_exports.string(),
|
|
16352
|
-
startedAt: external_exports.iso.datetime()
|
|
16353
|
-
}).meta({ id: "RescanResponse" });
|
|
16354
|
-
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16355
|
-
var ListAssetsQuery = external_exports.object({
|
|
16356
|
-
/** Filter by one or more AssetType values; absent means all types. */
|
|
16357
|
-
type: external_exports.array(AssetType).optional(),
|
|
16358
|
-
/** Free-text search term. */
|
|
16359
|
-
q: external_exports.string().optional()
|
|
16360
|
-
});
|
|
16361
|
-
var GetProjectTreeQuery = external_exports.object({
|
|
16362
|
-
/** Subtree root path; defaults to repository root when absent. */
|
|
16363
|
-
path: external_exports.string().optional(),
|
|
16364
|
-
/** Free-text filter applied to file paths. */
|
|
16365
|
-
q: external_exports.string().optional(),
|
|
16366
|
-
/**
|
|
16367
|
-
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16368
|
-
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16369
|
-
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16370
|
-
*/
|
|
16371
|
-
filter: external_exports.enum(["blocked"]).optional()
|
|
16372
|
-
});
|
|
16373
|
-
var GetProjectFileQuery = external_exports.object({
|
|
16374
|
-
/** Repository-relative file path; absent or empty → 400. */
|
|
16375
|
-
path: external_exports.string()
|
|
16376
|
-
});
|
|
16377
|
-
var GetHarnessEventsQuery = external_exports.object({
|
|
16378
|
-
/** Maximum number of events to return. Range: 1–50; default: 7. */
|
|
16379
|
-
limit: external_exports.coerce.number().int().min(1).max(50).default(7)
|
|
16380
|
-
});
|
|
16381
|
-
|
|
16382
|
-
// ../../packages/schema/src/zod/exception.ts
|
|
16383
|
-
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
16384
|
-
var ExceptionConditions = external_exports.object({
|
|
16385
|
-
repo: external_exports.string().optional(),
|
|
16386
|
-
sourceTool: external_exports.string().optional(),
|
|
16387
|
-
provider: external_exports.string().optional()
|
|
16388
|
-
}).strict();
|
|
16389
|
-
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
16390
|
-
var DetectionException = external_exports.object({
|
|
16391
|
-
id: external_exports.guid(),
|
|
16392
|
-
ruleId: external_exports.string(),
|
|
16393
|
-
// Denormalized from the rule, for reporting — never matched on.
|
|
16394
|
-
category: DetectionCategory,
|
|
16395
|
-
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
16396
|
-
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
16397
|
-
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
16398
|
-
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
16399
|
-
// at the boundary rather than persisted.
|
|
16400
|
-
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
16401
|
-
// Version of the fingerprint key the grant was written under; a rotated key
|
|
16402
|
-
// invalidates old grants rather than silently mismatching them.
|
|
16403
|
-
keyVersion: external_exports.number().int().positive(),
|
|
16404
|
-
// maskMatch() preview of the approved value — never the raw value.
|
|
16405
|
-
maskedValue: external_exports.string(),
|
|
16406
|
-
capability: ExceptionCapability.default("suppress"),
|
|
16407
|
-
scope: ExceptionScope,
|
|
16408
|
-
expiresAt: external_exports.iso.datetime().nullable(),
|
|
16409
|
-
maxUses: external_exports.number().int().positive().nullable(),
|
|
16410
|
-
useCount: external_exports.number().int().nonnegative(),
|
|
16411
|
-
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
16412
|
-
// Mandatory: every grant carries the human reason it exists.
|
|
16413
|
-
justification: external_exports.string().min(1),
|
|
16414
|
-
conditions: ExceptionConditions.nullable(),
|
|
16415
|
-
createdBy: external_exports.string(),
|
|
16416
|
-
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
16417
|
-
createdAt: external_exports.iso.datetime(),
|
|
16418
|
-
updatedAt: external_exports.iso.datetime(),
|
|
16419
|
-
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
16420
|
-
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
16421
|
-
revokedAt: external_exports.iso.datetime().nullable(),
|
|
16422
|
-
revokedBy: external_exports.string().nullable(),
|
|
16423
|
-
revokeReason: external_exports.string().nullable()
|
|
16424
|
-
});
|
|
16425
|
-
var ExceptionBundleEntry = DetectionException.pick({
|
|
16426
|
-
id: true,
|
|
16427
|
-
ruleId: true,
|
|
16428
|
-
valueFingerprint: true,
|
|
16429
|
-
keyVersion: true,
|
|
16430
|
-
capability: true,
|
|
16431
|
-
expiresAt: true,
|
|
16432
|
-
maxUses: true,
|
|
16433
|
-
useCount: true,
|
|
16434
|
-
conditions: true
|
|
16435
|
-
});
|
|
16436
|
-
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
16437
|
-
|
|
16438
|
-
// ../../packages/schema/src/zod/rule.ts
|
|
16439
|
-
var MatcherType = external_exports.enum(["keyword", "regex", "validator"]).meta({ id: "MatcherType" });
|
|
16440
|
-
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
16441
|
-
var KeywordMatcher = external_exports.object({
|
|
16442
|
-
type: external_exports.literal("keyword"),
|
|
16443
|
-
// An empty keyword matches at every position, yielding one zero-length span
|
|
16444
|
-
// per character. Rejected here because a keyword that matches everything is
|
|
16445
|
-
// never intentional.
|
|
16446
|
-
keywords: external_exports.array(external_exports.string().min(1)).min(1),
|
|
16447
|
-
caseSensitive: external_exports.boolean().default(false)
|
|
16448
|
-
});
|
|
16449
|
-
function isValidRegex(pattern, flags) {
|
|
16450
|
-
try {
|
|
16451
|
-
new RegExp(pattern, flags);
|
|
16452
|
-
return true;
|
|
16453
|
-
} catch {
|
|
16454
|
-
return false;
|
|
16455
|
-
}
|
|
16456
|
-
}
|
|
16457
|
-
function matchesEmptyString(pattern, flags) {
|
|
16458
|
-
try {
|
|
16459
|
-
const re = new RegExp(pattern, flags.replace(/[gy]/g, ""));
|
|
16460
|
-
return re.exec("")?.[0].length === 0;
|
|
16461
|
-
} catch {
|
|
16462
|
-
return false;
|
|
16463
|
-
}
|
|
16464
|
-
}
|
|
16465
|
-
var MAX_PATTERN_LENGTH = 2e3;
|
|
16466
|
-
var RegexMatcher = external_exports.object({
|
|
16467
|
-
type: external_exports.literal("regex"),
|
|
16468
|
-
pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
|
|
16469
|
-
flags: external_exports.string().default("gi"),
|
|
16470
|
-
captureGroup: external_exports.number().int().nonnegative().optional()
|
|
16471
|
-
}).refine((v) => isValidRegex(v.pattern, v.flags), {
|
|
16472
|
-
message: "pattern/flags do not form a valid JavaScript regular expression",
|
|
16473
|
-
path: ["pattern"]
|
|
16474
|
-
}).refine((v) => v.captureGroup !== void 0 || !matchesEmptyString(v.pattern, v.flags), {
|
|
16475
|
-
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',
|
|
16476
|
-
path: ["pattern"]
|
|
16477
|
-
});
|
|
16478
|
-
var ValidatorMatcher = external_exports.object({
|
|
16479
|
-
type: external_exports.literal("validator"),
|
|
16480
|
-
name: external_exports.enum(["luhn", "entropy", "ssn-checksum"]),
|
|
16481
|
-
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16482
|
-
});
|
|
16483
|
-
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher, ValidatorMatcher]).meta({ id: "Matcher" });
|
|
16484
|
-
var AppliesTo = external_exports.object({
|
|
16485
|
-
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
16486
|
-
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
16487
|
-
}).meta({ id: "AppliesTo" });
|
|
16488
|
-
var PostValidatorRef = external_exports.union([
|
|
16489
|
-
external_exports.string(),
|
|
16490
|
-
external_exports.object({
|
|
16491
|
-
name: external_exports.string(),
|
|
16492
|
-
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16493
|
-
})
|
|
16494
|
-
]).meta({ id: "PostValidatorRef" });
|
|
16495
|
-
var RequiresNearby = external_exports.object({
|
|
16496
|
-
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
16497
|
-
// an empty/blank criterion would either never fire or (for labels) match
|
|
16498
|
-
// everything.
|
|
16499
|
-
categories: external_exports.array(DetectionCategory).min(1).optional(),
|
|
16500
|
-
ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16501
|
-
labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16502
|
-
windowChars: external_exports.number().int().positive().default(160),
|
|
16503
|
-
// Optional confidence bump applied when a gated match is corroborated. Capped
|
|
16504
|
-
// small: it nudges confidence, it does not assert certainty.
|
|
16505
|
-
confidenceBoost: external_exports.number().min(0).max(0.3).optional()
|
|
16506
|
-
}).refine(
|
|
16507
|
-
(v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
|
|
16508
|
-
{ message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
|
|
16509
|
-
).meta({ id: "RequiresNearby" });
|
|
16510
|
-
var RuleFixture = external_exports.object({
|
|
16511
|
-
label: external_exports.string(),
|
|
16512
|
-
text: external_exports.string().max(5e4),
|
|
16513
|
-
shouldMatch: external_exports.boolean(),
|
|
16514
|
-
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
16515
|
-
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
16516
|
-
filePath: external_exports.string().optional(),
|
|
16517
|
-
expectedSpans: external_exports.array(external_exports.object({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
16518
|
-
}).meta({ id: "RuleFixture" });
|
|
16519
|
-
var Rule = external_exports.object({
|
|
16520
|
-
specVersion: external_exports.literal(1),
|
|
16521
|
-
// `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
|
|
16522
|
-
// the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
|
|
16523
|
-
// detection id (`namespace/packId`, decoded by splitDetectionId). A Rule.id
|
|
16524
|
-
// therefore carries no namespace and is not globally unique across publishers;
|
|
16525
|
-
// never feed one to splitDetectionId. `category` below (per-rule) is the
|
|
16526
|
-
// taxonomy axis; the pack's enforcement policy is installed_packs.policy_id.
|
|
16527
|
-
id: external_exports.string().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/),
|
|
16528
|
-
name: external_exports.string(),
|
|
16529
|
-
category: DetectionCategory,
|
|
16530
|
-
severity: Severity,
|
|
16531
|
-
matcher: Matcher,
|
|
16532
|
-
appliesTo: AppliesTo.optional(),
|
|
16533
|
-
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
16534
|
-
requiresNearby: RequiresNearby.optional(),
|
|
16535
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
16536
|
-
}).meta({ id: "Rule" });
|
|
16537
|
-
var Author = external_exports.object({
|
|
16538
|
-
name: external_exports.string(),
|
|
16539
|
-
email: external_exports.email().optional(),
|
|
16540
|
-
url: external_exports.url().optional()
|
|
16541
|
-
}).meta({ id: "Author" });
|
|
16542
|
-
var PackManifest = external_exports.object({
|
|
16543
|
-
specVersion: external_exports.literal(1),
|
|
16544
|
-
id: external_exports.string(),
|
|
16545
|
-
name: external_exports.string(),
|
|
16546
|
-
version: external_exports.string(),
|
|
16547
|
-
rules: external_exports.array(external_exports.string()),
|
|
16548
|
-
// Optional attribution/provenance — consumed by the rule marketplace.
|
|
16549
|
-
description: external_exports.string().optional(),
|
|
16550
|
-
author: Author.optional(),
|
|
16551
|
-
license: external_exports.string().optional(),
|
|
16552
|
-
sourceUrl: external_exports.url().optional()
|
|
16553
|
-
}).meta({ id: "PackManifest" });
|
|
16554
|
-
|
|
16555
|
-
// ../../packages/schema/src/zod/policy.ts
|
|
16556
|
-
var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
|
|
16557
|
-
var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
|
|
16558
|
-
var Policy = external_exports.object({
|
|
16559
|
-
id: external_exports.guid(),
|
|
16560
|
-
scope: PolicyScope,
|
|
16561
|
-
target: PolicyTarget,
|
|
16562
|
-
action: ActionTaken,
|
|
16563
|
-
enabled: external_exports.boolean().default(true),
|
|
16564
|
-
customKeywords: external_exports.array(external_exports.string()).optional(),
|
|
16565
|
-
// Display name — optional so older policy rows without name still parse.
|
|
16566
|
-
// Added for the findings API (policy.name column migration).
|
|
16567
|
-
name: external_exports.string().optional()
|
|
16568
|
-
}).meta({ id: "Policy" });
|
|
16569
|
-
var PolicyBundle = external_exports.object({
|
|
16570
|
-
version: external_exports.string(),
|
|
16571
|
-
policies: external_exports.array(Policy),
|
|
16572
|
-
// Rules from the installed marketplace packs (snapshotted by the
|
|
16573
|
-
// control plane). The plugin registers these in addition to its bundled
|
|
16574
|
-
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
16575
|
-
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
16576
|
-
rules: external_exports.array(Rule).optional(),
|
|
16577
|
-
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
16578
|
-
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
16579
|
-
// after reading the user's installed snapshot (installed_packs, enabled
|
|
16580
|
-
// packs only), which is how detection updates stay manual: new bundled
|
|
16581
|
-
// rules run only after the user applies the pack update. Absent/false keeps
|
|
16582
|
-
// the historical composition (bundled packs + rules) — older caches.
|
|
16583
|
-
rulesComplete: external_exports.boolean().optional(),
|
|
16584
|
-
// Active detection exceptions, evaluation subset only (see
|
|
16585
|
-
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
16586
|
-
// on-disk caches — that omit the field still parse; consumers read
|
|
16587
|
-
// `bundle.exceptions ?? []`.
|
|
16588
|
-
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
16589
|
-
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
16590
|
-
// from a versioned installed pack. Optional so older backends — and older
|
|
16591
|
-
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
16592
|
-
// the rule's own spec version. NOT the bundle version above — see
|
|
16593
|
-
// installedRuleset's ruleVersions for the source of truth.
|
|
16594
|
-
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
16595
|
-
customKeywords: external_exports.array(external_exports.string()),
|
|
16596
|
-
fetchedAt: external_exports.iso.datetime()
|
|
16597
|
-
}).meta({ id: "PolicyBundle" });
|
|
16598
|
-
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
16599
|
-
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
16600
|
-
var CATEGORY_PEAK_SEVERITY = {
|
|
16601
|
-
secret: "critical",
|
|
16602
|
-
financial: "critical",
|
|
16603
|
-
// core-financial/credit-card
|
|
16604
|
-
code_flaw: "critical",
|
|
16605
|
-
pii: "high",
|
|
16606
|
-
phi: "high",
|
|
16607
|
-
custom: "high",
|
|
16608
|
-
// user-defined; conservative
|
|
16609
|
-
code_context: "low",
|
|
16610
|
-
config: "low"
|
|
16611
|
-
// observe-only; floors to monitor regardless
|
|
16612
|
-
};
|
|
16613
|
-
function severityFloorPolicy(category) {
|
|
16614
|
-
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
16615
|
-
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
16616
|
-
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
16617
|
-
}
|
|
16618
|
-
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
16619
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "block"];
|
|
16620
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
16621
|
-
var BUILTIN_ORDER = KNOWN_BUILTIN_IDS;
|
|
16622
|
-
var BUILTIN_POLICY_SPECS = {
|
|
16623
|
-
monitor: {
|
|
16624
|
-
name: "Monitor",
|
|
16625
|
-
action: "log",
|
|
16626
|
-
description: "Log every match for audit. The request is allowed through untouched."
|
|
16627
|
-
},
|
|
16628
|
-
warn: {
|
|
16629
|
-
name: "Warn",
|
|
16630
|
-
action: "warn",
|
|
16631
|
-
description: "Allow the request, but warn the user inline before it is sent."
|
|
16632
|
-
},
|
|
16633
|
-
redact: {
|
|
16634
|
-
name: "Redact",
|
|
16635
|
-
action: "redact",
|
|
16636
|
-
description: "Automatically strip the matched value from the request, then continue."
|
|
16637
|
-
},
|
|
16638
|
-
block: {
|
|
16639
|
-
name: "Block",
|
|
16640
|
-
action: "block",
|
|
16641
|
-
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
16642
|
-
}
|
|
16643
|
-
};
|
|
16644
|
-
function builtinPolicyToAction(id) {
|
|
16645
|
-
return BUILTIN_POLICY_SPECS[id].action;
|
|
16646
|
-
}
|
|
16647
|
-
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
16648
|
-
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
16649
|
-
);
|
|
16650
|
-
var BUILTIN_POLICIES = Object.fromEntries(
|
|
16651
|
-
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
16652
|
-
);
|
|
16653
|
-
var DEFAULT_PACK_POLICY_ID = "monitor";
|
|
16654
|
-
function policyIdToAction(policyId) {
|
|
16655
|
-
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
16656
|
-
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
16657
|
-
return BUILTIN_POLICIES[id].action;
|
|
16658
|
-
}
|
|
16659
|
-
var UsedByItem = external_exports.object({
|
|
16660
|
-
id: external_exports.string(),
|
|
16661
|
-
name: external_exports.string(),
|
|
16662
|
-
ruleCount: external_exports.number().int().nonnegative(),
|
|
16663
|
-
enabled: external_exports.boolean()
|
|
16664
|
-
}).meta({ id: "UsedByItem" });
|
|
16665
|
-
var PolicyListItem = external_exports.object({
|
|
16666
|
-
id: external_exports.string(),
|
|
16667
|
-
kind: PolicyKind,
|
|
16668
|
-
name: external_exports.string(),
|
|
16669
|
-
enabled: external_exports.boolean(),
|
|
16670
|
-
usedByCount: external_exports.number().int().nonnegative()
|
|
16671
|
-
}).meta({ id: "PolicyListItem" });
|
|
16672
|
-
var PolicyDetail = external_exports.object({
|
|
16673
|
-
specVersion: external_exports.literal(1),
|
|
16674
|
-
id: external_exports.string(),
|
|
16675
|
-
kind: PolicyKind,
|
|
16676
|
-
name: external_exports.string(),
|
|
16677
|
-
enabled: external_exports.boolean(),
|
|
16678
|
-
description: external_exports.string(),
|
|
16679
|
-
usedBy: external_exports.array(UsedByItem)
|
|
16680
|
-
}).meta({ id: "PolicyDetail" });
|
|
16681
|
-
var PolicyStatsResponse = external_exports.object({
|
|
16682
|
-
policies: external_exports.number().int().nonnegative(),
|
|
16683
|
-
builtin: external_exports.number().int().nonnegative(),
|
|
16684
|
-
custom: external_exports.number().int().nonnegative(),
|
|
16685
|
-
detectionsGoverned: external_exports.number().int().nonnegative()
|
|
16686
|
-
}).meta({ id: "PolicyStatsResponse" });
|
|
16687
|
-
|
|
16688
|
-
// ../../packages/schema/src/zod/api.ts
|
|
16689
|
-
var LIST_QUERY_MAX_LIMIT = 200;
|
|
16690
|
-
var ListEventsQuery = external_exports.object({
|
|
16691
|
-
cursor: external_exports.string().optional(),
|
|
16692
|
-
limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
|
|
16693
|
-
sourceTool: external_exports.string().optional(),
|
|
16694
|
-
kind: external_exports.string().optional(),
|
|
16695
|
-
from: external_exports.iso.datetime().optional(),
|
|
16696
|
-
to: external_exports.iso.datetime().optional()
|
|
16697
|
-
});
|
|
16698
|
-
var ListEventsResponse = external_exports.object({
|
|
16699
|
-
items: external_exports.array(Event),
|
|
16700
|
-
nextCursor: external_exports.string().nullable()
|
|
16701
|
-
}).meta({ id: "ListEventsResponse" });
|
|
16702
|
-
var IngestResponse = external_exports.object({
|
|
16703
|
-
accepted: external_exports.number().int().nonnegative(),
|
|
16704
|
-
duplicates: external_exports.number().int().nonnegative()
|
|
16705
|
-
}).meta({ id: "IngestResponse" });
|
|
16706
|
-
var ListFindingsQuery = external_exports.object({
|
|
16707
|
-
cursor: external_exports.string().optional(),
|
|
16708
|
-
limit: external_exports.coerce.number().int().min(1).max(LIST_QUERY_MAX_LIMIT).default(50),
|
|
16709
|
-
severity: external_exports.string().optional(),
|
|
16710
|
-
category: external_exports.string().optional(),
|
|
16711
|
-
eventId: external_exports.guid().optional()
|
|
16712
|
-
});
|
|
16713
|
-
var ListFindingsResponse = external_exports.object({
|
|
16714
|
-
items: external_exports.array(Finding),
|
|
16715
|
-
nextCursor: external_exports.string().nullable()
|
|
16716
|
-
}).meta({ id: "ListFindingsResponse" });
|
|
16717
|
-
var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
|
|
16718
|
-
var CreatePolicyRequest = Policy.omit({ id: true }).meta({
|
|
16719
|
-
id: "CreatePolicyRequest"
|
|
16720
|
-
});
|
|
16721
|
-
var UpdatePolicyRequest = Policy.partial().required({ id: true }).meta({ id: "UpdatePolicyRequest" });
|
|
16722
|
-
var RecordAuditEventResponse = external_exports.object({ accepted: external_exports.boolean() }).meta({ id: "RecordAuditEventResponse" });
|
|
16723
|
-
var ErrorResponse = external_exports.object({
|
|
16724
|
-
error: external_exports.object({
|
|
16725
|
-
code: external_exports.string(),
|
|
16726
|
-
message: external_exports.string(),
|
|
16727
|
-
details: external_exports.unknown().optional()
|
|
16728
|
-
})
|
|
16729
|
-
}).meta({ id: "ErrorResponse" });
|
|
16730
|
-
|
|
16731
|
-
// ../../packages/schema/src/zod/config-inventory.ts
|
|
16732
|
-
var ConfigScope = external_exports.enum(["user", "project", "local", "plugin"]);
|
|
16733
|
-
var SkillScanEntry = external_exports.object({
|
|
16734
|
-
name: external_exports.string().min(1),
|
|
16735
|
-
// The identity source: a marketplace repo for plugin skills (e.g.
|
|
16736
|
-
// 'anthropics/skills'), 'local' for personal ~/.claude/skills, or
|
|
16737
|
-
// 'project:<repo-identity>' for checked-in project skills. The surrogate keeps
|
|
16738
|
-
// a personal skill named 'pdf' from colliding with the marketplace 'pdf'.
|
|
16739
|
-
source: external_exports.string().min(1),
|
|
16740
|
-
scope: ConfigScope,
|
|
16741
|
-
pluginName: external_exports.string().optional(),
|
|
16742
|
-
// Volatile — rides the attribute bag, never the identity hash.
|
|
16743
|
-
version: external_exports.string().optional(),
|
|
16744
|
-
description: external_exports.string().optional(),
|
|
16745
|
-
// Skill directory mtime (ISO) — the "updated Nd ago" freshness signal.
|
|
16746
|
-
updatedAt: external_exports.iso.datetime().optional(),
|
|
16747
|
-
// Filesystem path — the promoted inventory `location` column.
|
|
16748
|
-
location: external_exports.string().optional()
|
|
16749
|
-
});
|
|
16750
|
-
var HookScanEntry = external_exports.object({
|
|
16751
|
-
// Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
|
|
16752
|
-
// set is harness-defined and grows without a schema change.
|
|
16753
|
-
event: external_exports.string().min(1),
|
|
16754
|
-
// The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
|
|
16755
|
-
matcher: external_exports.string().optional(),
|
|
16756
|
-
command: external_exports.string().min(1),
|
|
16757
|
-
timeout: external_exports.number().optional(),
|
|
16758
|
-
scope: ConfigScope,
|
|
16759
|
-
pluginName: external_exports.string().optional(),
|
|
16760
|
-
// The settings file / hooks.json the entry came from.
|
|
16761
|
-
location: external_exports.string().optional()
|
|
16124
|
+
var HookScanEntry = external_exports.object({
|
|
16125
|
+
// Hook event name (PreToolUse, PostToolUse, …). Open string, not an enum: the
|
|
16126
|
+
// set is harness-defined and grows without a schema change.
|
|
16127
|
+
event: external_exports.string().min(1),
|
|
16128
|
+
// The tool matcher ('Bash', 'Edit|Write', …). Absent = matches all tools.
|
|
16129
|
+
matcher: external_exports.string().optional(),
|
|
16130
|
+
command: external_exports.string().min(1),
|
|
16131
|
+
timeout: external_exports.number().optional(),
|
|
16132
|
+
scope: ConfigScope,
|
|
16133
|
+
pluginName: external_exports.string().optional(),
|
|
16134
|
+
// The settings file / hooks.json the entry came from.
|
|
16135
|
+
location: external_exports.string().optional()
|
|
16762
16136
|
});
|
|
16763
16137
|
var McpServerScanEntry = external_exports.object({
|
|
16764
16138
|
// The server's config key ("github", "filesystem", …) — identity, with the
|
|
@@ -16833,12 +16207,170 @@ var ConfigScanRecord = external_exports.object({
|
|
|
16833
16207
|
definitions: external_exports.array(InspectionDefinitionInput).optional(),
|
|
16834
16208
|
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
16835
16209
|
});
|
|
16836
|
-
|
|
16837
|
-
// ../../packages/schema/src/zod/registry.ts
|
|
16838
|
-
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16839
|
-
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16840
|
-
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16841
|
-
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16210
|
+
|
|
16211
|
+
// ../../packages/schema/src/zod/registry.ts
|
|
16212
|
+
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16213
|
+
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16214
|
+
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16215
|
+
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16216
|
+
|
|
16217
|
+
// ../../packages/schema/src/zod/rule.ts
|
|
16218
|
+
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
16219
|
+
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
16220
|
+
var KeywordMatcher = external_exports.strictObject({
|
|
16221
|
+
type: external_exports.literal("keyword"),
|
|
16222
|
+
// An empty keyword matches at every position, yielding one zero-length span
|
|
16223
|
+
// per character. Rejected here because a keyword that matches everything is
|
|
16224
|
+
// never intentional.
|
|
16225
|
+
keywords: external_exports.array(external_exports.string().min(1)).min(1),
|
|
16226
|
+
caseSensitive: external_exports.boolean().default(false)
|
|
16227
|
+
});
|
|
16228
|
+
function isValidRegex(pattern, flags) {
|
|
16229
|
+
try {
|
|
16230
|
+
new RegExp(pattern, flags);
|
|
16231
|
+
return true;
|
|
16232
|
+
} catch {
|
|
16233
|
+
return false;
|
|
16234
|
+
}
|
|
16235
|
+
}
|
|
16236
|
+
function probeFlags(flags) {
|
|
16237
|
+
return flags.replace(/[gy]/g, "");
|
|
16238
|
+
}
|
|
16239
|
+
function matchesEmptyString(pattern, flags) {
|
|
16240
|
+
try {
|
|
16241
|
+
const re = new RegExp(pattern, probeFlags(flags));
|
|
16242
|
+
return re.exec("")?.[0].length === 0;
|
|
16243
|
+
} catch {
|
|
16244
|
+
return false;
|
|
16245
|
+
}
|
|
16246
|
+
}
|
|
16247
|
+
function spansWholeMatch(captureGroup) {
|
|
16248
|
+
return captureGroup === void 0 || captureGroup === 0;
|
|
16249
|
+
}
|
|
16250
|
+
function captureGroupCount(pattern, flags) {
|
|
16251
|
+
try {
|
|
16252
|
+
const probe = new RegExp(`${pattern}|`, probeFlags(flags));
|
|
16253
|
+
const result = probe.exec("");
|
|
16254
|
+
return result ? result.length - 1 : void 0;
|
|
16255
|
+
} catch {
|
|
16256
|
+
return void 0;
|
|
16257
|
+
}
|
|
16258
|
+
}
|
|
16259
|
+
var MAX_PATTERN_LENGTH = 2e3;
|
|
16260
|
+
var RegexMatcher = external_exports.strictObject({
|
|
16261
|
+
type: external_exports.literal("regex"),
|
|
16262
|
+
pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
|
|
16263
|
+
flags: external_exports.string().default("gi"),
|
|
16264
|
+
captureGroup: external_exports.number().int().nonnegative().optional()
|
|
16265
|
+
}).refine((v) => isValidRegex(v.pattern, v.flags), {
|
|
16266
|
+
message: "pattern/flags do not form a valid JavaScript regular expression",
|
|
16267
|
+
path: ["pattern"]
|
|
16268
|
+
}).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
|
|
16269
|
+
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',
|
|
16270
|
+
path: ["pattern"]
|
|
16271
|
+
}).superRefine((v, ctx) => {
|
|
16272
|
+
if (v.captureGroup === void 0) return;
|
|
16273
|
+
const groups = captureGroupCount(v.pattern, v.flags);
|
|
16274
|
+
if (groups === void 0 || v.captureGroup <= groups) return;
|
|
16275
|
+
ctx.addIssue({
|
|
16276
|
+
code: "custom",
|
|
16277
|
+
path: ["captureGroup"],
|
|
16278
|
+
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.`
|
|
16279
|
+
});
|
|
16280
|
+
});
|
|
16281
|
+
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
|
|
16282
|
+
var MATCHER_TYPES = MatcherType.options;
|
|
16283
|
+
var AppliesTo = external_exports.strictObject({
|
|
16284
|
+
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
16285
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
16286
|
+
}).meta({ id: "AppliesTo" });
|
|
16287
|
+
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
16288
|
+
var PostValidatorRef = external_exports.union(
|
|
16289
|
+
[
|
|
16290
|
+
PostValidatorName,
|
|
16291
|
+
external_exports.strictObject({
|
|
16292
|
+
name: PostValidatorName,
|
|
16293
|
+
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16294
|
+
})
|
|
16295
|
+
],
|
|
16296
|
+
{
|
|
16297
|
+
// A union reports one collapsed issue for every way its arms can fail, so
|
|
16298
|
+
// this has to describe the whole shape rather than just the name — it is
|
|
16299
|
+
// what an author sees for a misspelled name AND for a stray key in the
|
|
16300
|
+
// object form. The names come from the enum so the message cannot go
|
|
16301
|
+
// stale. Without it Zod says only "Invalid input", which is precisely the
|
|
16302
|
+
// no-feedback outcome this schema exists to remove.
|
|
16303
|
+
error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
|
|
16304
|
+
" or "
|
|
16305
|
+
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
16306
|
+
}
|
|
16307
|
+
).meta({ id: "PostValidatorRef" });
|
|
16308
|
+
var RequiresNearby = external_exports.strictObject({
|
|
16309
|
+
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
16310
|
+
// an empty/blank criterion would either never fire or (for labels) match
|
|
16311
|
+
// everything.
|
|
16312
|
+
categories: external_exports.array(DetectionCategory).min(1).optional(),
|
|
16313
|
+
ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16314
|
+
labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16315
|
+
windowChars: external_exports.number().int().positive().default(160),
|
|
16316
|
+
// Optional confidence bump applied when a gated match is corroborated. Capped
|
|
16317
|
+
// small: it nudges confidence, it does not assert certainty.
|
|
16318
|
+
confidenceBoost: external_exports.number().min(0).max(0.3).optional()
|
|
16319
|
+
}).refine(
|
|
16320
|
+
(v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
|
|
16321
|
+
{ message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
|
|
16322
|
+
).meta({ id: "RequiresNearby" });
|
|
16323
|
+
var RuleFixture = external_exports.strictObject({
|
|
16324
|
+
label: external_exports.string(),
|
|
16325
|
+
text: external_exports.string().max(5e4),
|
|
16326
|
+
shouldMatch: external_exports.boolean(),
|
|
16327
|
+
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
16328
|
+
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
16329
|
+
filePath: external_exports.string().optional(),
|
|
16330
|
+
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
16331
|
+
}).meta({ id: "RuleFixture" });
|
|
16332
|
+
var Rule = external_exports.strictObject({
|
|
16333
|
+
// A pinned literal over a STRICT object, and the two together decide how this
|
|
16334
|
+
// format may grow. A rule carrying a key not listed below is refused with
|
|
16335
|
+
// `unrecognized_keys`; a rule declaring `specVersion: 2` is refused with
|
|
16336
|
+
// `invalid_value`. So the only additive path is adding an OPTIONAL field here
|
|
16337
|
+
// — that keeps every rule authored before it valid — and a rule author has no
|
|
16338
|
+
// way to introduce a field of their own or to opt into a later version.
|
|
16339
|
+
// Widening the format means changing this literal and every consumer of it.
|
|
16340
|
+
specVersion: external_exports.literal(1),
|
|
16341
|
+
// `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
|
|
16342
|
+
// the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
|
|
16343
|
+
// detection id (`namespace/packId`, decoded by splitDetectionId). A Rule.id
|
|
16344
|
+
// therefore carries no namespace and is not globally unique across publishers;
|
|
16345
|
+
// never feed one to splitDetectionId. `category` below (per-rule) is the
|
|
16346
|
+
// taxonomy axis; the pack's enforcement policy is installed_packs.policy_id.
|
|
16347
|
+
id: external_exports.string().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/),
|
|
16348
|
+
name: external_exports.string(),
|
|
16349
|
+
category: DetectionCategory,
|
|
16350
|
+
severity: Severity,
|
|
16351
|
+
matcher: Matcher,
|
|
16352
|
+
appliesTo: AppliesTo.optional(),
|
|
16353
|
+
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
16354
|
+
requiresNearby: RequiresNearby.optional(),
|
|
16355
|
+
examples: external_exports.array(external_exports.string()).optional()
|
|
16356
|
+
}).meta({ id: "Rule" });
|
|
16357
|
+
var Author = external_exports.object({
|
|
16358
|
+
name: external_exports.string(),
|
|
16359
|
+
email: external_exports.email().optional(),
|
|
16360
|
+
url: external_exports.url().optional()
|
|
16361
|
+
}).meta({ id: "Author" });
|
|
16362
|
+
var PackManifest = external_exports.object({
|
|
16363
|
+
specVersion: external_exports.literal(1),
|
|
16364
|
+
id: external_exports.string(),
|
|
16365
|
+
name: external_exports.string(),
|
|
16366
|
+
version: external_exports.string(),
|
|
16367
|
+
rules: external_exports.array(external_exports.string()),
|
|
16368
|
+
// Optional attribution/provenance — consumed by the rule marketplace.
|
|
16369
|
+
description: external_exports.string().optional(),
|
|
16370
|
+
author: Author.optional(),
|
|
16371
|
+
license: external_exports.string().optional(),
|
|
16372
|
+
sourceUrl: external_exports.url().optional()
|
|
16373
|
+
}).meta({ id: "PackManifest" });
|
|
16842
16374
|
|
|
16843
16375
|
// ../../packages/schema/src/zod/detection.ts
|
|
16844
16376
|
var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
|
|
@@ -17038,6 +16570,231 @@ function buildDetectionsList(summaries, query) {
|
|
|
17038
16570
|
return { counts, items: filtered.map(summaryToDetectionListItem) };
|
|
17039
16571
|
}
|
|
17040
16572
|
|
|
16573
|
+
// ../../packages/schema/src/zod/inventory.ts
|
|
16574
|
+
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
16575
|
+
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
16576
|
+
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
16577
|
+
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
16578
|
+
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
16579
|
+
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
16580
|
+
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
16581
|
+
var HarnessId = Harness.extract(["ClaudeCode", "Cursor", "Codex", "Antigravity"]).meta({
|
|
16582
|
+
id: "HarnessId"
|
|
16583
|
+
});
|
|
16584
|
+
var AccessCounts = external_exports.object({
|
|
16585
|
+
open: external_exports.number().int().nonnegative(),
|
|
16586
|
+
approved: external_exports.number().int().nonnegative(),
|
|
16587
|
+
blocked: external_exports.number().int().nonnegative(),
|
|
16588
|
+
total: external_exports.number().int().nonnegative()
|
|
16589
|
+
}).meta({ id: "AccessCounts" });
|
|
16590
|
+
var AssetSummary = external_exports.object({
|
|
16591
|
+
id: external_exports.string(),
|
|
16592
|
+
type: AssetType,
|
|
16593
|
+
name: external_exports.string(),
|
|
16594
|
+
sub: external_exports.string(),
|
|
16595
|
+
flags: external_exports.array(Flag),
|
|
16596
|
+
/** MCP servers only — omitted for all other types. */
|
|
16597
|
+
trust: TrustLevel.optional()
|
|
16598
|
+
}).meta({ id: "AssetSummary" });
|
|
16599
|
+
var ProjectSummary = external_exports.object({
|
|
16600
|
+
id: external_exports.string(),
|
|
16601
|
+
name: external_exports.string(),
|
|
16602
|
+
repo: external_exports.string(),
|
|
16603
|
+
visibility: Visibility,
|
|
16604
|
+
language: external_exports.string(),
|
|
16605
|
+
policyDefault: AccessLevel,
|
|
16606
|
+
updatedAt: external_exports.iso.datetime(),
|
|
16607
|
+
accessCounts: AccessCounts,
|
|
16608
|
+
findingsCount: external_exports.number().int().nonnegative()
|
|
16609
|
+
}).meta({ id: "ProjectSummary" });
|
|
16610
|
+
var HarnessCategory = external_exports.object({
|
|
16611
|
+
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
16612
|
+
type: AssetType,
|
|
16613
|
+
assets: external_exports.array(AssetSummary)
|
|
16614
|
+
});
|
|
16615
|
+
var HarnessSummary = external_exports.object({
|
|
16616
|
+
id: HarnessId,
|
|
16617
|
+
label: external_exports.string(),
|
|
16618
|
+
kind: external_exports.string(),
|
|
16619
|
+
version: external_exports.string(),
|
|
16620
|
+
sessions: external_exports.number().int().nonnegative(),
|
|
16621
|
+
assetCount: external_exports.number().int().nonnegative(),
|
|
16622
|
+
flagCount: external_exports.number().int().nonnegative(),
|
|
16623
|
+
projects: external_exports.array(ProjectSummary),
|
|
16624
|
+
categories: external_exports.array(HarnessCategory)
|
|
16625
|
+
}).meta({ id: "HarnessSummary" });
|
|
16626
|
+
var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
|
|
16627
|
+
var AssetGroup = external_exports.object({
|
|
16628
|
+
/** Group key — never project (enforced at service layer). */
|
|
16629
|
+
type: AssetType,
|
|
16630
|
+
total: external_exports.number().int().nonnegative(),
|
|
16631
|
+
/**
|
|
16632
|
+
* MCP group only — omitted for all other types.
|
|
16633
|
+
* Partial: only TrustLevel keys with non-zero counts are included.
|
|
16634
|
+
* Strict: unknown keys are rejected — only TrustLevel values are valid keys.
|
|
16635
|
+
*/
|
|
16636
|
+
trustRollup: external_exports.object({
|
|
16637
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16638
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16639
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16640
|
+
}).partial().strict().optional(),
|
|
16641
|
+
/**
|
|
16642
|
+
* Partial: only Flag keys with non-zero counts are included.
|
|
16643
|
+
* Strict: unknown keys are rejected — only Flag values are valid keys.
|
|
16644
|
+
*/
|
|
16645
|
+
flagRollup: external_exports.object({
|
|
16646
|
+
update: external_exports.number().int().nonnegative(),
|
|
16647
|
+
stale: external_exports.number().int().nonnegative(),
|
|
16648
|
+
conflict: external_exports.number().int().nonnegative(),
|
|
16649
|
+
unknown: external_exports.number().int().nonnegative(),
|
|
16650
|
+
change: external_exports.number().int().nonnegative(),
|
|
16651
|
+
untracked: external_exports.number().int().nonnegative(),
|
|
16652
|
+
risk: external_exports.number().int().nonnegative(),
|
|
16653
|
+
findings: external_exports.number().int().nonnegative()
|
|
16654
|
+
}).partial().strict(),
|
|
16655
|
+
items: external_exports.array(AssetSummary)
|
|
16656
|
+
}).meta({ id: "AssetGroup" });
|
|
16657
|
+
var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
|
|
16658
|
+
var McpTool = external_exports.object({
|
|
16659
|
+
name: external_exports.string(),
|
|
16660
|
+
signature: external_exports.string(),
|
|
16661
|
+
description: external_exports.string(),
|
|
16662
|
+
write: external_exports.boolean(),
|
|
16663
|
+
/** Non-null string when tool is dangerous / blocked; null otherwise. */
|
|
16664
|
+
risk: external_exports.string().nullable()
|
|
16665
|
+
}).meta({ id: "McpTool" });
|
|
16666
|
+
var AssetFindingRef = external_exports.object({
|
|
16667
|
+
id: external_exports.string(),
|
|
16668
|
+
title: external_exports.string(),
|
|
16669
|
+
note: external_exports.string()
|
|
16670
|
+
});
|
|
16671
|
+
var AssetDetail = AssetSummary.extend({
|
|
16672
|
+
/** string | null — null when no description is available. */
|
|
16673
|
+
description: external_exports.string().nullable(),
|
|
16674
|
+
/** trustLevel | null — null for non-MCP assets. */
|
|
16675
|
+
trust: TrustLevel.nullable(),
|
|
16676
|
+
/** Type-specific raw key/values — FE renders the grid. */
|
|
16677
|
+
meta: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
16678
|
+
/** always present — object when there is an active finding, null when absent. */
|
|
16679
|
+
finding: AssetFindingRef.nullable(),
|
|
16680
|
+
/** MCP exposed-tools list — omitted for non-mcp. */
|
|
16681
|
+
tools: external_exports.array(McpTool).optional()
|
|
16682
|
+
}).meta({ id: "AssetDetail" });
|
|
16683
|
+
var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
|
|
16684
|
+
var InventoryStats = external_exports.object({
|
|
16685
|
+
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16686
|
+
attention: external_exports.number().int().nonnegative(),
|
|
16687
|
+
byType: external_exports.object({
|
|
16688
|
+
project: external_exports.number().int().nonnegative(),
|
|
16689
|
+
skill: external_exports.number().int().nonnegative(),
|
|
16690
|
+
mcp: external_exports.number().int().nonnegative(),
|
|
16691
|
+
hook: external_exports.number().int().nonnegative(),
|
|
16692
|
+
config: external_exports.number().int().nonnegative()
|
|
16693
|
+
}),
|
|
16694
|
+
harnesses: external_exports.number().int().nonnegative(),
|
|
16695
|
+
mcpTrust: external_exports.object({
|
|
16696
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16697
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16698
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16699
|
+
})
|
|
16700
|
+
}).meta({ id: "InventoryStats" });
|
|
16701
|
+
var FileSummary = external_exports.object({
|
|
16702
|
+
path: external_exports.string(),
|
|
16703
|
+
name: external_exports.string(),
|
|
16704
|
+
origin: Origin,
|
|
16705
|
+
/** Effective access (override applied). */
|
|
16706
|
+
access: AccessLevel,
|
|
16707
|
+
/** True when a file_access_override differs from the computed default. */
|
|
16708
|
+
isCustom: external_exports.boolean(),
|
|
16709
|
+
findings: external_exports.number().int().nonnegative(),
|
|
16710
|
+
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16711
|
+
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16712
|
+
/** Why the file was blocked; null when absent. */
|
|
16713
|
+
note: external_exports.string().nullable().optional()
|
|
16714
|
+
}).meta({ id: "FileSummary" });
|
|
16715
|
+
var FolderSummary = external_exports.object({
|
|
16716
|
+
name: external_exports.string(),
|
|
16717
|
+
path: external_exports.string(),
|
|
16718
|
+
/** Rollup of effective access across all descendants. */
|
|
16719
|
+
accessCounts: AccessCounts
|
|
16720
|
+
}).meta({ id: "FolderSummary" });
|
|
16721
|
+
var ProjectTreeResponse = external_exports.object({
|
|
16722
|
+
project: external_exports.object({
|
|
16723
|
+
id: external_exports.string(),
|
|
16724
|
+
repo: external_exports.string(),
|
|
16725
|
+
visibility: Visibility
|
|
16726
|
+
}),
|
|
16727
|
+
path: external_exports.string(),
|
|
16728
|
+
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16729
|
+
folders: external_exports.array(FolderSummary).optional(),
|
|
16730
|
+
files: external_exports.array(FileSummary)
|
|
16731
|
+
}).meta({ id: "ProjectTreeResponse" });
|
|
16732
|
+
var FileDetail = FileSummary.extend({
|
|
16733
|
+
project: external_exports.object({
|
|
16734
|
+
repo: external_exports.string(),
|
|
16735
|
+
visibility: Visibility,
|
|
16736
|
+
language: external_exports.string(),
|
|
16737
|
+
policyDefault: AccessLevel,
|
|
16738
|
+
updatedAt: external_exports.iso.datetime()
|
|
16739
|
+
}),
|
|
16740
|
+
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16741
|
+
}).meta({ id: "FileDetail" });
|
|
16742
|
+
var SetFileAccessBody = external_exports.object({
|
|
16743
|
+
path: external_exports.string(),
|
|
16744
|
+
access: AccessLevel
|
|
16745
|
+
}).meta({ id: "SetFileAccessBody" });
|
|
16746
|
+
var SetFileAccessResponse = external_exports.object({
|
|
16747
|
+
file: FileSummary,
|
|
16748
|
+
accessCounts: AccessCounts
|
|
16749
|
+
}).meta({ id: "SetFileAccessResponse" });
|
|
16750
|
+
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16751
|
+
var HarnessEventItem = external_exports.object({
|
|
16752
|
+
kind: HarnessEventKind,
|
|
16753
|
+
title: external_exports.string(),
|
|
16754
|
+
detail: external_exports.string(),
|
|
16755
|
+
occurredAt: external_exports.iso.datetime(),
|
|
16756
|
+
findingId: external_exports.string().nullable().optional()
|
|
16757
|
+
}).meta({ id: "HarnessEventItem" });
|
|
16758
|
+
var HarnessEventsResponse = external_exports.object({
|
|
16759
|
+
counts: external_exports.object({
|
|
16760
|
+
block: external_exports.number().int().nonnegative(),
|
|
16761
|
+
redact: external_exports.number().int().nonnegative(),
|
|
16762
|
+
warn: external_exports.number().int().nonnegative()
|
|
16763
|
+
}),
|
|
16764
|
+
items: external_exports.array(HarnessEventItem)
|
|
16765
|
+
}).meta({ id: "HarnessEventsResponse" });
|
|
16766
|
+
var RescanResponse = external_exports.object({
|
|
16767
|
+
jobId: external_exports.string(),
|
|
16768
|
+
startedAt: external_exports.iso.datetime()
|
|
16769
|
+
}).meta({ id: "RescanResponse" });
|
|
16770
|
+
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16771
|
+
var ListAssetsQuery = external_exports.object({
|
|
16772
|
+
/** Filter by one or more AssetType values; absent means all types. */
|
|
16773
|
+
type: external_exports.array(AssetType).optional(),
|
|
16774
|
+
/** Free-text search term. */
|
|
16775
|
+
q: external_exports.string().optional()
|
|
16776
|
+
});
|
|
16777
|
+
var GetProjectTreeQuery = external_exports.object({
|
|
16778
|
+
/** Subtree root path; defaults to repository root when absent. */
|
|
16779
|
+
path: external_exports.string().optional(),
|
|
16780
|
+
/** Free-text filter applied to file paths. */
|
|
16781
|
+
q: external_exports.string().optional(),
|
|
16782
|
+
/**
|
|
16783
|
+
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16784
|
+
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16785
|
+
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16786
|
+
*/
|
|
16787
|
+
filter: external_exports.enum(["blocked"]).optional()
|
|
16788
|
+
});
|
|
16789
|
+
var GetProjectFileQuery = external_exports.object({
|
|
16790
|
+
/** Repository-relative file path; absent or empty → 400. */
|
|
16791
|
+
path: external_exports.string()
|
|
16792
|
+
});
|
|
16793
|
+
var GetHarnessEventsQuery = external_exports.object({
|
|
16794
|
+
/** Maximum number of events to return. Range: 1–50; default: 7. */
|
|
16795
|
+
limit: external_exports.coerce.number().int().min(1).max(50).default(7)
|
|
16796
|
+
});
|
|
16797
|
+
|
|
17041
16798
|
// ../../packages/schema/src/zod/shares.ts
|
|
17042
16799
|
var DestinationKind = external_exports.enum(["provider", "internal", "external", "ip"]).meta({ id: "DestinationKind" });
|
|
17043
16800
|
var Transport = external_exports.enum(["https", "http", "sftp", "grpc", "smtp", "ws", "wss"]).meta({ id: "Transport" });
|
|
@@ -17244,6 +17001,127 @@ var EgressWriteSummary = external_exports.object({
|
|
|
17244
17001
|
droppedFiles: external_exports.array(external_exports.string()).default([])
|
|
17245
17002
|
}).meta({ id: "EgressWriteSummary" });
|
|
17246
17003
|
|
|
17004
|
+
// ../../packages/schema/src/zod/event.ts
|
|
17005
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
17006
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
17007
|
+
var EventMetadata = external_exports.object({
|
|
17008
|
+
sessionId: external_exports.string().optional(),
|
|
17009
|
+
repo: external_exports.string().optional(),
|
|
17010
|
+
filePath: external_exports.string().optional(),
|
|
17011
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
17012
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
17013
|
+
// arguments or output, which can carry the very value a finding masked
|
|
17014
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
17015
|
+
// display location ("via Bash") when no filePath exists.
|
|
17016
|
+
toolName: external_exports.string().optional(),
|
|
17017
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
17018
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
17019
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
17020
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
17021
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
17022
|
+
gitignored: external_exports.boolean().optional(),
|
|
17023
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
17024
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
17025
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
17026
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
17027
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
17028
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
17029
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
17030
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
17031
|
+
// non-authoritative path.
|
|
17032
|
+
wholeFile: external_exports.boolean().optional(),
|
|
17033
|
+
model: external_exports.string().optional(),
|
|
17034
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
17035
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
17036
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
17037
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
17038
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
17039
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
17040
|
+
correlationId: external_exports.uuid().optional(),
|
|
17041
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
17042
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
17043
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
17044
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
17045
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
17046
|
+
}).meta({ id: "EventMetadata" });
|
|
17047
|
+
var Event = external_exports.object({
|
|
17048
|
+
id: external_exports.guid(),
|
|
17049
|
+
sourceTool: SourceTool,
|
|
17050
|
+
kind: EventKind,
|
|
17051
|
+
occurredAt: external_exports.iso.datetime(),
|
|
17052
|
+
contentHash: external_exports.string(),
|
|
17053
|
+
content: external_exports.string(),
|
|
17054
|
+
metadata: EventMetadata.optional()
|
|
17055
|
+
}).meta({ id: "Event" });
|
|
17056
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
17057
|
+
var IngestBatch = external_exports.object({
|
|
17058
|
+
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
17059
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
17060
|
+
// additionally rejects any event whose contentHash the store has already
|
|
17061
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
17062
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
17063
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
17064
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
17065
|
+
// the timeline.
|
|
17066
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
17067
|
+
}).meta({ id: "IngestBatch" });
|
|
17068
|
+
|
|
17069
|
+
// ../../packages/schema/src/zod/exception.ts
|
|
17070
|
+
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
17071
|
+
var ExceptionConditions = external_exports.object({
|
|
17072
|
+
repo: external_exports.string().optional(),
|
|
17073
|
+
sourceTool: external_exports.string().optional(),
|
|
17074
|
+
provider: external_exports.string().optional()
|
|
17075
|
+
}).strict();
|
|
17076
|
+
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
17077
|
+
var DetectionException = external_exports.object({
|
|
17078
|
+
id: external_exports.guid(),
|
|
17079
|
+
ruleId: external_exports.string(),
|
|
17080
|
+
// Denormalized from the rule, for reporting — never matched on.
|
|
17081
|
+
category: DetectionCategory,
|
|
17082
|
+
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
17083
|
+
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
17084
|
+
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
17085
|
+
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
17086
|
+
// at the boundary rather than persisted.
|
|
17087
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17088
|
+
// Version of the fingerprint key the grant was written under; a rotated key
|
|
17089
|
+
// invalidates old grants rather than silently mismatching them.
|
|
17090
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17091
|
+
// maskMatch() preview of the approved value — never the raw value.
|
|
17092
|
+
maskedValue: external_exports.string(),
|
|
17093
|
+
capability: ExceptionCapability.default("suppress"),
|
|
17094
|
+
scope: ExceptionScope,
|
|
17095
|
+
expiresAt: external_exports.iso.datetime().nullable(),
|
|
17096
|
+
maxUses: external_exports.number().int().positive().nullable(),
|
|
17097
|
+
useCount: external_exports.number().int().nonnegative(),
|
|
17098
|
+
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
17099
|
+
// Mandatory: every grant carries the human reason it exists.
|
|
17100
|
+
justification: external_exports.string().min(1),
|
|
17101
|
+
conditions: ExceptionConditions.nullable(),
|
|
17102
|
+
createdBy: external_exports.string(),
|
|
17103
|
+
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
17104
|
+
createdAt: external_exports.iso.datetime(),
|
|
17105
|
+
updatedAt: external_exports.iso.datetime(),
|
|
17106
|
+
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
17107
|
+
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
17108
|
+
revokedAt: external_exports.iso.datetime().nullable(),
|
|
17109
|
+
revokedBy: external_exports.string().nullable(),
|
|
17110
|
+
revokeReason: external_exports.string().nullable()
|
|
17111
|
+
});
|
|
17112
|
+
var ExceptionBundleEntry = DetectionException.pick({
|
|
17113
|
+
id: true,
|
|
17114
|
+
ruleId: true,
|
|
17115
|
+
valueFingerprint: true,
|
|
17116
|
+
keyVersion: true,
|
|
17117
|
+
capability: true,
|
|
17118
|
+
expiresAt: true,
|
|
17119
|
+
maxUses: true,
|
|
17120
|
+
useCount: true,
|
|
17121
|
+
conditions: true
|
|
17122
|
+
});
|
|
17123
|
+
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
17124
|
+
|
|
17247
17125
|
// ../../packages/schema/src/zod/exception-action.ts
|
|
17248
17126
|
var confirmation = external_exports.string().optional();
|
|
17249
17127
|
var ApproveBlockedInput = external_exports.object({
|
|
@@ -17286,10 +17164,11 @@ function toApiAction(dbVal) {
|
|
|
17286
17164
|
}
|
|
17287
17165
|
function toApiCategory(dbVal) {
|
|
17288
17166
|
if (dbVal === "code_context") return "source_code";
|
|
17289
|
-
|
|
17167
|
+
const parsed = FindingCategory.safeParse(dbVal);
|
|
17168
|
+
return parsed.success ? parsed.data : "custom";
|
|
17290
17169
|
}
|
|
17291
17170
|
function toApiProvider(sourceTool) {
|
|
17292
|
-
return TOOL_TO_HARNESS[sourceTool] ??
|
|
17171
|
+
return TOOL_TO_HARNESS[sourceTool] ?? HARNESS.Api;
|
|
17293
17172
|
}
|
|
17294
17173
|
var STATUS_PRECEDENCE = ["open", "handled", "dismissed", "resolved"];
|
|
17295
17174
|
function foldGroupStatus(instanceStatuses) {
|
|
@@ -17861,6 +17740,7 @@ var ListVaultDerefsResponse = external_exports.object({
|
|
|
17861
17740
|
});
|
|
17862
17741
|
var VaultKeyCustody = external_exports.string();
|
|
17863
17742
|
var VaultInlineReveal = external_exports.enum(["masked", "full", "off"]);
|
|
17743
|
+
var VAULT_CONSENT_VERSION = 1;
|
|
17864
17744
|
var VaultConsent = external_exports.object({
|
|
17865
17745
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
17866
17746
|
version: external_exports.number().int().positive()
|
|
@@ -17868,7 +17748,14 @@ var VaultConsent = external_exports.object({
|
|
|
17868
17748
|
|
|
17869
17749
|
// ../../packages/schema/src/zod/local.ts
|
|
17870
17750
|
var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
|
|
17871
|
-
var
|
|
17751
|
+
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
17752
|
+
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
17753
|
+
var ControlPlaneConnection = external_exports.object({
|
|
17754
|
+
endpoint: external_exports.string().min(1),
|
|
17755
|
+
// Display name for the deployment, shown instead of the raw endpoint.
|
|
17756
|
+
label: external_exports.string().min(1).optional(),
|
|
17757
|
+
attachedAt: external_exports.iso.datetime()
|
|
17758
|
+
}).meta({ id: "ControlPlaneConnection" });
|
|
17872
17759
|
var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
|
|
17873
17760
|
var HistoricalAccess = external_exports.enum(["full", "session-only"]);
|
|
17874
17761
|
var ModelJudgeConsent = external_exports.object({
|
|
@@ -17877,12 +17764,10 @@ var ModelJudgeConsent = external_exports.object({
|
|
|
17877
17764
|
});
|
|
17878
17765
|
var WorkspaceSettings = external_exports.object({
|
|
17879
17766
|
specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
|
|
17880
|
-
|
|
17881
|
-
//
|
|
17882
|
-
runMode:
|
|
17883
|
-
|
|
17884
|
-
RunMode.default("standalone")
|
|
17885
|
-
),
|
|
17767
|
+
runMode: RunMode.default("standalone"),
|
|
17768
|
+
// Present only while attached; a detach clears it. Its presence is what makes
|
|
17769
|
+
// `runMode: 'attached'` mean anything — see isAttached.
|
|
17770
|
+
controlPlane: ControlPlaneConnection.optional(),
|
|
17886
17771
|
policy: SimpleDetectionPolicy.default("redact"),
|
|
17887
17772
|
// Consent for scanning pre-install surfaces; opt-in (see HistoricalAccess).
|
|
17888
17773
|
historicalAccess: HistoricalAccess.default("session-only"),
|
|
@@ -17969,54 +17854,259 @@ function toInspectionDefinitionRow(input, id) {
|
|
|
17969
17854
|
version: input.version
|
|
17970
17855
|
};
|
|
17971
17856
|
}
|
|
17972
|
-
function toInspectionFindingRow(input) {
|
|
17973
|
-
return {
|
|
17974
|
-
id: input.id,
|
|
17975
|
-
auditEventId: input.auditEventId,
|
|
17976
|
-
inspectionDefinitionId: input.inspectionDefinitionId,
|
|
17977
|
-
classifiedDataId: input.classifiedDataId ?? null,
|
|
17978
|
-
spanStart: input.span.start,
|
|
17979
|
-
spanEnd: input.span.end,
|
|
17980
|
-
maskedMatch: input.maskedMatch,
|
|
17981
|
-
actionTaken: input.actionTaken,
|
|
17982
|
-
confidence: input.confidence,
|
|
17983
|
-
findingKey: input.findingKey ?? null,
|
|
17984
|
-
firstDetectedAt: input.firstDetectedAt ? isoToEpochMillis(input.firstDetectedAt) : null
|
|
17985
|
-
};
|
|
17857
|
+
function toInspectionFindingRow(input) {
|
|
17858
|
+
return {
|
|
17859
|
+
id: input.id,
|
|
17860
|
+
auditEventId: input.auditEventId,
|
|
17861
|
+
inspectionDefinitionId: input.inspectionDefinitionId,
|
|
17862
|
+
classifiedDataId: input.classifiedDataId ?? null,
|
|
17863
|
+
spanStart: input.span.start,
|
|
17864
|
+
spanEnd: input.span.end,
|
|
17865
|
+
maskedMatch: input.maskedMatch,
|
|
17866
|
+
actionTaken: input.actionTaken,
|
|
17867
|
+
confidence: input.confidence,
|
|
17868
|
+
findingKey: input.findingKey ?? null,
|
|
17869
|
+
firstDetectedAt: input.firstDetectedAt ? isoToEpochMillis(input.firstDetectedAt) : null
|
|
17870
|
+
};
|
|
17871
|
+
}
|
|
17872
|
+
function toCaptureAttributes(event) {
|
|
17873
|
+
const metadata = event.metadata;
|
|
17874
|
+
return {
|
|
17875
|
+
source_tool: event.sourceTool,
|
|
17876
|
+
...metadata?.repo !== void 0 ? { repo: metadata.repo } : {},
|
|
17877
|
+
...metadata?.filePath !== void 0 ? { file_path: metadata.filePath } : {},
|
|
17878
|
+
...metadata?.toolName !== void 0 ? { tool_name: metadata.toolName } : {},
|
|
17879
|
+
...metadata?.gitignored !== void 0 ? { gitignored: metadata.gitignored } : {},
|
|
17880
|
+
...metadata?.wholeFile !== void 0 ? { whole_file: metadata.wholeFile } : {},
|
|
17881
|
+
...metadata?.correlationId !== void 0 ? { correlation_id: metadata.correlationId } : {},
|
|
17882
|
+
...metadata?.traceId !== void 0 ? { trace_id: metadata.traceId } : {},
|
|
17883
|
+
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
17884
|
+
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
17885
|
+
// has ever populated either), but every legacy metadata key still rides
|
|
17886
|
+
// the bag rather than being silently dropped — CaptureAttributes'
|
|
17887
|
+
// `.catchall(z.unknown())` carries the long tail.
|
|
17888
|
+
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
17889
|
+
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {}
|
|
17890
|
+
};
|
|
17891
|
+
}
|
|
17892
|
+
function captureDefinitionVersion(finding) {
|
|
17893
|
+
return `capture/${finding.category}/${finding.severity}`;
|
|
17894
|
+
}
|
|
17895
|
+
function toCaptureDefinitionInput(finding) {
|
|
17896
|
+
return {
|
|
17897
|
+
ruleId: finding.ruleId,
|
|
17898
|
+
version: captureDefinitionVersion(finding),
|
|
17899
|
+
name: finding.ruleId,
|
|
17900
|
+
category: finding.category,
|
|
17901
|
+
severity: finding.severity,
|
|
17902
|
+
definition: JSON.stringify({ ruleId: finding.ruleId })
|
|
17903
|
+
};
|
|
17904
|
+
}
|
|
17905
|
+
|
|
17906
|
+
// ../../packages/schema/src/zod/managed.ts
|
|
17907
|
+
var MANAGED_SETTINGS_FILENAME = "managed-settings.json";
|
|
17908
|
+
var MANAGED_SETTINGS_SPEC_VERSION = 1;
|
|
17909
|
+
var ManagedSettingKey = external_exports.enum([
|
|
17910
|
+
"runMode",
|
|
17911
|
+
"historicalAccess",
|
|
17912
|
+
"vaultConsent",
|
|
17913
|
+
"vaultKeyCustody",
|
|
17914
|
+
"vaultInlineReveal",
|
|
17915
|
+
"modelJudgeConsent",
|
|
17916
|
+
"dataSharesInPlace"
|
|
17917
|
+
]).meta({ id: "ManagedSettingKey" });
|
|
17918
|
+
var ManagedSettingsValues = external_exports.object({
|
|
17919
|
+
runMode: external_exports.enum(["standalone", "attached"]).optional(),
|
|
17920
|
+
controlPlane: external_exports.object({
|
|
17921
|
+
endpoint: external_exports.string().min(1),
|
|
17922
|
+
label: external_exports.string().min(1).optional()
|
|
17923
|
+
}).optional(),
|
|
17924
|
+
historicalAccess: external_exports.enum(["full", "session-only"]).optional(),
|
|
17925
|
+
vaultConsent: external_exports.boolean().optional(),
|
|
17926
|
+
vaultKeyCustody: external_exports.enum(["file", "keychain"]).optional(),
|
|
17927
|
+
vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
|
|
17928
|
+
modelJudgeConsent: external_exports.boolean().optional(),
|
|
17929
|
+
dataSharesInPlace: external_exports.boolean().optional()
|
|
17930
|
+
}).meta({ id: "ManagedSettingsValues" });
|
|
17931
|
+
var ManagedSettings = external_exports.object({
|
|
17932
|
+
specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
|
|
17933
|
+
// Shown on every locked control, so the user can tell an administrative
|
|
17934
|
+
// decision from a bug. Absent renders as a generic "your organization".
|
|
17935
|
+
organization: external_exports.string().min(1).optional(),
|
|
17936
|
+
// What the administrator pinned.
|
|
17937
|
+
values: ManagedSettingsValues.default({}),
|
|
17938
|
+
// Which of those the user may not change. A key here with no matching value
|
|
17939
|
+
// freezes whatever the user last chose; a value with no lock is a DEFAULT
|
|
17940
|
+
// the user may still override. The two are separable on purpose.
|
|
17941
|
+
lockedFields: external_exports.array(ManagedSettingKey).default([])
|
|
17942
|
+
}).meta({ id: "ManagedSettings" });
|
|
17943
|
+
|
|
17944
|
+
// ../../packages/schema/src/zod/policy.ts
|
|
17945
|
+
var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
|
|
17946
|
+
var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
|
|
17947
|
+
var Policy = external_exports.object({
|
|
17948
|
+
id: external_exports.guid(),
|
|
17949
|
+
scope: PolicyScope,
|
|
17950
|
+
target: PolicyTarget,
|
|
17951
|
+
action: ActionTaken,
|
|
17952
|
+
enabled: external_exports.boolean().default(true),
|
|
17953
|
+
customKeywords: external_exports.array(external_exports.string()).optional(),
|
|
17954
|
+
// Display name — optional so older policy rows without name still parse.
|
|
17955
|
+
// Added for the findings API (policy.name column migration).
|
|
17956
|
+
name: external_exports.string().optional()
|
|
17957
|
+
}).meta({ id: "Policy" });
|
|
17958
|
+
var PolicyBundle = external_exports.object({
|
|
17959
|
+
version: external_exports.string(),
|
|
17960
|
+
policies: external_exports.array(Policy),
|
|
17961
|
+
// Rules from the installed marketplace packs (snapshotted by the
|
|
17962
|
+
// control plane). The plugin registers these in addition to its bundled
|
|
17963
|
+
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
17964
|
+
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
17965
|
+
rules: external_exports.array(Rule).optional(),
|
|
17966
|
+
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
17967
|
+
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
17968
|
+
// after reading the user's installed snapshot (installed_packs, enabled
|
|
17969
|
+
// packs only), which is how detection updates stay manual: new bundled
|
|
17970
|
+
// rules run only after the user applies the pack update. Absent/false keeps
|
|
17971
|
+
// the historical composition (bundled packs + rules) — older caches.
|
|
17972
|
+
rulesComplete: external_exports.boolean().optional(),
|
|
17973
|
+
// Active detection exceptions, evaluation subset only (see
|
|
17974
|
+
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
17975
|
+
// on-disk caches — that omit the field still parse; consumers read
|
|
17976
|
+
// `bundle.exceptions ?? []`.
|
|
17977
|
+
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
17978
|
+
// Rule ids whose pack is assigned a REVERSIBLE archetype (Redact & Vault).
|
|
17979
|
+
// A second axis over the same `redact` action, carried beside the policies
|
|
17980
|
+
// rather than on them: nothing writes ruleId-targeted policies to disk, so
|
|
17981
|
+
// widening Policy itself would change a persisted shape to express something
|
|
17982
|
+
// only the in-memory bundle needs. Optional so an older producer — or an
|
|
17983
|
+
// older on-disk cache — still parses; consumers read `?? []` and get the
|
|
17984
|
+
// pre-existing one-way behaviour, which is the safe direction to default.
|
|
17985
|
+
reversibleRuleIds: external_exports.array(external_exports.string()).optional(),
|
|
17986
|
+
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
17987
|
+
// from a versioned installed pack. Optional so older backends — and older
|
|
17988
|
+
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
17989
|
+
// the rule's own spec version. NOT the bundle version above — see
|
|
17990
|
+
// installedRuleset's ruleVersions for the source of truth.
|
|
17991
|
+
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
17992
|
+
customKeywords: external_exports.array(external_exports.string()),
|
|
17993
|
+
fetchedAt: external_exports.iso.datetime()
|
|
17994
|
+
}).meta({ id: "PolicyBundle" });
|
|
17995
|
+
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
17996
|
+
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
17997
|
+
var CATEGORY_PEAK_SEVERITY = {
|
|
17998
|
+
secret: "critical",
|
|
17999
|
+
financial: "critical",
|
|
18000
|
+
// core-financial/credit-card
|
|
18001
|
+
code_flaw: "critical",
|
|
18002
|
+
pii: "high",
|
|
18003
|
+
phi: "high",
|
|
18004
|
+
custom: "high",
|
|
18005
|
+
// user-defined; conservative
|
|
18006
|
+
code_context: "low",
|
|
18007
|
+
config: "low"
|
|
18008
|
+
// observe-only; floors to monitor regardless
|
|
18009
|
+
};
|
|
18010
|
+
function severityFloorPolicy(category) {
|
|
18011
|
+
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
18012
|
+
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
18013
|
+
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
18014
|
+
}
|
|
18015
|
+
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
18016
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
18017
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
18018
|
+
var BUILTIN_ORDER = KNOWN_BUILTIN_IDS;
|
|
18019
|
+
var BUILTIN_POLICY_SPECS = {
|
|
18020
|
+
monitor: {
|
|
18021
|
+
name: "Monitor",
|
|
18022
|
+
action: "log",
|
|
18023
|
+
reversible: false,
|
|
18024
|
+
description: "Log every match for audit. The request is allowed through untouched."
|
|
18025
|
+
},
|
|
18026
|
+
warn: {
|
|
18027
|
+
name: "Warn",
|
|
18028
|
+
action: "warn",
|
|
18029
|
+
reversible: false,
|
|
18030
|
+
description: "Allow the request, but warn the user inline before it is sent."
|
|
18031
|
+
},
|
|
18032
|
+
redact: {
|
|
18033
|
+
name: "Redact",
|
|
18034
|
+
action: "redact",
|
|
18035
|
+
reversible: false,
|
|
18036
|
+
description: "Strip the matched value from the request and destroy it, then continue. What was removed cannot be recovered."
|
|
18037
|
+
},
|
|
18038
|
+
vault: {
|
|
18039
|
+
name: "Redact & Vault",
|
|
18040
|
+
action: "redact",
|
|
18041
|
+
reversible: true,
|
|
18042
|
+
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."
|
|
18043
|
+
},
|
|
18044
|
+
block: {
|
|
18045
|
+
name: "Block",
|
|
18046
|
+
action: "block",
|
|
18047
|
+
reversible: false,
|
|
18048
|
+
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
18049
|
+
}
|
|
18050
|
+
};
|
|
18051
|
+
function builtinPolicyToAction(id) {
|
|
18052
|
+
return BUILTIN_POLICY_SPECS[id].action;
|
|
17986
18053
|
}
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
...metadata?.correlationId !== void 0 ? { correlation_id: metadata.correlationId } : {},
|
|
17997
|
-
...metadata?.traceId !== void 0 ? { trace_id: metadata.traceId } : {},
|
|
17998
|
-
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
17999
|
-
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
18000
|
-
// has ever populated either), but every legacy metadata key still rides
|
|
18001
|
-
// the bag rather than being silently dropped — CaptureAttributes'
|
|
18002
|
-
// `.catchall(z.unknown())` carries the long tail.
|
|
18003
|
-
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
18004
|
-
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {}
|
|
18005
|
-
};
|
|
18054
|
+
var CATEGORY_EXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
18055
|
+
(id) => !BUILTIN_POLICY_SPECS[id].reversible
|
|
18056
|
+
);
|
|
18057
|
+
var CATEGORY_INEXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
18058
|
+
(id) => BUILTIN_POLICY_SPECS[id].reversible
|
|
18059
|
+
);
|
|
18060
|
+
var CategoryPolicyId = external_exports.enum(CATEGORY_EXPRESSIBLE_IDS).meta({ id: "CategoryPolicyId" });
|
|
18061
|
+
function builtinPolicyIsReversible(id) {
|
|
18062
|
+
return BUILTIN_POLICY_SPECS[id].reversible;
|
|
18006
18063
|
}
|
|
18007
|
-
function
|
|
18008
|
-
|
|
18064
|
+
function policyIdIsReversible(policyId) {
|
|
18065
|
+
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
18066
|
+
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
18067
|
+
return builtinPolicyIsReversible(id);
|
|
18009
18068
|
}
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18069
|
+
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
18070
|
+
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
18071
|
+
);
|
|
18072
|
+
var BUILTIN_POLICIES = Object.fromEntries(
|
|
18073
|
+
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
18074
|
+
);
|
|
18075
|
+
var DEFAULT_PACK_POLICY_ID = "monitor";
|
|
18076
|
+
function policyIdToAction(policyId) {
|
|
18077
|
+
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
18078
|
+
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
18079
|
+
return BUILTIN_POLICIES[id].action;
|
|
18019
18080
|
}
|
|
18081
|
+
var UsedByItem = external_exports.object({
|
|
18082
|
+
id: external_exports.string(),
|
|
18083
|
+
name: external_exports.string(),
|
|
18084
|
+
ruleCount: external_exports.number().int().nonnegative(),
|
|
18085
|
+
enabled: external_exports.boolean()
|
|
18086
|
+
}).meta({ id: "UsedByItem" });
|
|
18087
|
+
var PolicyListItem = external_exports.object({
|
|
18088
|
+
id: external_exports.string(),
|
|
18089
|
+
kind: PolicyKind,
|
|
18090
|
+
name: external_exports.string(),
|
|
18091
|
+
enabled: external_exports.boolean(),
|
|
18092
|
+
usedByCount: external_exports.number().int().nonnegative()
|
|
18093
|
+
}).meta({ id: "PolicyListItem" });
|
|
18094
|
+
var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
|
|
18095
|
+
var PolicyDetail = external_exports.object({
|
|
18096
|
+
specVersion: external_exports.literal(1),
|
|
18097
|
+
id: external_exports.string(),
|
|
18098
|
+
kind: PolicyKind,
|
|
18099
|
+
name: external_exports.string(),
|
|
18100
|
+
enabled: external_exports.boolean(),
|
|
18101
|
+
description: external_exports.string(),
|
|
18102
|
+
usedBy: external_exports.array(UsedByItem)
|
|
18103
|
+
}).meta({ id: "PolicyDetail" });
|
|
18104
|
+
var PolicyStatsResponse = external_exports.object({
|
|
18105
|
+
policies: external_exports.number().int().nonnegative(),
|
|
18106
|
+
builtin: external_exports.number().int().nonnegative(),
|
|
18107
|
+
custom: external_exports.number().int().nonnegative(),
|
|
18108
|
+
detectionsGoverned: external_exports.number().int().nonnegative()
|
|
18109
|
+
}).meta({ id: "PolicyStatsResponse" });
|
|
18020
18110
|
|
|
18021
18111
|
// ../../packages/schema/src/zod/project-files.ts
|
|
18022
18112
|
var ProjectFileInput = external_exports.object({
|
|
@@ -18096,44 +18186,6 @@ var BatchedRemediation = external_exports.discriminatedUnion("kind", [
|
|
|
18096
18186
|
NoRemediationDecision
|
|
18097
18187
|
]);
|
|
18098
18188
|
|
|
18099
|
-
// ../../packages/schema/src/zod/rule-test.ts
|
|
18100
|
-
var TestRulesRequest = external_exports.object({
|
|
18101
|
-
rules: external_exports.array(Rule).min(1).max(100),
|
|
18102
|
-
text: external_exports.string().max(5e4).optional(),
|
|
18103
|
-
fixtures: external_exports.array(RuleFixture).max(200).optional()
|
|
18104
|
-
}).refine((v) => v.text !== void 0 || (v.fixtures?.length ?? 0) > 0, {
|
|
18105
|
-
message: "Provide `text`, `fixtures`, or both \u2014 there must be something to test"
|
|
18106
|
-
}).meta({ id: "TestRulesRequest" });
|
|
18107
|
-
var RuleTestMatch = external_exports.object({
|
|
18108
|
-
ruleId: external_exports.string(),
|
|
18109
|
-
category: DetectionCategory,
|
|
18110
|
-
severity: Severity,
|
|
18111
|
-
span: Span,
|
|
18112
|
-
confidence: external_exports.number().min(0).max(1),
|
|
18113
|
-
match: external_exports.string()
|
|
18114
|
-
}).meta({ id: "RuleTestMatch" });
|
|
18115
|
-
var FixtureResult = external_exports.object({
|
|
18116
|
-
label: external_exports.string(),
|
|
18117
|
-
shouldMatch: external_exports.boolean(),
|
|
18118
|
-
didMatch: external_exports.boolean(),
|
|
18119
|
-
passed: external_exports.boolean(),
|
|
18120
|
-
matches: external_exports.array(RuleTestMatch)
|
|
18121
|
-
}).meta({ id: "FixtureResult" });
|
|
18122
|
-
var TestRulesResponse = external_exports.object({
|
|
18123
|
-
// Present only when the request supplied `text`.
|
|
18124
|
-
adhoc: external_exports.object({ matches: external_exports.array(RuleTestMatch) }).optional(),
|
|
18125
|
-
fixtures: external_exports.array(FixtureResult),
|
|
18126
|
-
summary: external_exports.object({
|
|
18127
|
-
total: external_exports.number().int().nonnegative(),
|
|
18128
|
-
passed: external_exports.number().int().nonnegative(),
|
|
18129
|
-
failed: external_exports.number().int().nonnegative()
|
|
18130
|
-
}),
|
|
18131
|
-
// Ids of rules whose matcher type the engine cannot evaluate today (e.g.
|
|
18132
|
-
// `validator`), so they silently never match. Surfaced so an author is not
|
|
18133
|
-
// misled by a green run that actually skipped a rule.
|
|
18134
|
-
unsupportedRuleIds: external_exports.array(external_exports.string())
|
|
18135
|
-
}).meta({ id: "TestRulesResponse" });
|
|
18136
|
-
|
|
18137
18189
|
// ../../packages/schema/src/zod/security.ts
|
|
18138
18190
|
var SeveritySummaryItem = external_exports.object({
|
|
18139
18191
|
severity: Severity,
|
|
@@ -18231,10 +18283,22 @@ var TopSourcesQuery = external_exports.object({
|
|
|
18231
18283
|
// Omit for both kinds.
|
|
18232
18284
|
kind: external_exports.enum(SOURCE_KINDS).optional()
|
|
18233
18285
|
});
|
|
18234
|
-
var Provider =
|
|
18286
|
+
var Provider = Harness.extract([
|
|
18287
|
+
"ClaudeCode",
|
|
18288
|
+
"Cursor",
|
|
18289
|
+
"Codex",
|
|
18290
|
+
"Antigravity",
|
|
18291
|
+
"ClaudeAi",
|
|
18292
|
+
"ChatGpt",
|
|
18293
|
+
"Copilot",
|
|
18294
|
+
"Api"
|
|
18295
|
+
]).meta({ id: "Provider" });
|
|
18235
18296
|
var ScanCoverageProvider = external_exports.object({
|
|
18236
18297
|
provider: Provider,
|
|
18237
|
-
// Percent of that provider's traffic
|
|
18298
|
+
// Percent of that provider's traffic the shipped capture surface reaches.
|
|
18299
|
+
// A curated business fact, constant across every `range` — not a measured
|
|
18300
|
+
// per-window metric. 0 exactly when `supported` is false. See the comment
|
|
18301
|
+
// above the block for where these numbers are decided.
|
|
18238
18302
|
coverage: external_exports.number().int().min(0).max(100),
|
|
18239
18303
|
supported: external_exports.boolean()
|
|
18240
18304
|
}).meta({ id: "ScanCoverageProvider" });
|
|
@@ -18288,6 +18352,18 @@ var ApplyRecommendedActionResponse = external_exports.object({
|
|
|
18288
18352
|
var DismissRecommendedActionResponse = external_exports.object({ id: external_exports.string(), status: external_exports.literal("dismissed") }).meta({ id: "DismissRecommendedActionResponse" });
|
|
18289
18353
|
var RecommendedActionIdParam = external_exports.object({ id: external_exports.string() });
|
|
18290
18354
|
|
|
18355
|
+
// ../../packages/schema/src/zod/settings-action.ts
|
|
18356
|
+
var SaveSettingsInput = external_exports.object({
|
|
18357
|
+
historicalAccess: external_exports.string(),
|
|
18358
|
+
modelJudgeConsent: external_exports.boolean(),
|
|
18359
|
+
vaultConsent: external_exports.string(),
|
|
18360
|
+
vaultInlineReveal: external_exports.string()
|
|
18361
|
+
});
|
|
18362
|
+
var AttachInput = external_exports.object({
|
|
18363
|
+
endpoint: external_exports.string(),
|
|
18364
|
+
label: external_exports.string().optional()
|
|
18365
|
+
});
|
|
18366
|
+
|
|
18291
18367
|
// ../../packages/schema/src/zod/triage.ts
|
|
18292
18368
|
var TriageHit = external_exports.object({
|
|
18293
18369
|
ruleId: external_exports.string(),
|
|
@@ -18302,7 +18378,7 @@ var TriageHit = external_exports.object({
|
|
|
18302
18378
|
valueFingerprint: external_exports.string().optional(),
|
|
18303
18379
|
keyVersion: external_exports.number().int().nonnegative().optional()
|
|
18304
18380
|
});
|
|
18305
|
-
var TriagePolicy =
|
|
18381
|
+
var TriagePolicy = CategoryPolicyId;
|
|
18306
18382
|
var TriageCategoryRec = external_exports.object({
|
|
18307
18383
|
category: DetectionCategory,
|
|
18308
18384
|
action: TriagePolicy,
|
|
@@ -18520,8 +18596,11 @@ function chmodBestEffort(path, mode) {
|
|
|
18520
18596
|
function tightenDir(dir) {
|
|
18521
18597
|
chmodBestEffort(dir, DATA_DIR_MODE);
|
|
18522
18598
|
}
|
|
18599
|
+
function mkdirOwnerOnlySync(dir, recursive = false) {
|
|
18600
|
+
mkdirSync(dir, { recursive, mode: DATA_DIR_MODE });
|
|
18601
|
+
}
|
|
18523
18602
|
function ensureDataDirSync(dir) {
|
|
18524
|
-
|
|
18603
|
+
mkdirOwnerOnlySync(dir, true);
|
|
18525
18604
|
tightenDir(dir);
|
|
18526
18605
|
}
|
|
18527
18606
|
function dbSidecars(file2) {
|
|
@@ -18533,6 +18612,9 @@ function tightenFile(file2) {
|
|
|
18533
18612
|
function tightenPerms(file2) {
|
|
18534
18613
|
for (const path of [file2, ...dbSidecars(file2)]) chmodBestEffort(path, DATA_FILE_MODE);
|
|
18535
18614
|
}
|
|
18615
|
+
function writeExclusiveOwnerOnlySync(file2, data) {
|
|
18616
|
+
writeFileSync(file2, data, { mode: DATA_FILE_MODE, flag: "wx" });
|
|
18617
|
+
}
|
|
18536
18618
|
function classifyOccupant(file2) {
|
|
18537
18619
|
try {
|
|
18538
18620
|
if (lstatSync(file2).isSymbolicLink()) return { kind: "symlink" };
|
|
@@ -18561,7 +18643,7 @@ function createOwnerOnlyFileSync(file2, data) {
|
|
|
18561
18643
|
}
|
|
18562
18644
|
let created;
|
|
18563
18645
|
try {
|
|
18564
|
-
|
|
18646
|
+
writeExclusiveOwnerOnlySync(tmp, data);
|
|
18565
18647
|
created = publishByLink(tmp, file2, data);
|
|
18566
18648
|
} finally {
|
|
18567
18649
|
try {
|
|
@@ -18583,7 +18665,7 @@ function publishByLink(tmp, file2, data) {
|
|
|
18583
18665
|
if (!LINK_UNSUPPORTED.has(code ?? "")) throw err;
|
|
18584
18666
|
}
|
|
18585
18667
|
try {
|
|
18586
|
-
|
|
18668
|
+
writeExclusiveOwnerOnlySync(file2, data);
|
|
18587
18669
|
return true;
|
|
18588
18670
|
} catch (err) {
|
|
18589
18671
|
if (err.code === "EEXIST") return false;
|
|
@@ -18596,6 +18678,25 @@ function backupPath(file2, tag) {
|
|
|
18596
18678
|
return `${file2}.${tag}.${String(Date.now())}.${randomUUID().slice(0, 8)}.bak`;
|
|
18597
18679
|
}
|
|
18598
18680
|
var STALE_PARTIAL_MS = 5 * 6e4;
|
|
18681
|
+
var SNAPSHOT_STAGING_SUFFIX = ".partial";
|
|
18682
|
+
var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18683
|
+
var SNAPSHOT_STAGING_COPY = "copy";
|
|
18684
|
+
function createSnapshotStaging(backup) {
|
|
18685
|
+
const stage = `${backup}${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18686
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18687
|
+
mkdirOwnerOnlySync(stage);
|
|
18688
|
+
tightenDir(stage);
|
|
18689
|
+
return { stage, copy: join(stage, SNAPSHOT_STAGING_COPY) };
|
|
18690
|
+
}
|
|
18691
|
+
function idleMs(entry) {
|
|
18692
|
+
for (const candidate of [join(entry, SNAPSHOT_STAGING_COPY), entry]) {
|
|
18693
|
+
try {
|
|
18694
|
+
return Date.now() - statSync(candidate).mtimeMs;
|
|
18695
|
+
} catch {
|
|
18696
|
+
}
|
|
18697
|
+
}
|
|
18698
|
+
return null;
|
|
18699
|
+
}
|
|
18599
18700
|
function reapStalePartials(file2) {
|
|
18600
18701
|
const dir = dirname(file2);
|
|
18601
18702
|
const prefix = `${basename(file2)}.`;
|
|
@@ -18606,30 +18707,34 @@ function reapStalePartials(file2) {
|
|
|
18606
18707
|
return;
|
|
18607
18708
|
}
|
|
18608
18709
|
for (const name of entries) {
|
|
18609
|
-
if (!name.startsWith(prefix) || !name.endsWith(
|
|
18610
|
-
const
|
|
18710
|
+
if (!name.startsWith(prefix) || !name.endsWith(STAGED_NAME_SUFFIX)) continue;
|
|
18711
|
+
const staging = join(dir, name);
|
|
18611
18712
|
try {
|
|
18612
|
-
|
|
18613
|
-
|
|
18713
|
+
const idle = idleMs(staging);
|
|
18714
|
+
if (idle !== null && idle > STALE_PARTIAL_MS) {
|
|
18715
|
+
rmSync2(staging, { recursive: true, force: true });
|
|
18614
18716
|
}
|
|
18615
18717
|
} catch {
|
|
18616
18718
|
}
|
|
18617
18719
|
}
|
|
18618
18720
|
}
|
|
18619
18721
|
function snapshotStore(db, backup) {
|
|
18620
|
-
const
|
|
18722
|
+
const { stage, copy } = createSnapshotStaging(backup);
|
|
18621
18723
|
try {
|
|
18622
|
-
|
|
18623
|
-
|
|
18624
|
-
|
|
18625
|
-
renameSync2(partial2, backup);
|
|
18724
|
+
db.prepare("VACUUM INTO ?").run(copy);
|
|
18725
|
+
tightenFile(copy);
|
|
18726
|
+
renameSync2(copy, backup);
|
|
18626
18727
|
} catch (error51) {
|
|
18627
18728
|
try {
|
|
18628
|
-
rmSync2(
|
|
18729
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18629
18730
|
} catch {
|
|
18630
18731
|
}
|
|
18631
18732
|
throw error51;
|
|
18632
18733
|
}
|
|
18734
|
+
try {
|
|
18735
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18736
|
+
} catch {
|
|
18737
|
+
}
|
|
18633
18738
|
}
|
|
18634
18739
|
function moveStoreAside(file2, backup) {
|
|
18635
18740
|
const undo = [];
|
|
@@ -19357,9 +19462,10 @@ function safeParseStringArray(raw) {
|
|
|
19357
19462
|
const parsed = safeJson(raw, null);
|
|
19358
19463
|
return Array.isArray(parsed) ? parsed : [];
|
|
19359
19464
|
}
|
|
19465
|
+
var DEFAULT_HARNESS = HARNESS.ClaudeCode;
|
|
19360
19466
|
function toHarness(raw) {
|
|
19361
19467
|
const parsed = Harness.safeParse(raw);
|
|
19362
|
-
return parsed.success ? parsed.data :
|
|
19468
|
+
return parsed.success ? parsed.data : DEFAULT_HARNESS;
|
|
19363
19469
|
}
|
|
19364
19470
|
function resolveLifecycle(row, lastActivityMs, nowMs) {
|
|
19365
19471
|
if (row.status) {
|
|
@@ -19490,7 +19596,7 @@ var SqliteActivityRepository = class {
|
|
|
19490
19596
|
const params = [];
|
|
19491
19597
|
if (query.harness && query.harness.length > 0) {
|
|
19492
19598
|
conditions.push(
|
|
19493
|
-
`coalesce(json_extract(attributes, '$.harness'), '
|
|
19599
|
+
`coalesce(json_extract(attributes, '$.harness'), '${DEFAULT_HARNESS}') IN (${placeholders(query.harness.length)})`
|
|
19494
19600
|
);
|
|
19495
19601
|
params.push(...query.harness);
|
|
19496
19602
|
}
|
|
@@ -19697,13 +19803,13 @@ var SqliteActivityRepository = class {
|
|
|
19697
19803
|
* The DISTINCT harnesses that actually have sessions (optionally within a
|
|
19698
19804
|
* `started_at >= fromMs` window), so the filter can offer only the harnesses
|
|
19699
19805
|
* present rather than the full enum. Each stored value is normalized through
|
|
19700
|
-
* the SAME `toHarness` default the list uses (missing →
|
|
19701
|
-
* store of bare (harness-less) roots surfaces exactly
|
|
19806
|
+
* the SAME `toHarness` default the list uses (missing → DEFAULT_HARNESS), so
|
|
19807
|
+
* a store of bare (harness-less) roots surfaces exactly that one harness.
|
|
19702
19808
|
*/
|
|
19703
19809
|
harnessFacets(fromMs) {
|
|
19704
19810
|
const where = fromMs === void 0 ? "" : " AND started_at >= ?";
|
|
19705
19811
|
const stmt = this.db.prepare(
|
|
19706
|
-
`SELECT DISTINCT coalesce(json_extract(attributes, '$.harness'), '
|
|
19812
|
+
`SELECT DISTINCT coalesce(json_extract(attributes, '$.harness'), '${DEFAULT_HARNESS}') AS harness
|
|
19707
19813
|
FROM audit_events WHERE ${SESSION_ROOT}${where}`
|
|
19708
19814
|
);
|
|
19709
19815
|
const rows = allRows(
|
|
@@ -19917,8 +20023,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
19917
20023
|
}
|
|
19918
20024
|
// Insert one transcript-derived `llm_call` leaf. Unlike `insertAuditEvent`
|
|
19919
20025
|
// (which takes a caller-supplied random id), the id here is MINTED internally
|
|
19920
|
-
// from the natural key — `llmCallId(sessionId, messageId)` —
|
|
19921
|
-
//
|
|
20026
|
+
// from the natural key — `llmCallId(sessionId, messageId)` — derived from the
|
|
20027
|
+
// session and message alone, like the sibling local-store ids. The deterministic
|
|
19922
20028
|
// id + the UPSERT-take-MAX(output_tokens) statement make every re-read idempotent
|
|
19923
20029
|
// AND converge a streaming partial/final split across two incremental passes:
|
|
19924
20030
|
// a whole-file re-read no-ops (equal output), a lagging final replaces a
|
|
@@ -20883,6 +20989,42 @@ var SqliteFindingsRepository = class {
|
|
|
20883
20989
|
this.db = db;
|
|
20884
20990
|
}
|
|
20885
20991
|
db;
|
|
20992
|
+
/**
|
|
20993
|
+
* The newest `limit` findings, newest first.
|
|
20994
|
+
*
|
|
20995
|
+
* THE PLAN IS THE POINT HERE, and two things in the SQL below exist only to
|
|
20996
|
+
* pin it. The natural spelling — drive from `inspection_findings`, order by the
|
|
20997
|
+
* JOINED `e.started_at` — cannot push the LIMIT down, because the sort key is
|
|
20998
|
+
* not on the driving table: SQLite sorts every finding in the store through a
|
|
20999
|
+
* temp B-tree to return 500 rows. Measured at 35.0 ms on a 40,000-event corpus
|
|
21000
|
+
* against 0.9 ms for the form below, and the gap is a ratio of the store size
|
|
21001
|
+
* rather than a constant.
|
|
21002
|
+
*
|
|
21003
|
+
* What it takes to make `started_at` order come out of an index instead:
|
|
21004
|
+
*
|
|
21005
|
+
* - **`+e.event_type`** — the unary plus makes that term non-indexable, so the
|
|
21006
|
+
* planner stops choosing `idx_audit_type_t` (`event_type, started_at`). That
|
|
21007
|
+
* index cannot serve the ORDER BY: the predicate spans four event types, so
|
|
21008
|
+
* satisfying a global `started_at` order across them needs a range merge
|
|
21009
|
+
* SQLite will not do, and it sorts instead. Freed of it, the planner scans
|
|
21010
|
+
* `idx_audit_started_at` — a bare `started_at` index — in DESC order and
|
|
21011
|
+
* filters the type per row, which lets the LIMIT stop the scan early.
|
|
21012
|
+
* - **`CROSS JOIN`** — semantically identical to JOIN in SQLite, and there
|
|
21013
|
+
* purely to stop the tables being reordered. With plain JOINs the planner
|
|
21014
|
+
* drives from `f` and sorts everything again: measured at 23.6 ms, i.e. the
|
|
21015
|
+
* unary plus ALONE recovers almost none of the win. Both are needed.
|
|
21016
|
+
*
|
|
21017
|
+
* Neither is a micro-optimisation that a later reader should tidy away, and
|
|
21018
|
+
* `packages/persistence/test/performance/hot-read-query-plans.test.ts` fails if
|
|
21019
|
+
* the temp B-tree comes back.
|
|
21020
|
+
*
|
|
21021
|
+
* Degrading gracefully was the reason for `+` over `INDEXED BY`, which measured
|
|
21022
|
+
* identically (0.9 ms): `INDEXED BY` is a hard requirement, so dropping or
|
|
21023
|
+
* renaming the index turns this read into an ERROR, where `+` turns it into a
|
|
21024
|
+
* scan-and-sort — slower, still correct. The worst case for the chosen form is
|
|
21025
|
+
* a store whose recent captures carry no findings at all, where the scan walks
|
|
21026
|
+
* the whole index; that is still no worse than the full sort it replaced.
|
|
21027
|
+
*/
|
|
20886
21028
|
recentFindings(opts) {
|
|
20887
21029
|
const limit = opts?.limit ?? 50;
|
|
20888
21030
|
const rows = allRows(
|
|
@@ -20891,10 +21033,10 @@ var SqliteFindingsRepository = class {
|
|
|
20891
21033
|
f.masked_match, f.action_taken, f.confidence, e.started_at AS occurred_at,
|
|
20892
21034
|
json_extract(e.attributes, '$.source_tool') AS source_tool,
|
|
20893
21035
|
e.event_type AS kind
|
|
20894
|
-
FROM
|
|
20895
|
-
JOIN
|
|
20896
|
-
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
20897
|
-
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
21036
|
+
FROM audit_events e
|
|
21037
|
+
CROSS JOIN inspection_findings f ON f.audit_event_id = e.id
|
|
21038
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
21039
|
+
WHERE +e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
20898
21040
|
ORDER BY e.started_at DESC, f.rowid DESC
|
|
20899
21041
|
LIMIT :limit`
|
|
20900
21042
|
),
|
|
@@ -21538,7 +21680,8 @@ var SqliteInspectionDefinitionsRepository = class {
|
|
|
21538
21680
|
}
|
|
21539
21681
|
db;
|
|
21540
21682
|
insertStmt;
|
|
21541
|
-
//
|
|
21683
|
+
// Insert-if-absent; returns the content-addressed definition id. An id already
|
|
21684
|
+
// present keeps the stored row untouched — see the class doc.
|
|
21542
21685
|
upsert(input) {
|
|
21543
21686
|
const id = inspectionDefinitionId(input.ruleId, input.version);
|
|
21544
21687
|
const row = toInspectionDefinitionRow(input, id);
|
|
@@ -21682,11 +21825,23 @@ function isParseableBinaryVersion(version2) {
|
|
|
21682
21825
|
|
|
21683
21826
|
// ../../packages/persistence/src/repositories/installed-packs.ts
|
|
21684
21827
|
var DEFAULT_POLICY_ID = DEFAULT_PACK_POLICY_ID;
|
|
21828
|
+
function printableRuleId(entry) {
|
|
21829
|
+
if (typeof entry !== "object" || entry === null) return null;
|
|
21830
|
+
const candidate = entry.id;
|
|
21831
|
+
return Rule.shape.id.safeParse(candidate).success ? candidate : null;
|
|
21832
|
+
}
|
|
21833
|
+
function firstIssueReason(error51) {
|
|
21834
|
+
const issue2 = error51.issues[0];
|
|
21835
|
+
if (!issue2) return "unknown";
|
|
21836
|
+
const path = issue2.path.map((segment) => String(segment)).join(".");
|
|
21837
|
+
return path ? `${path}: ${issue2.code}` : issue2.code;
|
|
21838
|
+
}
|
|
21839
|
+
var REJECTED_RULE_DETAIL_CAP = 10;
|
|
21685
21840
|
function inventorySignature(packs2) {
|
|
21686
21841
|
return packs2.map((p) => `${p.namespace}/${p.packId}@${p.version}#${hashRules(p.rulesJson)}`).sort().join(",");
|
|
21687
21842
|
}
|
|
21688
21843
|
function hashRules(rulesJson) {
|
|
21689
|
-
return createHash2("
|
|
21844
|
+
return createHash2("sha256").update(rulesJson).digest("hex");
|
|
21690
21845
|
}
|
|
21691
21846
|
function parseVersion(v) {
|
|
21692
21847
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -21898,10 +22053,21 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21898
22053
|
* (all detection off) instead of falling back to the bundled packs. Every
|
|
21899
22054
|
* JSON-level failure therefore counts as invalid.
|
|
21900
22055
|
*/
|
|
22056
|
+
/**
|
|
22057
|
+
* ORDERED, because a rule id is unique only WITHIN a pack — the sole unique
|
|
22058
|
+
* index is (namespace, pack_id) — so two enabled packs may contribute the same
|
|
22059
|
+
* id, and the per-rule maps below are last-write-wins. Without an ORDER BY the
|
|
22060
|
+
* winner is whatever order SQLite happens to return, which makes a collision
|
|
22061
|
+
* resolve differently on two machines holding identical stores. Ordering by
|
|
22062
|
+
* (namespace, pack_id) makes the loser deterministic and therefore testable.
|
|
22063
|
+
*/
|
|
21901
22064
|
installedRuleset() {
|
|
21902
22065
|
const rows = allRows(
|
|
21903
22066
|
this.db.prepare(
|
|
21904
|
-
`SELECT enabled, policy_id AS policyId, rules_json AS rulesJson, version
|
|
22067
|
+
`SELECT enabled, policy_id AS policyId, rules_json AS rulesJson, version,
|
|
22068
|
+
namespace, pack_id AS packId
|
|
22069
|
+
FROM installed_packs
|
|
22070
|
+
ORDER BY namespace, pack_id`
|
|
21905
22071
|
)
|
|
21906
22072
|
);
|
|
21907
22073
|
const out = {
|
|
@@ -21909,22 +22075,32 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21909
22075
|
enabledPacks: 0,
|
|
21910
22076
|
rules: [],
|
|
21911
22077
|
invalidRules: 0,
|
|
22078
|
+
rejectedRules: [],
|
|
21912
22079
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
21913
|
-
ruleVersions: /* @__PURE__ */ new Map()
|
|
22080
|
+
ruleVersions: /* @__PURE__ */ new Map(),
|
|
22081
|
+
reversibleRules: /* @__PURE__ */ new Set()
|
|
22082
|
+
};
|
|
22083
|
+
const reject = (pack, ruleId, reason) => {
|
|
22084
|
+
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
22085
|
+
out.rejectedRules.push({ pack, ruleId, reason });
|
|
21914
22086
|
};
|
|
21915
22087
|
for (const row of rows) {
|
|
21916
22088
|
if (!intToBool(row.enabled)) continue;
|
|
21917
22089
|
out.enabledPacks += 1;
|
|
21918
22090
|
const action = policyIdToAction(row.policyId);
|
|
22091
|
+
const reversible = policyIdIsReversible(row.policyId);
|
|
22092
|
+
const pack = `${row.namespace}/${row.packId}`;
|
|
21919
22093
|
let raw;
|
|
21920
22094
|
try {
|
|
21921
22095
|
raw = JSON.parse(row.rulesJson);
|
|
21922
22096
|
} catch {
|
|
21923
22097
|
out.invalidRules += 1;
|
|
22098
|
+
reject(pack, null, "rules_json: malformed JSON");
|
|
21924
22099
|
continue;
|
|
21925
22100
|
}
|
|
21926
22101
|
if (!Array.isArray(raw)) {
|
|
21927
22102
|
out.invalidRules += 1;
|
|
22103
|
+
reject(pack, null, "rules_json: not an array");
|
|
21928
22104
|
continue;
|
|
21929
22105
|
}
|
|
21930
22106
|
for (const entry of raw) {
|
|
@@ -21933,7 +22109,12 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21933
22109
|
out.rules.push(parsed.data);
|
|
21934
22110
|
out.ruleActions.set(parsed.data.id, action);
|
|
21935
22111
|
out.ruleVersions.set(parsed.data.id, row.version);
|
|
21936
|
-
|
|
22112
|
+
if (reversible) out.reversibleRules.add(parsed.data.id);
|
|
22113
|
+
else out.reversibleRules.delete(parsed.data.id);
|
|
22114
|
+
} else {
|
|
22115
|
+
out.invalidRules += 1;
|
|
22116
|
+
reject(pack, printableRuleId(entry), firstIssueReason(parsed.error));
|
|
22117
|
+
}
|
|
21937
22118
|
}
|
|
21938
22119
|
}
|
|
21939
22120
|
return out;
|
|
@@ -22127,31 +22308,38 @@ var CATEGORY_ORDER = ["config", "skill", "mcp", "hook"];
|
|
|
22127
22308
|
var VALID_HARNESS_IDS = new Set(HarnessId.options);
|
|
22128
22309
|
var WORKTREE_CHECKOUT_FILTER = "(url IS NULL OR (url NOT LIKE '%/.claude/worktrees/%' AND url NOT LIKE '%\\.claude\\worktrees\\%'))";
|
|
22129
22310
|
var HARNESS_LABELS = {
|
|
22130
|
-
|
|
22131
|
-
|
|
22132
|
-
|
|
22133
|
-
|
|
22311
|
+
[HARNESS.ClaudeCode]: "Claude Code",
|
|
22312
|
+
[HARNESS.Cursor]: "Cursor",
|
|
22313
|
+
[HARNESS.Codex]: "Codex",
|
|
22314
|
+
[HARNESS.Antigravity]: "Antigravity"
|
|
22134
22315
|
};
|
|
22135
22316
|
var HARNESS_LIVENESS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
22136
22317
|
var EMPTY_PROJECT_AGG = {
|
|
22137
22318
|
accessCounts: { open: 0, approved: 0, blocked: 0, total: 0 },
|
|
22138
22319
|
findingsCount: 0
|
|
22139
22320
|
};
|
|
22321
|
+
var stripSeparators = (value) => value.toLowerCase().replace(/[\s-]/g, "");
|
|
22322
|
+
var TITLE_NEEDLES = {
|
|
22323
|
+
ClaudeCode: stripSeparators(SOURCE_TOOL.ClaudeCode),
|
|
22324
|
+
Cursor: stripSeparators(SOURCE_TOOL.Cursor),
|
|
22325
|
+
Codex: stripSeparators(SOURCE_TOOL.Codex),
|
|
22326
|
+
Antigravity: stripSeparators(SOURCE_TOOL.Antigravity)
|
|
22327
|
+
};
|
|
22140
22328
|
function resolveHarnessId(attrs, row) {
|
|
22141
22329
|
if (attrs.provider && VALID_HARNESS_IDS.has(attrs.provider)) {
|
|
22142
22330
|
return attrs.provider;
|
|
22143
22331
|
}
|
|
22144
|
-
const t = (row.title ?? "")
|
|
22145
|
-
if (t.includes(
|
|
22146
|
-
if (t.includes(
|
|
22147
|
-
if (t.includes(
|
|
22148
|
-
if (t.includes(
|
|
22332
|
+
const t = stripSeparators(row.title ?? "");
|
|
22333
|
+
if (t.includes(TITLE_NEEDLES.ClaudeCode) || t === "claude") return HARNESS.ClaudeCode;
|
|
22334
|
+
if (t.includes(TITLE_NEEDLES.Cursor)) return HARNESS.Cursor;
|
|
22335
|
+
if (t.includes(TITLE_NEEDLES.Codex)) return HARNESS.Codex;
|
|
22336
|
+
if (t.includes(TITLE_NEEDLES.Antigravity)) return HARNESS.Antigravity;
|
|
22149
22337
|
return null;
|
|
22150
22338
|
}
|
|
22151
22339
|
function isLiveRealClaudeCode(rows) {
|
|
22152
22340
|
return rows.some((r) => {
|
|
22153
22341
|
const attrs = safeJson(r.attributes, {});
|
|
22154
|
-
return attrs.provenance !== "sample" && resolveHarnessId(attrs, r) ===
|
|
22342
|
+
return attrs.provenance !== "sample" && resolveHarnessId(attrs, r) === HARNESS.ClaudeCode;
|
|
22155
22343
|
});
|
|
22156
22344
|
}
|
|
22157
22345
|
function toAssetSummary(row) {
|
|
@@ -22419,7 +22607,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
22419
22607
|
const isRealHarness = rows.some(
|
|
22420
22608
|
(r) => safeJson(r.attributes, {}).provenance !== "sample"
|
|
22421
22609
|
);
|
|
22422
|
-
const attachConfig = isRealHarness && harnessId ===
|
|
22610
|
+
const attachConfig = isRealHarness && harnessId === HARNESS.ClaudeCode && configAssets.length > 0;
|
|
22423
22611
|
const assets = attachConfig ? [...harnessAssets, ...configAssets].sort((a, b) => a.name.localeCompare(b.name)) : harnessAssets;
|
|
22424
22612
|
if (q && assets.length === 0) continue;
|
|
22425
22613
|
const firstRow = rows[0];
|
|
@@ -23093,9 +23281,10 @@ var SqliteProjectFilesRepository = class {
|
|
|
23093
23281
|
// ../../packages/persistence/src/repositories/resolutions.ts
|
|
23094
23282
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
23095
23283
|
var SqliteResolutionsRepository = class {
|
|
23096
|
-
constructor(db, now = () => Date.now()) {
|
|
23284
|
+
constructor(db, now = () => Date.now(), newId = () => randomUUID7()) {
|
|
23097
23285
|
this.db = db;
|
|
23098
23286
|
this.now = now;
|
|
23287
|
+
this.newId = newId;
|
|
23099
23288
|
this.insertStmt = db.prepare(
|
|
23100
23289
|
`INSERT INTO finding_resolution (id, finding_key, status, method, resolved_at, evidence, created_at)
|
|
23101
23290
|
VALUES (:id, :findingKey, :status, :method, :resolvedAt, :evidence, :createdAt)`
|
|
@@ -23128,12 +23317,14 @@ var SqliteResolutionsRepository = class {
|
|
|
23128
23317
|
}
|
|
23129
23318
|
db;
|
|
23130
23319
|
now;
|
|
23320
|
+
newId;
|
|
23131
23321
|
insertStmt;
|
|
23132
23322
|
latestStmt;
|
|
23133
23323
|
openAtRestStmt;
|
|
23134
23324
|
resolvedAtRestStmt;
|
|
23135
23325
|
/**
|
|
23136
|
-
* Insert one disposition row. The repo mints the id and stamps created_at
|
|
23326
|
+
* Insert one disposition row. The repo mints the id and stamps created_at,
|
|
23327
|
+
* both through the constructor's injectable seams.
|
|
23137
23328
|
* `status`/`method` are typed AND re-parsed here against @akasecurity/schema's
|
|
23138
23329
|
* FindingStatus/ResolutionMethod, so the persisted vocabulary can never drift
|
|
23139
23330
|
* from the schema enums. NOTE for future manual-resolution writers: this is
|
|
@@ -23145,7 +23336,7 @@ var SqliteResolutionsRepository = class {
|
|
|
23145
23336
|
*/
|
|
23146
23337
|
insertResolution(r) {
|
|
23147
23338
|
this.insertStmt.run({
|
|
23148
|
-
id:
|
|
23339
|
+
id: this.newId(),
|
|
23149
23340
|
findingKey: r.findingKey,
|
|
23150
23341
|
status: FindingStatus.parse(r.status),
|
|
23151
23342
|
method: ResolutionMethod.parse(r.method),
|
|
@@ -23724,16 +23915,16 @@ var ACTION_TO_KIND = {
|
|
|
23724
23915
|
warn: "warned"
|
|
23725
23916
|
};
|
|
23726
23917
|
var ENFORCEMENT_KINDS = ["blocked", "redacted", "warned"];
|
|
23727
|
-
var SCAN_COVERAGE =
|
|
23728
|
-
|
|
23729
|
-
|
|
23730
|
-
|
|
23731
|
-
|
|
23732
|
-
|
|
23733
|
-
|
|
23734
|
-
|
|
23735
|
-
|
|
23736
|
-
|
|
23918
|
+
var SCAN_COVERAGE = {
|
|
23919
|
+
[HARNESS.Antigravity]: { coverage: 60, supported: true },
|
|
23920
|
+
[HARNESS.Api]: { coverage: 0, supported: false },
|
|
23921
|
+
[HARNESS.ChatGpt]: { coverage: 40, supported: true },
|
|
23922
|
+
[HARNESS.ClaudeAi]: { coverage: 40, supported: true },
|
|
23923
|
+
[HARNESS.ClaudeCode]: { coverage: 100, supported: true },
|
|
23924
|
+
[HARNESS.Codex]: { coverage: 80, supported: true },
|
|
23925
|
+
[HARNESS.Copilot]: { coverage: 0, supported: false },
|
|
23926
|
+
[HARNESS.Cursor]: { coverage: 0, supported: false }
|
|
23927
|
+
};
|
|
23737
23928
|
var GRANULARITY = {
|
|
23738
23929
|
"7d": "day",
|
|
23739
23930
|
"30d": "day",
|
|
@@ -23832,9 +24023,22 @@ var SqliteSecurityRepository = class {
|
|
|
23832
24023
|
return Promise.resolve({ total, needsRemediation, bySeverity });
|
|
23833
24024
|
}
|
|
23834
24025
|
// Range is echoed but does not change the result today — coverage is a constant
|
|
23835
|
-
// business fact (see SCAN_COVERAGE), not a measured per-window metric.
|
|
24026
|
+
// business fact (see SCAN_COVERAGE), not a measured per-window metric. Order
|
|
24027
|
+
// comes from Provider.options (the enum's declaration order), not from
|
|
24028
|
+
// SCAN_COVERAGE's own key order — deliberately, not because object literals
|
|
24029
|
+
// leave key order unspecified (ES2015 guarantees insertion order for these
|
|
24030
|
+
// non-integer string keys, so iterating SCAN_COVERAGE directly would be
|
|
24031
|
+
// reliable too). The reason is the schema comment's promise: the returned
|
|
24032
|
+
// order must mirror the generated OpenAPI enum list, which is Provider's
|
|
24033
|
+
// contract, not this table's.
|
|
23836
24034
|
scanCoverage(range) {
|
|
23837
|
-
return Promise.resolve({
|
|
24035
|
+
return Promise.resolve({
|
|
24036
|
+
range,
|
|
24037
|
+
providers: Provider.options.map((provider) => ({
|
|
24038
|
+
provider,
|
|
24039
|
+
...SCAN_COVERAGE[provider]
|
|
24040
|
+
}))
|
|
24041
|
+
});
|
|
23838
24042
|
}
|
|
23839
24043
|
enforcementActions(range) {
|
|
23840
24044
|
const lenMs = RANGE_DAYS[range] * DAY_MS4;
|
|
@@ -23892,10 +24096,10 @@ var SqliteSecurityRepository = class {
|
|
|
23892
24096
|
// count; a superseding open/redetected row means the finding is not
|
|
23893
24097
|
// remediated and is excluded, same invariant as severitySummary. Legacy
|
|
23894
24098
|
// at-rest findings with finding_key IS NULL can never have a resolution row
|
|
23895
|
-
// (the lifecycle is keyed by finding_key), so
|
|
23896
|
-
//
|
|
23897
|
-
//
|
|
23898
|
-
// mirroring this file's other methods.
|
|
24099
|
+
// (the lifecycle is keyed by finding_key), so they cannot reach the driving
|
|
24100
|
+
// set below. One raw-row query (fetch the findings with resolution activity in
|
|
24101
|
+
// the window + each one's latest resolution status/method/resolved_at) +
|
|
24102
|
+
// pure-JS filter/bucket/mean, mirroring this file's other methods.
|
|
23899
24103
|
mttrTrend(range) {
|
|
23900
24104
|
const granularity = granularityFor(range);
|
|
23901
24105
|
const bucketMs = (granularity === "day" ? 1 : 7) * DAY_MS4;
|
|
@@ -23911,29 +24115,80 @@ var SqliteSecurityRepository = class {
|
|
|
23911
24115
|
// started_at the upsert overwrites onto inspection_findings.audit_event_id.
|
|
23912
24116
|
// COALESCE onto the parent event's started_at defends against any
|
|
23913
24117
|
// legacy/edge row the backfill left null.
|
|
23914
|
-
`SELECT
|
|
24118
|
+
`SELECT DISTINCT f.finding_key AS finding_key,
|
|
24119
|
+
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at, d.severity AS severity,
|
|
23915
24120
|
latest.status AS latest_status,
|
|
23916
24121
|
latest.method AS latest_method,
|
|
23917
24122
|
latest.resolved_at AS latest_resolved_at
|
|
23918
|
-
FROM
|
|
23919
|
-
JOIN
|
|
23920
|
-
JOIN
|
|
24123
|
+
FROM finding_resolution fr
|
|
24124
|
+
CROSS JOIN inspection_findings f ON f.finding_key = fr.finding_key
|
|
24125
|
+
CROSS JOIN audit_events e ON e.id = f.audit_event_id
|
|
24126
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
23921
24127
|
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
23922
24128
|
ON latest.finding_key = f.finding_key
|
|
23923
|
-
WHERE
|
|
23924
|
-
AND e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
23925
|
-
|
|
23926
|
-
SELECT 1 FROM finding_resolution fr
|
|
23927
|
-
WHERE fr.finding_key = f.finding_key
|
|
23928
|
-
AND fr.resolved_at >= :windowStart
|
|
23929
|
-
)`
|
|
23930
|
-
// The EXISTS is a SUPERSET prefilter that bounds the scan to keys with
|
|
23931
|
-
// any resolution activity at/after the window start — a row this method
|
|
24129
|
+
WHERE fr.resolved_at >= :windowStart
|
|
24130
|
+
AND e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})`
|
|
24131
|
+
// `fr` is a SUPERSET prefilter, not the answer: a finding this method
|
|
23932
24132
|
// ultimately counts has its LATEST resolution inside the window, which
|
|
23933
|
-
// implies
|
|
23934
|
-
// latest-wins + status/method + window gate
|
|
23935
|
-
// dialect-agnostic.
|
|
23936
|
-
//
|
|
24133
|
+
// implies a resolution row at/after the window start exists, so nothing
|
|
24134
|
+
// wanted is dropped. The exact latest-wins + status/method + window gate
|
|
24135
|
+
// stays in JS below, dialect-agnostic. `f.finding_key IS NOT NULL` is
|
|
24136
|
+
// implied rather than dropped — the join key comes from
|
|
24137
|
+
// finding_resolution, whose finding_key is NOT NULL.
|
|
24138
|
+
//
|
|
24139
|
+
// IT IS THE DRIVING TABLE THAT MAKES THAT PREFILTER A BOUND, which is
|
|
24140
|
+
// the correction this replaced. Spelled as an `EXISTS` in the WHERE it
|
|
24141
|
+
// READ as a bound and was not one: SQLite drove from `audit_events` on
|
|
24142
|
+
// event_type, joined every capture event to its findings, and evaluated
|
|
24143
|
+
// the EXISTS last — bounding the RESULT and not the scan, so a 7d request
|
|
24144
|
+
// still cost the store's whole trackable history. Measured at 44.6 ms on
|
|
24145
|
+
// 50,000 events and 171.3 ms on 150,000 — linear in the STORE, and in
|
|
24146
|
+
// both cases returning rows for a window holding a fraction of it.
|
|
24147
|
+
//
|
|
24148
|
+
// Two things carry it, and they answer DIFFERENT halves — which is worth
|
|
24149
|
+
// stating precisely, because the obvious reading (both are needed for the
|
|
24150
|
+
// speed) is wrong and was measured to be wrong:
|
|
24151
|
+
//
|
|
24152
|
+
// - **`CROSS JOIN`** is the whole of the store-size fix. In SQLite the
|
|
24153
|
+
// keyword is semantically identical to JOIN and exists only to stop the
|
|
24154
|
+
// tables being reordered; with plain JOINs the planner puts `e` back on
|
|
24155
|
+
// the outside, because with no ANALYZE statistics it prices
|
|
24156
|
+
// `event_type IN (...)` as a selective probe. Reverting it alone takes
|
|
24157
|
+
// the 2k->20k flatness ratio from 1.32 to 16.87.
|
|
24158
|
+
// - **`idx_finding_resolution_resolved_at`** (migration 0021) makes
|
|
24159
|
+
// `resolved_at >= :windowStart` a range SEARCH instead of a bare
|
|
24160
|
+
// `SCAN fr` — finding_key was this table's only index before it, so the
|
|
24161
|
+
// range had none. It buys NO flatness in store size: remove it and the
|
|
24162
|
+
// ratio above does not move, because the latest-resolution derived
|
|
24163
|
+
// table already passes over the whole of finding_resolution, so this
|
|
24164
|
+
// read is O(resolutions) either way and resolutions are not the store.
|
|
24165
|
+
// What it buys is the criterion `hot-read-query-plans.test.ts` enforces
|
|
24166
|
+
// — no hot read may pass over a table with no index — and that is the
|
|
24167
|
+
// guard that goes red when it is dropped. Neither test catches the
|
|
24168
|
+
// other's defect.
|
|
24169
|
+
//
|
|
24170
|
+
// SELECT DISTINCT is a CORRECTNESS requirement of driving from `fr`, not a
|
|
24171
|
+
// tidy-up. finding_resolution is append-only, so a key that was fixed,
|
|
24172
|
+
// redetected and fixed again carries several rows inside one window and
|
|
24173
|
+
// matches once per row — and the value below is a MEAN, so a key matched
|
|
24174
|
+
// three times is a key weighted three times.
|
|
24175
|
+
//
|
|
24176
|
+
// The skew is easy to argue away and the argument is wrong, so it is worth
|
|
24177
|
+
// recording. Duplicate rows for ONE key are identical (every projected
|
|
24178
|
+
// column is per-key: `latest.*` is latest-wins, `first_detected_at` is
|
|
24179
|
+
// preserved), so sums and counts scale together and that key's own mean
|
|
24180
|
+
// does not move. What moves is a bucket holding TWO findings that duplicate
|
|
24181
|
+
// UNEQUALLY: three rows for a 5.9-day fix and one for a 1.9-day fix average
|
|
24182
|
+
// 4.9 days weighted against 3.9 unweighted. Measured, and pinned by
|
|
24183
|
+
// `security.test.ts`'s "weights a finding ONCE however many resolution rows
|
|
24184
|
+
// it has inside the window" — which needed a fixture built for it, since no
|
|
24185
|
+
// single-key case can show it.
|
|
24186
|
+
//
|
|
24187
|
+
// `finding_key` is selected to make the DISTINCT dedup by KEY rather than
|
|
24188
|
+
// by value tuple. On the other columns alone, two genuinely different
|
|
24189
|
+
// findings sharing a severity, a first-detection event and a resolution
|
|
24190
|
+
// instant — one commit fixing two secrets in one file — are one tuple, and
|
|
24191
|
+
// collapsing them would under-count in the other direction.
|
|
23937
24192
|
),
|
|
23938
24193
|
{ windowStart }
|
|
23939
24194
|
);
|
|
@@ -23991,16 +24246,47 @@ var SqliteSecurityRepository = class {
|
|
|
23991
24246
|
}
|
|
23992
24247
|
// Recently-resolved activity feed: findings whose finding_key's LATEST
|
|
23993
24248
|
// finding_resolution row is status:'resolved'/method:'fixed-at-source' —
|
|
23994
|
-
// same latest-resolution-wins
|
|
23995
|
-
//
|
|
23996
|
-
//
|
|
23997
|
-
//
|
|
23998
|
-
//
|
|
23999
|
-
//
|
|
24000
|
-
//
|
|
24001
|
-
//
|
|
24002
|
-
//
|
|
24003
|
-
//
|
|
24249
|
+
// same latest-resolution-wins derived table as severitySummary / mttrTrend
|
|
24250
|
+
// (NOT a plain JOIN, which would surface every historical resolution row for
|
|
24251
|
+
// a key rather than just its current disposition). A key whose latest row is
|
|
24252
|
+
// a superseding 'open'/'redetected' row (the same secret came back) is
|
|
24253
|
+
// excluded — it is not currently resolved. Legacy at-rest findings with
|
|
24254
|
+
// finding_key IS NULL are excluded outright (the resolution lifecycle can
|
|
24255
|
+
// never attach to them). Path comes from the finding's parent event
|
|
24256
|
+
// (event_type 'code_change', attributes.file_path) — mirrors resolutions.ts's
|
|
24257
|
+
// openAtRestStmt accessor. Ordered by resolved_at DESC, capped at `limit`.
|
|
24258
|
+
//
|
|
24259
|
+
// THE RESOLUTION SET DRIVES THIS QUERY, and that is a correctness property of
|
|
24260
|
+
// the plan rather than a preference. Written the other way round — driving
|
|
24261
|
+
// from inspection_findings/audit_events with `latest` LEFT JOINed on — SQLite
|
|
24262
|
+
// cannot use the join key: `f` is reached FROM `latest` by finding_key, so
|
|
24263
|
+
// `latest` gets probed on (rn, status, method) instead and the plan enumerates
|
|
24264
|
+
// every (code_change event x resolved key) pair before `f` can reject it. That
|
|
24265
|
+
// is a cross product, and it is quadratic in the store: measured at 10,966 ms
|
|
24266
|
+
// on a corpus of 50,000 events carrying 2,051 resolutions, against 20 rows
|
|
24267
|
+
// returned. It was invisible for as long as it was, and reported at 8 ms,
|
|
24268
|
+
// because an empty finding_resolution table makes the inner side empty and the
|
|
24269
|
+
// cross product collapses to nothing — so the shape is only observable on a
|
|
24270
|
+
// corpus that seeds resolutions.
|
|
24271
|
+
//
|
|
24272
|
+
// Driving from `latest` instead makes every step below it a unique-index or
|
|
24273
|
+
// primary-key lookup (uq_inspection_findings_key, then audit_events' own PK),
|
|
24274
|
+
// so the cost is the derived table's own — linear in resolutions, which is
|
|
24275
|
+
// what this feed is legitimately about.
|
|
24276
|
+
//
|
|
24277
|
+
// CROSS JOIN is what actually pins that, and it is load-bearing rather than
|
|
24278
|
+
// decorative: in SQLite the keyword is semantically identical to JOIN and
|
|
24279
|
+
// exists only to stop the optimizer reordering the tables. Written as plain
|
|
24280
|
+
// JOINs in this order the planner puts `e` back on the outside — it has no
|
|
24281
|
+
// ANALYZE statistics to price the alternatives with, so it takes
|
|
24282
|
+
// `event_type = 'code_change'` for a selective index probe and rebuilds the
|
|
24283
|
+
// cross product. The FROM order alone was measured to change the plan not at
|
|
24284
|
+
// all.
|
|
24285
|
+
//
|
|
24286
|
+
// The LEFT JOIN it replaced was already an inner join in effect: three
|
|
24287
|
+
// `latest.*` predicates sit in the WHERE, and each of them is false for a
|
|
24288
|
+
// null-extended row. Spelling it JOIN changes no row and stops the plan
|
|
24289
|
+
// reading as though the findings side could drive.
|
|
24004
24290
|
recentlyResolved(limit = 20) {
|
|
24005
24291
|
const rows = allRows(
|
|
24006
24292
|
this.db.prepare(
|
|
@@ -24010,17 +24296,15 @@ var SqliteSecurityRepository = class {
|
|
|
24010
24296
|
json_extract(e.attributes, '$.file_path') AS path,
|
|
24011
24297
|
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at,
|
|
24012
24298
|
latest.resolved_at AS latest_resolved_at
|
|
24013
|
-
FROM
|
|
24014
|
-
JOIN
|
|
24015
|
-
JOIN
|
|
24016
|
-
|
|
24017
|
-
|
|
24018
|
-
WHERE e.event_type = 'code_change'
|
|
24019
|
-
AND f.finding_key IS NOT NULL
|
|
24020
|
-
AND latest.status = 'resolved'
|
|
24299
|
+
FROM ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
24300
|
+
CROSS JOIN inspection_findings f ON f.finding_key = latest.finding_key
|
|
24301
|
+
CROSS JOIN audit_events e ON e.id = f.audit_event_id
|
|
24302
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
24303
|
+
WHERE latest.status = 'resolved'
|
|
24021
24304
|
AND latest.method = 'fixed-at-source'
|
|
24022
24305
|
AND latest.resolved_at IS NOT NULL
|
|
24023
|
-
|
|
24306
|
+
AND e.event_type = 'code_change'
|
|
24307
|
+
ORDER BY latest.resolved_at DESC
|
|
24024
24308
|
LIMIT :limit`
|
|
24025
24309
|
),
|
|
24026
24310
|
{ limit }
|
|
@@ -24957,6 +25241,7 @@ function openAndInitialize(file2) {
|
|
|
24957
25241
|
function openLocalDatabase(dir) {
|
|
24958
25242
|
ensureDataDirSync(dir);
|
|
24959
25243
|
const file2 = join2(dir, DB_FILENAME);
|
|
25244
|
+
reapStalePartials(file2);
|
|
24960
25245
|
const {
|
|
24961
25246
|
db,
|
|
24962
25247
|
events,
|
|
@@ -25368,11 +25653,79 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25368
25653
|
}
|
|
25369
25654
|
}
|
|
25370
25655
|
|
|
25371
|
-
// ../../packages/persistence/src/settings.ts
|
|
25656
|
+
// ../../packages/persistence/src/managed-settings.ts
|
|
25372
25657
|
import { readFileSync as readFileSync3 } from "fs";
|
|
25658
|
+
import { posix, win32 } from "path";
|
|
25659
|
+
function managedSettingsPaths(platform2 = process.platform) {
|
|
25660
|
+
if (platform2 === "darwin") {
|
|
25661
|
+
return [
|
|
25662
|
+
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
25663
|
+
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
25664
|
+
];
|
|
25665
|
+
}
|
|
25666
|
+
if (platform2 === "win32") {
|
|
25667
|
+
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
25668
|
+
}
|
|
25669
|
+
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
25670
|
+
}
|
|
25671
|
+
function readManagedSettings(paths = managedSettingsPaths()) {
|
|
25672
|
+
for (const path of paths) {
|
|
25673
|
+
let text;
|
|
25674
|
+
try {
|
|
25675
|
+
text = readFileSync3(path, "utf8");
|
|
25676
|
+
} catch {
|
|
25677
|
+
continue;
|
|
25678
|
+
}
|
|
25679
|
+
const record2 = parseJsonObject(text);
|
|
25680
|
+
if (!record2) continue;
|
|
25681
|
+
const parsed = ManagedSettings.safeParse(record2);
|
|
25682
|
+
if (parsed.success) return parsed.data;
|
|
25683
|
+
}
|
|
25684
|
+
return null;
|
|
25685
|
+
}
|
|
25686
|
+
function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ new Date()) {
|
|
25687
|
+
if (!managed) return settings;
|
|
25688
|
+
const { values } = managed;
|
|
25689
|
+
const merged = { ...settings };
|
|
25690
|
+
if (values.runMode !== void 0) merged.runMode = values.runMode;
|
|
25691
|
+
if (values.controlPlane !== void 0) {
|
|
25692
|
+
merged.controlPlane = {
|
|
25693
|
+
...values.controlPlane,
|
|
25694
|
+
// The administrator pinned WHICH deployment, not WHEN this machine
|
|
25695
|
+
// joined it. Keep the user's own attach time when the endpoint is
|
|
25696
|
+
// unchanged, so a managed machine does not appear to re-attach on every
|
|
25697
|
+
// read; stamp a fresh one when the administrator moved it.
|
|
25698
|
+
attachedAt: settings.controlPlane?.endpoint === values.controlPlane.endpoint ? settings.controlPlane.attachedAt : now().toISOString()
|
|
25699
|
+
};
|
|
25700
|
+
}
|
|
25701
|
+
if (values.historicalAccess !== void 0) merged.historicalAccess = values.historicalAccess;
|
|
25702
|
+
if (values.vaultKeyCustody !== void 0) merged.vaultKeyCustody = values.vaultKeyCustody;
|
|
25703
|
+
if (values.vaultInlineReveal !== void 0) merged.vaultInlineReveal = values.vaultInlineReveal;
|
|
25704
|
+
if (values.dataSharesInPlace !== void 0) merged.dataSharesInPlace = values.dataSharesInPlace;
|
|
25705
|
+
if (values.vaultConsent !== void 0) {
|
|
25706
|
+
merged.vaultConsent = values.vaultConsent ? (
|
|
25707
|
+
// Keep an existing valid grant so its acknowledgedAt survives; mint one
|
|
25708
|
+
// at the current version otherwise.
|
|
25709
|
+
settings.vaultConsent?.version === VAULT_CONSENT_VERSION ? settings.vaultConsent : { acknowledgedAt: now().toISOString(), version: VAULT_CONSENT_VERSION }
|
|
25710
|
+
) : void 0;
|
|
25711
|
+
}
|
|
25712
|
+
if (values.modelJudgeConsent !== void 0) {
|
|
25713
|
+
merged.modelJudgeConsent = values.modelJudgeConsent ? settings.modelJudgeConsent?.payloadVersion === MODEL_JUDGE_PAYLOAD_VERSION ? settings.modelJudgeConsent : {
|
|
25714
|
+
acknowledgedAt: now().toISOString(),
|
|
25715
|
+
payloadVersion: MODEL_JUDGE_PAYLOAD_VERSION
|
|
25716
|
+
} : void 0;
|
|
25717
|
+
}
|
|
25718
|
+
return merged;
|
|
25719
|
+
}
|
|
25720
|
+
|
|
25721
|
+
// ../../packages/persistence/src/settings.ts
|
|
25722
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25373
25723
|
import { join as join5 } from "path";
|
|
25374
25724
|
var SETTINGS_FILENAME = "settings.json";
|
|
25375
25725
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
25726
|
+
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25727
|
+
}
|
|
25728
|
+
function readUserSettings(base) {
|
|
25376
25729
|
const record2 = readJson(join5(settingsDir(base), SETTINGS_FILENAME));
|
|
25377
25730
|
if (!record2) return defaultWorkspaceSettings();
|
|
25378
25731
|
try {
|
|
@@ -25384,7 +25737,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
25384
25737
|
function readJson(file2) {
|
|
25385
25738
|
let text;
|
|
25386
25739
|
try {
|
|
25387
|
-
text =
|
|
25740
|
+
text = readFileSync4(file2, "utf8");
|
|
25388
25741
|
} catch {
|
|
25389
25742
|
return null;
|
|
25390
25743
|
}
|
|
@@ -25403,15 +25756,7 @@ import {
|
|
|
25403
25756
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25404
25757
|
import { execFileSync } from "child_process";
|
|
25405
25758
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25406
|
-
import {
|
|
25407
|
-
chmodSync as chmodSync2,
|
|
25408
|
-
mkdirSync as mkdirSync2,
|
|
25409
|
-
readFileSync as readFileSync4,
|
|
25410
|
-
renameSync as renameSync4,
|
|
25411
|
-
rmSync as rmSync4,
|
|
25412
|
-
statSync as statSync3,
|
|
25413
|
-
writeFileSync as writeFileSync3
|
|
25414
|
-
} from "fs";
|
|
25759
|
+
import { chmodSync as chmodSync2, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
25415
25760
|
import { join as join6 } from "path";
|
|
25416
25761
|
|
|
25417
25762
|
// ../../packages/persistence/src/vault/vault.ts
|
|
@@ -25507,7 +25852,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
25507
25852
|
}
|
|
25508
25853
|
|
|
25509
25854
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
25510
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
25855
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync7, realpathSync, statSync as statSync5 } from "fs";
|
|
25511
25856
|
import { homedir as homedir2 } from "os";
|
|
25512
25857
|
import { basename as basename3, join as join10 } from "path";
|
|
25513
25858
|
|
|
@@ -26215,6 +26560,10 @@ function luhnCheck(digits) {
|
|
|
26215
26560
|
// ../../packages/detections/src/engine.ts
|
|
26216
26561
|
var keywordMatcher = new KeywordMatcher2();
|
|
26217
26562
|
var regexMatcher = new RegexMatcher2();
|
|
26563
|
+
var MATCHERS = {
|
|
26564
|
+
keyword: (text, rule) => keywordMatcher.match(text, rule),
|
|
26565
|
+
regex: (text, rule) => regexMatcher.match(text, rule)
|
|
26566
|
+
};
|
|
26218
26567
|
var packs = /* @__PURE__ */ new Map();
|
|
26219
26568
|
var POST_VALIDATORS = {
|
|
26220
26569
|
entropy: (value, config2) => isHighEntropy(value, numberOption(config2, "threshold"), numberOption(config2, "minLength")),
|
|
@@ -26230,8 +26579,7 @@ function passesPostValidators(rule, value) {
|
|
|
26230
26579
|
for (const ref of validators) {
|
|
26231
26580
|
const name = typeof ref === "string" ? ref : ref.name;
|
|
26232
26581
|
const config2 = typeof ref === "string" ? void 0 : ref.config;
|
|
26233
|
-
|
|
26234
|
-
if (validate && !validate(value, config2)) return false;
|
|
26582
|
+
if (!POST_VALIDATORS[name](value, config2)) return false;
|
|
26235
26583
|
}
|
|
26236
26584
|
return true;
|
|
26237
26585
|
}
|
|
@@ -26292,14 +26640,7 @@ function scan(text, rules, context) {
|
|
|
26292
26640
|
const candidates = [];
|
|
26293
26641
|
for (const rule of ruleset) {
|
|
26294
26642
|
if (!ruleApplies(rule, extension)) continue;
|
|
26295
|
-
|
|
26296
|
-
if (rule.matcher.type === "keyword") {
|
|
26297
|
-
spans = keywordMatcher.match(text, rule);
|
|
26298
|
-
} else if (rule.matcher.type === "regex") {
|
|
26299
|
-
spans = regexMatcher.match(text, rule);
|
|
26300
|
-
} else {
|
|
26301
|
-
continue;
|
|
26302
|
-
}
|
|
26643
|
+
const spans = MATCHERS[rule.matcher.type](text, rule);
|
|
26303
26644
|
for (const span of spans) {
|
|
26304
26645
|
const rawMatch = text.slice(span.start, span.end);
|
|
26305
26646
|
if (!passesPostValidators(rule, rawMatch)) continue;
|
|
@@ -26541,24 +26882,32 @@ function probesFor(rule) {
|
|
|
26541
26882
|
return [...derived, ...EXPONENTIAL_PROBES, ...POLYNOMIAL_PROBES];
|
|
26542
26883
|
}
|
|
26543
26884
|
var wallClock = () => performance.now();
|
|
26544
|
-
function worstProbeMs(rule, now = wallClock) {
|
|
26885
|
+
function worstProbeMs(rule, now = wallClock, corroborate) {
|
|
26545
26886
|
let ms = 0;
|
|
26546
26887
|
let probe = "";
|
|
26888
|
+
let corroboratedMs;
|
|
26547
26889
|
for (const text of probesFor(rule)) {
|
|
26548
26890
|
const start = now();
|
|
26891
|
+
const corroborateStart = corroborate?.();
|
|
26549
26892
|
scan(text, [rule]);
|
|
26550
26893
|
const elapsed = now() - start;
|
|
26894
|
+
const corroborateEnd = corroborate?.();
|
|
26551
26895
|
if (elapsed > ms) {
|
|
26552
26896
|
ms = elapsed;
|
|
26553
26897
|
probe = text;
|
|
26898
|
+
corroboratedMs = corroborateStart === void 0 || corroborateEnd === void 0 ? void 0 : corroborateEnd - corroborateStart;
|
|
26554
26899
|
}
|
|
26555
26900
|
if (ms >= BUDGET_MS) break;
|
|
26556
26901
|
}
|
|
26557
|
-
return { ms, probe };
|
|
26902
|
+
return { ms, probe, corroboratedMs };
|
|
26558
26903
|
}
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26904
|
+
var CPU_CORROBORATION_SHARE = 0.2;
|
|
26905
|
+
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
26906
|
+
function checkRuleTiming(rule, corroborate) {
|
|
26907
|
+
const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
|
|
26908
|
+
const work = corroboratedMs ?? 0;
|
|
26909
|
+
const verdict = ms < BUDGET_MS ? "safe" : work >= CORROBORATION_FLOOR_MS ? "over-budget" : "uncorroborated";
|
|
26910
|
+
return { verdict, worstMs: ms, corroboratedMs: work, probe };
|
|
26562
26911
|
}
|
|
26563
26912
|
|
|
26564
26913
|
// ../../rules/code-flaws/auth-jwt-no-verify.json
|
|
@@ -28636,7 +28985,7 @@ function scanText(text, ruleVersions) {
|
|
|
28636
28985
|
}
|
|
28637
28986
|
|
|
28638
28987
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
28639
|
-
import { existsSync as existsSync6, readFileSync as
|
|
28988
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
|
|
28640
28989
|
import { basename as basename2, dirname as dirname2, isAbsolute, join as join9, sep as sep2 } from "path";
|
|
28641
28990
|
function resolveRepoIdentity(cwd) {
|
|
28642
28991
|
try {
|
|
@@ -28688,7 +29037,7 @@ function resolveGitContext(root) {
|
|
|
28688
29037
|
}
|
|
28689
29038
|
function safeRead(path) {
|
|
28690
29039
|
try {
|
|
28691
|
-
return
|
|
29040
|
+
return readFileSync6(path, "utf8");
|
|
28692
29041
|
} catch {
|
|
28693
29042
|
return void 0;
|
|
28694
29043
|
}
|
|
@@ -28989,7 +29338,12 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
28989
29338
|
build: (id) => ({ kind: "probe", id, rule }),
|
|
28990
29339
|
reply: (message) => {
|
|
28991
29340
|
if (message.kind !== "probed") return false;
|
|
28992
|
-
resolve({
|
|
29341
|
+
resolve({
|
|
29342
|
+
status: "ok",
|
|
29343
|
+
verdict: message.verdict,
|
|
29344
|
+
worstMs: message.worstMs,
|
|
29345
|
+
corroboratedMs: message.corroboratedMs
|
|
29346
|
+
});
|
|
28993
29347
|
return true;
|
|
28994
29348
|
}
|
|
28995
29349
|
},
|
|
@@ -29009,6 +29363,12 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
29009
29363
|
};
|
|
29010
29364
|
}
|
|
29011
29365
|
|
|
29366
|
+
// ../../packages/plugin-sdk/src/work-clock.ts
|
|
29367
|
+
function workClockMs() {
|
|
29368
|
+
const usage = typeof process.threadCpuUsage === "function" ? process.threadCpuUsage() : process.cpuUsage();
|
|
29369
|
+
return (usage.user + usage.system) / 1e3;
|
|
29370
|
+
}
|
|
29371
|
+
|
|
29012
29372
|
// ../../packages/plugin-sdk/src/rule-quarantine.ts
|
|
29013
29373
|
var PASS_BUDGET_MS = 2e3;
|
|
29014
29374
|
var UNQUARANTINE_HINT = "clear it with `aka detections unquarantine`";
|
|
@@ -29037,6 +29397,14 @@ function warnUnmeasured(rule) {
|
|
|
29037
29397
|
false
|
|
29038
29398
|
);
|
|
29039
29399
|
}
|
|
29400
|
+
function warnUncorroborated(rule, worstMs, corroboratedMs) {
|
|
29401
|
+
warn(
|
|
29402
|
+
rule,
|
|
29403
|
+
"deferred",
|
|
29404
|
+
`its regex matcher ran past the ReDoS timing budget (${worstMs.toFixed(1)}ms) but spent only ${corroboratedMs.toFixed(1)}ms of CPU doing it, which is a busy machine rather than a slow pattern; excluded from this run and measured again next time, with nothing recorded against it.`,
|
|
29405
|
+
false
|
|
29406
|
+
);
|
|
29407
|
+
}
|
|
29040
29408
|
function warnUnmeasurable(reason, count) {
|
|
29041
29409
|
process.stderr.write(
|
|
29042
29410
|
`[aka] ${String(count)} pulled/custom-pack rule(s) could not be time-checked: ${reason}. That is a problem with this install, not with the rules \u2014 until it is fixed they are excluded from every scan on this machine. Nothing was quarantined, so reinstalling AKA brings them straight back.
|
|
@@ -29083,24 +29451,31 @@ async function filterUnsafeRules(rules, gateway, opts) {
|
|
|
29083
29451
|
warnUnmeasured(rule);
|
|
29084
29452
|
continue;
|
|
29085
29453
|
}
|
|
29086
|
-
let
|
|
29454
|
+
let verdict;
|
|
29087
29455
|
let worstMs;
|
|
29456
|
+
let corroboratedMs = 0;
|
|
29088
29457
|
if (prober) {
|
|
29089
29458
|
const outcome = await prober.probe(rule);
|
|
29090
29459
|
if (outcome.status === "unavailable") {
|
|
29091
29460
|
unmeasurable.set(outcome.reason, (unmeasurable.get(outcome.reason) ?? 0) + 1);
|
|
29092
29461
|
continue;
|
|
29093
29462
|
}
|
|
29094
|
-
|
|
29463
|
+
verdict = outcome.status === "ok" ? outcome.verdict : "over-budget";
|
|
29095
29464
|
worstMs = outcome.status === "ok" ? outcome.worstMs : outcome.elapsedMs;
|
|
29465
|
+
if (outcome.status === "ok") corroboratedMs = outcome.corroboratedMs;
|
|
29096
29466
|
} else {
|
|
29097
29467
|
try {
|
|
29098
|
-
({
|
|
29468
|
+
({ verdict, worstMs, corroboratedMs } = checkRuleTiming(rule, workClockMs));
|
|
29099
29469
|
} catch {
|
|
29100
|
-
|
|
29470
|
+
verdict = "over-budget";
|
|
29101
29471
|
worstMs = Number.POSITIVE_INFINITY;
|
|
29102
29472
|
}
|
|
29103
29473
|
}
|
|
29474
|
+
if (verdict === "uncorroborated") {
|
|
29475
|
+
warnUncorroborated(rule, worstMs, corroboratedMs);
|
|
29476
|
+
continue;
|
|
29477
|
+
}
|
|
29478
|
+
const isSafe = verdict === "safe";
|
|
29104
29479
|
let persisted = false;
|
|
29105
29480
|
try {
|
|
29106
29481
|
await gateway.setRuleProbeVerdict(key, isSafe ? "safe" : "quarantined", worstMs);
|
|
@@ -29200,6 +29575,11 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
29200
29575
|
};
|
|
29201
29576
|
}
|
|
29202
29577
|
|
|
29578
|
+
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
29579
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
29580
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
29581
|
+
import { join as join11 } from "path";
|
|
29582
|
+
|
|
29203
29583
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
29204
29584
|
import { arch, hostname as hostname4, platform, release } from "os";
|
|
29205
29585
|
function resolveInventoryContext(input) {
|
|
@@ -29230,17 +29610,16 @@ function resolveInventoryContext(input) {
|
|
|
29230
29610
|
}
|
|
29231
29611
|
|
|
29232
29612
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
29233
|
-
import { mkdirSync as
|
|
29234
|
-
import { join as
|
|
29613
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
|
|
29614
|
+
import { join as join12 } from "path";
|
|
29235
29615
|
|
|
29236
29616
|
// ../../packages/plugin-sdk/src/paths.ts
|
|
29237
29617
|
import { readdirSync as readdirSync3, realpathSync as realpathSync2 } from "fs";
|
|
29238
29618
|
import { basename as basename4, dirname as dirname3, sep as sep3 } from "path";
|
|
29239
29619
|
|
|
29240
29620
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
29241
|
-
|
|
29242
|
-
import {
|
|
29243
|
-
import { basename as basename5, join as join12 } from "path";
|
|
29621
|
+
import { existsSync as existsSync8, readdirSync as readdirSync4 } from "fs";
|
|
29622
|
+
import { basename as basename5, join as join13 } from "path";
|
|
29244
29623
|
|
|
29245
29624
|
// ../../packages/plugin-sdk/src/provider-env-antigravity.ts
|
|
29246
29625
|
var optionalBaseUrl2 = external_exports.preprocess((v) => {
|
|
@@ -29350,6 +29729,7 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
29350
29729
|
let initialized = false;
|
|
29351
29730
|
const ruleActionIndex = /* @__PURE__ */ new Map();
|
|
29352
29731
|
const categoryActionIndex = /* @__PURE__ */ new Map();
|
|
29732
|
+
let reversibleRuleIndex = /* @__PURE__ */ new Set();
|
|
29353
29733
|
async function ensureInitialized() {
|
|
29354
29734
|
if (initialized) return;
|
|
29355
29735
|
const bundle = await gateway.getPolicyBundle();
|
|
@@ -29362,6 +29742,7 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
29362
29742
|
categoryActionIndex.set(p.target.category, p.action);
|
|
29363
29743
|
}
|
|
29364
29744
|
}
|
|
29745
|
+
reversibleRuleIndex = new Set(bundle.reversibleRuleIds ?? []);
|
|
29365
29746
|
const bundledProbeKeys = new Set(
|
|
29366
29747
|
getLoadedRules().map(ruleProbeKey).filter((key) => key !== void 0)
|
|
29367
29748
|
);
|
|
@@ -29440,11 +29821,13 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
29440
29821
|
if (worst === "block") return { action: "block", text: null, findings };
|
|
29441
29822
|
if (worst === "redact") {
|
|
29442
29823
|
const redactFindings = findings.filter((f) => actionFor(f) === "redact");
|
|
29824
|
+
const reversibleFindings = redactFindings.filter((f) => reversibleRuleIndex.has(f.ruleId));
|
|
29443
29825
|
return {
|
|
29444
29826
|
action: "redact",
|
|
29445
29827
|
text: redact(text, redactFindings),
|
|
29446
29828
|
findings,
|
|
29447
|
-
enforcedFindings: redactFindings
|
|
29829
|
+
enforcedFindings: redactFindings,
|
|
29830
|
+
reversibleFindings
|
|
29448
29831
|
};
|
|
29449
29832
|
}
|
|
29450
29833
|
return { action: worst, text, findings };
|
|
@@ -29658,17 +30041,22 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
29658
30041
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
29659
30042
|
|
|
29660
30043
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
29661
|
-
import { mkdirSync as
|
|
29662
|
-
import { join as
|
|
30044
|
+
import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
30045
|
+
import { join as join14 } from "path";
|
|
29663
30046
|
|
|
29664
30047
|
// ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
|
|
29665
30048
|
import { writeFileSync as writeFileSync7 } from "fs";
|
|
29666
|
-
import { join as
|
|
30049
|
+
import { join as join15 } from "path";
|
|
30050
|
+
|
|
30051
|
+
// ../../packages/setup-wizard/src/triage/merge.ts
|
|
30052
|
+
var RANK = Object.fromEntries(
|
|
30053
|
+
KNOWN_BUILTIN_IDS.map((id, i) => [id, i])
|
|
30054
|
+
);
|
|
29667
30055
|
|
|
29668
30056
|
// ../../packages/setup-wizard/src/triage/plan-file.ts
|
|
29669
|
-
import { mkdtempSync, readFileSync as
|
|
30057
|
+
import { mkdtempSync, readFileSync as readFileSync10, rmdirSync, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "fs";
|
|
29670
30058
|
import { tmpdir } from "os";
|
|
29671
|
-
import { basename as basename6, dirname as dirname4, join as
|
|
30059
|
+
import { basename as basename6, dirname as dirname4, join as join16 } from "path";
|
|
29672
30060
|
var SuppressionEntrySchema = external_exports.object({
|
|
29673
30061
|
ruleId: external_exports.string(),
|
|
29674
30062
|
category: DetectionCategory,
|
|
@@ -29723,6 +30111,8 @@ var StandaloneDataGateway = class {
|
|
|
29723
30111
|
db;
|
|
29724
30112
|
// Kept for the fingerprint key lookup (exception.key lives beside the store).
|
|
29725
30113
|
dataDir;
|
|
30114
|
+
// One notice per gateway — see warnRulesetDiscarded.
|
|
30115
|
+
warnedRulesetDiscarded = false;
|
|
29726
30116
|
constructor(dataDir2, detections = [], meta3) {
|
|
29727
30117
|
this.db = openLocalDatabase(dataDir2);
|
|
29728
30118
|
this.dataDir = dataDir2;
|
|
@@ -29842,28 +30232,69 @@ var StandaloneDataGateway = class {
|
|
|
29842
30232
|
// - ANY invalid rule among enabled packs (all-invalid, partial corruption,
|
|
29843
30233
|
// or a single malformed entry) → undefined → bundled fallback. Serving a
|
|
29844
30234
|
// reduced "complete" set would silently drop exactly the corrupted rules
|
|
29845
|
-
// with no fallback
|
|
29846
|
-
// never loses coverage
|
|
29847
|
-
//
|
|
29848
|
-
//
|
|
30235
|
+
// with no fallback. The bundled packs are a superset of AKA's OWN packs,
|
|
30236
|
+
// so falling back never loses coverage there — but they contain no
|
|
30237
|
+
// pulled or custom pack, so for those this trades a partial ruleset for
|
|
30238
|
+
// none of them plus the loss of every pack's per-detection enforcement
|
|
30239
|
+
// action. That is deliberate (a store this machine cannot fully validate
|
|
30240
|
+
// is not authoritative), and it is why the cost of REJECTING a rule
|
|
30241
|
+
// matters: `Rule` is strict, so one unrecognized key in one custom rule
|
|
30242
|
+
// reaches this branch, not just a genuinely malformed or foreign store.
|
|
30243
|
+
// `installed-packs.test.ts` pins that per-rule counting;
|
|
29849
30244
|
// - enabled packs that produce ZERO rules with no invalids (e.g. every
|
|
29850
30245
|
// enabled pack's rules_json is `[]`) → undefined → bundled fallback: an
|
|
29851
30246
|
// enabled pack contributing nothing is untrustworthy, not a real
|
|
29852
30247
|
// "detect nothing" (that is expressed by disabling packs, handled above);
|
|
29853
30248
|
// - otherwise → the enabled packs' validated rules, marked complete.
|
|
30249
|
+
/**
|
|
30250
|
+
* The discard above is the one ruleset decision this gateway reaches on its
|
|
30251
|
+
* own, and it is the most expensive one here: ONE rejected entry costs the
|
|
30252
|
+
* user every custom rule and every per-detection enforcement action, replaced
|
|
30253
|
+
* by bundled packs that contain neither. Nothing else reports it — a hook is a
|
|
30254
|
+
* short-lived process whose stderr is the only channel it has — so name what
|
|
30255
|
+
* was rejected and where the rest of the list lives.
|
|
30256
|
+
*
|
|
30257
|
+
* Unlike a quarantine verdict this caches nothing: the rejection is re-derived
|
|
30258
|
+
* from the store on every run, so the recovery is to fix or reinstall the pack,
|
|
30259
|
+
* and no line here may offer a command that clears a stored verdict.
|
|
30260
|
+
*
|
|
30261
|
+
* Written at most once per gateway — a second getPolicyBundle() in the same
|
|
30262
|
+
* process would re-report the same finding.
|
|
30263
|
+
*/
|
|
30264
|
+
warnRulesetDiscarded(snapshot) {
|
|
30265
|
+
if (this.warnedRulesetDiscarded) return;
|
|
30266
|
+
this.warnedRulesetDiscarded = true;
|
|
30267
|
+
const listed = snapshot.rejectedRules.map((r) => `${r.pack}${r.ruleId === null ? "" : ` "${r.ruleId}"`} (${r.reason})`).join(", ");
|
|
30268
|
+
const undisclosed = snapshot.invalidRules - snapshot.rejectedRules.length;
|
|
30269
|
+
const more = undisclosed > 0 ? `, and ${String(undisclosed)} more` : "";
|
|
30270
|
+
process.stderr.write(
|
|
30271
|
+
`[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\`
|
|
30272
|
+
`
|
|
30273
|
+
);
|
|
30274
|
+
}
|
|
29854
30275
|
installedScanRules() {
|
|
29855
30276
|
try {
|
|
29856
30277
|
const snapshot = this.db.installedPacks.installedRuleset();
|
|
29857
30278
|
if (snapshot.installedPacks === 0) return void 0;
|
|
29858
30279
|
if (snapshot.enabledPacks === 0) {
|
|
29859
|
-
return {
|
|
30280
|
+
return {
|
|
30281
|
+
rules: [],
|
|
30282
|
+
ruleActions: /* @__PURE__ */ new Map(),
|
|
30283
|
+
ruleVersions: /* @__PURE__ */ new Map(),
|
|
30284
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
30285
|
+
complete: true
|
|
30286
|
+
};
|
|
30287
|
+
}
|
|
30288
|
+
if (snapshot.invalidRules > 0) {
|
|
30289
|
+
this.warnRulesetDiscarded(snapshot);
|
|
30290
|
+
return void 0;
|
|
29860
30291
|
}
|
|
29861
|
-
if (snapshot.invalidRules > 0) return void 0;
|
|
29862
30292
|
if (snapshot.rules.length === 0) return void 0;
|
|
29863
30293
|
return {
|
|
29864
30294
|
rules: snapshot.rules,
|
|
29865
30295
|
ruleActions: snapshot.ruleActions,
|
|
29866
30296
|
ruleVersions: snapshot.ruleVersions,
|
|
30297
|
+
reversibleRules: snapshot.reversibleRules,
|
|
29867
30298
|
complete: true
|
|
29868
30299
|
};
|
|
29869
30300
|
} catch {
|
|
@@ -29891,6 +30322,11 @@ var StandaloneDataGateway = class {
|
|
|
29891
30322
|
return {
|
|
29892
30323
|
version: "local",
|
|
29893
30324
|
policies: [...policies, ...rulePolicies],
|
|
30325
|
+
// The reversibility half of each pack's assignment. Emitted only under the
|
|
30326
|
+
// authoritative installed snapshot, exactly like rulePolicies above: the
|
|
30327
|
+
// bundled-packs fallback carries no per-pack assignment, so it carries no
|
|
30328
|
+
// reversibility either and every redaction there stays one-way.
|
|
30329
|
+
reversibleRuleIds: installed ? [...installed.reversibleRules] : [],
|
|
29894
30330
|
rules: installed ? installed.rules : [],
|
|
29895
30331
|
...installed ? { rulesComplete: true } : {},
|
|
29896
30332
|
...installed ? { ruleVersions: Object.fromEntries(installed.ruleVersions) } : {},
|
|
@@ -29909,29 +30345,32 @@ var StandaloneDataGateway = class {
|
|
|
29909
30345
|
return this.db.exceptions.recordBlocked(entry);
|
|
29910
30346
|
}
|
|
29911
30347
|
// Retention sweep over TERMINAL exception rows (revoked / expired / budget
|
|
29912
|
-
// exhausted) —
|
|
29913
|
-
//
|
|
30348
|
+
// exhausted) — local-store maintenance, invoked from SessionStart through the
|
|
30349
|
+
// LocalStoreMaintenance capability rather than the DataGateway port. Active
|
|
30350
|
+
// grants are never touched.
|
|
29914
30351
|
sweepTerminalExceptions(retentionMs) {
|
|
29915
30352
|
return this.db.exceptions.sweepTerminal(retentionMs);
|
|
29916
30353
|
}
|
|
29917
|
-
// The warn-era enforcement cap
|
|
29918
|
-
//
|
|
29919
|
-
// of block/redact rows capped to
|
|
29920
|
-
// already-capped one).
|
|
30354
|
+
// The warn-era enforcement cap — local-store maintenance, invoked from
|
|
30355
|
+
// SessionStart through the LocalStoreMaintenance capability rather than
|
|
30356
|
+
// the DataGateway port. Returns the number of block/redact rows capped to
|
|
30357
|
+
// warn (0 for a redact-policy store or an already-capped one).
|
|
29921
30358
|
capWarnEraEnforcement(policyMode) {
|
|
29922
30359
|
const { capped } = capWarnEraEnforcementOnce(this.db, policyMode, this.dataDir);
|
|
29923
30360
|
return { capped };
|
|
29924
30361
|
}
|
|
29925
30362
|
// One project-file scan → the local project_file tree (one transaction inside
|
|
29926
|
-
// the LocalDatabase, fail-open there). Like the sweep above, this is
|
|
29927
|
-
//
|
|
30363
|
+
// the LocalDatabase, fail-open there). Like the sweep above, this is reached
|
|
30364
|
+
// through the LocalStoreMaintenance capability rather than the DataGateway
|
|
30365
|
+
// port: the file tree is a local-store read model.
|
|
29928
30366
|
recordProjectFiles(projectId, scan2) {
|
|
29929
30367
|
this.db.recordProjectFiles(projectId, scan2);
|
|
29930
30368
|
return Promise.resolve();
|
|
29931
30369
|
}
|
|
29932
30370
|
// Fold ghost source_project rows minted by the pre-worktree-fix resolver
|
|
29933
|
-
// (checkout-path identities) into the repo's canonical row.
|
|
29934
|
-
//
|
|
30371
|
+
// (checkout-path identities) into the repo's canonical row. Local-store
|
|
30372
|
+
// maintenance, invoked from SessionStart through the LocalStoreMaintenance
|
|
30373
|
+
// capability. Fail-open in the store.
|
|
29935
30374
|
reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot) {
|
|
29936
30375
|
this.db.reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot);
|
|
29937
30376
|
return Promise.resolve();
|
|
@@ -29942,10 +30381,10 @@ var StandaloneDataGateway = class {
|
|
|
29942
30381
|
* executing the plugin generation they started with (Claude Code caches
|
|
29943
30382
|
* plugin versions), and the write gate makes their installed-pack writes
|
|
29944
30383
|
* silent no-ops — this is the one-line nudge telling the user WHY, and that
|
|
29945
|
-
* a restart picks the newer plugin up.
|
|
29946
|
-
* SessionStart
|
|
29947
|
-
* null (no notice), and
|
|
29948
|
-
* never fire it.
|
|
30384
|
+
* a restart picks the newer plugin up. Local-store maintenance, invoked
|
|
30385
|
+
* from SessionStart through the LocalStoreMaintenance capability rather
|
|
30386
|
+
* than the DataGateway port. Fail-open: any error → null (no notice), and
|
|
30387
|
+
* unparseable versions compare equal so garbage can never fire it.
|
|
29949
30388
|
*/
|
|
29950
30389
|
staleBinaryNotice(currentVersion) {
|
|
29951
30390
|
try {
|
|
@@ -30023,7 +30462,8 @@ var StandaloneDataGateway = class {
|
|
|
30023
30462
|
|
|
30024
30463
|
// ../../packages/plugin-runtime/src/resolve.ts
|
|
30025
30464
|
var standaloneGatewayFactory = (config2, meta3) => new StandaloneDataGateway(config2.dataDir, bundledDetections(), meta3);
|
|
30026
|
-
|
|
30465
|
+
var defaultGatewayFactory = standaloneGatewayFactory;
|
|
30466
|
+
function resolveDataGateway(config2, meta3, gatewayFactory = defaultGatewayFactory) {
|
|
30027
30467
|
return gatewayFactory(config2, meta3);
|
|
30028
30468
|
}
|
|
30029
30469
|
|
|
@@ -30032,11 +30472,11 @@ import { randomUUID as randomUUID16 } from "crypto";
|
|
|
30032
30472
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
30033
30473
|
|
|
30034
30474
|
// src/history/transcripts.ts
|
|
30035
|
-
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync5, readFileSync as
|
|
30475
|
+
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync5, readFileSync as readFileSync11, readSync, statSync as statSync7 } from "fs";
|
|
30036
30476
|
import { homedir as homedir3 } from "os";
|
|
30037
|
-
import { join as
|
|
30477
|
+
import { join as join17 } from "path";
|
|
30038
30478
|
function transcriptsDir(home) {
|
|
30039
|
-
return
|
|
30479
|
+
return join17(home ?? homedir3(), ".gemini", "antigravity", "brain");
|
|
30040
30480
|
}
|
|
30041
30481
|
function isRecord(value) {
|
|
30042
30482
|
return typeof value === "object" && value !== null;
|
|
@@ -30276,7 +30716,7 @@ function* walkJsonlFiles(dir, depth = 0) {
|
|
|
30276
30716
|
}
|
|
30277
30717
|
const hasFull = entries.some((e) => e.isFile() && e.name === FULL_TRANSCRIPT);
|
|
30278
30718
|
for (const entry of entries) {
|
|
30279
|
-
const full =
|
|
30719
|
+
const full = join17(dir, entry.name);
|
|
30280
30720
|
if (entry.isDirectory()) {
|
|
30281
30721
|
yield* walkJsonlFiles(full, depth + 1);
|
|
30282
30722
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
@@ -30289,7 +30729,7 @@ function* iterateFileContents(dir) {
|
|
|
30289
30729
|
for (const filePath of walkJsonlFiles(dir)) {
|
|
30290
30730
|
try {
|
|
30291
30731
|
statSync7(filePath);
|
|
30292
|
-
yield { content:
|
|
30732
|
+
yield { content: readFileSync11(filePath, "utf8"), filePath };
|
|
30293
30733
|
} catch {
|
|
30294
30734
|
}
|
|
30295
30735
|
}
|
|
@@ -30368,7 +30808,7 @@ async function scanHistory(config2, opts = {}, onHit) {
|
|
|
30368
30808
|
const result = await runtime.capture(
|
|
30369
30809
|
{
|
|
30370
30810
|
kind: message.kind,
|
|
30371
|
-
sourceTool:
|
|
30811
|
+
sourceTool: SOURCE_TOOL.Antigravity,
|
|
30372
30812
|
text: message.text,
|
|
30373
30813
|
occurredAt: message.occurredAt
|
|
30374
30814
|
},
|
|
@@ -30401,13 +30841,13 @@ import { createHash as createHash5 } from "crypto";
|
|
|
30401
30841
|
import {
|
|
30402
30842
|
closeSync as closeSync3,
|
|
30403
30843
|
fstatSync,
|
|
30404
|
-
mkdirSync as
|
|
30844
|
+
mkdirSync as mkdirSync4,
|
|
30405
30845
|
openSync as openSync3,
|
|
30406
|
-
readFileSync as
|
|
30846
|
+
readFileSync as readFileSync12,
|
|
30407
30847
|
readSync as readSync2,
|
|
30408
30848
|
writeFileSync as writeFileSync9
|
|
30409
30849
|
} from "fs";
|
|
30410
|
-
import { join as
|
|
30850
|
+
import { join as join18 } from "path";
|
|
30411
30851
|
|
|
30412
30852
|
// src/history/usage.ts
|
|
30413
30853
|
var NO_PROJECT_CWD = "/nonexistent/aka-reconciler/no-project";
|
|
@@ -30421,7 +30861,7 @@ async function reconcileSession(gateway, sessionId, records, opts = {}) {
|
|
|
30421
30861
|
if (anchor === void 0) return { llmCalls: 0, skipped: 0, lastPromptId };
|
|
30422
30862
|
const ctx = resolveInventoryContext({
|
|
30423
30863
|
cwd: anchor.cwd ?? NO_PROJECT_CWD,
|
|
30424
|
-
tool:
|
|
30864
|
+
tool: SOURCE_TOOL.Antigravity,
|
|
30425
30865
|
harnessVersion: anchor.version,
|
|
30426
30866
|
// Descriptive only (never hashed, never forks the harness dimension) —
|
|
30427
30867
|
// distinguishes e.g. 'codex_desktop' (Antigravity inside the ChatGPT desktop
|
|
@@ -30556,7 +30996,7 @@ function buildSessionRoot(sessionId, ctx, resolved, anchor, provider) {
|
|
|
30556
30996
|
if (anchor.version !== void 0) attributes.harness_version = anchor.version;
|
|
30557
30997
|
if (anchor.originator !== void 0) attributes.harness_interface = anchor.originator;
|
|
30558
30998
|
attributes.provider = provider;
|
|
30559
|
-
attributes.harness = harnessFromTool(
|
|
30999
|
+
attributes.harness = harnessFromTool(SOURCE_TOOL.Antigravity);
|
|
30560
31000
|
if (anchor.cwd !== void 0) attributes.cwd = anchor.cwd;
|
|
30561
31001
|
if (anchor.version !== void 0) attributes.version = anchor.version;
|
|
30562
31002
|
const hostName = ctx.host?.attributes.host_name;
|