@akasecurity/ai-tc-codex 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/package.json +5 -4
- package/scripts/apply-suppressions.js +1432 -974
- package/scripts/backfill.js +1429 -989
- package/scripts/dashboard.js +131 -10
- package/scripts/filescan.js +1458 -1009
- package/scripts/firstrun.js +1310 -904
- package/scripts/intro.js +1002 -896
- package/scripts/onboard.js +1333 -893
- package/scripts/post-tool-use.js +1358 -923
- package/scripts/pre-tool-use.js +1413 -978
- package/scripts/query.js +1315 -904
- package/scripts/reconcile.js +1320 -923
- package/scripts/remediate.js +1429 -989
- package/scripts/scan-worker.js +996 -916
- package/scripts/session-start.js +1432 -1000
- package/scripts/start-light.js +1009 -904
- package/scripts/stop.js +1069 -898
- package/scripts/user-prompt-submit.js +1416 -981
- package/skills/setup/SKILL.md +0 -17
package/scripts/session-start.js
CHANGED
|
@@ -492,7 +492,7 @@ var require_ignore = __commonJS({
|
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
// src/hooks/session-start.ts
|
|
495
|
-
import { readFileSync as
|
|
495
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
496
496
|
|
|
497
497
|
// ../../packages/plugin-sdk/src/config.ts
|
|
498
498
|
import { existsSync as existsSync5 } from "fs";
|
|
@@ -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
|
|
@@ -16947,12 +16321,170 @@ var ConfigScanRecord = external_exports.object({
|
|
|
16947
16321
|
definitions: external_exports.array(InspectionDefinitionInput).optional(),
|
|
16948
16322
|
findings: external_exports.array(ConfigPostureFindingInput).optional()
|
|
16949
16323
|
});
|
|
16950
|
-
|
|
16951
|
-
// ../../packages/schema/src/zod/registry.ts
|
|
16952
|
-
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16953
|
-
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16954
|
-
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16955
|
-
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16324
|
+
|
|
16325
|
+
// ../../packages/schema/src/zod/registry.ts
|
|
16326
|
+
var Namespace = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16327
|
+
var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
16328
|
+
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
16329
|
+
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
16330
|
+
|
|
16331
|
+
// ../../packages/schema/src/zod/rule.ts
|
|
16332
|
+
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
16333
|
+
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
16334
|
+
var KeywordMatcher = external_exports.strictObject({
|
|
16335
|
+
type: external_exports.literal("keyword"),
|
|
16336
|
+
// An empty keyword matches at every position, yielding one zero-length span
|
|
16337
|
+
// per character. Rejected here because a keyword that matches everything is
|
|
16338
|
+
// never intentional.
|
|
16339
|
+
keywords: external_exports.array(external_exports.string().min(1)).min(1),
|
|
16340
|
+
caseSensitive: external_exports.boolean().default(false)
|
|
16341
|
+
});
|
|
16342
|
+
function isValidRegex(pattern, flags) {
|
|
16343
|
+
try {
|
|
16344
|
+
new RegExp(pattern, flags);
|
|
16345
|
+
return true;
|
|
16346
|
+
} catch {
|
|
16347
|
+
return false;
|
|
16348
|
+
}
|
|
16349
|
+
}
|
|
16350
|
+
function probeFlags(flags) {
|
|
16351
|
+
return flags.replace(/[gy]/g, "");
|
|
16352
|
+
}
|
|
16353
|
+
function matchesEmptyString(pattern, flags) {
|
|
16354
|
+
try {
|
|
16355
|
+
const re = new RegExp(pattern, probeFlags(flags));
|
|
16356
|
+
return re.exec("")?.[0].length === 0;
|
|
16357
|
+
} catch {
|
|
16358
|
+
return false;
|
|
16359
|
+
}
|
|
16360
|
+
}
|
|
16361
|
+
function spansWholeMatch(captureGroup) {
|
|
16362
|
+
return captureGroup === void 0 || captureGroup === 0;
|
|
16363
|
+
}
|
|
16364
|
+
function captureGroupCount(pattern, flags) {
|
|
16365
|
+
try {
|
|
16366
|
+
const probe = new RegExp(`${pattern}|`, probeFlags(flags));
|
|
16367
|
+
const result = probe.exec("");
|
|
16368
|
+
return result ? result.length - 1 : void 0;
|
|
16369
|
+
} catch {
|
|
16370
|
+
return void 0;
|
|
16371
|
+
}
|
|
16372
|
+
}
|
|
16373
|
+
var MAX_PATTERN_LENGTH = 2e3;
|
|
16374
|
+
var RegexMatcher = external_exports.strictObject({
|
|
16375
|
+
type: external_exports.literal("regex"),
|
|
16376
|
+
pattern: external_exports.string().min(1).max(MAX_PATTERN_LENGTH),
|
|
16377
|
+
flags: external_exports.string().default("gi"),
|
|
16378
|
+
captureGroup: external_exports.number().int().nonnegative().optional()
|
|
16379
|
+
}).refine((v) => isValidRegex(v.pattern, v.flags), {
|
|
16380
|
+
message: "pattern/flags do not form a valid JavaScript regular expression",
|
|
16381
|
+
path: ["pattern"]
|
|
16382
|
+
}).refine((v) => !spansWholeMatch(v.captureGroup) || !matchesEmptyString(v.pattern, v.flags), {
|
|
16383
|
+
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',
|
|
16384
|
+
path: ["pattern"]
|
|
16385
|
+
}).superRefine((v, ctx) => {
|
|
16386
|
+
if (v.captureGroup === void 0) return;
|
|
16387
|
+
const groups = captureGroupCount(v.pattern, v.flags);
|
|
16388
|
+
if (groups === void 0 || v.captureGroup <= groups) return;
|
|
16389
|
+
ctx.addIssue({
|
|
16390
|
+
code: "custom",
|
|
16391
|
+
path: ["captureGroup"],
|
|
16392
|
+
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.`
|
|
16393
|
+
});
|
|
16394
|
+
});
|
|
16395
|
+
var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, RegexMatcher]).meta({ id: "Matcher" });
|
|
16396
|
+
var MATCHER_TYPES = MatcherType.options;
|
|
16397
|
+
var AppliesTo = external_exports.strictObject({
|
|
16398
|
+
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
16399
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
16400
|
+
}).meta({ id: "AppliesTo" });
|
|
16401
|
+
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
16402
|
+
var PostValidatorRef = external_exports.union(
|
|
16403
|
+
[
|
|
16404
|
+
PostValidatorName,
|
|
16405
|
+
external_exports.strictObject({
|
|
16406
|
+
name: PostValidatorName,
|
|
16407
|
+
config: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
16408
|
+
})
|
|
16409
|
+
],
|
|
16410
|
+
{
|
|
16411
|
+
// A union reports one collapsed issue for every way its arms can fail, so
|
|
16412
|
+
// this has to describe the whole shape rather than just the name — it is
|
|
16413
|
+
// what an author sees for a misspelled name AND for a stray key in the
|
|
16414
|
+
// object form. The names come from the enum so the message cannot go
|
|
16415
|
+
// stale. Without it Zod says only "Invalid input", which is precisely the
|
|
16416
|
+
// no-feedback outcome this schema exists to remove.
|
|
16417
|
+
error: () => `not a valid post-validator: use a bare name (${PostValidatorName.options.map((name) => JSON.stringify(name)).join(
|
|
16418
|
+
" or "
|
|
16419
|
+
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
16420
|
+
}
|
|
16421
|
+
).meta({ id: "PostValidatorRef" });
|
|
16422
|
+
var RequiresNearby = external_exports.strictObject({
|
|
16423
|
+
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
16424
|
+
// an empty/blank criterion would either never fire or (for labels) match
|
|
16425
|
+
// everything.
|
|
16426
|
+
categories: external_exports.array(DetectionCategory).min(1).optional(),
|
|
16427
|
+
ruleIds: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16428
|
+
labels: external_exports.array(external_exports.string().min(1)).min(1).optional(),
|
|
16429
|
+
windowChars: external_exports.number().int().positive().default(160),
|
|
16430
|
+
// Optional confidence bump applied when a gated match is corroborated. Capped
|
|
16431
|
+
// small: it nudges confidence, it does not assert certainty.
|
|
16432
|
+
confidenceBoost: external_exports.number().min(0).max(0.3).optional()
|
|
16433
|
+
}).refine(
|
|
16434
|
+
(v) => (v.categories?.length ?? 0) + (v.ruleIds?.length ?? 0) + (v.labels?.length ?? 0) > 0,
|
|
16435
|
+
{ message: "requiresNearby needs at least one of categories, ruleIds, or labels" }
|
|
16436
|
+
).meta({ id: "RequiresNearby" });
|
|
16437
|
+
var RuleFixture = external_exports.strictObject({
|
|
16438
|
+
label: external_exports.string(),
|
|
16439
|
+
text: external_exports.string().max(5e4),
|
|
16440
|
+
shouldMatch: external_exports.boolean(),
|
|
16441
|
+
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
16442
|
+
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
16443
|
+
filePath: external_exports.string().optional(),
|
|
16444
|
+
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
16445
|
+
}).meta({ id: "RuleFixture" });
|
|
16446
|
+
var Rule = external_exports.strictObject({
|
|
16447
|
+
// A pinned literal over a STRICT object, and the two together decide how this
|
|
16448
|
+
// format may grow. A rule carrying a key not listed below is refused with
|
|
16449
|
+
// `unrecognized_keys`; a rule declaring `specVersion: 2` is refused with
|
|
16450
|
+
// `invalid_value`. So the only additive path is adding an OPTIONAL field here
|
|
16451
|
+
// — that keeps every rule authored before it valid — and a rule author has no
|
|
16452
|
+
// way to introduce a field of their own or to opt into a later version.
|
|
16453
|
+
// Widening the format means changing this literal and every consumer of it.
|
|
16454
|
+
specVersion: external_exports.literal(1),
|
|
16455
|
+
// `packId/ruleName` (e.g. `secrets/aws-access-key`). NOTE the first segment is
|
|
16456
|
+
// the PACK id, NOT a namespace — this is a DIFFERENT slug space from a
|
|
16457
|
+
// detection id (`namespace/packId`, decoded by splitDetectionId). A Rule.id
|
|
16458
|
+
// therefore carries no namespace and is not globally unique across publishers;
|
|
16459
|
+
// never feed one to splitDetectionId. `category` below (per-rule) is the
|
|
16460
|
+
// taxonomy axis; the pack's enforcement policy is installed_packs.policy_id.
|
|
16461
|
+
id: external_exports.string().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/),
|
|
16462
|
+
name: external_exports.string(),
|
|
16463
|
+
category: DetectionCategory,
|
|
16464
|
+
severity: Severity,
|
|
16465
|
+
matcher: Matcher,
|
|
16466
|
+
appliesTo: AppliesTo.optional(),
|
|
16467
|
+
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
16468
|
+
requiresNearby: RequiresNearby.optional(),
|
|
16469
|
+
examples: external_exports.array(external_exports.string()).optional()
|
|
16470
|
+
}).meta({ id: "Rule" });
|
|
16471
|
+
var Author = external_exports.object({
|
|
16472
|
+
name: external_exports.string(),
|
|
16473
|
+
email: external_exports.email().optional(),
|
|
16474
|
+
url: external_exports.url().optional()
|
|
16475
|
+
}).meta({ id: "Author" });
|
|
16476
|
+
var PackManifest = external_exports.object({
|
|
16477
|
+
specVersion: external_exports.literal(1),
|
|
16478
|
+
id: external_exports.string(),
|
|
16479
|
+
name: external_exports.string(),
|
|
16480
|
+
version: external_exports.string(),
|
|
16481
|
+
rules: external_exports.array(external_exports.string()),
|
|
16482
|
+
// Optional attribution/provenance — consumed by the rule marketplace.
|
|
16483
|
+
description: external_exports.string().optional(),
|
|
16484
|
+
author: Author.optional(),
|
|
16485
|
+
license: external_exports.string().optional(),
|
|
16486
|
+
sourceUrl: external_exports.url().optional()
|
|
16487
|
+
}).meta({ id: "PackManifest" });
|
|
16956
16488
|
|
|
16957
16489
|
// ../../packages/schema/src/zod/detection.ts
|
|
16958
16490
|
var OriginEnum = external_exports.enum(["library"]).meta({ id: "OriginEnum" });
|
|
@@ -17152,6 +16684,231 @@ function buildDetectionsList(summaries, query) {
|
|
|
17152
16684
|
return { counts, items: filtered.map(summaryToDetectionListItem) };
|
|
17153
16685
|
}
|
|
17154
16686
|
|
|
16687
|
+
// ../../packages/schema/src/zod/inventory.ts
|
|
16688
|
+
var AssetType = external_exports.enum(["project", "skill", "mcp", "hook", "config"]).meta({ id: "AssetType" });
|
|
16689
|
+
var AccessLevel = external_exports.enum(["open", "approved", "blocked"]).meta({ id: "AccessLevel" });
|
|
16690
|
+
var Origin = external_exports.enum(["source", "public-dep", "vendored", "config", "data", "docs", "generated"]).meta({ id: "Origin" });
|
|
16691
|
+
var TrustLevel = external_exports.enum(["known-good", "risky", "unapproved"]).meta({ id: "TrustLevel" });
|
|
16692
|
+
var Flag = external_exports.enum(["update", "stale", "conflict", "unknown", "change", "untracked", "risk", "findings"]).meta({ id: "Flag" });
|
|
16693
|
+
var Visibility = external_exports.enum(["public", "private"]).meta({ id: "Visibility" });
|
|
16694
|
+
var HarnessEventKind = external_exports.enum(["block", "redact", "warn"]).meta({ id: "HarnessEventKind" });
|
|
16695
|
+
var HarnessId = Harness.extract(["ClaudeCode", "Cursor", "Codex", "Antigravity"]).meta({
|
|
16696
|
+
id: "HarnessId"
|
|
16697
|
+
});
|
|
16698
|
+
var AccessCounts = external_exports.object({
|
|
16699
|
+
open: external_exports.number().int().nonnegative(),
|
|
16700
|
+
approved: external_exports.number().int().nonnegative(),
|
|
16701
|
+
blocked: external_exports.number().int().nonnegative(),
|
|
16702
|
+
total: external_exports.number().int().nonnegative()
|
|
16703
|
+
}).meta({ id: "AccessCounts" });
|
|
16704
|
+
var AssetSummary = external_exports.object({
|
|
16705
|
+
id: external_exports.string(),
|
|
16706
|
+
type: AssetType,
|
|
16707
|
+
name: external_exports.string(),
|
|
16708
|
+
sub: external_exports.string(),
|
|
16709
|
+
flags: external_exports.array(Flag),
|
|
16710
|
+
/** MCP servers only — omitted for all other types. */
|
|
16711
|
+
trust: TrustLevel.optional()
|
|
16712
|
+
}).meta({ id: "AssetSummary" });
|
|
16713
|
+
var ProjectSummary = external_exports.object({
|
|
16714
|
+
id: external_exports.string(),
|
|
16715
|
+
name: external_exports.string(),
|
|
16716
|
+
repo: external_exports.string(),
|
|
16717
|
+
visibility: Visibility,
|
|
16718
|
+
language: external_exports.string(),
|
|
16719
|
+
policyDefault: AccessLevel,
|
|
16720
|
+
updatedAt: external_exports.iso.datetime(),
|
|
16721
|
+
accessCounts: AccessCounts,
|
|
16722
|
+
findingsCount: external_exports.number().int().nonnegative()
|
|
16723
|
+
}).meta({ id: "ProjectSummary" });
|
|
16724
|
+
var HarnessCategory = external_exports.object({
|
|
16725
|
+
/** One of config/skill/mcp/hook — never project (enforced at service layer). */
|
|
16726
|
+
type: AssetType,
|
|
16727
|
+
assets: external_exports.array(AssetSummary)
|
|
16728
|
+
});
|
|
16729
|
+
var HarnessSummary = external_exports.object({
|
|
16730
|
+
id: HarnessId,
|
|
16731
|
+
label: external_exports.string(),
|
|
16732
|
+
kind: external_exports.string(),
|
|
16733
|
+
version: external_exports.string(),
|
|
16734
|
+
sessions: external_exports.number().int().nonnegative(),
|
|
16735
|
+
assetCount: external_exports.number().int().nonnegative(),
|
|
16736
|
+
flagCount: external_exports.number().int().nonnegative(),
|
|
16737
|
+
projects: external_exports.array(ProjectSummary),
|
|
16738
|
+
categories: external_exports.array(HarnessCategory)
|
|
16739
|
+
}).meta({ id: "HarnessSummary" });
|
|
16740
|
+
var ListHarnessesResponse = external_exports.object({ items: external_exports.array(HarnessSummary) }).meta({ id: "ListHarnessesResponse" });
|
|
16741
|
+
var AssetGroup = external_exports.object({
|
|
16742
|
+
/** Group key — never project (enforced at service layer). */
|
|
16743
|
+
type: AssetType,
|
|
16744
|
+
total: external_exports.number().int().nonnegative(),
|
|
16745
|
+
/**
|
|
16746
|
+
* MCP group only — omitted for all other types.
|
|
16747
|
+
* Partial: only TrustLevel keys with non-zero counts are included.
|
|
16748
|
+
* Strict: unknown keys are rejected — only TrustLevel values are valid keys.
|
|
16749
|
+
*/
|
|
16750
|
+
trustRollup: external_exports.object({
|
|
16751
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16752
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16753
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16754
|
+
}).partial().strict().optional(),
|
|
16755
|
+
/**
|
|
16756
|
+
* Partial: only Flag keys with non-zero counts are included.
|
|
16757
|
+
* Strict: unknown keys are rejected — only Flag values are valid keys.
|
|
16758
|
+
*/
|
|
16759
|
+
flagRollup: external_exports.object({
|
|
16760
|
+
update: external_exports.number().int().nonnegative(),
|
|
16761
|
+
stale: external_exports.number().int().nonnegative(),
|
|
16762
|
+
conflict: external_exports.number().int().nonnegative(),
|
|
16763
|
+
unknown: external_exports.number().int().nonnegative(),
|
|
16764
|
+
change: external_exports.number().int().nonnegative(),
|
|
16765
|
+
untracked: external_exports.number().int().nonnegative(),
|
|
16766
|
+
risk: external_exports.number().int().nonnegative(),
|
|
16767
|
+
findings: external_exports.number().int().nonnegative()
|
|
16768
|
+
}).partial().strict(),
|
|
16769
|
+
items: external_exports.array(AssetSummary)
|
|
16770
|
+
}).meta({ id: "AssetGroup" });
|
|
16771
|
+
var ListAssetsResponse = external_exports.object({ groups: external_exports.array(AssetGroup) }).meta({ id: "ListAssetsResponse" });
|
|
16772
|
+
var McpTool = external_exports.object({
|
|
16773
|
+
name: external_exports.string(),
|
|
16774
|
+
signature: external_exports.string(),
|
|
16775
|
+
description: external_exports.string(),
|
|
16776
|
+
write: external_exports.boolean(),
|
|
16777
|
+
/** Non-null string when tool is dangerous / blocked; null otherwise. */
|
|
16778
|
+
risk: external_exports.string().nullable()
|
|
16779
|
+
}).meta({ id: "McpTool" });
|
|
16780
|
+
var AssetFindingRef = external_exports.object({
|
|
16781
|
+
id: external_exports.string(),
|
|
16782
|
+
title: external_exports.string(),
|
|
16783
|
+
note: external_exports.string()
|
|
16784
|
+
});
|
|
16785
|
+
var AssetDetail = AssetSummary.extend({
|
|
16786
|
+
/** string | null — null when no description is available. */
|
|
16787
|
+
description: external_exports.string().nullable(),
|
|
16788
|
+
/** trustLevel | null — null for non-MCP assets. */
|
|
16789
|
+
trust: TrustLevel.nullable(),
|
|
16790
|
+
/** Type-specific raw key/values — FE renders the grid. */
|
|
16791
|
+
meta: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
16792
|
+
/** always present — object when there is an active finding, null when absent. */
|
|
16793
|
+
finding: AssetFindingRef.nullable(),
|
|
16794
|
+
/** MCP exposed-tools list — omitted for non-mcp. */
|
|
16795
|
+
tools: external_exports.array(McpTool).optional()
|
|
16796
|
+
}).meta({ id: "AssetDetail" });
|
|
16797
|
+
var ListProjectsResponse = external_exports.object({ items: external_exports.array(ProjectSummary) }).meta({ id: "ListProjectsResponse" });
|
|
16798
|
+
var InventoryStats = external_exports.object({
|
|
16799
|
+
/** Total assets/projects with ≥1 flag or finding (drives the attention header chip). */
|
|
16800
|
+
attention: external_exports.number().int().nonnegative(),
|
|
16801
|
+
byType: external_exports.object({
|
|
16802
|
+
project: external_exports.number().int().nonnegative(),
|
|
16803
|
+
skill: external_exports.number().int().nonnegative(),
|
|
16804
|
+
mcp: external_exports.number().int().nonnegative(),
|
|
16805
|
+
hook: external_exports.number().int().nonnegative(),
|
|
16806
|
+
config: external_exports.number().int().nonnegative()
|
|
16807
|
+
}),
|
|
16808
|
+
harnesses: external_exports.number().int().nonnegative(),
|
|
16809
|
+
mcpTrust: external_exports.object({
|
|
16810
|
+
"known-good": external_exports.number().int().nonnegative(),
|
|
16811
|
+
risky: external_exports.number().int().nonnegative(),
|
|
16812
|
+
unapproved: external_exports.number().int().nonnegative()
|
|
16813
|
+
})
|
|
16814
|
+
}).meta({ id: "InventoryStats" });
|
|
16815
|
+
var FileSummary = external_exports.object({
|
|
16816
|
+
path: external_exports.string(),
|
|
16817
|
+
name: external_exports.string(),
|
|
16818
|
+
origin: Origin,
|
|
16819
|
+
/** Effective access (override applied). */
|
|
16820
|
+
access: AccessLevel,
|
|
16821
|
+
/** True when a file_access_override differs from the computed default. */
|
|
16822
|
+
isCustom: external_exports.boolean(),
|
|
16823
|
+
findings: external_exports.number().int().nonnegative(),
|
|
16824
|
+
/** When the file was auto-blocked by a detection; null when not blocked. */
|
|
16825
|
+
blockedAt: external_exports.iso.datetime().nullable().optional(),
|
|
16826
|
+
/** Why the file was blocked; null when absent. */
|
|
16827
|
+
note: external_exports.string().nullable().optional()
|
|
16828
|
+
}).meta({ id: "FileSummary" });
|
|
16829
|
+
var FolderSummary = external_exports.object({
|
|
16830
|
+
name: external_exports.string(),
|
|
16831
|
+
path: external_exports.string(),
|
|
16832
|
+
/** Rollup of effective access across all descendants. */
|
|
16833
|
+
accessCounts: AccessCounts
|
|
16834
|
+
}).meta({ id: "FolderSummary" });
|
|
16835
|
+
var ProjectTreeResponse = external_exports.object({
|
|
16836
|
+
project: external_exports.object({
|
|
16837
|
+
id: external_exports.string(),
|
|
16838
|
+
repo: external_exports.string(),
|
|
16839
|
+
visibility: Visibility
|
|
16840
|
+
}),
|
|
16841
|
+
path: external_exports.string(),
|
|
16842
|
+
/** Browse mode: one-level folders at the current path. Omitted in search mode. */
|
|
16843
|
+
folders: external_exports.array(FolderSummary).optional(),
|
|
16844
|
+
files: external_exports.array(FileSummary)
|
|
16845
|
+
}).meta({ id: "ProjectTreeResponse" });
|
|
16846
|
+
var FileDetail = FileSummary.extend({
|
|
16847
|
+
project: external_exports.object({
|
|
16848
|
+
repo: external_exports.string(),
|
|
16849
|
+
visibility: Visibility,
|
|
16850
|
+
language: external_exports.string(),
|
|
16851
|
+
policyDefault: AccessLevel,
|
|
16852
|
+
updatedAt: external_exports.iso.datetime()
|
|
16853
|
+
}),
|
|
16854
|
+
findingsRefs: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
|
|
16855
|
+
}).meta({ id: "FileDetail" });
|
|
16856
|
+
var SetFileAccessBody = external_exports.object({
|
|
16857
|
+
path: external_exports.string(),
|
|
16858
|
+
access: AccessLevel
|
|
16859
|
+
}).meta({ id: "SetFileAccessBody" });
|
|
16860
|
+
var SetFileAccessResponse = external_exports.object({
|
|
16861
|
+
file: FileSummary,
|
|
16862
|
+
accessCounts: AccessCounts
|
|
16863
|
+
}).meta({ id: "SetFileAccessResponse" });
|
|
16864
|
+
var SetMcpTrustBody = external_exports.object({ trust: TrustLevel }).meta({ id: "SetMcpTrustBody" });
|
|
16865
|
+
var HarnessEventItem = external_exports.object({
|
|
16866
|
+
kind: HarnessEventKind,
|
|
16867
|
+
title: external_exports.string(),
|
|
16868
|
+
detail: external_exports.string(),
|
|
16869
|
+
occurredAt: external_exports.iso.datetime(),
|
|
16870
|
+
findingId: external_exports.string().nullable().optional()
|
|
16871
|
+
}).meta({ id: "HarnessEventItem" });
|
|
16872
|
+
var HarnessEventsResponse = external_exports.object({
|
|
16873
|
+
counts: external_exports.object({
|
|
16874
|
+
block: external_exports.number().int().nonnegative(),
|
|
16875
|
+
redact: external_exports.number().int().nonnegative(),
|
|
16876
|
+
warn: external_exports.number().int().nonnegative()
|
|
16877
|
+
}),
|
|
16878
|
+
items: external_exports.array(HarnessEventItem)
|
|
16879
|
+
}).meta({ id: "HarnessEventsResponse" });
|
|
16880
|
+
var RescanResponse = external_exports.object({
|
|
16881
|
+
jobId: external_exports.string(),
|
|
16882
|
+
startedAt: external_exports.iso.datetime()
|
|
16883
|
+
}).meta({ id: "RescanResponse" });
|
|
16884
|
+
var ConnectProjectBody = external_exports.object({ repo: external_exports.string() }).meta({ id: "ConnectProjectBody" });
|
|
16885
|
+
var ListAssetsQuery = external_exports.object({
|
|
16886
|
+
/** Filter by one or more AssetType values; absent means all types. */
|
|
16887
|
+
type: external_exports.array(AssetType).optional(),
|
|
16888
|
+
/** Free-text search term. */
|
|
16889
|
+
q: external_exports.string().optional()
|
|
16890
|
+
});
|
|
16891
|
+
var GetProjectTreeQuery = external_exports.object({
|
|
16892
|
+
/** Subtree root path; defaults to repository root when absent. */
|
|
16893
|
+
path: external_exports.string().optional(),
|
|
16894
|
+
/** Free-text filter applied to file paths. */
|
|
16895
|
+
q: external_exports.string().optional(),
|
|
16896
|
+
/**
|
|
16897
|
+
* Special listing mode. `blocked` returns every effectively-blocked, auto-blocked
|
|
16898
|
+
* file across the whole repo (folders omitted, most-recent first), ignoring
|
|
16899
|
+
* `path`/`q` — powers the project-wide "recently blocked" strip.
|
|
16900
|
+
*/
|
|
16901
|
+
filter: external_exports.enum(["blocked"]).optional()
|
|
16902
|
+
});
|
|
16903
|
+
var GetProjectFileQuery = external_exports.object({
|
|
16904
|
+
/** Repository-relative file path; absent or empty → 400. */
|
|
16905
|
+
path: external_exports.string()
|
|
16906
|
+
});
|
|
16907
|
+
var GetHarnessEventsQuery = external_exports.object({
|
|
16908
|
+
/** Maximum number of events to return. Range: 1–50; default: 7. */
|
|
16909
|
+
limit: external_exports.coerce.number().int().min(1).max(50).default(7)
|
|
16910
|
+
});
|
|
16911
|
+
|
|
17155
16912
|
// ../../packages/schema/src/zod/shares.ts
|
|
17156
16913
|
var DestinationKind = external_exports.enum(["provider", "internal", "external", "ip"]).meta({ id: "DestinationKind" });
|
|
17157
16914
|
var Transport = external_exports.enum(["https", "http", "sftp", "grpc", "smtp", "ws", "wss"]).meta({ id: "Transport" });
|
|
@@ -17358,6 +17115,127 @@ var EgressWriteSummary = external_exports.object({
|
|
|
17358
17115
|
droppedFiles: external_exports.array(external_exports.string()).default([])
|
|
17359
17116
|
}).meta({ id: "EgressWriteSummary" });
|
|
17360
17117
|
|
|
17118
|
+
// ../../packages/schema/src/zod/event.ts
|
|
17119
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
17120
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
17121
|
+
var EventMetadata = external_exports.object({
|
|
17122
|
+
sessionId: external_exports.string().optional(),
|
|
17123
|
+
repo: external_exports.string().optional(),
|
|
17124
|
+
filePath: external_exports.string().optional(),
|
|
17125
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
17126
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
17127
|
+
// arguments or output, which can carry the very value a finding masked
|
|
17128
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
17129
|
+
// display location ("via Bash") when no filePath exists.
|
|
17130
|
+
toolName: external_exports.string().optional(),
|
|
17131
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
17132
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
17133
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
17134
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
17135
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
17136
|
+
gitignored: external_exports.boolean().optional(),
|
|
17137
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
17138
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
17139
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
17140
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
17141
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
17142
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
17143
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
17144
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
17145
|
+
// non-authoritative path.
|
|
17146
|
+
wholeFile: external_exports.boolean().optional(),
|
|
17147
|
+
model: external_exports.string().optional(),
|
|
17148
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
17149
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
17150
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
17151
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
17152
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
17153
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
17154
|
+
correlationId: external_exports.uuid().optional(),
|
|
17155
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
17156
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
17157
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
17158
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
17159
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional()
|
|
17160
|
+
}).meta({ id: "EventMetadata" });
|
|
17161
|
+
var Event = external_exports.object({
|
|
17162
|
+
id: external_exports.guid(),
|
|
17163
|
+
sourceTool: SourceTool,
|
|
17164
|
+
kind: EventKind,
|
|
17165
|
+
occurredAt: external_exports.iso.datetime(),
|
|
17166
|
+
contentHash: external_exports.string(),
|
|
17167
|
+
content: external_exports.string(),
|
|
17168
|
+
metadata: EventMetadata.optional()
|
|
17169
|
+
}).meta({ id: "Event" });
|
|
17170
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
17171
|
+
var IngestBatch = external_exports.object({
|
|
17172
|
+
events: external_exports.array(IngestEvent).min(1).max(100),
|
|
17173
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
17174
|
+
// additionally rejects any event whose contentHash the store has already
|
|
17175
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
17176
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
17177
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
17178
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
17179
|
+
// the timeline.
|
|
17180
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
17181
|
+
}).meta({ id: "IngestBatch" });
|
|
17182
|
+
|
|
17183
|
+
// ../../packages/schema/src/zod/exception.ts
|
|
17184
|
+
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
17185
|
+
var ExceptionConditions = external_exports.object({
|
|
17186
|
+
repo: external_exports.string().optional(),
|
|
17187
|
+
sourceTool: external_exports.string().optional(),
|
|
17188
|
+
provider: external_exports.string().optional()
|
|
17189
|
+
}).strict();
|
|
17190
|
+
var ExceptionCapability = external_exports.enum(["suppress", "reveal_to_model"]);
|
|
17191
|
+
var DetectionException = external_exports.object({
|
|
17192
|
+
id: external_exports.guid(),
|
|
17193
|
+
ruleId: external_exports.string(),
|
|
17194
|
+
// Denormalized from the rule, for reporting — never matched on.
|
|
17195
|
+
category: DetectionCategory,
|
|
17196
|
+
// HMAC-SHA256 hex of the raw match under a machine-local key: a KEYED
|
|
17197
|
+
// fingerprint, never the raw value, and never reversible. Matching recomputes
|
|
17198
|
+
// the fingerprint from a fresh capture; the value itself is never stored.
|
|
17199
|
+
// Shape-constrained so a malformed — or accidentally raw — value is rejected
|
|
17200
|
+
// at the boundary rather than persisted.
|
|
17201
|
+
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
17202
|
+
// Version of the fingerprint key the grant was written under; a rotated key
|
|
17203
|
+
// invalidates old grants rather than silently mismatching them.
|
|
17204
|
+
keyVersion: external_exports.number().int().positive(),
|
|
17205
|
+
// maskMatch() preview of the approved value — never the raw value.
|
|
17206
|
+
maskedValue: external_exports.string(),
|
|
17207
|
+
capability: ExceptionCapability.default("suppress"),
|
|
17208
|
+
scope: ExceptionScope,
|
|
17209
|
+
expiresAt: external_exports.iso.datetime().nullable(),
|
|
17210
|
+
maxUses: external_exports.number().int().positive().nullable(),
|
|
17211
|
+
useCount: external_exports.number().int().nonnegative(),
|
|
17212
|
+
lastUsedAt: external_exports.iso.datetime().nullable(),
|
|
17213
|
+
// Mandatory: every grant carries the human reason it exists.
|
|
17214
|
+
justification: external_exports.string().min(1),
|
|
17215
|
+
conditions: ExceptionConditions.nullable(),
|
|
17216
|
+
createdBy: external_exports.string(),
|
|
17217
|
+
createdVia: external_exports.enum(["cli-approve", "cli-add", "web-approve", "web-add", "api", "setup-triage"]),
|
|
17218
|
+
createdAt: external_exports.iso.datetime(),
|
|
17219
|
+
updatedAt: external_exports.iso.datetime(),
|
|
17220
|
+
// Revocation is terminal and retained — consumed/expired/revoked rows are
|
|
17221
|
+
// audit evidence; nothing in the exception lifecycle hard-deletes.
|
|
17222
|
+
revokedAt: external_exports.iso.datetime().nullable(),
|
|
17223
|
+
revokedBy: external_exports.string().nullable(),
|
|
17224
|
+
revokeReason: external_exports.string().nullable()
|
|
17225
|
+
});
|
|
17226
|
+
var ExceptionBundleEntry = DetectionException.pick({
|
|
17227
|
+
id: true,
|
|
17228
|
+
ruleId: true,
|
|
17229
|
+
valueFingerprint: true,
|
|
17230
|
+
keyVersion: true,
|
|
17231
|
+
capability: true,
|
|
17232
|
+
expiresAt: true,
|
|
17233
|
+
maxUses: true,
|
|
17234
|
+
useCount: true,
|
|
17235
|
+
conditions: true
|
|
17236
|
+
});
|
|
17237
|
+
var ExceptionDescriptor = DetectionException.omit({ valueFingerprint: true });
|
|
17238
|
+
|
|
17361
17239
|
// ../../packages/schema/src/zod/exception-action.ts
|
|
17362
17240
|
var confirmation = external_exports.string().optional();
|
|
17363
17241
|
var ApproveBlockedInput = external_exports.object({
|
|
@@ -17400,10 +17278,11 @@ function toApiAction(dbVal) {
|
|
|
17400
17278
|
}
|
|
17401
17279
|
function toApiCategory(dbVal) {
|
|
17402
17280
|
if (dbVal === "code_context") return "source_code";
|
|
17403
|
-
|
|
17281
|
+
const parsed = FindingCategory.safeParse(dbVal);
|
|
17282
|
+
return parsed.success ? parsed.data : "custom";
|
|
17404
17283
|
}
|
|
17405
17284
|
function toApiProvider(sourceTool) {
|
|
17406
|
-
return TOOL_TO_HARNESS[sourceTool] ??
|
|
17285
|
+
return TOOL_TO_HARNESS[sourceTool] ?? HARNESS.Api;
|
|
17407
17286
|
}
|
|
17408
17287
|
var STATUS_PRECEDENCE = ["open", "handled", "dismissed", "resolved"];
|
|
17409
17288
|
function foldGroupStatus(instanceStatuses) {
|
|
@@ -17975,6 +17854,7 @@ var ListVaultDerefsResponse = external_exports.object({
|
|
|
17975
17854
|
});
|
|
17976
17855
|
var VaultKeyCustody = external_exports.string();
|
|
17977
17856
|
var VaultInlineReveal = external_exports.enum(["masked", "full", "off"]);
|
|
17857
|
+
var VAULT_CONSENT_VERSION = 1;
|
|
17978
17858
|
var VaultConsent = external_exports.object({
|
|
17979
17859
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
17980
17860
|
version: external_exports.number().int().positive()
|
|
@@ -17982,7 +17862,14 @@ var VaultConsent = external_exports.object({
|
|
|
17982
17862
|
|
|
17983
17863
|
// ../../packages/schema/src/zod/local.ts
|
|
17984
17864
|
var WORKSPACE_SETTINGS_SPEC_VERSION = 5;
|
|
17985
|
-
var
|
|
17865
|
+
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
17866
|
+
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
17867
|
+
var ControlPlaneConnection = external_exports.object({
|
|
17868
|
+
endpoint: external_exports.string().min(1),
|
|
17869
|
+
// Display name for the deployment, shown instead of the raw endpoint.
|
|
17870
|
+
label: external_exports.string().min(1).optional(),
|
|
17871
|
+
attachedAt: external_exports.iso.datetime()
|
|
17872
|
+
}).meta({ id: "ControlPlaneConnection" });
|
|
17986
17873
|
var SimpleDetectionPolicy = external_exports.enum(["redact", "warn"]);
|
|
17987
17874
|
var HistoricalAccess = external_exports.enum(["full", "session-only"]);
|
|
17988
17875
|
var ModelJudgeConsent = external_exports.object({
|
|
@@ -17991,12 +17878,10 @@ var ModelJudgeConsent = external_exports.object({
|
|
|
17991
17878
|
});
|
|
17992
17879
|
var WorkspaceSettings = external_exports.object({
|
|
17993
17880
|
specVersion: external_exports.number().int().positive().default(WORKSPACE_SETTINGS_SPEC_VERSION),
|
|
17994
|
-
|
|
17995
|
-
//
|
|
17996
|
-
runMode:
|
|
17997
|
-
|
|
17998
|
-
RunMode.default("standalone")
|
|
17999
|
-
),
|
|
17881
|
+
runMode: RunMode.default("standalone"),
|
|
17882
|
+
// Present only while attached; a detach clears it. Its presence is what makes
|
|
17883
|
+
// `runMode: 'attached'` mean anything — see isAttached.
|
|
17884
|
+
controlPlane: ControlPlaneConnection.optional(),
|
|
18000
17885
|
policy: SimpleDetectionPolicy.default("redact"),
|
|
18001
17886
|
// Consent for scanning pre-install surfaces; opt-in (see HistoricalAccess).
|
|
18002
17887
|
historicalAccess: HistoricalAccess.default("session-only"),
|
|
@@ -18098,39 +17983,244 @@ function toInspectionFindingRow(input) {
|
|
|
18098
17983
|
firstDetectedAt: input.firstDetectedAt ? isoToEpochMillis(input.firstDetectedAt) : null
|
|
18099
17984
|
};
|
|
18100
17985
|
}
|
|
18101
|
-
function toCaptureAttributes(event) {
|
|
18102
|
-
const metadata = event.metadata;
|
|
18103
|
-
return {
|
|
18104
|
-
source_tool: event.sourceTool,
|
|
18105
|
-
...metadata?.repo !== void 0 ? { repo: metadata.repo } : {},
|
|
18106
|
-
...metadata?.filePath !== void 0 ? { file_path: metadata.filePath } : {},
|
|
18107
|
-
...metadata?.toolName !== void 0 ? { tool_name: metadata.toolName } : {},
|
|
18108
|
-
...metadata?.gitignored !== void 0 ? { gitignored: metadata.gitignored } : {},
|
|
18109
|
-
...metadata?.wholeFile !== void 0 ? { whole_file: metadata.wholeFile } : {},
|
|
18110
|
-
...metadata?.correlationId !== void 0 ? { correlation_id: metadata.correlationId } : {},
|
|
18111
|
-
...metadata?.traceId !== void 0 ? { trace_id: metadata.traceId } : {},
|
|
18112
|
-
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
18113
|
-
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
18114
|
-
// has ever populated either), but every legacy metadata key still rides
|
|
18115
|
-
// the bag rather than being silently dropped — CaptureAttributes'
|
|
18116
|
-
// `.catchall(z.unknown())` carries the long tail.
|
|
18117
|
-
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
18118
|
-
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {}
|
|
18119
|
-
};
|
|
17986
|
+
function toCaptureAttributes(event) {
|
|
17987
|
+
const metadata = event.metadata;
|
|
17988
|
+
return {
|
|
17989
|
+
source_tool: event.sourceTool,
|
|
17990
|
+
...metadata?.repo !== void 0 ? { repo: metadata.repo } : {},
|
|
17991
|
+
...metadata?.filePath !== void 0 ? { file_path: metadata.filePath } : {},
|
|
17992
|
+
...metadata?.toolName !== void 0 ? { tool_name: metadata.toolName } : {},
|
|
17993
|
+
...metadata?.gitignored !== void 0 ? { gitignored: metadata.gitignored } : {},
|
|
17994
|
+
...metadata?.wholeFile !== void 0 ? { whole_file: metadata.wholeFile } : {},
|
|
17995
|
+
...metadata?.correlationId !== void 0 ? { correlation_id: metadata.correlationId } : {},
|
|
17996
|
+
...metadata?.traceId !== void 0 ? { trace_id: metadata.traceId } : {},
|
|
17997
|
+
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
17998
|
+
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
17999
|
+
// has ever populated either), but every legacy metadata key still rides
|
|
18000
|
+
// the bag rather than being silently dropped — CaptureAttributes'
|
|
18001
|
+
// `.catchall(z.unknown())` carries the long tail.
|
|
18002
|
+
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
18003
|
+
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {}
|
|
18004
|
+
};
|
|
18005
|
+
}
|
|
18006
|
+
function captureDefinitionVersion(finding2) {
|
|
18007
|
+
return `capture/${finding2.category}/${finding2.severity}`;
|
|
18008
|
+
}
|
|
18009
|
+
function toCaptureDefinitionInput(finding2) {
|
|
18010
|
+
return {
|
|
18011
|
+
ruleId: finding2.ruleId,
|
|
18012
|
+
version: captureDefinitionVersion(finding2),
|
|
18013
|
+
name: finding2.ruleId,
|
|
18014
|
+
category: finding2.category,
|
|
18015
|
+
severity: finding2.severity,
|
|
18016
|
+
definition: JSON.stringify({ ruleId: finding2.ruleId })
|
|
18017
|
+
};
|
|
18018
|
+
}
|
|
18019
|
+
|
|
18020
|
+
// ../../packages/schema/src/zod/managed.ts
|
|
18021
|
+
var MANAGED_SETTINGS_FILENAME = "managed-settings.json";
|
|
18022
|
+
var MANAGED_SETTINGS_SPEC_VERSION = 1;
|
|
18023
|
+
var ManagedSettingKey = external_exports.enum([
|
|
18024
|
+
"runMode",
|
|
18025
|
+
"historicalAccess",
|
|
18026
|
+
"vaultConsent",
|
|
18027
|
+
"vaultKeyCustody",
|
|
18028
|
+
"vaultInlineReveal",
|
|
18029
|
+
"modelJudgeConsent",
|
|
18030
|
+
"dataSharesInPlace"
|
|
18031
|
+
]).meta({ id: "ManagedSettingKey" });
|
|
18032
|
+
var ManagedSettingsValues = external_exports.object({
|
|
18033
|
+
runMode: external_exports.enum(["standalone", "attached"]).optional(),
|
|
18034
|
+
controlPlane: external_exports.object({
|
|
18035
|
+
endpoint: external_exports.string().min(1),
|
|
18036
|
+
label: external_exports.string().min(1).optional()
|
|
18037
|
+
}).optional(),
|
|
18038
|
+
historicalAccess: external_exports.enum(["full", "session-only"]).optional(),
|
|
18039
|
+
vaultConsent: external_exports.boolean().optional(),
|
|
18040
|
+
vaultKeyCustody: external_exports.enum(["file", "keychain"]).optional(),
|
|
18041
|
+
vaultInlineReveal: external_exports.enum(["masked", "full", "off"]).optional(),
|
|
18042
|
+
modelJudgeConsent: external_exports.boolean().optional(),
|
|
18043
|
+
dataSharesInPlace: external_exports.boolean().optional()
|
|
18044
|
+
}).meta({ id: "ManagedSettingsValues" });
|
|
18045
|
+
var ManagedSettings = external_exports.object({
|
|
18046
|
+
specVersion: external_exports.number().int().positive().default(MANAGED_SETTINGS_SPEC_VERSION),
|
|
18047
|
+
// Shown on every locked control, so the user can tell an administrative
|
|
18048
|
+
// decision from a bug. Absent renders as a generic "your organization".
|
|
18049
|
+
organization: external_exports.string().min(1).optional(),
|
|
18050
|
+
// What the administrator pinned.
|
|
18051
|
+
values: ManagedSettingsValues.default({}),
|
|
18052
|
+
// Which of those the user may not change. A key here with no matching value
|
|
18053
|
+
// freezes whatever the user last chose; a value with no lock is a DEFAULT
|
|
18054
|
+
// the user may still override. The two are separable on purpose.
|
|
18055
|
+
lockedFields: external_exports.array(ManagedSettingKey).default([])
|
|
18056
|
+
}).meta({ id: "ManagedSettings" });
|
|
18057
|
+
|
|
18058
|
+
// ../../packages/schema/src/zod/policy.ts
|
|
18059
|
+
var PolicyScope = external_exports.enum(["global", "repo", "user"]).meta({ id: "PolicyScope" });
|
|
18060
|
+
var PolicyTarget = external_exports.union([external_exports.object({ ruleId: external_exports.string() }), external_exports.object({ category: DetectionCategory })]).meta({ id: "PolicyTarget" });
|
|
18061
|
+
var Policy = external_exports.object({
|
|
18062
|
+
id: external_exports.guid(),
|
|
18063
|
+
scope: PolicyScope,
|
|
18064
|
+
target: PolicyTarget,
|
|
18065
|
+
action: ActionTaken,
|
|
18066
|
+
enabled: external_exports.boolean().default(true),
|
|
18067
|
+
customKeywords: external_exports.array(external_exports.string()).optional(),
|
|
18068
|
+
// Display name — optional so older policy rows without name still parse.
|
|
18069
|
+
// Added for the findings API (policy.name column migration).
|
|
18070
|
+
name: external_exports.string().optional()
|
|
18071
|
+
}).meta({ id: "Policy" });
|
|
18072
|
+
var PolicyBundle = external_exports.object({
|
|
18073
|
+
version: external_exports.string(),
|
|
18074
|
+
policies: external_exports.array(Policy),
|
|
18075
|
+
// Rules from the installed marketplace packs (snapshotted by the
|
|
18076
|
+
// control plane). The plugin registers these in addition to its bundled
|
|
18077
|
+
// packs. Optional so older backends — and older on-disk caches — that omit
|
|
18078
|
+
// the field still parse; consumers read `bundle.rules ?? []`.
|
|
18079
|
+
rules: external_exports.array(Rule).optional(),
|
|
18080
|
+
// When true, `rules` IS the complete effective ruleset and the runtime must
|
|
18081
|
+
// NOT merge its compiled-in bundled packs — the standalone gateway sets this
|
|
18082
|
+
// after reading the user's installed snapshot (installed_packs, enabled
|
|
18083
|
+
// packs only), which is how detection updates stay manual: new bundled
|
|
18084
|
+
// rules run only after the user applies the pack update. Absent/false keeps
|
|
18085
|
+
// the historical composition (bundled packs + rules) — older caches.
|
|
18086
|
+
rulesComplete: external_exports.boolean().optional(),
|
|
18087
|
+
// Active detection exceptions, evaluation subset only (see
|
|
18088
|
+
// ExceptionBundleEntry). Optional so older bundle producers — and older
|
|
18089
|
+
// on-disk caches — that omit the field still parse; consumers read
|
|
18090
|
+
// `bundle.exceptions ?? []`.
|
|
18091
|
+
exceptions: external_exports.array(ExceptionBundleEntry).optional(),
|
|
18092
|
+
// Rule ids whose pack is assigned a REVERSIBLE archetype (Redact & Vault).
|
|
18093
|
+
// A second axis over the same `redact` action, carried beside the policies
|
|
18094
|
+
// rather than on them: nothing writes ruleId-targeted policies to disk, so
|
|
18095
|
+
// widening Policy itself would change a persisted shape to express something
|
|
18096
|
+
// only the in-memory bundle needs. Optional so an older producer — or an
|
|
18097
|
+
// older on-disk cache — still parses; consumers read `?? []` and get the
|
|
18098
|
+
// pre-existing one-way behaviour, which is the safe direction to default.
|
|
18099
|
+
reversibleRuleIds: external_exports.array(external_exports.string()).optional(),
|
|
18100
|
+
// Installed pack version, keyed by ruleId, for rules in `rules` that came
|
|
18101
|
+
// from a versioned installed pack. Optional so older backends — and older
|
|
18102
|
+
// on-disk caches — that omit the field still parse; consumers fall back to
|
|
18103
|
+
// the rule's own spec version. NOT the bundle version above — see
|
|
18104
|
+
// installedRuleset's ruleVersions for the source of truth.
|
|
18105
|
+
ruleVersions: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
18106
|
+
customKeywords: external_exports.array(external_exports.string()),
|
|
18107
|
+
fetchedAt: external_exports.iso.datetime()
|
|
18108
|
+
}).meta({ id: "PolicyBundle" });
|
|
18109
|
+
var OBSERVE_ONLY_CATEGORIES = ["config"];
|
|
18110
|
+
var ENFORCEABLE_CATEGORIES = DetectionCategory.options.filter((c) => !OBSERVE_ONLY_CATEGORIES.includes(c));
|
|
18111
|
+
var CATEGORY_PEAK_SEVERITY = {
|
|
18112
|
+
secret: "critical",
|
|
18113
|
+
financial: "critical",
|
|
18114
|
+
// core-financial/credit-card
|
|
18115
|
+
code_flaw: "critical",
|
|
18116
|
+
pii: "high",
|
|
18117
|
+
phi: "high",
|
|
18118
|
+
custom: "high",
|
|
18119
|
+
// user-defined; conservative
|
|
18120
|
+
code_context: "low",
|
|
18121
|
+
config: "low"
|
|
18122
|
+
// observe-only; floors to monitor regardless
|
|
18123
|
+
};
|
|
18124
|
+
function severityFloorPolicy(category) {
|
|
18125
|
+
if (OBSERVE_ONLY_CATEGORIES.includes(category)) return "monitor";
|
|
18126
|
+
const peak = CATEGORY_PEAK_SEVERITY[category];
|
|
18127
|
+
return peak === "critical" || peak === "high" ? "warn" : "monitor";
|
|
18128
|
+
}
|
|
18129
|
+
var PolicyKind = external_exports.enum(["builtin", "custom"]).meta({ id: "PolicyKind" });
|
|
18130
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
18131
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
18132
|
+
var BUILTIN_ORDER = KNOWN_BUILTIN_IDS;
|
|
18133
|
+
var BUILTIN_POLICY_SPECS = {
|
|
18134
|
+
monitor: {
|
|
18135
|
+
name: "Monitor",
|
|
18136
|
+
action: "log",
|
|
18137
|
+
reversible: false,
|
|
18138
|
+
description: "Log every match for audit. The request is allowed through untouched."
|
|
18139
|
+
},
|
|
18140
|
+
warn: {
|
|
18141
|
+
name: "Warn",
|
|
18142
|
+
action: "warn",
|
|
18143
|
+
reversible: false,
|
|
18144
|
+
description: "Allow the request, but warn the user inline before it is sent."
|
|
18145
|
+
},
|
|
18146
|
+
redact: {
|
|
18147
|
+
name: "Redact",
|
|
18148
|
+
action: "redact",
|
|
18149
|
+
reversible: false,
|
|
18150
|
+
description: "Strip the matched value from the request and destroy it, then continue. What was removed cannot be recovered."
|
|
18151
|
+
},
|
|
18152
|
+
vault: {
|
|
18153
|
+
name: "Redact & Vault",
|
|
18154
|
+
action: "redact",
|
|
18155
|
+
reversible: true,
|
|
18156
|
+
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."
|
|
18157
|
+
},
|
|
18158
|
+
block: {
|
|
18159
|
+
name: "Block",
|
|
18160
|
+
action: "block",
|
|
18161
|
+
reversible: false,
|
|
18162
|
+
description: "Refuse the request entirely whenever any rule in this detection matches."
|
|
18163
|
+
}
|
|
18164
|
+
};
|
|
18165
|
+
function builtinPolicyToAction(id) {
|
|
18166
|
+
return BUILTIN_POLICY_SPECS[id].action;
|
|
18167
|
+
}
|
|
18168
|
+
var CATEGORY_EXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
18169
|
+
(id) => !BUILTIN_POLICY_SPECS[id].reversible
|
|
18170
|
+
);
|
|
18171
|
+
var CATEGORY_INEXPRESSIBLE_IDS = KNOWN_BUILTIN_IDS.filter(
|
|
18172
|
+
(id) => BUILTIN_POLICY_SPECS[id].reversible
|
|
18173
|
+
);
|
|
18174
|
+
var CategoryPolicyId = external_exports.enum(CATEGORY_EXPRESSIBLE_IDS).meta({ id: "CategoryPolicyId" });
|
|
18175
|
+
function builtinPolicyIsReversible(id) {
|
|
18176
|
+
return BUILTIN_POLICY_SPECS[id].reversible;
|
|
18120
18177
|
}
|
|
18121
|
-
function
|
|
18122
|
-
|
|
18178
|
+
function policyIdIsReversible(policyId) {
|
|
18179
|
+
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
18180
|
+
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
18181
|
+
return builtinPolicyIsReversible(id);
|
|
18123
18182
|
}
|
|
18124
|
-
|
|
18125
|
-
|
|
18126
|
-
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
|
|
18130
|
-
|
|
18131
|
-
|
|
18132
|
-
|
|
18183
|
+
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
18184
|
+
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
18185
|
+
);
|
|
18186
|
+
var BUILTIN_POLICIES = Object.fromEntries(
|
|
18187
|
+
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
18188
|
+
);
|
|
18189
|
+
var DEFAULT_PACK_POLICY_ID = "monitor";
|
|
18190
|
+
function policyIdToAction(policyId) {
|
|
18191
|
+
const parsed = BuiltinPolicyId.safeParse(policyId ?? DEFAULT_PACK_POLICY_ID);
|
|
18192
|
+
const id = parsed.success ? parsed.data : DEFAULT_PACK_POLICY_ID;
|
|
18193
|
+
return BUILTIN_POLICIES[id].action;
|
|
18133
18194
|
}
|
|
18195
|
+
var UsedByItem = external_exports.object({
|
|
18196
|
+
id: external_exports.string(),
|
|
18197
|
+
name: external_exports.string(),
|
|
18198
|
+
ruleCount: external_exports.number().int().nonnegative(),
|
|
18199
|
+
enabled: external_exports.boolean()
|
|
18200
|
+
}).meta({ id: "UsedByItem" });
|
|
18201
|
+
var PolicyListItem = external_exports.object({
|
|
18202
|
+
id: external_exports.string(),
|
|
18203
|
+
kind: PolicyKind,
|
|
18204
|
+
name: external_exports.string(),
|
|
18205
|
+
enabled: external_exports.boolean(),
|
|
18206
|
+
usedByCount: external_exports.number().int().nonnegative()
|
|
18207
|
+
}).meta({ id: "PolicyListItem" });
|
|
18208
|
+
var ListPoliciesResponse = external_exports.object({ items: external_exports.array(PolicyListItem) }).meta({ id: "ListPoliciesResponse" });
|
|
18209
|
+
var PolicyDetail = external_exports.object({
|
|
18210
|
+
specVersion: external_exports.literal(1),
|
|
18211
|
+
id: external_exports.string(),
|
|
18212
|
+
kind: PolicyKind,
|
|
18213
|
+
name: external_exports.string(),
|
|
18214
|
+
enabled: external_exports.boolean(),
|
|
18215
|
+
description: external_exports.string(),
|
|
18216
|
+
usedBy: external_exports.array(UsedByItem)
|
|
18217
|
+
}).meta({ id: "PolicyDetail" });
|
|
18218
|
+
var PolicyStatsResponse = external_exports.object({
|
|
18219
|
+
policies: external_exports.number().int().nonnegative(),
|
|
18220
|
+
builtin: external_exports.number().int().nonnegative(),
|
|
18221
|
+
custom: external_exports.number().int().nonnegative(),
|
|
18222
|
+
detectionsGoverned: external_exports.number().int().nonnegative()
|
|
18223
|
+
}).meta({ id: "PolicyStatsResponse" });
|
|
18134
18224
|
|
|
18135
18225
|
// ../../packages/schema/src/zod/project-files.ts
|
|
18136
18226
|
var ProjectFileInput = external_exports.object({
|
|
@@ -18210,44 +18300,6 @@ var BatchedRemediation = external_exports.discriminatedUnion("kind", [
|
|
|
18210
18300
|
NoRemediationDecision
|
|
18211
18301
|
]);
|
|
18212
18302
|
|
|
18213
|
-
// ../../packages/schema/src/zod/rule-test.ts
|
|
18214
|
-
var TestRulesRequest = external_exports.object({
|
|
18215
|
-
rules: external_exports.array(Rule).min(1).max(100),
|
|
18216
|
-
text: external_exports.string().max(5e4).optional(),
|
|
18217
|
-
fixtures: external_exports.array(RuleFixture).max(200).optional()
|
|
18218
|
-
}).refine((v) => v.text !== void 0 || (v.fixtures?.length ?? 0) > 0, {
|
|
18219
|
-
message: "Provide `text`, `fixtures`, or both \u2014 there must be something to test"
|
|
18220
|
-
}).meta({ id: "TestRulesRequest" });
|
|
18221
|
-
var RuleTestMatch = external_exports.object({
|
|
18222
|
-
ruleId: external_exports.string(),
|
|
18223
|
-
category: DetectionCategory,
|
|
18224
|
-
severity: Severity,
|
|
18225
|
-
span: Span,
|
|
18226
|
-
confidence: external_exports.number().min(0).max(1),
|
|
18227
|
-
match: external_exports.string()
|
|
18228
|
-
}).meta({ id: "RuleTestMatch" });
|
|
18229
|
-
var FixtureResult = external_exports.object({
|
|
18230
|
-
label: external_exports.string(),
|
|
18231
|
-
shouldMatch: external_exports.boolean(),
|
|
18232
|
-
didMatch: external_exports.boolean(),
|
|
18233
|
-
passed: external_exports.boolean(),
|
|
18234
|
-
matches: external_exports.array(RuleTestMatch)
|
|
18235
|
-
}).meta({ id: "FixtureResult" });
|
|
18236
|
-
var TestRulesResponse = external_exports.object({
|
|
18237
|
-
// Present only when the request supplied `text`.
|
|
18238
|
-
adhoc: external_exports.object({ matches: external_exports.array(RuleTestMatch) }).optional(),
|
|
18239
|
-
fixtures: external_exports.array(FixtureResult),
|
|
18240
|
-
summary: external_exports.object({
|
|
18241
|
-
total: external_exports.number().int().nonnegative(),
|
|
18242
|
-
passed: external_exports.number().int().nonnegative(),
|
|
18243
|
-
failed: external_exports.number().int().nonnegative()
|
|
18244
|
-
}),
|
|
18245
|
-
// Ids of rules whose matcher type the engine cannot evaluate today (e.g.
|
|
18246
|
-
// `validator`), so they silently never match. Surfaced so an author is not
|
|
18247
|
-
// misled by a green run that actually skipped a rule.
|
|
18248
|
-
unsupportedRuleIds: external_exports.array(external_exports.string())
|
|
18249
|
-
}).meta({ id: "TestRulesResponse" });
|
|
18250
|
-
|
|
18251
18303
|
// ../../packages/schema/src/zod/security.ts
|
|
18252
18304
|
var SeveritySummaryItem = external_exports.object({
|
|
18253
18305
|
severity: Severity,
|
|
@@ -18345,10 +18397,22 @@ var TopSourcesQuery = external_exports.object({
|
|
|
18345
18397
|
// Omit for both kinds.
|
|
18346
18398
|
kind: external_exports.enum(SOURCE_KINDS).optional()
|
|
18347
18399
|
});
|
|
18348
|
-
var Provider =
|
|
18400
|
+
var Provider = Harness.extract([
|
|
18401
|
+
"ClaudeCode",
|
|
18402
|
+
"Cursor",
|
|
18403
|
+
"Codex",
|
|
18404
|
+
"Antigravity",
|
|
18405
|
+
"ClaudeAi",
|
|
18406
|
+
"ChatGpt",
|
|
18407
|
+
"Copilot",
|
|
18408
|
+
"Api"
|
|
18409
|
+
]).meta({ id: "Provider" });
|
|
18349
18410
|
var ScanCoverageProvider = external_exports.object({
|
|
18350
18411
|
provider: Provider,
|
|
18351
|
-
// Percent of that provider's traffic
|
|
18412
|
+
// Percent of that provider's traffic the shipped capture surface reaches.
|
|
18413
|
+
// A curated business fact, constant across every `range` — not a measured
|
|
18414
|
+
// per-window metric. 0 exactly when `supported` is false. See the comment
|
|
18415
|
+
// above the block for where these numbers are decided.
|
|
18352
18416
|
coverage: external_exports.number().int().min(0).max(100),
|
|
18353
18417
|
supported: external_exports.boolean()
|
|
18354
18418
|
}).meta({ id: "ScanCoverageProvider" });
|
|
@@ -18402,6 +18466,18 @@ var ApplyRecommendedActionResponse = external_exports.object({
|
|
|
18402
18466
|
var DismissRecommendedActionResponse = external_exports.object({ id: external_exports.string(), status: external_exports.literal("dismissed") }).meta({ id: "DismissRecommendedActionResponse" });
|
|
18403
18467
|
var RecommendedActionIdParam = external_exports.object({ id: external_exports.string() });
|
|
18404
18468
|
|
|
18469
|
+
// ../../packages/schema/src/zod/settings-action.ts
|
|
18470
|
+
var SaveSettingsInput = external_exports.object({
|
|
18471
|
+
historicalAccess: external_exports.string(),
|
|
18472
|
+
modelJudgeConsent: external_exports.boolean(),
|
|
18473
|
+
vaultConsent: external_exports.string(),
|
|
18474
|
+
vaultInlineReveal: external_exports.string()
|
|
18475
|
+
});
|
|
18476
|
+
var AttachInput = external_exports.object({
|
|
18477
|
+
endpoint: external_exports.string(),
|
|
18478
|
+
label: external_exports.string().optional()
|
|
18479
|
+
});
|
|
18480
|
+
|
|
18405
18481
|
// ../../packages/schema/src/zod/triage.ts
|
|
18406
18482
|
var TriageHit = external_exports.object({
|
|
18407
18483
|
ruleId: external_exports.string(),
|
|
@@ -18416,7 +18492,7 @@ var TriageHit = external_exports.object({
|
|
|
18416
18492
|
valueFingerprint: external_exports.string().optional(),
|
|
18417
18493
|
keyVersion: external_exports.number().int().nonnegative().optional()
|
|
18418
18494
|
});
|
|
18419
|
-
var TriagePolicy =
|
|
18495
|
+
var TriagePolicy = CategoryPolicyId;
|
|
18420
18496
|
var TriageCategoryRec = external_exports.object({
|
|
18421
18497
|
category: DetectionCategory,
|
|
18422
18498
|
action: TriagePolicy,
|
|
@@ -18634,8 +18710,11 @@ function chmodBestEffort(path, mode) {
|
|
|
18634
18710
|
function tightenDir(dir) {
|
|
18635
18711
|
chmodBestEffort(dir, DATA_DIR_MODE);
|
|
18636
18712
|
}
|
|
18713
|
+
function mkdirOwnerOnlySync(dir, recursive = false) {
|
|
18714
|
+
mkdirSync(dir, { recursive, mode: DATA_DIR_MODE });
|
|
18715
|
+
}
|
|
18637
18716
|
function ensureDataDirSync(dir) {
|
|
18638
|
-
|
|
18717
|
+
mkdirOwnerOnlySync(dir, true);
|
|
18639
18718
|
tightenDir(dir);
|
|
18640
18719
|
}
|
|
18641
18720
|
function dbSidecars(file2) {
|
|
@@ -18653,6 +18732,25 @@ function backupPath(file2, tag) {
|
|
|
18653
18732
|
return `${file2}.${tag}.${String(Date.now())}.${randomUUID().slice(0, 8)}.bak`;
|
|
18654
18733
|
}
|
|
18655
18734
|
var STALE_PARTIAL_MS = 5 * 6e4;
|
|
18735
|
+
var SNAPSHOT_STAGING_SUFFIX = ".partial";
|
|
18736
|
+
var STAGED_NAME_SUFFIX = `.bak${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18737
|
+
var SNAPSHOT_STAGING_COPY = "copy";
|
|
18738
|
+
function createSnapshotStaging(backup) {
|
|
18739
|
+
const stage = `${backup}${SNAPSHOT_STAGING_SUFFIX}`;
|
|
18740
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18741
|
+
mkdirOwnerOnlySync(stage);
|
|
18742
|
+
tightenDir(stage);
|
|
18743
|
+
return { stage, copy: join(stage, SNAPSHOT_STAGING_COPY) };
|
|
18744
|
+
}
|
|
18745
|
+
function idleMs(entry) {
|
|
18746
|
+
for (const candidate of [join(entry, SNAPSHOT_STAGING_COPY), entry]) {
|
|
18747
|
+
try {
|
|
18748
|
+
return Date.now() - statSync(candidate).mtimeMs;
|
|
18749
|
+
} catch {
|
|
18750
|
+
}
|
|
18751
|
+
}
|
|
18752
|
+
return null;
|
|
18753
|
+
}
|
|
18656
18754
|
function reapStalePartials(file2) {
|
|
18657
18755
|
const dir = dirname(file2);
|
|
18658
18756
|
const prefix = `${basename(file2)}.`;
|
|
@@ -18663,30 +18761,34 @@ function reapStalePartials(file2) {
|
|
|
18663
18761
|
return;
|
|
18664
18762
|
}
|
|
18665
18763
|
for (const name of entries) {
|
|
18666
|
-
if (!name.startsWith(prefix) || !name.endsWith(
|
|
18667
|
-
const
|
|
18764
|
+
if (!name.startsWith(prefix) || !name.endsWith(STAGED_NAME_SUFFIX)) continue;
|
|
18765
|
+
const staging = join(dir, name);
|
|
18668
18766
|
try {
|
|
18669
|
-
|
|
18670
|
-
|
|
18767
|
+
const idle = idleMs(staging);
|
|
18768
|
+
if (idle !== null && idle > STALE_PARTIAL_MS) {
|
|
18769
|
+
rmSync2(staging, { recursive: true, force: true });
|
|
18671
18770
|
}
|
|
18672
18771
|
} catch {
|
|
18673
18772
|
}
|
|
18674
18773
|
}
|
|
18675
18774
|
}
|
|
18676
18775
|
function snapshotStore(db, backup) {
|
|
18677
|
-
const
|
|
18776
|
+
const { stage, copy } = createSnapshotStaging(backup);
|
|
18678
18777
|
try {
|
|
18679
|
-
|
|
18680
|
-
|
|
18681
|
-
|
|
18682
|
-
renameSync2(partial2, backup);
|
|
18778
|
+
db.prepare("VACUUM INTO ?").run(copy);
|
|
18779
|
+
tightenFile(copy);
|
|
18780
|
+
renameSync2(copy, backup);
|
|
18683
18781
|
} catch (error51) {
|
|
18684
18782
|
try {
|
|
18685
|
-
rmSync2(
|
|
18783
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18686
18784
|
} catch {
|
|
18687
18785
|
}
|
|
18688
18786
|
throw error51;
|
|
18689
18787
|
}
|
|
18788
|
+
try {
|
|
18789
|
+
rmSync2(stage, { recursive: true, force: true });
|
|
18790
|
+
} catch {
|
|
18791
|
+
}
|
|
18690
18792
|
}
|
|
18691
18793
|
function moveStoreAside(file2, backup) {
|
|
18692
18794
|
const undo = [];
|
|
@@ -19414,9 +19516,10 @@ function safeParseStringArray(raw) {
|
|
|
19414
19516
|
const parsed = safeJson(raw, null);
|
|
19415
19517
|
return Array.isArray(parsed) ? parsed : [];
|
|
19416
19518
|
}
|
|
19519
|
+
var DEFAULT_HARNESS = HARNESS.ClaudeCode;
|
|
19417
19520
|
function toHarness(raw) {
|
|
19418
19521
|
const parsed = Harness.safeParse(raw);
|
|
19419
|
-
return parsed.success ? parsed.data :
|
|
19522
|
+
return parsed.success ? parsed.data : DEFAULT_HARNESS;
|
|
19420
19523
|
}
|
|
19421
19524
|
function resolveLifecycle(row, lastActivityMs, nowMs) {
|
|
19422
19525
|
if (row.status) {
|
|
@@ -19547,7 +19650,7 @@ var SqliteActivityRepository = class {
|
|
|
19547
19650
|
const params = [];
|
|
19548
19651
|
if (query.harness && query.harness.length > 0) {
|
|
19549
19652
|
conditions.push(
|
|
19550
|
-
`coalesce(json_extract(attributes, '$.harness'), '
|
|
19653
|
+
`coalesce(json_extract(attributes, '$.harness'), '${DEFAULT_HARNESS}') IN (${placeholders(query.harness.length)})`
|
|
19551
19654
|
);
|
|
19552
19655
|
params.push(...query.harness);
|
|
19553
19656
|
}
|
|
@@ -19754,13 +19857,13 @@ var SqliteActivityRepository = class {
|
|
|
19754
19857
|
* The DISTINCT harnesses that actually have sessions (optionally within a
|
|
19755
19858
|
* `started_at >= fromMs` window), so the filter can offer only the harnesses
|
|
19756
19859
|
* present rather than the full enum. Each stored value is normalized through
|
|
19757
|
-
* the SAME `toHarness` default the list uses (missing →
|
|
19758
|
-
* store of bare (harness-less) roots surfaces exactly
|
|
19860
|
+
* the SAME `toHarness` default the list uses (missing → DEFAULT_HARNESS), so
|
|
19861
|
+
* a store of bare (harness-less) roots surfaces exactly that one harness.
|
|
19759
19862
|
*/
|
|
19760
19863
|
harnessFacets(fromMs) {
|
|
19761
19864
|
const where = fromMs === void 0 ? "" : " AND started_at >= ?";
|
|
19762
19865
|
const stmt = this.db.prepare(
|
|
19763
|
-
`SELECT DISTINCT coalesce(json_extract(attributes, '$.harness'), '
|
|
19866
|
+
`SELECT DISTINCT coalesce(json_extract(attributes, '$.harness'), '${DEFAULT_HARNESS}') AS harness
|
|
19764
19867
|
FROM audit_events WHERE ${SESSION_ROOT}${where}`
|
|
19765
19868
|
);
|
|
19766
19869
|
const rows = allRows(
|
|
@@ -19974,8 +20077,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
19974
20077
|
}
|
|
19975
20078
|
// Insert one transcript-derived `llm_call` leaf. Unlike `insertAuditEvent`
|
|
19976
20079
|
// (which takes a caller-supplied random id), the id here is MINTED internally
|
|
19977
|
-
// from the natural key — `llmCallId(sessionId, messageId)` —
|
|
19978
|
-
//
|
|
20080
|
+
// from the natural key — `llmCallId(sessionId, messageId)` — derived from the
|
|
20081
|
+
// session and message alone, like the sibling local-store ids. The deterministic
|
|
19979
20082
|
// id + the UPSERT-take-MAX(output_tokens) statement make every re-read idempotent
|
|
19980
20083
|
// AND converge a streaming partial/final split across two incremental passes:
|
|
19981
20084
|
// a whole-file re-read no-ops (equal output), a lagging final replaces a
|
|
@@ -20940,6 +21043,42 @@ var SqliteFindingsRepository = class {
|
|
|
20940
21043
|
this.db = db;
|
|
20941
21044
|
}
|
|
20942
21045
|
db;
|
|
21046
|
+
/**
|
|
21047
|
+
* The newest `limit` findings, newest first.
|
|
21048
|
+
*
|
|
21049
|
+
* THE PLAN IS THE POINT HERE, and two things in the SQL below exist only to
|
|
21050
|
+
* pin it. The natural spelling — drive from `inspection_findings`, order by the
|
|
21051
|
+
* JOINED `e.started_at` — cannot push the LIMIT down, because the sort key is
|
|
21052
|
+
* not on the driving table: SQLite sorts every finding in the store through a
|
|
21053
|
+
* temp B-tree to return 500 rows. Measured at 35.0 ms on a 40,000-event corpus
|
|
21054
|
+
* against 0.9 ms for the form below, and the gap is a ratio of the store size
|
|
21055
|
+
* rather than a constant.
|
|
21056
|
+
*
|
|
21057
|
+
* What it takes to make `started_at` order come out of an index instead:
|
|
21058
|
+
*
|
|
21059
|
+
* - **`+e.event_type`** — the unary plus makes that term non-indexable, so the
|
|
21060
|
+
* planner stops choosing `idx_audit_type_t` (`event_type, started_at`). That
|
|
21061
|
+
* index cannot serve the ORDER BY: the predicate spans four event types, so
|
|
21062
|
+
* satisfying a global `started_at` order across them needs a range merge
|
|
21063
|
+
* SQLite will not do, and it sorts instead. Freed of it, the planner scans
|
|
21064
|
+
* `idx_audit_started_at` — a bare `started_at` index — in DESC order and
|
|
21065
|
+
* filters the type per row, which lets the LIMIT stop the scan early.
|
|
21066
|
+
* - **`CROSS JOIN`** — semantically identical to JOIN in SQLite, and there
|
|
21067
|
+
* purely to stop the tables being reordered. With plain JOINs the planner
|
|
21068
|
+
* drives from `f` and sorts everything again: measured at 23.6 ms, i.e. the
|
|
21069
|
+
* unary plus ALONE recovers almost none of the win. Both are needed.
|
|
21070
|
+
*
|
|
21071
|
+
* Neither is a micro-optimisation that a later reader should tidy away, and
|
|
21072
|
+
* `packages/persistence/test/performance/hot-read-query-plans.test.ts` fails if
|
|
21073
|
+
* the temp B-tree comes back.
|
|
21074
|
+
*
|
|
21075
|
+
* Degrading gracefully was the reason for `+` over `INDEXED BY`, which measured
|
|
21076
|
+
* identically (0.9 ms): `INDEXED BY` is a hard requirement, so dropping or
|
|
21077
|
+
* renaming the index turns this read into an ERROR, where `+` turns it into a
|
|
21078
|
+
* scan-and-sort — slower, still correct. The worst case for the chosen form is
|
|
21079
|
+
* a store whose recent captures carry no findings at all, where the scan walks
|
|
21080
|
+
* the whole index; that is still no worse than the full sort it replaced.
|
|
21081
|
+
*/
|
|
20943
21082
|
recentFindings(opts) {
|
|
20944
21083
|
const limit = opts?.limit ?? 50;
|
|
20945
21084
|
const rows = allRows(
|
|
@@ -20948,10 +21087,10 @@ var SqliteFindingsRepository = class {
|
|
|
20948
21087
|
f.masked_match, f.action_taken, f.confidence, e.started_at AS occurred_at,
|
|
20949
21088
|
json_extract(e.attributes, '$.source_tool') AS source_tool,
|
|
20950
21089
|
e.event_type AS kind
|
|
20951
|
-
FROM
|
|
20952
|
-
JOIN
|
|
20953
|
-
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
20954
|
-
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
21090
|
+
FROM audit_events e
|
|
21091
|
+
CROSS JOIN inspection_findings f ON f.audit_event_id = e.id
|
|
21092
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
21093
|
+
WHERE +e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
20955
21094
|
ORDER BY e.started_at DESC, f.rowid DESC
|
|
20956
21095
|
LIMIT :limit`
|
|
20957
21096
|
),
|
|
@@ -21595,7 +21734,8 @@ var SqliteInspectionDefinitionsRepository = class {
|
|
|
21595
21734
|
}
|
|
21596
21735
|
db;
|
|
21597
21736
|
insertStmt;
|
|
21598
|
-
//
|
|
21737
|
+
// Insert-if-absent; returns the content-addressed definition id. An id already
|
|
21738
|
+
// present keeps the stored row untouched — see the class doc.
|
|
21599
21739
|
upsert(input) {
|
|
21600
21740
|
const id = inspectionDefinitionId(input.ruleId, input.version);
|
|
21601
21741
|
const row = toInspectionDefinitionRow(input, id);
|
|
@@ -21739,11 +21879,23 @@ function isParseableBinaryVersion(version2) {
|
|
|
21739
21879
|
|
|
21740
21880
|
// ../../packages/persistence/src/repositories/installed-packs.ts
|
|
21741
21881
|
var DEFAULT_POLICY_ID = DEFAULT_PACK_POLICY_ID;
|
|
21882
|
+
function printableRuleId(entry) {
|
|
21883
|
+
if (typeof entry !== "object" || entry === null) return null;
|
|
21884
|
+
const candidate = entry.id;
|
|
21885
|
+
return Rule.shape.id.safeParse(candidate).success ? candidate : null;
|
|
21886
|
+
}
|
|
21887
|
+
function firstIssueReason(error51) {
|
|
21888
|
+
const issue2 = error51.issues[0];
|
|
21889
|
+
if (!issue2) return "unknown";
|
|
21890
|
+
const path = issue2.path.map((segment) => String(segment)).join(".");
|
|
21891
|
+
return path ? `${path}: ${issue2.code}` : issue2.code;
|
|
21892
|
+
}
|
|
21893
|
+
var REJECTED_RULE_DETAIL_CAP = 10;
|
|
21742
21894
|
function inventorySignature(packs2) {
|
|
21743
21895
|
return packs2.map((p) => `${p.namespace}/${p.packId}@${p.version}#${hashRules(p.rulesJson)}`).sort().join(",");
|
|
21744
21896
|
}
|
|
21745
21897
|
function hashRules(rulesJson) {
|
|
21746
|
-
return createHash2("
|
|
21898
|
+
return createHash2("sha256").update(rulesJson).digest("hex");
|
|
21747
21899
|
}
|
|
21748
21900
|
function parseVersion(v) {
|
|
21749
21901
|
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
@@ -21955,10 +22107,21 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21955
22107
|
* (all detection off) instead of falling back to the bundled packs. Every
|
|
21956
22108
|
* JSON-level failure therefore counts as invalid.
|
|
21957
22109
|
*/
|
|
22110
|
+
/**
|
|
22111
|
+
* ORDERED, because a rule id is unique only WITHIN a pack — the sole unique
|
|
22112
|
+
* index is (namespace, pack_id) — so two enabled packs may contribute the same
|
|
22113
|
+
* id, and the per-rule maps below are last-write-wins. Without an ORDER BY the
|
|
22114
|
+
* winner is whatever order SQLite happens to return, which makes a collision
|
|
22115
|
+
* resolve differently on two machines holding identical stores. Ordering by
|
|
22116
|
+
* (namespace, pack_id) makes the loser deterministic and therefore testable.
|
|
22117
|
+
*/
|
|
21958
22118
|
installedRuleset() {
|
|
21959
22119
|
const rows = allRows(
|
|
21960
22120
|
this.db.prepare(
|
|
21961
|
-
`SELECT enabled, policy_id AS policyId, rules_json AS rulesJson, version
|
|
22121
|
+
`SELECT enabled, policy_id AS policyId, rules_json AS rulesJson, version,
|
|
22122
|
+
namespace, pack_id AS packId
|
|
22123
|
+
FROM installed_packs
|
|
22124
|
+
ORDER BY namespace, pack_id`
|
|
21962
22125
|
)
|
|
21963
22126
|
);
|
|
21964
22127
|
const out = {
|
|
@@ -21966,22 +22129,32 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21966
22129
|
enabledPacks: 0,
|
|
21967
22130
|
rules: [],
|
|
21968
22131
|
invalidRules: 0,
|
|
22132
|
+
rejectedRules: [],
|
|
21969
22133
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
21970
|
-
ruleVersions: /* @__PURE__ */ new Map()
|
|
22134
|
+
ruleVersions: /* @__PURE__ */ new Map(),
|
|
22135
|
+
reversibleRules: /* @__PURE__ */ new Set()
|
|
22136
|
+
};
|
|
22137
|
+
const reject = (pack, ruleId, reason) => {
|
|
22138
|
+
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
22139
|
+
out.rejectedRules.push({ pack, ruleId, reason });
|
|
21971
22140
|
};
|
|
21972
22141
|
for (const row of rows) {
|
|
21973
22142
|
if (!intToBool(row.enabled)) continue;
|
|
21974
22143
|
out.enabledPacks += 1;
|
|
21975
22144
|
const action = policyIdToAction(row.policyId);
|
|
22145
|
+
const reversible = policyIdIsReversible(row.policyId);
|
|
22146
|
+
const pack = `${row.namespace}/${row.packId}`;
|
|
21976
22147
|
let raw;
|
|
21977
22148
|
try {
|
|
21978
22149
|
raw = JSON.parse(row.rulesJson);
|
|
21979
22150
|
} catch {
|
|
21980
22151
|
out.invalidRules += 1;
|
|
22152
|
+
reject(pack, null, "rules_json: malformed JSON");
|
|
21981
22153
|
continue;
|
|
21982
22154
|
}
|
|
21983
22155
|
if (!Array.isArray(raw)) {
|
|
21984
22156
|
out.invalidRules += 1;
|
|
22157
|
+
reject(pack, null, "rules_json: not an array");
|
|
21985
22158
|
continue;
|
|
21986
22159
|
}
|
|
21987
22160
|
for (const entry of raw) {
|
|
@@ -21990,7 +22163,12 @@ var SqliteInstalledPacksRepository = class {
|
|
|
21990
22163
|
out.rules.push(parsed.data);
|
|
21991
22164
|
out.ruleActions.set(parsed.data.id, action);
|
|
21992
22165
|
out.ruleVersions.set(parsed.data.id, row.version);
|
|
21993
|
-
|
|
22166
|
+
if (reversible) out.reversibleRules.add(parsed.data.id);
|
|
22167
|
+
else out.reversibleRules.delete(parsed.data.id);
|
|
22168
|
+
} else {
|
|
22169
|
+
out.invalidRules += 1;
|
|
22170
|
+
reject(pack, printableRuleId(entry), firstIssueReason(parsed.error));
|
|
22171
|
+
}
|
|
21994
22172
|
}
|
|
21995
22173
|
}
|
|
21996
22174
|
return out;
|
|
@@ -22184,31 +22362,38 @@ var CATEGORY_ORDER = ["config", "skill", "mcp", "hook"];
|
|
|
22184
22362
|
var VALID_HARNESS_IDS = new Set(HarnessId.options);
|
|
22185
22363
|
var WORKTREE_CHECKOUT_FILTER = "(url IS NULL OR (url NOT LIKE '%/.claude/worktrees/%' AND url NOT LIKE '%\\.claude\\worktrees\\%'))";
|
|
22186
22364
|
var HARNESS_LABELS = {
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
|
|
22190
|
-
|
|
22365
|
+
[HARNESS.ClaudeCode]: "Claude Code",
|
|
22366
|
+
[HARNESS.Cursor]: "Cursor",
|
|
22367
|
+
[HARNESS.Codex]: "Codex",
|
|
22368
|
+
[HARNESS.Antigravity]: "Antigravity"
|
|
22191
22369
|
};
|
|
22192
22370
|
var HARNESS_LIVENESS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
22193
22371
|
var EMPTY_PROJECT_AGG = {
|
|
22194
22372
|
accessCounts: { open: 0, approved: 0, blocked: 0, total: 0 },
|
|
22195
22373
|
findingsCount: 0
|
|
22196
22374
|
};
|
|
22375
|
+
var stripSeparators = (value) => value.toLowerCase().replace(/[\s-]/g, "");
|
|
22376
|
+
var TITLE_NEEDLES = {
|
|
22377
|
+
ClaudeCode: stripSeparators(SOURCE_TOOL.ClaudeCode),
|
|
22378
|
+
Cursor: stripSeparators(SOURCE_TOOL.Cursor),
|
|
22379
|
+
Codex: stripSeparators(SOURCE_TOOL.Codex),
|
|
22380
|
+
Antigravity: stripSeparators(SOURCE_TOOL.Antigravity)
|
|
22381
|
+
};
|
|
22197
22382
|
function resolveHarnessId(attrs, row) {
|
|
22198
22383
|
if (attrs.provider && VALID_HARNESS_IDS.has(attrs.provider)) {
|
|
22199
22384
|
return attrs.provider;
|
|
22200
22385
|
}
|
|
22201
|
-
const t = (row.title ?? "")
|
|
22202
|
-
if (t.includes(
|
|
22203
|
-
if (t.includes(
|
|
22204
|
-
if (t.includes(
|
|
22205
|
-
if (t.includes(
|
|
22386
|
+
const t = stripSeparators(row.title ?? "");
|
|
22387
|
+
if (t.includes(TITLE_NEEDLES.ClaudeCode) || t === "claude") return HARNESS.ClaudeCode;
|
|
22388
|
+
if (t.includes(TITLE_NEEDLES.Cursor)) return HARNESS.Cursor;
|
|
22389
|
+
if (t.includes(TITLE_NEEDLES.Codex)) return HARNESS.Codex;
|
|
22390
|
+
if (t.includes(TITLE_NEEDLES.Antigravity)) return HARNESS.Antigravity;
|
|
22206
22391
|
return null;
|
|
22207
22392
|
}
|
|
22208
22393
|
function isLiveRealClaudeCode(rows) {
|
|
22209
22394
|
return rows.some((r) => {
|
|
22210
22395
|
const attrs = safeJson(r.attributes, {});
|
|
22211
|
-
return attrs.provenance !== "sample" && resolveHarnessId(attrs, r) ===
|
|
22396
|
+
return attrs.provenance !== "sample" && resolveHarnessId(attrs, r) === HARNESS.ClaudeCode;
|
|
22212
22397
|
});
|
|
22213
22398
|
}
|
|
22214
22399
|
function toAssetSummary(row) {
|
|
@@ -22476,7 +22661,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
22476
22661
|
const isRealHarness = rows.some(
|
|
22477
22662
|
(r) => safeJson(r.attributes, {}).provenance !== "sample"
|
|
22478
22663
|
);
|
|
22479
|
-
const attachConfig = isRealHarness && harnessId ===
|
|
22664
|
+
const attachConfig = isRealHarness && harnessId === HARNESS.ClaudeCode && configAssets.length > 0;
|
|
22480
22665
|
const assets = attachConfig ? [...harnessAssets, ...configAssets].sort((a, b) => a.name.localeCompare(b.name)) : harnessAssets;
|
|
22481
22666
|
if (q && assets.length === 0) continue;
|
|
22482
22667
|
const firstRow = rows[0];
|
|
@@ -23150,9 +23335,10 @@ var SqliteProjectFilesRepository = class {
|
|
|
23150
23335
|
// ../../packages/persistence/src/repositories/resolutions.ts
|
|
23151
23336
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
23152
23337
|
var SqliteResolutionsRepository = class {
|
|
23153
|
-
constructor(db, now = () => Date.now()) {
|
|
23338
|
+
constructor(db, now = () => Date.now(), newId = () => randomUUID7()) {
|
|
23154
23339
|
this.db = db;
|
|
23155
23340
|
this.now = now;
|
|
23341
|
+
this.newId = newId;
|
|
23156
23342
|
this.insertStmt = db.prepare(
|
|
23157
23343
|
`INSERT INTO finding_resolution (id, finding_key, status, method, resolved_at, evidence, created_at)
|
|
23158
23344
|
VALUES (:id, :findingKey, :status, :method, :resolvedAt, :evidence, :createdAt)`
|
|
@@ -23185,12 +23371,14 @@ var SqliteResolutionsRepository = class {
|
|
|
23185
23371
|
}
|
|
23186
23372
|
db;
|
|
23187
23373
|
now;
|
|
23374
|
+
newId;
|
|
23188
23375
|
insertStmt;
|
|
23189
23376
|
latestStmt;
|
|
23190
23377
|
openAtRestStmt;
|
|
23191
23378
|
resolvedAtRestStmt;
|
|
23192
23379
|
/**
|
|
23193
|
-
* Insert one disposition row. The repo mints the id and stamps created_at
|
|
23380
|
+
* Insert one disposition row. The repo mints the id and stamps created_at,
|
|
23381
|
+
* both through the constructor's injectable seams.
|
|
23194
23382
|
* `status`/`method` are typed AND re-parsed here against @akasecurity/schema's
|
|
23195
23383
|
* FindingStatus/ResolutionMethod, so the persisted vocabulary can never drift
|
|
23196
23384
|
* from the schema enums. NOTE for future manual-resolution writers: this is
|
|
@@ -23202,7 +23390,7 @@ var SqliteResolutionsRepository = class {
|
|
|
23202
23390
|
*/
|
|
23203
23391
|
insertResolution(r) {
|
|
23204
23392
|
this.insertStmt.run({
|
|
23205
|
-
id:
|
|
23393
|
+
id: this.newId(),
|
|
23206
23394
|
findingKey: r.findingKey,
|
|
23207
23395
|
status: FindingStatus.parse(r.status),
|
|
23208
23396
|
method: ResolutionMethod.parse(r.method),
|
|
@@ -23781,16 +23969,16 @@ var ACTION_TO_KIND = {
|
|
|
23781
23969
|
warn: "warned"
|
|
23782
23970
|
};
|
|
23783
23971
|
var ENFORCEMENT_KINDS = ["blocked", "redacted", "warned"];
|
|
23784
|
-
var SCAN_COVERAGE =
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23972
|
+
var SCAN_COVERAGE = {
|
|
23973
|
+
[HARNESS.Antigravity]: { coverage: 60, supported: true },
|
|
23974
|
+
[HARNESS.Api]: { coverage: 0, supported: false },
|
|
23975
|
+
[HARNESS.ChatGpt]: { coverage: 40, supported: true },
|
|
23976
|
+
[HARNESS.ClaudeAi]: { coverage: 40, supported: true },
|
|
23977
|
+
[HARNESS.ClaudeCode]: { coverage: 100, supported: true },
|
|
23978
|
+
[HARNESS.Codex]: { coverage: 80, supported: true },
|
|
23979
|
+
[HARNESS.Copilot]: { coverage: 0, supported: false },
|
|
23980
|
+
[HARNESS.Cursor]: { coverage: 0, supported: false }
|
|
23981
|
+
};
|
|
23794
23982
|
var GRANULARITY = {
|
|
23795
23983
|
"7d": "day",
|
|
23796
23984
|
"30d": "day",
|
|
@@ -23889,9 +24077,22 @@ var SqliteSecurityRepository = class {
|
|
|
23889
24077
|
return Promise.resolve({ total, needsRemediation, bySeverity });
|
|
23890
24078
|
}
|
|
23891
24079
|
// Range is echoed but does not change the result today — coverage is a constant
|
|
23892
|
-
// business fact (see SCAN_COVERAGE), not a measured per-window metric.
|
|
24080
|
+
// business fact (see SCAN_COVERAGE), not a measured per-window metric. Order
|
|
24081
|
+
// comes from Provider.options (the enum's declaration order), not from
|
|
24082
|
+
// SCAN_COVERAGE's own key order — deliberately, not because object literals
|
|
24083
|
+
// leave key order unspecified (ES2015 guarantees insertion order for these
|
|
24084
|
+
// non-integer string keys, so iterating SCAN_COVERAGE directly would be
|
|
24085
|
+
// reliable too). The reason is the schema comment's promise: the returned
|
|
24086
|
+
// order must mirror the generated OpenAPI enum list, which is Provider's
|
|
24087
|
+
// contract, not this table's.
|
|
23893
24088
|
scanCoverage(range) {
|
|
23894
|
-
return Promise.resolve({
|
|
24089
|
+
return Promise.resolve({
|
|
24090
|
+
range,
|
|
24091
|
+
providers: Provider.options.map((provider) => ({
|
|
24092
|
+
provider,
|
|
24093
|
+
...SCAN_COVERAGE[provider]
|
|
24094
|
+
}))
|
|
24095
|
+
});
|
|
23895
24096
|
}
|
|
23896
24097
|
enforcementActions(range) {
|
|
23897
24098
|
const lenMs = RANGE_DAYS[range] * DAY_MS4;
|
|
@@ -23949,10 +24150,10 @@ var SqliteSecurityRepository = class {
|
|
|
23949
24150
|
// count; a superseding open/redetected row means the finding is not
|
|
23950
24151
|
// remediated and is excluded, same invariant as severitySummary. Legacy
|
|
23951
24152
|
// at-rest findings with finding_key IS NULL can never have a resolution row
|
|
23952
|
-
// (the lifecycle is keyed by finding_key), so
|
|
23953
|
-
//
|
|
23954
|
-
//
|
|
23955
|
-
// mirroring this file's other methods.
|
|
24153
|
+
// (the lifecycle is keyed by finding_key), so they cannot reach the driving
|
|
24154
|
+
// set below. One raw-row query (fetch the findings with resolution activity in
|
|
24155
|
+
// the window + each one's latest resolution status/method/resolved_at) +
|
|
24156
|
+
// pure-JS filter/bucket/mean, mirroring this file's other methods.
|
|
23956
24157
|
mttrTrend(range) {
|
|
23957
24158
|
const granularity = granularityFor(range);
|
|
23958
24159
|
const bucketMs = (granularity === "day" ? 1 : 7) * DAY_MS4;
|
|
@@ -23968,29 +24169,80 @@ var SqliteSecurityRepository = class {
|
|
|
23968
24169
|
// started_at the upsert overwrites onto inspection_findings.audit_event_id.
|
|
23969
24170
|
// COALESCE onto the parent event's started_at defends against any
|
|
23970
24171
|
// legacy/edge row the backfill left null.
|
|
23971
|
-
`SELECT
|
|
24172
|
+
`SELECT DISTINCT f.finding_key AS finding_key,
|
|
24173
|
+
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at, d.severity AS severity,
|
|
23972
24174
|
latest.status AS latest_status,
|
|
23973
24175
|
latest.method AS latest_method,
|
|
23974
24176
|
latest.resolved_at AS latest_resolved_at
|
|
23975
|
-
FROM
|
|
23976
|
-
JOIN
|
|
23977
|
-
JOIN
|
|
24177
|
+
FROM finding_resolution fr
|
|
24178
|
+
CROSS JOIN inspection_findings f ON f.finding_key = fr.finding_key
|
|
24179
|
+
CROSS JOIN audit_events e ON e.id = f.audit_event_id
|
|
24180
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
23978
24181
|
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
23979
24182
|
ON latest.finding_key = f.finding_key
|
|
23980
|
-
WHERE
|
|
23981
|
-
AND e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
23982
|
-
|
|
23983
|
-
SELECT 1 FROM finding_resolution fr
|
|
23984
|
-
WHERE fr.finding_key = f.finding_key
|
|
23985
|
-
AND fr.resolved_at >= :windowStart
|
|
23986
|
-
)`
|
|
23987
|
-
// The EXISTS is a SUPERSET prefilter that bounds the scan to keys with
|
|
23988
|
-
// any resolution activity at/after the window start — a row this method
|
|
24183
|
+
WHERE fr.resolved_at >= :windowStart
|
|
24184
|
+
AND e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})`
|
|
24185
|
+
// `fr` is a SUPERSET prefilter, not the answer: a finding this method
|
|
23989
24186
|
// ultimately counts has its LATEST resolution inside the window, which
|
|
23990
|
-
// implies
|
|
23991
|
-
// latest-wins + status/method + window gate
|
|
23992
|
-
// dialect-agnostic.
|
|
23993
|
-
//
|
|
24187
|
+
// implies a resolution row at/after the window start exists, so nothing
|
|
24188
|
+
// wanted is dropped. The exact latest-wins + status/method + window gate
|
|
24189
|
+
// stays in JS below, dialect-agnostic. `f.finding_key IS NOT NULL` is
|
|
24190
|
+
// implied rather than dropped — the join key comes from
|
|
24191
|
+
// finding_resolution, whose finding_key is NOT NULL.
|
|
24192
|
+
//
|
|
24193
|
+
// IT IS THE DRIVING TABLE THAT MAKES THAT PREFILTER A BOUND, which is
|
|
24194
|
+
// the correction this replaced. Spelled as an `EXISTS` in the WHERE it
|
|
24195
|
+
// READ as a bound and was not one: SQLite drove from `audit_events` on
|
|
24196
|
+
// event_type, joined every capture event to its findings, and evaluated
|
|
24197
|
+
// the EXISTS last — bounding the RESULT and not the scan, so a 7d request
|
|
24198
|
+
// still cost the store's whole trackable history. Measured at 44.6 ms on
|
|
24199
|
+
// 50,000 events and 171.3 ms on 150,000 — linear in the STORE, and in
|
|
24200
|
+
// both cases returning rows for a window holding a fraction of it.
|
|
24201
|
+
//
|
|
24202
|
+
// Two things carry it, and they answer DIFFERENT halves — which is worth
|
|
24203
|
+
// stating precisely, because the obvious reading (both are needed for the
|
|
24204
|
+
// speed) is wrong and was measured to be wrong:
|
|
24205
|
+
//
|
|
24206
|
+
// - **`CROSS JOIN`** is the whole of the store-size fix. In SQLite the
|
|
24207
|
+
// keyword is semantically identical to JOIN and exists only to stop the
|
|
24208
|
+
// tables being reordered; with plain JOINs the planner puts `e` back on
|
|
24209
|
+
// the outside, because with no ANALYZE statistics it prices
|
|
24210
|
+
// `event_type IN (...)` as a selective probe. Reverting it alone takes
|
|
24211
|
+
// the 2k->20k flatness ratio from 1.32 to 16.87.
|
|
24212
|
+
// - **`idx_finding_resolution_resolved_at`** (migration 0021) makes
|
|
24213
|
+
// `resolved_at >= :windowStart` a range SEARCH instead of a bare
|
|
24214
|
+
// `SCAN fr` — finding_key was this table's only index before it, so the
|
|
24215
|
+
// range had none. It buys NO flatness in store size: remove it and the
|
|
24216
|
+
// ratio above does not move, because the latest-resolution derived
|
|
24217
|
+
// table already passes over the whole of finding_resolution, so this
|
|
24218
|
+
// read is O(resolutions) either way and resolutions are not the store.
|
|
24219
|
+
// What it buys is the criterion `hot-read-query-plans.test.ts` enforces
|
|
24220
|
+
// — no hot read may pass over a table with no index — and that is the
|
|
24221
|
+
// guard that goes red when it is dropped. Neither test catches the
|
|
24222
|
+
// other's defect.
|
|
24223
|
+
//
|
|
24224
|
+
// SELECT DISTINCT is a CORRECTNESS requirement of driving from `fr`, not a
|
|
24225
|
+
// tidy-up. finding_resolution is append-only, so a key that was fixed,
|
|
24226
|
+
// redetected and fixed again carries several rows inside one window and
|
|
24227
|
+
// matches once per row — and the value below is a MEAN, so a key matched
|
|
24228
|
+
// three times is a key weighted three times.
|
|
24229
|
+
//
|
|
24230
|
+
// The skew is easy to argue away and the argument is wrong, so it is worth
|
|
24231
|
+
// recording. Duplicate rows for ONE key are identical (every projected
|
|
24232
|
+
// column is per-key: `latest.*` is latest-wins, `first_detected_at` is
|
|
24233
|
+
// preserved), so sums and counts scale together and that key's own mean
|
|
24234
|
+
// does not move. What moves is a bucket holding TWO findings that duplicate
|
|
24235
|
+
// UNEQUALLY: three rows for a 5.9-day fix and one for a 1.9-day fix average
|
|
24236
|
+
// 4.9 days weighted against 3.9 unweighted. Measured, and pinned by
|
|
24237
|
+
// `security.test.ts`'s "weights a finding ONCE however many resolution rows
|
|
24238
|
+
// it has inside the window" — which needed a fixture built for it, since no
|
|
24239
|
+
// single-key case can show it.
|
|
24240
|
+
//
|
|
24241
|
+
// `finding_key` is selected to make the DISTINCT dedup by KEY rather than
|
|
24242
|
+
// by value tuple. On the other columns alone, two genuinely different
|
|
24243
|
+
// findings sharing a severity, a first-detection event and a resolution
|
|
24244
|
+
// instant — one commit fixing two secrets in one file — are one tuple, and
|
|
24245
|
+
// collapsing them would under-count in the other direction.
|
|
23994
24246
|
),
|
|
23995
24247
|
{ windowStart }
|
|
23996
24248
|
);
|
|
@@ -24048,16 +24300,47 @@ var SqliteSecurityRepository = class {
|
|
|
24048
24300
|
}
|
|
24049
24301
|
// Recently-resolved activity feed: findings whose finding_key's LATEST
|
|
24050
24302
|
// finding_resolution row is status:'resolved'/method:'fixed-at-source' —
|
|
24051
|
-
// same latest-resolution-wins
|
|
24052
|
-
//
|
|
24053
|
-
//
|
|
24054
|
-
//
|
|
24055
|
-
//
|
|
24056
|
-
//
|
|
24057
|
-
//
|
|
24058
|
-
//
|
|
24059
|
-
//
|
|
24060
|
-
//
|
|
24303
|
+
// same latest-resolution-wins derived table as severitySummary / mttrTrend
|
|
24304
|
+
// (NOT a plain JOIN, which would surface every historical resolution row for
|
|
24305
|
+
// a key rather than just its current disposition). A key whose latest row is
|
|
24306
|
+
// a superseding 'open'/'redetected' row (the same secret came back) is
|
|
24307
|
+
// excluded — it is not currently resolved. Legacy at-rest findings with
|
|
24308
|
+
// finding_key IS NULL are excluded outright (the resolution lifecycle can
|
|
24309
|
+
// never attach to them). Path comes from the finding's parent event
|
|
24310
|
+
// (event_type 'code_change', attributes.file_path) — mirrors resolutions.ts's
|
|
24311
|
+
// openAtRestStmt accessor. Ordered by resolved_at DESC, capped at `limit`.
|
|
24312
|
+
//
|
|
24313
|
+
// THE RESOLUTION SET DRIVES THIS QUERY, and that is a correctness property of
|
|
24314
|
+
// the plan rather than a preference. Written the other way round — driving
|
|
24315
|
+
// from inspection_findings/audit_events with `latest` LEFT JOINed on — SQLite
|
|
24316
|
+
// cannot use the join key: `f` is reached FROM `latest` by finding_key, so
|
|
24317
|
+
// `latest` gets probed on (rn, status, method) instead and the plan enumerates
|
|
24318
|
+
// every (code_change event x resolved key) pair before `f` can reject it. That
|
|
24319
|
+
// is a cross product, and it is quadratic in the store: measured at 10,966 ms
|
|
24320
|
+
// on a corpus of 50,000 events carrying 2,051 resolutions, against 20 rows
|
|
24321
|
+
// returned. It was invisible for as long as it was, and reported at 8 ms,
|
|
24322
|
+
// because an empty finding_resolution table makes the inner side empty and the
|
|
24323
|
+
// cross product collapses to nothing — so the shape is only observable on a
|
|
24324
|
+
// corpus that seeds resolutions.
|
|
24325
|
+
//
|
|
24326
|
+
// Driving from `latest` instead makes every step below it a unique-index or
|
|
24327
|
+
// primary-key lookup (uq_inspection_findings_key, then audit_events' own PK),
|
|
24328
|
+
// so the cost is the derived table's own — linear in resolutions, which is
|
|
24329
|
+
// what this feed is legitimately about.
|
|
24330
|
+
//
|
|
24331
|
+
// CROSS JOIN is what actually pins that, and it is load-bearing rather than
|
|
24332
|
+
// decorative: in SQLite the keyword is semantically identical to JOIN and
|
|
24333
|
+
// exists only to stop the optimizer reordering the tables. Written as plain
|
|
24334
|
+
// JOINs in this order the planner puts `e` back on the outside — it has no
|
|
24335
|
+
// ANALYZE statistics to price the alternatives with, so it takes
|
|
24336
|
+
// `event_type = 'code_change'` for a selective index probe and rebuilds the
|
|
24337
|
+
// cross product. The FROM order alone was measured to change the plan not at
|
|
24338
|
+
// all.
|
|
24339
|
+
//
|
|
24340
|
+
// The LEFT JOIN it replaced was already an inner join in effect: three
|
|
24341
|
+
// `latest.*` predicates sit in the WHERE, and each of them is false for a
|
|
24342
|
+
// null-extended row. Spelling it JOIN changes no row and stops the plan
|
|
24343
|
+
// reading as though the findings side could drive.
|
|
24061
24344
|
recentlyResolved(limit = 20) {
|
|
24062
24345
|
const rows = allRows(
|
|
24063
24346
|
this.db.prepare(
|
|
@@ -24067,17 +24350,15 @@ var SqliteSecurityRepository = class {
|
|
|
24067
24350
|
json_extract(e.attributes, '$.file_path') AS path,
|
|
24068
24351
|
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at,
|
|
24069
24352
|
latest.resolved_at AS latest_resolved_at
|
|
24070
|
-
FROM
|
|
24071
|
-
JOIN
|
|
24072
|
-
JOIN
|
|
24073
|
-
|
|
24074
|
-
|
|
24075
|
-
WHERE e.event_type = 'code_change'
|
|
24076
|
-
AND f.finding_key IS NOT NULL
|
|
24077
|
-
AND latest.status = 'resolved'
|
|
24353
|
+
FROM ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
24354
|
+
CROSS JOIN inspection_findings f ON f.finding_key = latest.finding_key
|
|
24355
|
+
CROSS JOIN audit_events e ON e.id = f.audit_event_id
|
|
24356
|
+
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
24357
|
+
WHERE latest.status = 'resolved'
|
|
24078
24358
|
AND latest.method = 'fixed-at-source'
|
|
24079
24359
|
AND latest.resolved_at IS NOT NULL
|
|
24080
|
-
|
|
24360
|
+
AND e.event_type = 'code_change'
|
|
24361
|
+
ORDER BY latest.resolved_at DESC
|
|
24081
24362
|
LIMIT :limit`
|
|
24082
24363
|
),
|
|
24083
24364
|
{ limit }
|
|
@@ -25014,6 +25295,7 @@ function openAndInitialize(file2) {
|
|
|
25014
25295
|
function openLocalDatabase(dir) {
|
|
25015
25296
|
ensureDataDirSync(dir);
|
|
25016
25297
|
const file2 = join2(dir, DB_FILENAME);
|
|
25298
|
+
reapStalePartials(file2);
|
|
25017
25299
|
const {
|
|
25018
25300
|
db,
|
|
25019
25301
|
events,
|
|
@@ -25334,11 +25616,79 @@ function migrateLegacyLayout(base = defaultDataDir()) {
|
|
|
25334
25616
|
}
|
|
25335
25617
|
}
|
|
25336
25618
|
|
|
25337
|
-
// ../../packages/persistence/src/settings.ts
|
|
25619
|
+
// ../../packages/persistence/src/managed-settings.ts
|
|
25338
25620
|
import { readFileSync as readFileSync3 } from "fs";
|
|
25621
|
+
import { posix, win32 } from "path";
|
|
25622
|
+
function managedSettingsPaths(platform2 = process.platform) {
|
|
25623
|
+
if (platform2 === "darwin") {
|
|
25624
|
+
return [
|
|
25625
|
+
posix.join("/Library", "Application Support", "AKASecurity", MANAGED_SETTINGS_FILENAME),
|
|
25626
|
+
posix.join("/Library", "Managed Preferences", MANAGED_SETTINGS_FILENAME)
|
|
25627
|
+
];
|
|
25628
|
+
}
|
|
25629
|
+
if (platform2 === "win32") {
|
|
25630
|
+
return [win32.join("C:\\", "ProgramData", "AKASecurity", MANAGED_SETTINGS_FILENAME)];
|
|
25631
|
+
}
|
|
25632
|
+
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
25633
|
+
}
|
|
25634
|
+
function readManagedSettings(paths = managedSettingsPaths()) {
|
|
25635
|
+
for (const path of paths) {
|
|
25636
|
+
let text;
|
|
25637
|
+
try {
|
|
25638
|
+
text = readFileSync3(path, "utf8");
|
|
25639
|
+
} catch {
|
|
25640
|
+
continue;
|
|
25641
|
+
}
|
|
25642
|
+
const record2 = parseJsonObject(text);
|
|
25643
|
+
if (!record2) continue;
|
|
25644
|
+
const parsed = ManagedSettings.safeParse(record2);
|
|
25645
|
+
if (parsed.success) return parsed.data;
|
|
25646
|
+
}
|
|
25647
|
+
return null;
|
|
25648
|
+
}
|
|
25649
|
+
function overlayManagedSettings(settings, managed, now = () => /* @__PURE__ */ new Date()) {
|
|
25650
|
+
if (!managed) return settings;
|
|
25651
|
+
const { values } = managed;
|
|
25652
|
+
const merged = { ...settings };
|
|
25653
|
+
if (values.runMode !== void 0) merged.runMode = values.runMode;
|
|
25654
|
+
if (values.controlPlane !== void 0) {
|
|
25655
|
+
merged.controlPlane = {
|
|
25656
|
+
...values.controlPlane,
|
|
25657
|
+
// The administrator pinned WHICH deployment, not WHEN this machine
|
|
25658
|
+
// joined it. Keep the user's own attach time when the endpoint is
|
|
25659
|
+
// unchanged, so a managed machine does not appear to re-attach on every
|
|
25660
|
+
// read; stamp a fresh one when the administrator moved it.
|
|
25661
|
+
attachedAt: settings.controlPlane?.endpoint === values.controlPlane.endpoint ? settings.controlPlane.attachedAt : now().toISOString()
|
|
25662
|
+
};
|
|
25663
|
+
}
|
|
25664
|
+
if (values.historicalAccess !== void 0) merged.historicalAccess = values.historicalAccess;
|
|
25665
|
+
if (values.vaultKeyCustody !== void 0) merged.vaultKeyCustody = values.vaultKeyCustody;
|
|
25666
|
+
if (values.vaultInlineReveal !== void 0) merged.vaultInlineReveal = values.vaultInlineReveal;
|
|
25667
|
+
if (values.dataSharesInPlace !== void 0) merged.dataSharesInPlace = values.dataSharesInPlace;
|
|
25668
|
+
if (values.vaultConsent !== void 0) {
|
|
25669
|
+
merged.vaultConsent = values.vaultConsent ? (
|
|
25670
|
+
// Keep an existing valid grant so its acknowledgedAt survives; mint one
|
|
25671
|
+
// at the current version otherwise.
|
|
25672
|
+
settings.vaultConsent?.version === VAULT_CONSENT_VERSION ? settings.vaultConsent : { acknowledgedAt: now().toISOString(), version: VAULT_CONSENT_VERSION }
|
|
25673
|
+
) : void 0;
|
|
25674
|
+
}
|
|
25675
|
+
if (values.modelJudgeConsent !== void 0) {
|
|
25676
|
+
merged.modelJudgeConsent = values.modelJudgeConsent ? settings.modelJudgeConsent?.payloadVersion === MODEL_JUDGE_PAYLOAD_VERSION ? settings.modelJudgeConsent : {
|
|
25677
|
+
acknowledgedAt: now().toISOString(),
|
|
25678
|
+
payloadVersion: MODEL_JUDGE_PAYLOAD_VERSION
|
|
25679
|
+
} : void 0;
|
|
25680
|
+
}
|
|
25681
|
+
return merged;
|
|
25682
|
+
}
|
|
25683
|
+
|
|
25684
|
+
// ../../packages/persistence/src/settings.ts
|
|
25685
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
25339
25686
|
import { join as join5 } from "path";
|
|
25340
25687
|
var SETTINGS_FILENAME = "settings.json";
|
|
25341
25688
|
function readWorkspaceSettings(base = defaultDataDir()) {
|
|
25689
|
+
return overlayManagedSettings(readUserSettings(base), readManagedSettings());
|
|
25690
|
+
}
|
|
25691
|
+
function readUserSettings(base) {
|
|
25342
25692
|
const record2 = readJson(join5(settingsDir(base), SETTINGS_FILENAME));
|
|
25343
25693
|
if (!record2) return defaultWorkspaceSettings();
|
|
25344
25694
|
try {
|
|
@@ -25350,7 +25700,7 @@ function readWorkspaceSettings(base = defaultDataDir()) {
|
|
|
25350
25700
|
function readJson(file2) {
|
|
25351
25701
|
let text;
|
|
25352
25702
|
try {
|
|
25353
|
-
text =
|
|
25703
|
+
text = readFileSync4(file2, "utf8");
|
|
25354
25704
|
} catch {
|
|
25355
25705
|
return null;
|
|
25356
25706
|
}
|
|
@@ -25369,15 +25719,7 @@ import {
|
|
|
25369
25719
|
// ../../packages/persistence/src/vault/key-provider.ts
|
|
25370
25720
|
import { execFileSync } from "child_process";
|
|
25371
25721
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25372
|
-
import {
|
|
25373
|
-
chmodSync as chmodSync2,
|
|
25374
|
-
mkdirSync as mkdirSync2,
|
|
25375
|
-
readFileSync as readFileSync4,
|
|
25376
|
-
renameSync as renameSync4,
|
|
25377
|
-
rmSync as rmSync4,
|
|
25378
|
-
statSync as statSync3,
|
|
25379
|
-
writeFileSync as writeFileSync3
|
|
25380
|
-
} from "fs";
|
|
25722
|
+
import { chmodSync as chmodSync2, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync4, statSync as statSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
25381
25723
|
import { join as join6 } from "path";
|
|
25382
25724
|
|
|
25383
25725
|
// ../../packages/persistence/src/vault/vault.ts
|
|
@@ -25473,7 +25815,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
25473
25815
|
}
|
|
25474
25816
|
|
|
25475
25817
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
25476
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
25818
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync7, realpathSync, statSync as statSync5 } from "fs";
|
|
25477
25819
|
import { homedir as homedir2 } from "os";
|
|
25478
25820
|
import { basename as basename4, join as join10 } from "path";
|
|
25479
25821
|
|
|
@@ -26181,6 +26523,10 @@ function luhnCheck(digits) {
|
|
|
26181
26523
|
// ../../packages/detections/src/engine.ts
|
|
26182
26524
|
var keywordMatcher = new KeywordMatcher2();
|
|
26183
26525
|
var regexMatcher = new RegexMatcher2();
|
|
26526
|
+
var MATCHERS = {
|
|
26527
|
+
keyword: (text, rule) => keywordMatcher.match(text, rule),
|
|
26528
|
+
regex: (text, rule) => regexMatcher.match(text, rule)
|
|
26529
|
+
};
|
|
26184
26530
|
var packs = /* @__PURE__ */ new Map();
|
|
26185
26531
|
var POST_VALIDATORS = {
|
|
26186
26532
|
entropy: (value, config2) => isHighEntropy(value, numberOption(config2, "threshold"), numberOption(config2, "minLength")),
|
|
@@ -26196,8 +26542,7 @@ function passesPostValidators(rule, value) {
|
|
|
26196
26542
|
for (const ref of validators) {
|
|
26197
26543
|
const name = typeof ref === "string" ? ref : ref.name;
|
|
26198
26544
|
const config2 = typeof ref === "string" ? void 0 : ref.config;
|
|
26199
|
-
|
|
26200
|
-
if (validate && !validate(value, config2)) return false;
|
|
26545
|
+
if (!POST_VALIDATORS[name](value, config2)) return false;
|
|
26201
26546
|
}
|
|
26202
26547
|
return true;
|
|
26203
26548
|
}
|
|
@@ -26258,14 +26603,7 @@ function scan(text, rules, context) {
|
|
|
26258
26603
|
const candidates = [];
|
|
26259
26604
|
for (const rule of ruleset) {
|
|
26260
26605
|
if (!ruleApplies(rule, extension)) continue;
|
|
26261
|
-
|
|
26262
|
-
if (rule.matcher.type === "keyword") {
|
|
26263
|
-
spans = keywordMatcher.match(text, rule);
|
|
26264
|
-
} else if (rule.matcher.type === "regex") {
|
|
26265
|
-
spans = regexMatcher.match(text, rule);
|
|
26266
|
-
} else {
|
|
26267
|
-
continue;
|
|
26268
|
-
}
|
|
26606
|
+
const spans = MATCHERS[rule.matcher.type](text, rule);
|
|
26269
26607
|
for (const span of spans) {
|
|
26270
26608
|
const rawMatch = text.slice(span.start, span.end);
|
|
26271
26609
|
if (!passesPostValidators(rule, rawMatch)) continue;
|
|
@@ -26503,6 +26841,7 @@ function whole(command) {
|
|
|
26503
26841
|
}
|
|
26504
26842
|
|
|
26505
26843
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
26844
|
+
var BUDGET_MS = 100;
|
|
26506
26845
|
var EXPONENTIAL_UNITS = [
|
|
26507
26846
|
"a",
|
|
26508
26847
|
"0",
|
|
@@ -26526,6 +26865,8 @@ var EXPONENTIAL_PROBES = EXPONENTIAL_UNITS.flatMap(
|
|
|
26526
26865
|
var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map(
|
|
26527
26866
|
(unit) => unit.repeat(1e4).slice(0, 4e4) + "!"
|
|
26528
26867
|
);
|
|
26868
|
+
var CPU_CORROBORATION_SHARE = 0.2;
|
|
26869
|
+
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
26529
26870
|
|
|
26530
26871
|
// ../../rules/code-flaws/auth-jwt-no-verify.json
|
|
26531
26872
|
var auth_jwt_no_verify_default = {
|
|
@@ -28605,7 +28946,7 @@ function maskText(text) {
|
|
|
28605
28946
|
}
|
|
28606
28947
|
|
|
28607
28948
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
28608
|
-
import { existsSync as existsSync6, readFileSync as
|
|
28949
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, statSync as statSync4 } from "fs";
|
|
28609
28950
|
import { basename as basename3, dirname as dirname2, isAbsolute, join as join9, sep as sep2 } from "path";
|
|
28610
28951
|
function resolveRepoIdentity(cwd) {
|
|
28611
28952
|
try {
|
|
@@ -28708,7 +29049,7 @@ function resolveGitContext(root) {
|
|
|
28708
29049
|
}
|
|
28709
29050
|
function safeRead(path) {
|
|
28710
29051
|
try {
|
|
28711
|
-
return
|
|
29052
|
+
return readFileSync6(path, "utf8");
|
|
28712
29053
|
} catch {
|
|
28713
29054
|
return void 0;
|
|
28714
29055
|
}
|
|
@@ -29208,7 +29549,7 @@ function dedupeMcpServers(servers) {
|
|
|
29208
29549
|
}
|
|
29209
29550
|
function readOptional(path) {
|
|
29210
29551
|
try {
|
|
29211
|
-
return
|
|
29552
|
+
return readFileSync7(path, "utf8");
|
|
29212
29553
|
} catch {
|
|
29213
29554
|
return void 0;
|
|
29214
29555
|
}
|
|
@@ -29227,6 +29568,11 @@ function str2(value) {
|
|
|
29227
29568
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
29228
29569
|
}
|
|
29229
29570
|
|
|
29571
|
+
// ../../packages/plugin-sdk/src/data-gateway.ts
|
|
29572
|
+
function offersMaintenance(gateway, member) {
|
|
29573
|
+
return typeof gateway[member] === "function";
|
|
29574
|
+
}
|
|
29575
|
+
|
|
29230
29576
|
// ../../packages/plugin-sdk/src/events.ts
|
|
29231
29577
|
import { createHash as createHash4, randomUUID as randomUUID13 } from "crypto";
|
|
29232
29578
|
|
|
@@ -29235,6 +29581,39 @@ import { existsSync as existsSync7 } from "fs";
|
|
|
29235
29581
|
import { fileURLToPath } from "url";
|
|
29236
29582
|
import { Worker } from "worker_threads";
|
|
29237
29583
|
|
|
29584
|
+
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
29585
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
29586
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
29587
|
+
import { join as join11 } from "path";
|
|
29588
|
+
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
29589
|
+
try {
|
|
29590
|
+
return { matcher: (0, import_ignore.default)().add(readFileSync8(join11(dir, filename), "utf8")), anchorLen };
|
|
29591
|
+
} catch {
|
|
29592
|
+
return void 0;
|
|
29593
|
+
}
|
|
29594
|
+
}
|
|
29595
|
+
function relToAnchor(dirRel, anchorLen, name) {
|
|
29596
|
+
if (anchorLen === dirRel.length) return name;
|
|
29597
|
+
return `${dirRel.slice(anchorLen === 0 ? 0 : anchorLen + 1)}/${name}`;
|
|
29598
|
+
}
|
|
29599
|
+
function evaluateIgnore(layers, dirRel, name, isDir) {
|
|
29600
|
+
const suffix = isDir ? "/" : "";
|
|
29601
|
+
for (let i = layers.length - 1; i >= 0; i--) {
|
|
29602
|
+
const layer = layers[i];
|
|
29603
|
+
if (layer === void 0) continue;
|
|
29604
|
+
const verdict = layer.matcher.test(relToAnchor(dirRel, layer.anchorLen, name) + suffix);
|
|
29605
|
+
if (verdict.ignored) return "ignored";
|
|
29606
|
+
if (verdict.unignored) return "unignored";
|
|
29607
|
+
}
|
|
29608
|
+
return "unmatched";
|
|
29609
|
+
}
|
|
29610
|
+
function childRel(dirRel, name) {
|
|
29611
|
+
return dirRel === "" ? name : `${dirRel}/${name}`;
|
|
29612
|
+
}
|
|
29613
|
+
function withLayer(layers, layer) {
|
|
29614
|
+
return layer ? [...layers, layer] : layers;
|
|
29615
|
+
}
|
|
29616
|
+
|
|
29238
29617
|
// ../../packages/plugin-sdk/src/inventory-resolver.ts
|
|
29239
29618
|
import { arch, hostname as hostname4, platform, release } from "os";
|
|
29240
29619
|
function resolveInventoryContext(input) {
|
|
@@ -29265,21 +29644,21 @@ function resolveInventoryContext(input) {
|
|
|
29265
29644
|
}
|
|
29266
29645
|
|
|
29267
29646
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
29268
|
-
import { mkdirSync as
|
|
29269
|
-
import { join as
|
|
29647
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
|
|
29648
|
+
import { join as join12 } from "path";
|
|
29270
29649
|
var SESSION_START_MARKER = "session-start-last";
|
|
29271
29650
|
function claimSessionStart(dataDir2, sessionId) {
|
|
29272
29651
|
return claimOncePerSession(dataDir2, SESSION_START_MARKER, sessionId);
|
|
29273
29652
|
}
|
|
29274
29653
|
function claimOncePerSession(dataDir2, marker, sessionId) {
|
|
29275
29654
|
if (!sessionId) return true;
|
|
29276
|
-
const path =
|
|
29655
|
+
const path = join12(dataDir2, marker);
|
|
29277
29656
|
try {
|
|
29278
|
-
if (
|
|
29657
|
+
if (readFileSync9(path, "utf8") === sessionId) return false;
|
|
29279
29658
|
} catch {
|
|
29280
29659
|
}
|
|
29281
29660
|
try {
|
|
29282
|
-
|
|
29661
|
+
mkdirSync2(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
29283
29662
|
writeFileSync5(path, sessionId, { mode: DATA_FILE_MODE });
|
|
29284
29663
|
} catch {
|
|
29285
29664
|
}
|
|
@@ -29291,9 +29670,8 @@ import { readdirSync as readdirSync3, realpathSync as realpathSync2 } from "fs";
|
|
|
29291
29670
|
import { basename as basename5, dirname as dirname3, sep as sep3 } from "path";
|
|
29292
29671
|
|
|
29293
29672
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
29294
|
-
|
|
29295
|
-
import {
|
|
29296
|
-
import { basename as basename6, join as join12 } from "path";
|
|
29673
|
+
import { existsSync as existsSync8, readdirSync as readdirSync4 } from "fs";
|
|
29674
|
+
import { basename as basename6, join as join13 } from "path";
|
|
29297
29675
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
29298
29676
|
".git",
|
|
29299
29677
|
"node_modules",
|
|
@@ -29311,28 +29689,10 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
29311
29689
|
".cache"
|
|
29312
29690
|
]);
|
|
29313
29691
|
var MAX_FILES = 2e4;
|
|
29314
|
-
|
|
29315
|
-
|
|
29316
|
-
const content = readFileSync8(join12(dir, ".gitignore"), "utf8");
|
|
29317
|
-
return { matcher: (0, import_ignore.default)().add(content), anchorLen };
|
|
29318
|
-
} catch {
|
|
29319
|
-
return void 0;
|
|
29320
|
-
}
|
|
29321
|
-
}
|
|
29322
|
-
function relToAnchor(dirRel, anchorLen, name) {
|
|
29323
|
-
if (anchorLen === dirRel.length) return name;
|
|
29324
|
-
return `${dirRel.slice(anchorLen === 0 ? 0 : anchorLen + 1)}/${name}`;
|
|
29325
|
-
}
|
|
29692
|
+
var PROJECT_WALK_BOUNDS = { maxDepth: 64, budgetMs: 4e3 };
|
|
29693
|
+
var DEADLINE_CHECK_INTERVAL = 512;
|
|
29326
29694
|
function isIgnored(layers, dirRel, name, isDir) {
|
|
29327
|
-
|
|
29328
|
-
for (let i = layers.length - 1; i >= 0; i--) {
|
|
29329
|
-
const layer = layers[i];
|
|
29330
|
-
if (layer === void 0) continue;
|
|
29331
|
-
const verdict = layer.matcher.test(relToAnchor(dirRel, layer.anchorLen, name) + suffix);
|
|
29332
|
-
if (verdict.ignored) return true;
|
|
29333
|
-
if (verdict.unignored) return false;
|
|
29334
|
-
}
|
|
29335
|
-
return false;
|
|
29695
|
+
return evaluateIgnore(layers, dirRel, name, isDir) === "ignored";
|
|
29336
29696
|
}
|
|
29337
29697
|
var GENERATED_FILES = /* @__PURE__ */ new Set([
|
|
29338
29698
|
"pnpm-lock.yaml",
|
|
@@ -29383,9 +29743,11 @@ function classifyOrigin(relPath, name) {
|
|
|
29383
29743
|
}
|
|
29384
29744
|
return "source";
|
|
29385
29745
|
}
|
|
29386
|
-
function resolveProjectFiles(cwd) {
|
|
29746
|
+
function resolveProjectFiles(cwd, opts = {}) {
|
|
29747
|
+
const bounds = opts.bounds ?? PROJECT_WALK_BOUNDS;
|
|
29748
|
+
const now = opts.now ?? (() => performance.now());
|
|
29387
29749
|
try {
|
|
29388
|
-
let visit2 = function(dir, dirRel, layers) {
|
|
29750
|
+
let visit2 = function(dir, dirRel, layers, depth) {
|
|
29389
29751
|
let dirents;
|
|
29390
29752
|
try {
|
|
29391
29753
|
dirents = readdirSync4(dir, { withFileTypes: true, encoding: "utf8" });
|
|
@@ -29393,22 +29755,33 @@ function resolveProjectFiles(cwd) {
|
|
|
29393
29755
|
walk.lostSubtree = true;
|
|
29394
29756
|
return false;
|
|
29395
29757
|
}
|
|
29396
|
-
|
|
29397
|
-
|
|
29758
|
+
if (now() > deadline) {
|
|
29759
|
+
walk.omitted = true;
|
|
29760
|
+
return true;
|
|
29761
|
+
}
|
|
29762
|
+
const dirLayers = withLayer(layers, readIgnoreLayer(dir, ".gitignore", dirRel.length));
|
|
29398
29763
|
for (const entry of dirents) {
|
|
29764
|
+
walk.seen++;
|
|
29765
|
+
if (walk.seen % DEADLINE_CHECK_INTERVAL === 0 && now() > deadline) {
|
|
29766
|
+
walk.omitted = true;
|
|
29767
|
+
return true;
|
|
29768
|
+
}
|
|
29399
29769
|
if (entry.isDirectory()) {
|
|
29400
29770
|
if (SKIP_DIRS.has(entry.name) || isIgnored(dirLayers, dirRel, entry.name, true)) continue;
|
|
29401
|
-
const fullPath =
|
|
29402
|
-
if (existsSync8(
|
|
29403
|
-
|
|
29404
|
-
|
|
29771
|
+
const fullPath = join13(dir, entry.name);
|
|
29772
|
+
if (existsSync8(join13(fullPath, ".git"))) continue;
|
|
29773
|
+
if (depth >= bounds.maxDepth) {
|
|
29774
|
+
walk.omitted = true;
|
|
29775
|
+
continue;
|
|
29776
|
+
}
|
|
29777
|
+
if (visit2(fullPath, childRel(dirRel, entry.name), dirLayers, depth + 1)) return true;
|
|
29405
29778
|
continue;
|
|
29406
29779
|
}
|
|
29407
29780
|
if (!entry.isFile()) continue;
|
|
29408
29781
|
if (entry.name === ".git") continue;
|
|
29409
29782
|
if (isIgnored(dirLayers, dirRel, entry.name, false)) continue;
|
|
29410
29783
|
if (files.length >= MAX_FILES) return true;
|
|
29411
|
-
const relPath = dirRel
|
|
29784
|
+
const relPath = childRel(dirRel, entry.name);
|
|
29412
29785
|
files.push({
|
|
29413
29786
|
path: relPath,
|
|
29414
29787
|
name: basename6(entry.name),
|
|
@@ -29424,8 +29797,9 @@ function resolveProjectFiles(cwd) {
|
|
|
29424
29797
|
const root = worktree;
|
|
29425
29798
|
const isLinkedCheckout = resolveHeadRoot(cwd) !== worktree;
|
|
29426
29799
|
const files = [];
|
|
29427
|
-
const walk = { lostSubtree: false };
|
|
29428
|
-
const
|
|
29800
|
+
const walk = { lostSubtree: false, omitted: false, seen: 0 };
|
|
29801
|
+
const deadline = now() + bounds.budgetMs;
|
|
29802
|
+
const truncated = visit2(root, "", [], 0) || walk.lostSubtree || walk.omitted || isLinkedCheckout;
|
|
29429
29803
|
if (files.length === 0) return void 0;
|
|
29430
29804
|
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
29431
29805
|
return { files, truncated, scannedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -29495,16 +29869,16 @@ import { randomUUID as randomUUID14 } from "crypto";
|
|
|
29495
29869
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
29496
29870
|
|
|
29497
29871
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
29498
|
-
import { mkdirSync as
|
|
29499
|
-
import { join as
|
|
29872
|
+
import { mkdirSync as mkdirSync3, statSync as statSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
29873
|
+
import { join as join14 } from "path";
|
|
29500
29874
|
function throttled(dataDir2, markerName, windowMs) {
|
|
29501
|
-
const marker =
|
|
29875
|
+
const marker = join14(dataDir2, markerName);
|
|
29502
29876
|
try {
|
|
29503
29877
|
if (Date.now() - statSync6(marker).mtimeMs < windowMs) return true;
|
|
29504
29878
|
} catch {
|
|
29505
29879
|
}
|
|
29506
29880
|
try {
|
|
29507
|
-
|
|
29881
|
+
mkdirSync3(dataDir2, { recursive: true, mode: DATA_DIR_MODE });
|
|
29508
29882
|
writeFileSync6(marker, String(Date.now()), { mode: DATA_FILE_MODE });
|
|
29509
29883
|
} catch {
|
|
29510
29884
|
}
|
|
@@ -29525,6 +29899,8 @@ var StandaloneDataGateway = class {
|
|
|
29525
29899
|
db;
|
|
29526
29900
|
// Kept for the fingerprint key lookup (exception.key lives beside the store).
|
|
29527
29901
|
dataDir;
|
|
29902
|
+
// One notice per gateway — see warnRulesetDiscarded.
|
|
29903
|
+
warnedRulesetDiscarded = false;
|
|
29528
29904
|
constructor(dataDir2, detections = [], meta3) {
|
|
29529
29905
|
this.db = openLocalDatabase(dataDir2);
|
|
29530
29906
|
this.dataDir = dataDir2;
|
|
@@ -29644,28 +30020,69 @@ var StandaloneDataGateway = class {
|
|
|
29644
30020
|
// - ANY invalid rule among enabled packs (all-invalid, partial corruption,
|
|
29645
30021
|
// or a single malformed entry) → undefined → bundled fallback. Serving a
|
|
29646
30022
|
// reduced "complete" set would silently drop exactly the corrupted rules
|
|
29647
|
-
// with no fallback
|
|
29648
|
-
// never loses coverage
|
|
29649
|
-
//
|
|
29650
|
-
//
|
|
30023
|
+
// with no fallback. The bundled packs are a superset of AKA's OWN packs,
|
|
30024
|
+
// so falling back never loses coverage there — but they contain no
|
|
30025
|
+
// pulled or custom pack, so for those this trades a partial ruleset for
|
|
30026
|
+
// none of them plus the loss of every pack's per-detection enforcement
|
|
30027
|
+
// action. That is deliberate (a store this machine cannot fully validate
|
|
30028
|
+
// is not authoritative), and it is why the cost of REJECTING a rule
|
|
30029
|
+
// matters: `Rule` is strict, so one unrecognized key in one custom rule
|
|
30030
|
+
// reaches this branch, not just a genuinely malformed or foreign store.
|
|
30031
|
+
// `installed-packs.test.ts` pins that per-rule counting;
|
|
29651
30032
|
// - enabled packs that produce ZERO rules with no invalids (e.g. every
|
|
29652
30033
|
// enabled pack's rules_json is `[]`) → undefined → bundled fallback: an
|
|
29653
30034
|
// enabled pack contributing nothing is untrustworthy, not a real
|
|
29654
30035
|
// "detect nothing" (that is expressed by disabling packs, handled above);
|
|
29655
30036
|
// - otherwise → the enabled packs' validated rules, marked complete.
|
|
30037
|
+
/**
|
|
30038
|
+
* The discard above is the one ruleset decision this gateway reaches on its
|
|
30039
|
+
* own, and it is the most expensive one here: ONE rejected entry costs the
|
|
30040
|
+
* user every custom rule and every per-detection enforcement action, replaced
|
|
30041
|
+
* by bundled packs that contain neither. Nothing else reports it — a hook is a
|
|
30042
|
+
* short-lived process whose stderr is the only channel it has — so name what
|
|
30043
|
+
* was rejected and where the rest of the list lives.
|
|
30044
|
+
*
|
|
30045
|
+
* Unlike a quarantine verdict this caches nothing: the rejection is re-derived
|
|
30046
|
+
* from the store on every run, so the recovery is to fix or reinstall the pack,
|
|
30047
|
+
* and no line here may offer a command that clears a stored verdict.
|
|
30048
|
+
*
|
|
30049
|
+
* Written at most once per gateway — a second getPolicyBundle() in the same
|
|
30050
|
+
* process would re-report the same finding.
|
|
30051
|
+
*/
|
|
30052
|
+
warnRulesetDiscarded(snapshot) {
|
|
30053
|
+
if (this.warnedRulesetDiscarded) return;
|
|
30054
|
+
this.warnedRulesetDiscarded = true;
|
|
30055
|
+
const listed = snapshot.rejectedRules.map((r) => `${r.pack}${r.ruleId === null ? "" : ` "${r.ruleId}"`} (${r.reason})`).join(", ");
|
|
30056
|
+
const undisclosed = snapshot.invalidRules - snapshot.rejectedRules.length;
|
|
30057
|
+
const more = undisclosed > 0 ? `, and ${String(undisclosed)} more` : "";
|
|
30058
|
+
process.stderr.write(
|
|
30059
|
+
`[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\`
|
|
30060
|
+
`
|
|
30061
|
+
);
|
|
30062
|
+
}
|
|
29656
30063
|
installedScanRules() {
|
|
29657
30064
|
try {
|
|
29658
30065
|
const snapshot = this.db.installedPacks.installedRuleset();
|
|
29659
30066
|
if (snapshot.installedPacks === 0) return void 0;
|
|
29660
30067
|
if (snapshot.enabledPacks === 0) {
|
|
29661
|
-
return {
|
|
30068
|
+
return {
|
|
30069
|
+
rules: [],
|
|
30070
|
+
ruleActions: /* @__PURE__ */ new Map(),
|
|
30071
|
+
ruleVersions: /* @__PURE__ */ new Map(),
|
|
30072
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
30073
|
+
complete: true
|
|
30074
|
+
};
|
|
30075
|
+
}
|
|
30076
|
+
if (snapshot.invalidRules > 0) {
|
|
30077
|
+
this.warnRulesetDiscarded(snapshot);
|
|
30078
|
+
return void 0;
|
|
29662
30079
|
}
|
|
29663
|
-
if (snapshot.invalidRules > 0) return void 0;
|
|
29664
30080
|
if (snapshot.rules.length === 0) return void 0;
|
|
29665
30081
|
return {
|
|
29666
30082
|
rules: snapshot.rules,
|
|
29667
30083
|
ruleActions: snapshot.ruleActions,
|
|
29668
30084
|
ruleVersions: snapshot.ruleVersions,
|
|
30085
|
+
reversibleRules: snapshot.reversibleRules,
|
|
29669
30086
|
complete: true
|
|
29670
30087
|
};
|
|
29671
30088
|
} catch {
|
|
@@ -29693,6 +30110,11 @@ var StandaloneDataGateway = class {
|
|
|
29693
30110
|
return {
|
|
29694
30111
|
version: "local",
|
|
29695
30112
|
policies: [...policies, ...rulePolicies],
|
|
30113
|
+
// The reversibility half of each pack's assignment. Emitted only under the
|
|
30114
|
+
// authoritative installed snapshot, exactly like rulePolicies above: the
|
|
30115
|
+
// bundled-packs fallback carries no per-pack assignment, so it carries no
|
|
30116
|
+
// reversibility either and every redaction there stays one-way.
|
|
30117
|
+
reversibleRuleIds: installed ? [...installed.reversibleRules] : [],
|
|
29696
30118
|
rules: installed ? installed.rules : [],
|
|
29697
30119
|
...installed ? { rulesComplete: true } : {},
|
|
29698
30120
|
...installed ? { ruleVersions: Object.fromEntries(installed.ruleVersions) } : {},
|
|
@@ -29711,29 +30133,32 @@ var StandaloneDataGateway = class {
|
|
|
29711
30133
|
return this.db.exceptions.recordBlocked(entry);
|
|
29712
30134
|
}
|
|
29713
30135
|
// Retention sweep over TERMINAL exception rows (revoked / expired / budget
|
|
29714
|
-
// exhausted) —
|
|
29715
|
-
//
|
|
30136
|
+
// exhausted) — local-store maintenance, invoked from SessionStart through the
|
|
30137
|
+
// LocalStoreMaintenance capability rather than the DataGateway port. Active
|
|
30138
|
+
// grants are never touched.
|
|
29716
30139
|
sweepTerminalExceptions(retentionMs) {
|
|
29717
30140
|
return this.db.exceptions.sweepTerminal(retentionMs);
|
|
29718
30141
|
}
|
|
29719
|
-
// The warn-era enforcement cap
|
|
29720
|
-
//
|
|
29721
|
-
// of block/redact rows capped to
|
|
29722
|
-
// already-capped one).
|
|
30142
|
+
// The warn-era enforcement cap — local-store maintenance, invoked from
|
|
30143
|
+
// SessionStart through the LocalStoreMaintenance capability rather than
|
|
30144
|
+
// the DataGateway port. Returns the number of block/redact rows capped to
|
|
30145
|
+
// warn (0 for a redact-policy store or an already-capped one).
|
|
29723
30146
|
capWarnEraEnforcement(policyMode) {
|
|
29724
30147
|
const { capped } = capWarnEraEnforcementOnce(this.db, policyMode, this.dataDir);
|
|
29725
30148
|
return { capped };
|
|
29726
30149
|
}
|
|
29727
30150
|
// One project-file scan → the local project_file tree (one transaction inside
|
|
29728
|
-
// the LocalDatabase, fail-open there). Like the sweep above, this is
|
|
29729
|
-
//
|
|
30151
|
+
// the LocalDatabase, fail-open there). Like the sweep above, this is reached
|
|
30152
|
+
// through the LocalStoreMaintenance capability rather than the DataGateway
|
|
30153
|
+
// port: the file tree is a local-store read model.
|
|
29730
30154
|
recordProjectFiles(projectId, scan2) {
|
|
29731
30155
|
this.db.recordProjectFiles(projectId, scan2);
|
|
29732
30156
|
return Promise.resolve();
|
|
29733
30157
|
}
|
|
29734
30158
|
// Fold ghost source_project rows minted by the pre-worktree-fix resolver
|
|
29735
|
-
// (checkout-path identities) into the repo's canonical row.
|
|
29736
|
-
//
|
|
30159
|
+
// (checkout-path identities) into the repo's canonical row. Local-store
|
|
30160
|
+
// maintenance, invoked from SessionStart through the LocalStoreMaintenance
|
|
30161
|
+
// capability. Fail-open in the store.
|
|
29737
30162
|
reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot) {
|
|
29738
30163
|
this.db.reconcileWorktreeProjects(canonicalId, headRoot, worktreeRoot);
|
|
29739
30164
|
return Promise.resolve();
|
|
@@ -29744,10 +30169,10 @@ var StandaloneDataGateway = class {
|
|
|
29744
30169
|
* executing the plugin generation they started with (Claude Code caches
|
|
29745
30170
|
* plugin versions), and the write gate makes their installed-pack writes
|
|
29746
30171
|
* silent no-ops — this is the one-line nudge telling the user WHY, and that
|
|
29747
|
-
* a restart picks the newer plugin up.
|
|
29748
|
-
* SessionStart
|
|
29749
|
-
* null (no notice), and
|
|
29750
|
-
* never fire it.
|
|
30172
|
+
* a restart picks the newer plugin up. Local-store maintenance, invoked
|
|
30173
|
+
* from SessionStart through the LocalStoreMaintenance capability rather
|
|
30174
|
+
* than the DataGateway port. Fail-open: any error → null (no notice), and
|
|
30175
|
+
* unparseable versions compare equal so garbage can never fire it.
|
|
29751
30176
|
*/
|
|
29752
30177
|
staleBinaryNotice(currentVersion) {
|
|
29753
30178
|
try {
|
|
@@ -29825,7 +30250,8 @@ var StandaloneDataGateway = class {
|
|
|
29825
30250
|
|
|
29826
30251
|
// ../../packages/plugin-runtime/src/resolve.ts
|
|
29827
30252
|
var standaloneGatewayFactory = (config2, meta3) => new StandaloneDataGateway(config2.dataDir, bundledDetections(), meta3);
|
|
29828
|
-
|
|
30253
|
+
var defaultGatewayFactory = standaloneGatewayFactory;
|
|
30254
|
+
function resolveDataGateway(config2, meta3, gatewayFactory = defaultGatewayFactory) {
|
|
29829
30255
|
return gatewayFactory(config2, meta3);
|
|
29830
30256
|
}
|
|
29831
30257
|
|
|
@@ -29854,11 +30280,13 @@ async function handleSessionStart(input, config2 = loadConfig()) {
|
|
|
29854
30280
|
buildSessionRoot(input.sessionId, input, ctx, resolved, config2.provider, branch)
|
|
29855
30281
|
);
|
|
29856
30282
|
await recordConfigInventory(gateway, input.sessionId, input.cwd, input.homeDir);
|
|
29857
|
-
if (gateway
|
|
30283
|
+
if (offersMaintenance(gateway, "sweepTerminalExceptions")) {
|
|
29858
30284
|
try {
|
|
29859
30285
|
await gateway.sweepTerminalExceptions(EXCEPTION_RETENTION_MS);
|
|
29860
30286
|
} catch {
|
|
29861
30287
|
}
|
|
30288
|
+
}
|
|
30289
|
+
if (offersMaintenance(gateway, "capWarnEraEnforcement")) {
|
|
29862
30290
|
try {
|
|
29863
30291
|
const { capped } = gateway.capWarnEraEnforcement(config2.settings.policy);
|
|
29864
30292
|
if (capped > 0) {
|
|
@@ -29868,6 +30296,8 @@ async function handleSessionStart(input, config2 = loadConfig()) {
|
|
|
29868
30296
|
}
|
|
29869
30297
|
} catch {
|
|
29870
30298
|
}
|
|
30299
|
+
}
|
|
30300
|
+
if (offersMaintenance(gateway, "recordProjectFiles")) {
|
|
29871
30301
|
try {
|
|
29872
30302
|
if (resolved.sourceProjectId) {
|
|
29873
30303
|
const filesScan = resolveProjectFiles(input.cwd);
|
|
@@ -29875,6 +30305,8 @@ async function handleSessionStart(input, config2 = loadConfig()) {
|
|
|
29875
30305
|
}
|
|
29876
30306
|
} catch {
|
|
29877
30307
|
}
|
|
30308
|
+
}
|
|
30309
|
+
if (offersMaintenance(gateway, "reconcileWorktreeProjects")) {
|
|
29878
30310
|
try {
|
|
29879
30311
|
const headRoot = resolveHeadRoot(input.cwd);
|
|
29880
30312
|
const worktreeRoot = resolveWorktreeRoot(input.cwd);
|
|
@@ -29887,9 +30319,9 @@ async function handleSessionStart(input, config2 = loadConfig()) {
|
|
|
29887
30319
|
}
|
|
29888
30320
|
} catch {
|
|
29889
30321
|
}
|
|
29890
|
-
|
|
29891
|
-
|
|
29892
|
-
}
|
|
30322
|
+
}
|
|
30323
|
+
if (input.harnessVersion !== void 0 && offersMaintenance(gateway, "staleBinaryNotice")) {
|
|
30324
|
+
return { staleBinaryNotice: gateway.staleBinaryNotice(input.harnessVersion) };
|
|
29893
30325
|
}
|
|
29894
30326
|
} finally {
|
|
29895
30327
|
await gateway.close();
|
|
@@ -29963,7 +30395,7 @@ function buildSessionRoot(sessionId, input, ctx, resolved, provider, branch) {
|
|
|
29963
30395
|
|
|
29964
30396
|
// src/history/reconcile-trigger.ts
|
|
29965
30397
|
import { spawn } from "child_process";
|
|
29966
|
-
import { dirname as dirname4, join as
|
|
30398
|
+
import { dirname as dirname4, join as join16 } from "path";
|
|
29967
30399
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
29968
30400
|
|
|
29969
30401
|
// src/history/tail.ts
|
|
@@ -29971,13 +30403,13 @@ import { createHash as createHash5 } from "crypto";
|
|
|
29971
30403
|
import {
|
|
29972
30404
|
closeSync as closeSync2,
|
|
29973
30405
|
fstatSync,
|
|
29974
|
-
mkdirSync as
|
|
30406
|
+
mkdirSync as mkdirSync4,
|
|
29975
30407
|
openSync as openSync2,
|
|
29976
|
-
readFileSync as
|
|
30408
|
+
readFileSync as readFileSync10,
|
|
29977
30409
|
readSync,
|
|
29978
30410
|
writeFileSync as writeFileSync7
|
|
29979
30411
|
} from "fs";
|
|
29980
|
-
import { join as
|
|
30412
|
+
import { join as join15 } from "path";
|
|
29981
30413
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
29982
30414
|
function safeSessionId(sessionId) {
|
|
29983
30415
|
if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
|
|
@@ -29994,7 +30426,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
29994
30426
|
const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
|
|
29995
30427
|
if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
|
|
29996
30428
|
const here = dirname4(fileURLToPath2(import.meta.url));
|
|
29997
|
-
const child = spawn(process.execPath, [
|
|
30429
|
+
const child = spawn(process.execPath, [join16(here, "reconcile.js"), sessionId, transcriptPath], {
|
|
29998
30430
|
detached: true,
|
|
29999
30431
|
stdio: "ignore"
|
|
30000
30432
|
});
|
|
@@ -30004,9 +30436,9 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
30004
30436
|
}
|
|
30005
30437
|
|
|
30006
30438
|
// src/history/transcripts.ts
|
|
30007
|
-
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5, readFileSync as
|
|
30439
|
+
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5, readFileSync as readFileSync11, readSync as readSync2, statSync as statSync7 } from "fs";
|
|
30008
30440
|
import { homedir as homedir3 } from "os";
|
|
30009
|
-
import { join as
|
|
30441
|
+
import { join as join17 } from "path";
|
|
30010
30442
|
function isRecord(value) {
|
|
30011
30443
|
return typeof value === "object" && value !== null;
|
|
30012
30444
|
}
|
|
@@ -30084,7 +30516,7 @@ function harnessVersion() {
|
|
|
30084
30516
|
const manifestPath = process.argv[2];
|
|
30085
30517
|
if (!manifestPath) return void 0;
|
|
30086
30518
|
try {
|
|
30087
|
-
const manifest = JSON.parse(
|
|
30519
|
+
const manifest = JSON.parse(readFileSync12(manifestPath, "utf8"));
|
|
30088
30520
|
return typeof manifest.version === "string" ? manifest.version : void 0;
|
|
30089
30521
|
} catch {
|
|
30090
30522
|
return void 0;
|
|
@@ -30101,7 +30533,7 @@ async function main() {
|
|
|
30101
30533
|
{
|
|
30102
30534
|
sessionId,
|
|
30103
30535
|
cwd,
|
|
30104
|
-
tool:
|
|
30536
|
+
tool: SOURCE_TOOL.Codex,
|
|
30105
30537
|
harnessVersion: harnessVersion(),
|
|
30106
30538
|
harnessInterface
|
|
30107
30539
|
},
|