@akasecurity/ai-tc-codex 0.9.12 → 0.9.13
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 +3 -3
- package/scripts/apply-suppressions.js +331 -22
- package/scripts/backfill.js +464 -124
- package/scripts/content-retention.js +334 -22
- package/scripts/filescan.js +464 -124
- package/scripts/firstrun.js +464 -124
- package/scripts/history-sync.js +379 -42
- package/scripts/intro.js +209 -17
- package/scripts/onboard.js +331 -22
- package/scripts/post-tool-use.js +464 -124
- package/scripts/pre-tool-use.js +464 -124
- package/scripts/query.js +580 -126
- package/scripts/reconcile.js +464 -124
- package/scripts/remediate.js +464 -124
- package/scripts/scan-worker.js +209 -17
- package/scripts/session-start.js +464 -124
- package/scripts/start-light.js +209 -17
- package/scripts/stop.js +212 -17
- package/scripts/sync.js +464 -124
- package/scripts/user-prompt-submit.js +488 -127
package/scripts/session-start.js
CHANGED
|
@@ -20481,7 +20481,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20481
20481
|
"gateway",
|
|
20482
20482
|
"unknown",
|
|
20483
20483
|
"cli",
|
|
20484
|
-
"api"
|
|
20484
|
+
"api",
|
|
20485
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20486
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20487
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20488
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20489
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20490
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20491
|
+
// the reason on the way, rather than quietly adding one to
|
|
20492
|
+
// PROVIDER_PLATFORM.
|
|
20493
|
+
"chatgpt",
|
|
20494
|
+
"claude-ai"
|
|
20485
20495
|
]);
|
|
20486
20496
|
function platformForProvider(provider) {
|
|
20487
20497
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20624,7 +20634,12 @@ var HARNESS = {
|
|
|
20624
20634
|
ClaudeDesktop: "claudedesktop",
|
|
20625
20635
|
ChatGpt: "chatgpt",
|
|
20626
20636
|
ClaudeAi: "claudeai",
|
|
20627
|
-
Api: "api"
|
|
20637
|
+
Api: "api",
|
|
20638
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20639
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20640
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20641
|
+
// whose wire spelling differs from its display spelling.
|
|
20642
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20628
20643
|
};
|
|
20629
20644
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20630
20645
|
var SOURCE_TOOL = {
|
|
@@ -20640,9 +20655,15 @@ var SOURCE_TOOL = {
|
|
|
20640
20655
|
// whose tool could not be identified both render through the read side's
|
|
20641
20656
|
// miss path rather than as a harness of their own.
|
|
20642
20657
|
Cli: "cli",
|
|
20643
|
-
Unknown: "unknown"
|
|
20658
|
+
Unknown: "unknown",
|
|
20659
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20660
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20661
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20662
|
+
// assistant's own hook contract.
|
|
20663
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20644
20664
|
};
|
|
20645
20665
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20666
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20646
20667
|
var TOOL_TO_HARNESS = {
|
|
20647
20668
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20648
20669
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20651,7 +20672,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20651
20672
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20652
20673
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20653
20674
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20654
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20675
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20676
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20677
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20678
|
+
// their intersection — leaving a shared member out would read as an
|
|
20679
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20680
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20655
20681
|
};
|
|
20656
20682
|
function harnessFromTool(tool) {
|
|
20657
20683
|
return (Object.hasOwn(TOOL_TO_HARNESS, tool) ? TOOL_TO_HARNESS[tool] : void 0) ?? tool;
|
|
@@ -20688,7 +20714,8 @@ var FindingProvider = Harness.extract([
|
|
|
20688
20714
|
"ClaudeAi",
|
|
20689
20715
|
"Codex",
|
|
20690
20716
|
"Antigravity",
|
|
20691
|
-
"Api"
|
|
20717
|
+
"Api",
|
|
20718
|
+
"AiTcSdk"
|
|
20692
20719
|
]).meta({ id: "FindingProvider" });
|
|
20693
20720
|
var FindingCategory = external_exports.enum([
|
|
20694
20721
|
"secret",
|
|
@@ -21065,18 +21092,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21065
21092
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21066
21093
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21067
21094
|
"tool_use",
|
|
21068
|
-
// One row per model REFUSAL
|
|
21069
|
-
//
|
|
21070
|
-
//
|
|
21071
|
-
//
|
|
21072
|
-
//
|
|
21073
|
-
//
|
|
21095
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21096
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21097
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21098
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21099
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21100
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21101
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21102
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21103
|
+
// product exists to keep from travelling.
|
|
21074
21104
|
"model_refusal",
|
|
21105
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21106
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21107
|
+
// against that call's non-streamed response. A structural row like
|
|
21108
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21109
|
+
// which side, which seam, what action and which field are decided rides
|
|
21110
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21111
|
+
// travels.
|
|
21112
|
+
//
|
|
21113
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21114
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21115
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21116
|
+
// than splitting one governance concept across two event types. This
|
|
21117
|
+
// member carries every OTHER request-path decision.
|
|
21118
|
+
"request_decision",
|
|
21075
21119
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21076
21120
|
// fact the posture inspection findings reference (findings require an
|
|
21077
21121
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21078
21122
|
// surface renders.
|
|
21079
|
-
"config_scan"
|
|
21123
|
+
"config_scan",
|
|
21124
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21125
|
+
// session root. The durable home of what one tab's network interception
|
|
21126
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21127
|
+
// second process (aka extension status) and a restarted host both have
|
|
21128
|
+
// somewhere to read it back from.
|
|
21129
|
+
"capture_status"
|
|
21080
21130
|
]).meta({ id: "AuditEventType" });
|
|
21081
21131
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21082
21132
|
var HostAttributes = external_exports.object({
|
|
@@ -21236,6 +21286,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21236
21286
|
// repeated rather than referenced because a store reader opens this file.
|
|
21237
21287
|
redact_degraded_to: ActionTaken.optional()
|
|
21238
21288
|
}).catchall(external_exports.unknown());
|
|
21289
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21290
|
+
source_tool: external_exports.string().optional(),
|
|
21291
|
+
patched: external_exports.boolean().optional(),
|
|
21292
|
+
live: external_exports.boolean().optional(),
|
|
21293
|
+
blind: external_exports.boolean().optional(),
|
|
21294
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21295
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21296
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21297
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21298
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21299
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21300
|
+
closed: external_exports.boolean().optional(),
|
|
21301
|
+
enforcement: external_exports.string().optional()
|
|
21302
|
+
}).catchall(external_exports.unknown());
|
|
21239
21303
|
var ToolCallInspection = external_exports.object({
|
|
21240
21304
|
ruleId: external_exports.string().min(1),
|
|
21241
21305
|
ruleName: external_exports.string(),
|
|
@@ -22209,6 +22273,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22209
22273
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22210
22274
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22211
22275
|
});
|
|
22276
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22277
|
+
function unsafeEndpointReason(endpoint) {
|
|
22278
|
+
let parsed2;
|
|
22279
|
+
try {
|
|
22280
|
+
parsed2 = new URL(endpoint);
|
|
22281
|
+
} catch {
|
|
22282
|
+
return "unparseable";
|
|
22283
|
+
}
|
|
22284
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22285
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22286
|
+
if (parsed2.protocol === "https:") return null;
|
|
22287
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22288
|
+
}
|
|
22289
|
+
function isSafeEndpoint(endpoint) {
|
|
22290
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22291
|
+
}
|
|
22292
|
+
function originOnly(endpoint) {
|
|
22293
|
+
try {
|
|
22294
|
+
const parsed2 = new URL(endpoint);
|
|
22295
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22296
|
+
} catch {
|
|
22297
|
+
return "(unparseable endpoint)";
|
|
22298
|
+
}
|
|
22299
|
+
}
|
|
22212
22300
|
var MAX_DATE_MS = 253402300799999;
|
|
22213
22301
|
var MAX_INT4 = 2147483647;
|
|
22214
22302
|
var StorePosturePack = external_exports.object({
|
|
@@ -22363,6 +22451,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22363
22451
|
"rejected",
|
|
22364
22452
|
"unreachable"
|
|
22365
22453
|
]);
|
|
22454
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22455
|
+
"unauthorized",
|
|
22456
|
+
"forbidden",
|
|
22457
|
+
"unreachable"
|
|
22458
|
+
]);
|
|
22366
22459
|
var AttachDeviceRequest = external_exports.object({
|
|
22367
22460
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22368
22461
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22902,7 +22995,12 @@ var EventMetadata = external_exports.object({
|
|
|
22902
22995
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22903
22996
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22904
22997
|
// on every other capture path, which has no such id.
|
|
22905
|
-
|
|
22998
|
+
//
|
|
22999
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
23000
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
23001
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
23002
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
23003
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22906
23004
|
conversationId: external_exports.string().optional(),
|
|
22907
23005
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22908
23006
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23744,6 +23842,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23744
23842
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23745
23843
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23746
23844
|
);
|
|
23845
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23846
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23847
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23848
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23849
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23850
|
+
return map2;
|
|
23851
|
+
}
|
|
23852
|
+
function policyKey(policy) {
|
|
23853
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23854
|
+
}
|
|
23855
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23856
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23857
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23858
|
+
}
|
|
23859
|
+
function strongerOf(a, b) {
|
|
23860
|
+
if (a === null) return b;
|
|
23861
|
+
if (b === null) return a;
|
|
23862
|
+
return strongerAction(a, b);
|
|
23863
|
+
}
|
|
23864
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23865
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23866
|
+
const disabled = [];
|
|
23867
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23868
|
+
for (const policy of remotePolicies) {
|
|
23869
|
+
if (!policy.enabled) continue;
|
|
23870
|
+
if (!("category" in policy.target)) continue;
|
|
23871
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23872
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23873
|
+
remoteCategoryAction.set(
|
|
23874
|
+
policy.target.category,
|
|
23875
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23876
|
+
);
|
|
23877
|
+
}
|
|
23878
|
+
for (const policy of localPolicies) {
|
|
23879
|
+
if (!policy.enabled) {
|
|
23880
|
+
disabled.push(policy);
|
|
23881
|
+
continue;
|
|
23882
|
+
}
|
|
23883
|
+
const key = policyKey(policy);
|
|
23884
|
+
if (merged.has(key)) continue;
|
|
23885
|
+
let remoteFloor = null;
|
|
23886
|
+
if ("ruleId" in policy.target) {
|
|
23887
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23888
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23889
|
+
}
|
|
23890
|
+
merged.set(
|
|
23891
|
+
key,
|
|
23892
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23893
|
+
);
|
|
23894
|
+
}
|
|
23895
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23896
|
+
for (const policy of merged.values()) {
|
|
23897
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23898
|
+
}
|
|
23899
|
+
for (const policy of remotePolicies) {
|
|
23900
|
+
if (!policy.enabled) {
|
|
23901
|
+
disabled.push(policy);
|
|
23902
|
+
continue;
|
|
23903
|
+
}
|
|
23904
|
+
const key = policyKey(policy);
|
|
23905
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23906
|
+
let localFloor = null;
|
|
23907
|
+
if ("ruleId" in policy.target) {
|
|
23908
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23909
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23910
|
+
}
|
|
23911
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23912
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23913
|
+
const existing = merged.get(key);
|
|
23914
|
+
if (existing === void 0) {
|
|
23915
|
+
merged.set(key, clamped);
|
|
23916
|
+
continue;
|
|
23917
|
+
}
|
|
23918
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23919
|
+
merged.set(key, clamped);
|
|
23920
|
+
}
|
|
23921
|
+
}
|
|
23922
|
+
return [...merged.values(), ...disabled];
|
|
23923
|
+
}
|
|
23747
23924
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23748
23925
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23749
23926
|
);
|
|
@@ -23974,6 +24151,18 @@ function isHistorySyncConsentValid(consent, endpoint) {
|
|
|
23974
24151
|
if (consent === void 0 || endpoint === void 0) return false;
|
|
23975
24152
|
return consent.payloadVersion === HISTORY_SYNC_PAYLOAD_VERSION && consent.endpoint === endpoint;
|
|
23976
24153
|
}
|
|
24154
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24155
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24156
|
+
version: external_exports.number().int().positive()
|
|
24157
|
+
});
|
|
24158
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24159
|
+
var WebChatCapture = external_exports.object({
|
|
24160
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24161
|
+
account: external_exports.boolean().default(false),
|
|
24162
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24163
|
+
// isWebChatCaptureConsentValid.
|
|
24164
|
+
consent: WebChatCaptureConsent.optional()
|
|
24165
|
+
});
|
|
23977
24166
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23978
24167
|
var BodyRetention = external_exports.object({
|
|
23979
24168
|
enabled: external_exports.boolean().default(false),
|
|
@@ -24032,6 +24221,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
24032
24221
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
24033
24222
|
// or an older payload no longer counts.
|
|
24034
24223
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24224
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24225
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24226
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24227
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24228
|
+
// webChatCaptureOf's answer, in one place.
|
|
24229
|
+
//
|
|
24230
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24231
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24232
|
+
// written down.
|
|
24233
|
+
webChatCapture: WebChatCapture.optional(),
|
|
24035
24234
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
24036
24235
|
// body never removes the row or its findings.
|
|
24037
24236
|
bodyRetention: BodyRetention.default({
|
|
@@ -24139,7 +24338,10 @@ function toCaptureAttributes(event) {
|
|
|
24139
24338
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24140
24339
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24141
24340
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24142
|
-
|
|
24341
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24342
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24343
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24344
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24143
24345
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24144
24346
|
};
|
|
24145
24347
|
}
|
|
@@ -24513,12 +24715,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24513
24715
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24514
24716
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24515
24717
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24718
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24516
24719
|
var SaveSettingsInput = external_exports.object({
|
|
24517
24720
|
historicalAccess: external_exports.string(),
|
|
24518
24721
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24519
24722
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24520
24723
|
vaultConsent: external_exports.string(),
|
|
24521
24724
|
vaultInlineReveal: external_exports.string(),
|
|
24725
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24522
24726
|
// Widened to `string` like its neighbours rather than typed as
|
|
24523
24727
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24524
24728
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24733,11 +24937,24 @@ var WebExchange = external_exports.object({
|
|
|
24733
24937
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24734
24938
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24735
24939
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24736
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24737
|
-
//
|
|
24940
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24941
|
+
// reply.
|
|
24738
24942
|
responseText: external_exports.string().optional(),
|
|
24943
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24944
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24945
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24946
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24947
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24948
|
+
// should branch as though it could.
|
|
24739
24949
|
truncated: external_exports.boolean().default(false)
|
|
24740
24950
|
});
|
|
24951
|
+
var WebEnforcementState = external_exports.enum([
|
|
24952
|
+
"watching",
|
|
24953
|
+
"composer-only",
|
|
24954
|
+
"button-only",
|
|
24955
|
+
"unattached",
|
|
24956
|
+
"unknown"
|
|
24957
|
+
]);
|
|
24741
24958
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24742
24959
|
var WebCaptureStatus = external_exports.object({
|
|
24743
24960
|
patched: external_exports.boolean(),
|
|
@@ -24749,8 +24966,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24749
24966
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24750
24967
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24751
24968
|
// the earliest signal that a site's contract moved.
|
|
24752
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24753
|
-
|
|
24969
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24970
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24971
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24972
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24973
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24974
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24975
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24976
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24977
|
+
// its `pagehide` report and nowhere else.
|
|
24978
|
+
//
|
|
24979
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24980
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24981
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24982
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24983
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24984
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24985
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24986
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24987
|
+
//
|
|
24988
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24989
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24990
|
+
// is not a final one.
|
|
24991
|
+
closed: external_exports.boolean().default(false),
|
|
24992
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24993
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24994
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24995
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24996
|
+
// predating the field is not read as reporting a healthy one.
|
|
24997
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24998
|
+
});
|
|
24999
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
25000
|
+
if (!status.patched) return true;
|
|
25001
|
+
if (status.conversationEndpoints === 0) return true;
|
|
25002
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
25003
|
+
}
|
|
25004
|
+
function pickReportedCaptureStatus(candidates) {
|
|
25005
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
25006
|
+
}
|
|
25007
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
25008
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
25009
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
25010
|
+
function fromCaptureStatusAttributes(bag) {
|
|
25011
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
25012
|
+
if (!parsedBag.success) return null;
|
|
25013
|
+
const b = parsedBag.data;
|
|
25014
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
25015
|
+
patched: b.patched,
|
|
25016
|
+
live: b.live,
|
|
25017
|
+
blind: b.blind,
|
|
25018
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
25019
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
25020
|
+
parseFailures: b.parse_failures,
|
|
25021
|
+
unparsedBodies: b.unparsed_bodies,
|
|
25022
|
+
shapeMisses: b.shape_misses,
|
|
25023
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
25024
|
+
closed: b.closed,
|
|
25025
|
+
enforcement: b.enforcement
|
|
25026
|
+
});
|
|
25027
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
25028
|
+
}
|
|
24754
25029
|
|
|
24755
25030
|
// ../../packages/persistence/src/paths.ts
|
|
24756
25031
|
import {
|
|
@@ -24861,17 +25136,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24861
25136
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24862
25137
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24863
25138
|
}
|
|
24864
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24865
|
-
function isSafeEndpoint(endpoint) {
|
|
24866
|
-
let parsed2;
|
|
24867
|
-
try {
|
|
24868
|
-
parsed2 = new URL(endpoint);
|
|
24869
|
-
} catch {
|
|
24870
|
-
return false;
|
|
24871
|
-
}
|
|
24872
|
-
if (parsed2.protocol === "https:") return true;
|
|
24873
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24874
|
-
}
|
|
24875
25139
|
function repairOrRefuseMode(file2) {
|
|
24876
25140
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24877
25141
|
if (link === void 0) return "absent";
|
|
@@ -26658,7 +26922,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26658
26922
|
var HAS_ACTIVITY = `EXISTS (
|
|
26659
26923
|
SELECT 1 FROM audit_events c
|
|
26660
26924
|
WHERE c.root_session_id = audit_events.id
|
|
26661
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26925
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26662
26926
|
var SqliteActivityRepository = class {
|
|
26663
26927
|
constructor(db, now = () => Date.now()) {
|
|
26664
26928
|
this.db = db;
|
|
@@ -26685,10 +26949,10 @@ var SqliteActivityRepository = class {
|
|
|
26685
26949
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26686
26950
|
UNION
|
|
26687
26951
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26688
|
-
WHERE started_at >= ?
|
|
26952
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26689
26953
|
UNION
|
|
26690
26954
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26691
|
-
WHERE ended_at >= ?)`,
|
|
26955
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26692
26956
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26693
26957
|
);
|
|
26694
26958
|
const toolCallsToday = countScalar(
|
|
@@ -27095,7 +27359,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27095
27359
|
attributes = excluded.attributes,
|
|
27096
27360
|
ended_at = excluded.ended_at
|
|
27097
27361
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27098
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27362
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27363
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27364
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27365
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27099
27366
|
);
|
|
27100
27367
|
this.upsertSessionRootStmt = db.prepare(
|
|
27101
27368
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27363,6 +27630,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27363
27630
|
}
|
|
27364
27631
|
};
|
|
27365
27632
|
|
|
27633
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27634
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27635
|
+
var SqliteCaptureStatusRepository = class {
|
|
27636
|
+
constructor(db) {
|
|
27637
|
+
this.db = db;
|
|
27638
|
+
this.recentStmt = db.prepare(
|
|
27639
|
+
`SELECT a.started_at AS startedAt,
|
|
27640
|
+
a.attributes AS attributes,
|
|
27641
|
+
a.root_session_id AS rootSessionId
|
|
27642
|
+
FROM audit_events a
|
|
27643
|
+
WHERE a.event_type = 'capture_status'
|
|
27644
|
+
AND a.source_tool = ?
|
|
27645
|
+
AND a.started_at >= ?
|
|
27646
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27647
|
+
LIMIT ?`
|
|
27648
|
+
);
|
|
27649
|
+
}
|
|
27650
|
+
db;
|
|
27651
|
+
recentStmt;
|
|
27652
|
+
/**
|
|
27653
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27654
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27655
|
+
*
|
|
27656
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27657
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27658
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27659
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27660
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27661
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27662
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27663
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27664
|
+
* this package may not import it.
|
|
27665
|
+
*
|
|
27666
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27667
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27668
|
+
* the window without moving the wall clock.
|
|
27669
|
+
*
|
|
27670
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27671
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27672
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27673
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27674
|
+
* clear it.
|
|
27675
|
+
*/
|
|
27676
|
+
latest(now) {
|
|
27677
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27678
|
+
const documents = [];
|
|
27679
|
+
for (const tool of WebSourceTool.options) {
|
|
27680
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27681
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27682
|
+
for (const row of allRows(this.recentStmt, [
|
|
27683
|
+
tool,
|
|
27684
|
+
since,
|
|
27685
|
+
STATUS_LOOKBACK_ROWS
|
|
27686
|
+
])) {
|
|
27687
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27688
|
+
if (status === null) continue;
|
|
27689
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27690
|
+
const group = rows.get(row.rootSessionId);
|
|
27691
|
+
if (group === void 0) {
|
|
27692
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27693
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27694
|
+
} else {
|
|
27695
|
+
group.push(record2);
|
|
27696
|
+
}
|
|
27697
|
+
}
|
|
27698
|
+
for (const [root, candidates] of rows) {
|
|
27699
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27700
|
+
const last = lastWord.get(root);
|
|
27701
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27702
|
+
documents.push({
|
|
27703
|
+
...picked,
|
|
27704
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27705
|
+
lastReportAt: last.at,
|
|
27706
|
+
closed: last.closed
|
|
27707
|
+
});
|
|
27708
|
+
}
|
|
27709
|
+
}
|
|
27710
|
+
return documents;
|
|
27711
|
+
}
|
|
27712
|
+
};
|
|
27713
|
+
|
|
27366
27714
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27367
27715
|
var SqliteClassifiedDataRepository = class {
|
|
27368
27716
|
constructor(db) {
|
|
@@ -32943,6 +33291,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32943
33291
|
activity: new SqliteActivityRepository(db),
|
|
32944
33292
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32945
33293
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33294
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32946
33295
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32947
33296
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32948
33297
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32983,6 +33332,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32983
33332
|
activity,
|
|
32984
33333
|
sourceProject,
|
|
32985
33334
|
auditEvents,
|
|
33335
|
+
captureStatus,
|
|
32986
33336
|
classifiedData,
|
|
32987
33337
|
inspectionDefinitions,
|
|
32988
33338
|
inspectionFindings,
|
|
@@ -33200,6 +33550,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33200
33550
|
activity,
|
|
33201
33551
|
sourceProject,
|
|
33202
33552
|
auditEvents,
|
|
33553
|
+
captureStatus,
|
|
33203
33554
|
classifiedData,
|
|
33204
33555
|
inspectionDefinitions,
|
|
33205
33556
|
inspectionFindings,
|
|
@@ -33334,11 +33685,6 @@ function readFingerprintKey(dataDir2) {
|
|
|
33334
33685
|
// ../../packages/persistence/src/forward-health.ts
|
|
33335
33686
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33336
33687
|
import { join as join9 } from "path";
|
|
33337
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33338
|
-
"unauthorized",
|
|
33339
|
-
"forbidden",
|
|
33340
|
-
"unreachable"
|
|
33341
|
-
]);
|
|
33342
33688
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33343
33689
|
function parseForwardHealth(raw, nowMs) {
|
|
33344
33690
|
try {
|
|
@@ -33347,7 +33693,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33347
33693
|
const record2 = parsed2;
|
|
33348
33694
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33349
33695
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33350
|
-
const
|
|
33696
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33697
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33351
33698
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33352
33699
|
} catch {
|
|
33353
33700
|
return null;
|
|
@@ -33484,6 +33831,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
33484
33831
|
}
|
|
33485
33832
|
cause;
|
|
33486
33833
|
};
|
|
33834
|
+
var RemoteEndpointRefused = class extends Error {
|
|
33835
|
+
constructor(endpoint) {
|
|
33836
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
33837
|
+
this.name = "RemoteEndpointRefused";
|
|
33838
|
+
}
|
|
33839
|
+
};
|
|
33487
33840
|
var RemoteResponseInvalid = class extends Error {
|
|
33488
33841
|
constructor(route, detail) {
|
|
33489
33842
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -33636,14 +33989,15 @@ function parsed(schema, body, route) {
|
|
|
33636
33989
|
}
|
|
33637
33990
|
return result.data;
|
|
33638
33991
|
}
|
|
33639
|
-
function
|
|
33992
|
+
function resolveBaseUrl(endpoint) {
|
|
33993
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
33640
33994
|
let end = endpoint.length;
|
|
33641
33995
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
33642
33996
|
return endpoint.slice(0, end);
|
|
33643
33997
|
}
|
|
33644
33998
|
var SLASH2 = "/".charCodeAt(0);
|
|
33645
33999
|
function createRemoteClient(options) {
|
|
33646
|
-
const base =
|
|
34000
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
33647
34001
|
const url2 = (route) => `${base}${route}`;
|
|
33648
34002
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
33649
34003
|
const sendOne = async (event) => {
|
|
@@ -33773,6 +34127,7 @@ function classifyRemoteFailure(err) {
|
|
|
33773
34127
|
case "RemoteRouteAbsent":
|
|
33774
34128
|
return "route-absent";
|
|
33775
34129
|
case "RemoteRequestInvalid":
|
|
34130
|
+
case "RemoteEndpointRefused":
|
|
33776
34131
|
return "invalid-request";
|
|
33777
34132
|
case "RemoteResponseInvalid":
|
|
33778
34133
|
return "rejected";
|
|
@@ -34971,6 +35326,56 @@ function whole(command) {
|
|
|
34971
35326
|
return { start: 0, end: command.length };
|
|
34972
35327
|
}
|
|
34973
35328
|
|
|
35329
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
35330
|
+
var RULE_VERSION2 = "1";
|
|
35331
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
35332
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
35333
|
+
"blind",
|
|
35334
|
+
"degraded"
|
|
35335
|
+
]);
|
|
35336
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
35337
|
+
ruleId: "web-capture-drift",
|
|
35338
|
+
version: RULE_VERSION2,
|
|
35339
|
+
name: "Web chat capture is not reading the site",
|
|
35340
|
+
category: "config",
|
|
35341
|
+
severity: "medium",
|
|
35342
|
+
definition: JSON.stringify({
|
|
35343
|
+
kind: "web-capture-drift",
|
|
35344
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
35345
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
35346
|
+
})
|
|
35347
|
+
};
|
|
35348
|
+
var STATIC_COPY = {
|
|
35349
|
+
active: { headline: "turns are being observed on this site" },
|
|
35350
|
+
unreported: {
|
|
35351
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
35352
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
35353
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
35354
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
35355
|
+
// copy may not claim the stronger of them.
|
|
35356
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
35357
|
+
},
|
|
35358
|
+
standby: {
|
|
35359
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
35360
|
+
},
|
|
35361
|
+
unpatched: {
|
|
35362
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
35363
|
+
// that installed and hooked neither transport and for one that never ran
|
|
35364
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
35365
|
+
// assert one of them.
|
|
35366
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
35367
|
+
},
|
|
35368
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
35369
|
+
blind: {
|
|
35370
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
35371
|
+
remediation: "reload the tab. If it persists after `aka update` and reloading the extension at chrome://extensions, the site's send path has changed and needs a new extension build."
|
|
35372
|
+
},
|
|
35373
|
+
degraded: {
|
|
35374
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
35375
|
+
remediation: "run `aka update`, then reload the extension at chrome://extensions. If it stays degraded after an update, the site's contract has changed and needs a new extension build."
|
|
35376
|
+
}
|
|
35377
|
+
};
|
|
35378
|
+
|
|
34974
35379
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34975
35380
|
var BUDGET_MS = 100;
|
|
34976
35381
|
var EXPONENTIAL_UNITS = [
|
|
@@ -38163,86 +38568,10 @@ function createForwardPolicy(deps) {
|
|
|
38163
38568
|
}
|
|
38164
38569
|
|
|
38165
38570
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
38166
|
-
|
|
38167
|
-
|
|
38168
|
-
|
|
38169
|
-
return
|
|
38170
|
-
}
|
|
38171
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
38172
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
38173
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
38174
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
38175
|
-
for (const pack of bundledDetections()) {
|
|
38176
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
38177
|
-
}
|
|
38178
|
-
return map2;
|
|
38179
|
-
}
|
|
38180
|
-
function policyKey(policy) {
|
|
38181
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
38182
|
-
}
|
|
38183
|
-
function floorFor(policy, categoryByRuleId) {
|
|
38184
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
38185
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
38186
|
-
}
|
|
38187
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
38188
|
-
const merged = /* @__PURE__ */ new Map();
|
|
38189
|
-
const disabled = [];
|
|
38190
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
38191
|
-
for (const policy of remotePolicies) {
|
|
38192
|
-
if (!policy.enabled) continue;
|
|
38193
|
-
if (!("category" in policy.target)) continue;
|
|
38194
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
38195
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38196
|
-
remoteCategoryAction.set(
|
|
38197
|
-
policy.target.category,
|
|
38198
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
38199
|
-
);
|
|
38200
|
-
}
|
|
38201
|
-
for (const policy of localPolicies) {
|
|
38202
|
-
if (!policy.enabled) {
|
|
38203
|
-
disabled.push(policy);
|
|
38204
|
-
continue;
|
|
38205
|
-
}
|
|
38206
|
-
const key = policyKey(policy);
|
|
38207
|
-
if (merged.has(key)) continue;
|
|
38208
|
-
let remoteFloor = null;
|
|
38209
|
-
if ("ruleId" in policy.target) {
|
|
38210
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38211
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
38212
|
-
}
|
|
38213
|
-
merged.set(
|
|
38214
|
-
key,
|
|
38215
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
38216
|
-
);
|
|
38217
|
-
}
|
|
38218
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
38219
|
-
for (const policy of merged.values()) {
|
|
38220
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
38221
|
-
}
|
|
38222
|
-
for (const policy of remotePolicies) {
|
|
38223
|
-
if (!policy.enabled) {
|
|
38224
|
-
disabled.push(policy);
|
|
38225
|
-
continue;
|
|
38226
|
-
}
|
|
38227
|
-
const key = policyKey(policy);
|
|
38228
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38229
|
-
let localFloor = null;
|
|
38230
|
-
if ("ruleId" in policy.target) {
|
|
38231
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38232
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
38233
|
-
}
|
|
38234
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
38235
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
38236
|
-
const existing = merged.get(key);
|
|
38237
|
-
if (existing === void 0) {
|
|
38238
|
-
merged.set(key, clamped);
|
|
38239
|
-
continue;
|
|
38240
|
-
}
|
|
38241
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
38242
|
-
merged.set(key, clamped);
|
|
38243
|
-
}
|
|
38244
|
-
}
|
|
38245
|
-
return [...merged.values(), ...disabled];
|
|
38571
|
+
var bundledRulesFlatCache;
|
|
38572
|
+
function bundledRulesFlat() {
|
|
38573
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
38574
|
+
return bundledRulesFlatCache;
|
|
38246
38575
|
}
|
|
38247
38576
|
var AttachedDataGateway = class {
|
|
38248
38577
|
constructor(deps) {
|
|
@@ -38562,6 +38891,9 @@ var AttachedDataGateway = class {
|
|
|
38562
38891
|
async readSessionProvider(sessionId) {
|
|
38563
38892
|
return this.deps.local.readSessionProvider(sessionId);
|
|
38564
38893
|
}
|
|
38894
|
+
async readCaptureStatuses() {
|
|
38895
|
+
return this.deps.local.readCaptureStatuses();
|
|
38896
|
+
}
|
|
38565
38897
|
async facets() {
|
|
38566
38898
|
return this.deps.local.facets();
|
|
38567
38899
|
}
|
|
@@ -38644,7 +38976,7 @@ var AttachedDataGateway = class {
|
|
|
38644
38976
|
policies: mergeRaiseOnly(
|
|
38645
38977
|
local.policies,
|
|
38646
38978
|
cached2.policies,
|
|
38647
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
38979
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
38648
38980
|
),
|
|
38649
38981
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
38650
38982
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -38884,10 +39216,15 @@ import { join as join27 } from "path";
|
|
|
38884
39216
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
38885
39217
|
import { rename as rename2 } from "fs/promises";
|
|
38886
39218
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
38887
|
-
var
|
|
39219
|
+
var IMMEDIATE_RETRIES = 8;
|
|
39220
|
+
var TIMED_RETRIES = 4;
|
|
39221
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
38888
39222
|
var delay = (ms) => new Promise((resolve2) => {
|
|
38889
39223
|
setTimeout(resolve2, ms);
|
|
38890
39224
|
});
|
|
39225
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
39226
|
+
setImmediate(resolve2);
|
|
39227
|
+
});
|
|
38891
39228
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
38892
39229
|
for (let attempt = 1; ; attempt += 1) {
|
|
38893
39230
|
try {
|
|
@@ -38896,7 +39233,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
38896
39233
|
} catch (err) {
|
|
38897
39234
|
const code = err.code;
|
|
38898
39235
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
38899
|
-
await delay(attempt * 10);
|
|
39236
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
38900
39237
|
}
|
|
38901
39238
|
}
|
|
38902
39239
|
}
|
|
@@ -39404,6 +39741,9 @@ var StandaloneDataGateway = class {
|
|
|
39404
39741
|
readSessionProvider(sessionId) {
|
|
39405
39742
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
39406
39743
|
}
|
|
39744
|
+
readCaptureStatuses() {
|
|
39745
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
39746
|
+
}
|
|
39407
39747
|
facets() {
|
|
39408
39748
|
return Promise.resolve(this.db.facets());
|
|
39409
39749
|
}
|