@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/post-tool-use.js
CHANGED
|
@@ -20478,7 +20478,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20478
20478
|
"gateway",
|
|
20479
20479
|
"unknown",
|
|
20480
20480
|
"cli",
|
|
20481
|
-
"api"
|
|
20481
|
+
"api",
|
|
20482
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20483
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20484
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20485
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20486
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20487
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20488
|
+
// the reason on the way, rather than quietly adding one to
|
|
20489
|
+
// PROVIDER_PLATFORM.
|
|
20490
|
+
"chatgpt",
|
|
20491
|
+
"claude-ai"
|
|
20482
20492
|
]);
|
|
20483
20493
|
function platformForProvider(provider) {
|
|
20484
20494
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20621,7 +20631,12 @@ var HARNESS = {
|
|
|
20621
20631
|
ClaudeDesktop: "claudedesktop",
|
|
20622
20632
|
ChatGpt: "chatgpt",
|
|
20623
20633
|
ClaudeAi: "claudeai",
|
|
20624
|
-
Api: "api"
|
|
20634
|
+
Api: "api",
|
|
20635
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20636
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20637
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20638
|
+
// whose wire spelling differs from its display spelling.
|
|
20639
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20625
20640
|
};
|
|
20626
20641
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20627
20642
|
var SOURCE_TOOL = {
|
|
@@ -20637,9 +20652,15 @@ var SOURCE_TOOL = {
|
|
|
20637
20652
|
// whose tool could not be identified both render through the read side's
|
|
20638
20653
|
// miss path rather than as a harness of their own.
|
|
20639
20654
|
Cli: "cli",
|
|
20640
|
-
Unknown: "unknown"
|
|
20655
|
+
Unknown: "unknown",
|
|
20656
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20657
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20658
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20659
|
+
// assistant's own hook contract.
|
|
20660
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20641
20661
|
};
|
|
20642
20662
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20663
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20643
20664
|
var TOOL_TO_HARNESS = {
|
|
20644
20665
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20645
20666
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20648,7 +20669,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20648
20669
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20649
20670
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20650
20671
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20651
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20672
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20673
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20674
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20675
|
+
// their intersection — leaving a shared member out would read as an
|
|
20676
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20677
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20652
20678
|
};
|
|
20653
20679
|
|
|
20654
20680
|
// ../../packages/schema/src/zod/finding.ts
|
|
@@ -20682,7 +20708,8 @@ var FindingProvider = Harness.extract([
|
|
|
20682
20708
|
"ClaudeAi",
|
|
20683
20709
|
"Codex",
|
|
20684
20710
|
"Antigravity",
|
|
20685
|
-
"Api"
|
|
20711
|
+
"Api",
|
|
20712
|
+
"AiTcSdk"
|
|
20686
20713
|
]).meta({ id: "FindingProvider" });
|
|
20687
20714
|
var FindingCategory = external_exports.enum([
|
|
20688
20715
|
"secret",
|
|
@@ -21059,18 +21086,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21059
21086
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21060
21087
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21061
21088
|
"tool_use",
|
|
21062
|
-
// One row per model REFUSAL
|
|
21063
|
-
//
|
|
21064
|
-
//
|
|
21065
|
-
//
|
|
21066
|
-
//
|
|
21067
|
-
//
|
|
21089
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21090
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21091
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21092
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21093
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21094
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21095
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21096
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21097
|
+
// product exists to keep from travelling.
|
|
21068
21098
|
"model_refusal",
|
|
21099
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21100
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21101
|
+
// against that call's non-streamed response. A structural row like
|
|
21102
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21103
|
+
// which side, which seam, what action and which field are decided rides
|
|
21104
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21105
|
+
// travels.
|
|
21106
|
+
//
|
|
21107
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21108
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21109
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21110
|
+
// than splitting one governance concept across two event types. This
|
|
21111
|
+
// member carries every OTHER request-path decision.
|
|
21112
|
+
"request_decision",
|
|
21069
21113
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21070
21114
|
// fact the posture inspection findings reference (findings require an
|
|
21071
21115
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21072
21116
|
// surface renders.
|
|
21073
|
-
"config_scan"
|
|
21117
|
+
"config_scan",
|
|
21118
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21119
|
+
// session root. The durable home of what one tab's network interception
|
|
21120
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21121
|
+
// second process (aka extension status) and a restarted host both have
|
|
21122
|
+
// somewhere to read it back from.
|
|
21123
|
+
"capture_status"
|
|
21074
21124
|
]).meta({ id: "AuditEventType" });
|
|
21075
21125
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21076
21126
|
var HostAttributes = external_exports.object({
|
|
@@ -21230,6 +21280,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21230
21280
|
// repeated rather than referenced because a store reader opens this file.
|
|
21231
21281
|
redact_degraded_to: ActionTaken.optional()
|
|
21232
21282
|
}).catchall(external_exports.unknown());
|
|
21283
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21284
|
+
source_tool: external_exports.string().optional(),
|
|
21285
|
+
patched: external_exports.boolean().optional(),
|
|
21286
|
+
live: external_exports.boolean().optional(),
|
|
21287
|
+
blind: external_exports.boolean().optional(),
|
|
21288
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21289
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21290
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21291
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21292
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21293
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21294
|
+
closed: external_exports.boolean().optional(),
|
|
21295
|
+
enforcement: external_exports.string().optional()
|
|
21296
|
+
}).catchall(external_exports.unknown());
|
|
21233
21297
|
var ToolCallInspection = external_exports.object({
|
|
21234
21298
|
ruleId: external_exports.string().min(1),
|
|
21235
21299
|
ruleName: external_exports.string(),
|
|
@@ -22089,6 +22153,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22089
22153
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22090
22154
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22091
22155
|
});
|
|
22156
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22157
|
+
function unsafeEndpointReason(endpoint) {
|
|
22158
|
+
let parsed2;
|
|
22159
|
+
try {
|
|
22160
|
+
parsed2 = new URL(endpoint);
|
|
22161
|
+
} catch {
|
|
22162
|
+
return "unparseable";
|
|
22163
|
+
}
|
|
22164
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22165
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22166
|
+
if (parsed2.protocol === "https:") return null;
|
|
22167
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22168
|
+
}
|
|
22169
|
+
function isSafeEndpoint(endpoint) {
|
|
22170
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22171
|
+
}
|
|
22172
|
+
function originOnly(endpoint) {
|
|
22173
|
+
try {
|
|
22174
|
+
const parsed2 = new URL(endpoint);
|
|
22175
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22176
|
+
} catch {
|
|
22177
|
+
return "(unparseable endpoint)";
|
|
22178
|
+
}
|
|
22179
|
+
}
|
|
22092
22180
|
var MAX_DATE_MS = 253402300799999;
|
|
22093
22181
|
var MAX_INT4 = 2147483647;
|
|
22094
22182
|
var StorePosturePack = external_exports.object({
|
|
@@ -22243,6 +22331,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22243
22331
|
"rejected",
|
|
22244
22332
|
"unreachable"
|
|
22245
22333
|
]);
|
|
22334
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22335
|
+
"unauthorized",
|
|
22336
|
+
"forbidden",
|
|
22337
|
+
"unreachable"
|
|
22338
|
+
]);
|
|
22246
22339
|
var AttachDeviceRequest = external_exports.object({
|
|
22247
22340
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22248
22341
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22782,7 +22875,12 @@ var EventMetadata = external_exports.object({
|
|
|
22782
22875
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22783
22876
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22784
22877
|
// on every other capture path, which has no such id.
|
|
22785
|
-
|
|
22878
|
+
//
|
|
22879
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22880
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22881
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22882
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22883
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22786
22884
|
conversationId: external_exports.string().optional(),
|
|
22787
22885
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22788
22886
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23629,6 +23727,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23629
23727
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23630
23728
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23631
23729
|
);
|
|
23730
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23731
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23732
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23733
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23734
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23735
|
+
return map2;
|
|
23736
|
+
}
|
|
23737
|
+
function policyKey(policy) {
|
|
23738
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23739
|
+
}
|
|
23740
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23741
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23742
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23743
|
+
}
|
|
23744
|
+
function strongerOf(a, b) {
|
|
23745
|
+
if (a === null) return b;
|
|
23746
|
+
if (b === null) return a;
|
|
23747
|
+
return strongerAction(a, b);
|
|
23748
|
+
}
|
|
23749
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23750
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23751
|
+
const disabled = [];
|
|
23752
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23753
|
+
for (const policy of remotePolicies) {
|
|
23754
|
+
if (!policy.enabled) continue;
|
|
23755
|
+
if (!("category" in policy.target)) continue;
|
|
23756
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23757
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23758
|
+
remoteCategoryAction.set(
|
|
23759
|
+
policy.target.category,
|
|
23760
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23761
|
+
);
|
|
23762
|
+
}
|
|
23763
|
+
for (const policy of localPolicies) {
|
|
23764
|
+
if (!policy.enabled) {
|
|
23765
|
+
disabled.push(policy);
|
|
23766
|
+
continue;
|
|
23767
|
+
}
|
|
23768
|
+
const key = policyKey(policy);
|
|
23769
|
+
if (merged.has(key)) continue;
|
|
23770
|
+
let remoteFloor = null;
|
|
23771
|
+
if ("ruleId" in policy.target) {
|
|
23772
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23773
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23774
|
+
}
|
|
23775
|
+
merged.set(
|
|
23776
|
+
key,
|
|
23777
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23778
|
+
);
|
|
23779
|
+
}
|
|
23780
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23781
|
+
for (const policy of merged.values()) {
|
|
23782
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23783
|
+
}
|
|
23784
|
+
for (const policy of remotePolicies) {
|
|
23785
|
+
if (!policy.enabled) {
|
|
23786
|
+
disabled.push(policy);
|
|
23787
|
+
continue;
|
|
23788
|
+
}
|
|
23789
|
+
const key = policyKey(policy);
|
|
23790
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23791
|
+
let localFloor = null;
|
|
23792
|
+
if ("ruleId" in policy.target) {
|
|
23793
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23794
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23795
|
+
}
|
|
23796
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23797
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23798
|
+
const existing = merged.get(key);
|
|
23799
|
+
if (existing === void 0) {
|
|
23800
|
+
merged.set(key, clamped);
|
|
23801
|
+
continue;
|
|
23802
|
+
}
|
|
23803
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23804
|
+
merged.set(key, clamped);
|
|
23805
|
+
}
|
|
23806
|
+
}
|
|
23807
|
+
return [...merged.values(), ...disabled];
|
|
23808
|
+
}
|
|
23632
23809
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23633
23810
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23634
23811
|
);
|
|
@@ -23854,6 +24031,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23854
24031
|
payloadVersion: external_exports.number().int().positive(),
|
|
23855
24032
|
endpoint: external_exports.string()
|
|
23856
24033
|
});
|
|
24034
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24035
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24036
|
+
version: external_exports.number().int().positive()
|
|
24037
|
+
});
|
|
24038
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24039
|
+
var WebChatCapture = external_exports.object({
|
|
24040
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24041
|
+
account: external_exports.boolean().default(false),
|
|
24042
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24043
|
+
// isWebChatCaptureConsentValid.
|
|
24044
|
+
consent: WebChatCaptureConsent.optional()
|
|
24045
|
+
});
|
|
23857
24046
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23858
24047
|
var BodyRetention = external_exports.object({
|
|
23859
24048
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23912,6 +24101,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23912
24101
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23913
24102
|
// or an older payload no longer counts.
|
|
23914
24103
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24104
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24105
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24106
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24107
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24108
|
+
// webChatCaptureOf's answer, in one place.
|
|
24109
|
+
//
|
|
24110
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24111
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24112
|
+
// written down.
|
|
24113
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23915
24114
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23916
24115
|
// body never removes the row or its findings.
|
|
23917
24116
|
bodyRetention: BodyRetention.default({
|
|
@@ -24019,7 +24218,10 @@ function toCaptureAttributes(event) {
|
|
|
24019
24218
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24020
24219
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24021
24220
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24022
|
-
|
|
24221
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24222
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24223
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24224
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24023
24225
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24024
24226
|
};
|
|
24025
24227
|
}
|
|
@@ -24393,12 +24595,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24393
24595
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24394
24596
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24395
24597
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24598
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24396
24599
|
var SaveSettingsInput = external_exports.object({
|
|
24397
24600
|
historicalAccess: external_exports.string(),
|
|
24398
24601
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24399
24602
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24400
24603
|
vaultConsent: external_exports.string(),
|
|
24401
24604
|
vaultInlineReveal: external_exports.string(),
|
|
24605
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24402
24606
|
// Widened to `string` like its neighbours rather than typed as
|
|
24403
24607
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24404
24608
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24613,11 +24817,24 @@ var WebExchange = external_exports.object({
|
|
|
24613
24817
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24614
24818
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24615
24819
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24616
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24617
|
-
//
|
|
24820
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24821
|
+
// reply.
|
|
24618
24822
|
responseText: external_exports.string().optional(),
|
|
24823
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24824
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24825
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24826
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24827
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24828
|
+
// should branch as though it could.
|
|
24619
24829
|
truncated: external_exports.boolean().default(false)
|
|
24620
24830
|
});
|
|
24831
|
+
var WebEnforcementState = external_exports.enum([
|
|
24832
|
+
"watching",
|
|
24833
|
+
"composer-only",
|
|
24834
|
+
"button-only",
|
|
24835
|
+
"unattached",
|
|
24836
|
+
"unknown"
|
|
24837
|
+
]);
|
|
24621
24838
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24622
24839
|
var WebCaptureStatus = external_exports.object({
|
|
24623
24840
|
patched: external_exports.boolean(),
|
|
@@ -24629,8 +24846,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24629
24846
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24630
24847
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24631
24848
|
// the earliest signal that a site's contract moved.
|
|
24632
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24633
|
-
|
|
24849
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24850
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24851
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24852
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24853
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24854
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24855
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24856
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24857
|
+
// its `pagehide` report and nowhere else.
|
|
24858
|
+
//
|
|
24859
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24860
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24861
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24862
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24863
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24864
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24865
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24866
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24867
|
+
//
|
|
24868
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24869
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24870
|
+
// is not a final one.
|
|
24871
|
+
closed: external_exports.boolean().default(false),
|
|
24872
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24873
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24874
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24875
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24876
|
+
// predating the field is not read as reporting a healthy one.
|
|
24877
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24878
|
+
});
|
|
24879
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24880
|
+
if (!status.patched) return true;
|
|
24881
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24882
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24883
|
+
}
|
|
24884
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24885
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24886
|
+
}
|
|
24887
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24888
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24889
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24890
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24891
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24892
|
+
if (!parsedBag.success) return null;
|
|
24893
|
+
const b = parsedBag.data;
|
|
24894
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24895
|
+
patched: b.patched,
|
|
24896
|
+
live: b.live,
|
|
24897
|
+
blind: b.blind,
|
|
24898
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24899
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24900
|
+
parseFailures: b.parse_failures,
|
|
24901
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24902
|
+
shapeMisses: b.shape_misses,
|
|
24903
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24904
|
+
closed: b.closed,
|
|
24905
|
+
enforcement: b.enforcement
|
|
24906
|
+
});
|
|
24907
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24908
|
+
}
|
|
24634
24909
|
|
|
24635
24910
|
// ../../packages/persistence/src/paths.ts
|
|
24636
24911
|
import {
|
|
@@ -24761,17 +25036,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24761
25036
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24762
25037
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24763
25038
|
}
|
|
24764
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24765
|
-
function isSafeEndpoint(endpoint) {
|
|
24766
|
-
let parsed2;
|
|
24767
|
-
try {
|
|
24768
|
-
parsed2 = new URL(endpoint);
|
|
24769
|
-
} catch {
|
|
24770
|
-
return false;
|
|
24771
|
-
}
|
|
24772
|
-
if (parsed2.protocol === "https:") return true;
|
|
24773
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24774
|
-
}
|
|
24775
25039
|
function repairOrRefuseMode(file2) {
|
|
24776
25040
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24777
25041
|
if (link === void 0) return "absent";
|
|
@@ -26564,7 +26828,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26564
26828
|
var HAS_ACTIVITY = `EXISTS (
|
|
26565
26829
|
SELECT 1 FROM audit_events c
|
|
26566
26830
|
WHERE c.root_session_id = audit_events.id
|
|
26567
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26831
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26568
26832
|
var SqliteActivityRepository = class {
|
|
26569
26833
|
constructor(db, now = () => Date.now()) {
|
|
26570
26834
|
this.db = db;
|
|
@@ -26591,10 +26855,10 @@ var SqliteActivityRepository = class {
|
|
|
26591
26855
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26592
26856
|
UNION
|
|
26593
26857
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26594
|
-
WHERE started_at >= ?
|
|
26858
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26595
26859
|
UNION
|
|
26596
26860
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26597
|
-
WHERE ended_at >= ?)`,
|
|
26861
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26598
26862
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26599
26863
|
);
|
|
26600
26864
|
const toolCallsToday = countScalar(
|
|
@@ -27001,7 +27265,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27001
27265
|
attributes = excluded.attributes,
|
|
27002
27266
|
ended_at = excluded.ended_at
|
|
27003
27267
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27004
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27268
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27269
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27270
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27271
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27005
27272
|
);
|
|
27006
27273
|
this.upsertSessionRootStmt = db.prepare(
|
|
27007
27274
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27269,6 +27536,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27269
27536
|
}
|
|
27270
27537
|
};
|
|
27271
27538
|
|
|
27539
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27540
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27541
|
+
var SqliteCaptureStatusRepository = class {
|
|
27542
|
+
constructor(db) {
|
|
27543
|
+
this.db = db;
|
|
27544
|
+
this.recentStmt = db.prepare(
|
|
27545
|
+
`SELECT a.started_at AS startedAt,
|
|
27546
|
+
a.attributes AS attributes,
|
|
27547
|
+
a.root_session_id AS rootSessionId
|
|
27548
|
+
FROM audit_events a
|
|
27549
|
+
WHERE a.event_type = 'capture_status'
|
|
27550
|
+
AND a.source_tool = ?
|
|
27551
|
+
AND a.started_at >= ?
|
|
27552
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27553
|
+
LIMIT ?`
|
|
27554
|
+
);
|
|
27555
|
+
}
|
|
27556
|
+
db;
|
|
27557
|
+
recentStmt;
|
|
27558
|
+
/**
|
|
27559
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27560
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27561
|
+
*
|
|
27562
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27563
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27564
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27565
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27566
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27567
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27568
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27569
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27570
|
+
* this package may not import it.
|
|
27571
|
+
*
|
|
27572
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27573
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27574
|
+
* the window without moving the wall clock.
|
|
27575
|
+
*
|
|
27576
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27577
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27578
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27579
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27580
|
+
* clear it.
|
|
27581
|
+
*/
|
|
27582
|
+
latest(now) {
|
|
27583
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27584
|
+
const documents = [];
|
|
27585
|
+
for (const tool of WebSourceTool.options) {
|
|
27586
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27587
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27588
|
+
for (const row of allRows(this.recentStmt, [
|
|
27589
|
+
tool,
|
|
27590
|
+
since,
|
|
27591
|
+
STATUS_LOOKBACK_ROWS
|
|
27592
|
+
])) {
|
|
27593
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27594
|
+
if (status === null) continue;
|
|
27595
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27596
|
+
const group = rows.get(row.rootSessionId);
|
|
27597
|
+
if (group === void 0) {
|
|
27598
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27599
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27600
|
+
} else {
|
|
27601
|
+
group.push(record2);
|
|
27602
|
+
}
|
|
27603
|
+
}
|
|
27604
|
+
for (const [root, candidates] of rows) {
|
|
27605
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27606
|
+
const last = lastWord.get(root);
|
|
27607
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27608
|
+
documents.push({
|
|
27609
|
+
...picked,
|
|
27610
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27611
|
+
lastReportAt: last.at,
|
|
27612
|
+
closed: last.closed
|
|
27613
|
+
});
|
|
27614
|
+
}
|
|
27615
|
+
}
|
|
27616
|
+
return documents;
|
|
27617
|
+
}
|
|
27618
|
+
};
|
|
27619
|
+
|
|
27272
27620
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27273
27621
|
var SqliteClassifiedDataRepository = class {
|
|
27274
27622
|
constructor(db) {
|
|
@@ -32849,6 +33197,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32849
33197
|
activity: new SqliteActivityRepository(db),
|
|
32850
33198
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32851
33199
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33200
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32852
33201
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32853
33202
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32854
33203
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32889,6 +33238,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32889
33238
|
activity,
|
|
32890
33239
|
sourceProject,
|
|
32891
33240
|
auditEvents,
|
|
33241
|
+
captureStatus,
|
|
32892
33242
|
classifiedData,
|
|
32893
33243
|
inspectionDefinitions,
|
|
32894
33244
|
inspectionFindings,
|
|
@@ -33106,6 +33456,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33106
33456
|
activity,
|
|
33107
33457
|
sourceProject,
|
|
33108
33458
|
auditEvents,
|
|
33459
|
+
captureStatus,
|
|
33109
33460
|
classifiedData,
|
|
33110
33461
|
inspectionDefinitions,
|
|
33111
33462
|
inspectionFindings,
|
|
@@ -33331,11 +33682,6 @@ function fingerprintValue(key, raw) {
|
|
|
33331
33682
|
// ../../packages/persistence/src/forward-health.ts
|
|
33332
33683
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33333
33684
|
import { join as join9 } from "path";
|
|
33334
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33335
|
-
"unauthorized",
|
|
33336
|
-
"forbidden",
|
|
33337
|
-
"unreachable"
|
|
33338
|
-
]);
|
|
33339
33685
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33340
33686
|
function parseForwardHealth(raw, nowMs) {
|
|
33341
33687
|
try {
|
|
@@ -33344,7 +33690,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33344
33690
|
const record2 = parsed2;
|
|
33345
33691
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33346
33692
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33347
|
-
const
|
|
33693
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33694
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33348
33695
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33349
33696
|
} catch {
|
|
33350
33697
|
return null;
|
|
@@ -33481,6 +33828,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
33481
33828
|
}
|
|
33482
33829
|
cause;
|
|
33483
33830
|
};
|
|
33831
|
+
var RemoteEndpointRefused = class extends Error {
|
|
33832
|
+
constructor(endpoint) {
|
|
33833
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
33834
|
+
this.name = "RemoteEndpointRefused";
|
|
33835
|
+
}
|
|
33836
|
+
};
|
|
33484
33837
|
var RemoteResponseInvalid = class extends Error {
|
|
33485
33838
|
constructor(route, detail) {
|
|
33486
33839
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -33633,14 +33986,15 @@ function parsed(schema, body, route) {
|
|
|
33633
33986
|
}
|
|
33634
33987
|
return result.data;
|
|
33635
33988
|
}
|
|
33636
|
-
function
|
|
33989
|
+
function resolveBaseUrl(endpoint) {
|
|
33990
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
33637
33991
|
let end = endpoint.length;
|
|
33638
33992
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
33639
33993
|
return endpoint.slice(0, end);
|
|
33640
33994
|
}
|
|
33641
33995
|
var SLASH2 = "/".charCodeAt(0);
|
|
33642
33996
|
function createRemoteClient(options) {
|
|
33643
|
-
const base =
|
|
33997
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
33644
33998
|
const url2 = (route) => `${base}${route}`;
|
|
33645
33999
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
33646
34000
|
const sendOne = async (event) => {
|
|
@@ -33770,6 +34124,7 @@ function classifyRemoteFailure(err) {
|
|
|
33770
34124
|
case "RemoteRouteAbsent":
|
|
33771
34125
|
return "route-absent";
|
|
33772
34126
|
case "RemoteRequestInvalid":
|
|
34127
|
+
case "RemoteEndpointRefused":
|
|
33773
34128
|
return "invalid-request";
|
|
33774
34129
|
case "RemoteResponseInvalid":
|
|
33775
34130
|
return "rejected";
|
|
@@ -34886,6 +35241,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34886
35241
|
}
|
|
34887
35242
|
];
|
|
34888
35243
|
|
|
35244
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
35245
|
+
var RULE_VERSION2 = "1";
|
|
35246
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
35247
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
35248
|
+
"blind",
|
|
35249
|
+
"degraded"
|
|
35250
|
+
]);
|
|
35251
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
35252
|
+
ruleId: "web-capture-drift",
|
|
35253
|
+
version: RULE_VERSION2,
|
|
35254
|
+
name: "Web chat capture is not reading the site",
|
|
35255
|
+
category: "config",
|
|
35256
|
+
severity: "medium",
|
|
35257
|
+
definition: JSON.stringify({
|
|
35258
|
+
kind: "web-capture-drift",
|
|
35259
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
35260
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
35261
|
+
})
|
|
35262
|
+
};
|
|
35263
|
+
var STATIC_COPY = {
|
|
35264
|
+
active: { headline: "turns are being observed on this site" },
|
|
35265
|
+
unreported: {
|
|
35266
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
35267
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
35268
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
35269
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
35270
|
+
// copy may not claim the stronger of them.
|
|
35271
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
35272
|
+
},
|
|
35273
|
+
standby: {
|
|
35274
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
35275
|
+
},
|
|
35276
|
+
unpatched: {
|
|
35277
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
35278
|
+
// that installed and hooked neither transport and for one that never ran
|
|
35279
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
35280
|
+
// assert one of them.
|
|
35281
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
35282
|
+
},
|
|
35283
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
35284
|
+
blind: {
|
|
35285
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
35286
|
+
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."
|
|
35287
|
+
},
|
|
35288
|
+
degraded: {
|
|
35289
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
35290
|
+
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."
|
|
35291
|
+
}
|
|
35292
|
+
};
|
|
35293
|
+
|
|
34889
35294
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34890
35295
|
var BUDGET_MS = 100;
|
|
34891
35296
|
var EXPONENTIAL_UNITS = [
|
|
@@ -38237,86 +38642,10 @@ function createForwardPolicy(deps) {
|
|
|
38237
38642
|
}
|
|
38238
38643
|
|
|
38239
38644
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
38240
|
-
|
|
38241
|
-
|
|
38242
|
-
|
|
38243
|
-
return
|
|
38244
|
-
}
|
|
38245
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
38246
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
38247
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
38248
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
38249
|
-
for (const pack of bundledDetections()) {
|
|
38250
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
38251
|
-
}
|
|
38252
|
-
return map2;
|
|
38253
|
-
}
|
|
38254
|
-
function policyKey(policy) {
|
|
38255
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
38256
|
-
}
|
|
38257
|
-
function floorFor(policy, categoryByRuleId) {
|
|
38258
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
38259
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
38260
|
-
}
|
|
38261
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
38262
|
-
const merged = /* @__PURE__ */ new Map();
|
|
38263
|
-
const disabled = [];
|
|
38264
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
38265
|
-
for (const policy of remotePolicies) {
|
|
38266
|
-
if (!policy.enabled) continue;
|
|
38267
|
-
if (!("category" in policy.target)) continue;
|
|
38268
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
38269
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38270
|
-
remoteCategoryAction.set(
|
|
38271
|
-
policy.target.category,
|
|
38272
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
38273
|
-
);
|
|
38274
|
-
}
|
|
38275
|
-
for (const policy of localPolicies) {
|
|
38276
|
-
if (!policy.enabled) {
|
|
38277
|
-
disabled.push(policy);
|
|
38278
|
-
continue;
|
|
38279
|
-
}
|
|
38280
|
-
const key = policyKey(policy);
|
|
38281
|
-
if (merged.has(key)) continue;
|
|
38282
|
-
let remoteFloor = null;
|
|
38283
|
-
if ("ruleId" in policy.target) {
|
|
38284
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38285
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
38286
|
-
}
|
|
38287
|
-
merged.set(
|
|
38288
|
-
key,
|
|
38289
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
38290
|
-
);
|
|
38291
|
-
}
|
|
38292
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
38293
|
-
for (const policy of merged.values()) {
|
|
38294
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
38295
|
-
}
|
|
38296
|
-
for (const policy of remotePolicies) {
|
|
38297
|
-
if (!policy.enabled) {
|
|
38298
|
-
disabled.push(policy);
|
|
38299
|
-
continue;
|
|
38300
|
-
}
|
|
38301
|
-
const key = policyKey(policy);
|
|
38302
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38303
|
-
let localFloor = null;
|
|
38304
|
-
if ("ruleId" in policy.target) {
|
|
38305
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38306
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
38307
|
-
}
|
|
38308
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
38309
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
38310
|
-
const existing = merged.get(key);
|
|
38311
|
-
if (existing === void 0) {
|
|
38312
|
-
merged.set(key, clamped);
|
|
38313
|
-
continue;
|
|
38314
|
-
}
|
|
38315
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
38316
|
-
merged.set(key, clamped);
|
|
38317
|
-
}
|
|
38318
|
-
}
|
|
38319
|
-
return [...merged.values(), ...disabled];
|
|
38645
|
+
var bundledRulesFlatCache;
|
|
38646
|
+
function bundledRulesFlat() {
|
|
38647
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
38648
|
+
return bundledRulesFlatCache;
|
|
38320
38649
|
}
|
|
38321
38650
|
var AttachedDataGateway = class {
|
|
38322
38651
|
constructor(deps) {
|
|
@@ -38636,6 +38965,9 @@ var AttachedDataGateway = class {
|
|
|
38636
38965
|
async readSessionProvider(sessionId) {
|
|
38637
38966
|
return this.deps.local.readSessionProvider(sessionId);
|
|
38638
38967
|
}
|
|
38968
|
+
async readCaptureStatuses() {
|
|
38969
|
+
return this.deps.local.readCaptureStatuses();
|
|
38970
|
+
}
|
|
38639
38971
|
async facets() {
|
|
38640
38972
|
return this.deps.local.facets();
|
|
38641
38973
|
}
|
|
@@ -38718,7 +39050,7 @@ var AttachedDataGateway = class {
|
|
|
38718
39050
|
policies: mergeRaiseOnly(
|
|
38719
39051
|
local.policies,
|
|
38720
39052
|
cached2.policies,
|
|
38721
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
39053
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
38722
39054
|
),
|
|
38723
39055
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
38724
39056
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -38919,10 +39251,15 @@ import { join as join27 } from "path";
|
|
|
38919
39251
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
38920
39252
|
import { rename as rename2 } from "fs/promises";
|
|
38921
39253
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
38922
|
-
var
|
|
39254
|
+
var IMMEDIATE_RETRIES = 8;
|
|
39255
|
+
var TIMED_RETRIES = 4;
|
|
39256
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
38923
39257
|
var delay = (ms) => new Promise((resolve2) => {
|
|
38924
39258
|
setTimeout(resolve2, ms);
|
|
38925
39259
|
});
|
|
39260
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
39261
|
+
setImmediate(resolve2);
|
|
39262
|
+
});
|
|
38926
39263
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
38927
39264
|
for (let attempt = 1; ; attempt += 1) {
|
|
38928
39265
|
try {
|
|
@@ -38931,7 +39268,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
38931
39268
|
} catch (err) {
|
|
38932
39269
|
const code = err.code;
|
|
38933
39270
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
38934
|
-
await delay(attempt * 10);
|
|
39271
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
38935
39272
|
}
|
|
38936
39273
|
}
|
|
38937
39274
|
}
|
|
@@ -39395,6 +39732,9 @@ var StandaloneDataGateway = class {
|
|
|
39395
39732
|
readSessionProvider(sessionId) {
|
|
39396
39733
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
39397
39734
|
}
|
|
39735
|
+
readCaptureStatuses() {
|
|
39736
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
39737
|
+
}
|
|
39398
39738
|
facets() {
|
|
39399
39739
|
return Promise.resolve(this.db.facets());
|
|
39400
39740
|
}
|