@akasecurity/ai-tc-antigravity 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/package.json +2 -2
- package/plugin.json +1 -1
- 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 +212 -17
- package/scripts/pre-invocation.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/start-light.js +209 -17
- package/scripts/stop.js +212 -17
- package/scripts/sync.js +464 -124
package/scripts/reconcile.js
CHANGED
|
@@ -20482,7 +20482,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20482
20482
|
"gateway",
|
|
20483
20483
|
"unknown",
|
|
20484
20484
|
"cli",
|
|
20485
|
-
"api"
|
|
20485
|
+
"api",
|
|
20486
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20487
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20488
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20489
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20490
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20491
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20492
|
+
// the reason on the way, rather than quietly adding one to
|
|
20493
|
+
// PROVIDER_PLATFORM.
|
|
20494
|
+
"chatgpt",
|
|
20495
|
+
"claude-ai"
|
|
20486
20496
|
]);
|
|
20487
20497
|
function platformForProvider(provider) {
|
|
20488
20498
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20625,7 +20635,12 @@ var HARNESS = {
|
|
|
20625
20635
|
ClaudeDesktop: "claudedesktop",
|
|
20626
20636
|
ChatGpt: "chatgpt",
|
|
20627
20637
|
ClaudeAi: "claudeai",
|
|
20628
|
-
Api: "api"
|
|
20638
|
+
Api: "api",
|
|
20639
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20640
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20641
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20642
|
+
// whose wire spelling differs from its display spelling.
|
|
20643
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20629
20644
|
};
|
|
20630
20645
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20631
20646
|
var SOURCE_TOOL = {
|
|
@@ -20641,9 +20656,15 @@ var SOURCE_TOOL = {
|
|
|
20641
20656
|
// whose tool could not be identified both render through the read side's
|
|
20642
20657
|
// miss path rather than as a harness of their own.
|
|
20643
20658
|
Cli: "cli",
|
|
20644
|
-
Unknown: "unknown"
|
|
20659
|
+
Unknown: "unknown",
|
|
20660
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20661
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20662
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20663
|
+
// assistant's own hook contract.
|
|
20664
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20645
20665
|
};
|
|
20646
20666
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20667
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20647
20668
|
var TOOL_TO_HARNESS = {
|
|
20648
20669
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20649
20670
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20652,7 +20673,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20652
20673
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20653
20674
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20654
20675
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20655
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20676
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20677
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20678
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20679
|
+
// their intersection — leaving a shared member out would read as an
|
|
20680
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20681
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20656
20682
|
};
|
|
20657
20683
|
function harnessFromTool(tool) {
|
|
20658
20684
|
return (Object.hasOwn(TOOL_TO_HARNESS, tool) ? TOOL_TO_HARNESS[tool] : void 0) ?? tool;
|
|
@@ -20689,7 +20715,8 @@ var FindingProvider = Harness.extract([
|
|
|
20689
20715
|
"ClaudeAi",
|
|
20690
20716
|
"Codex",
|
|
20691
20717
|
"Antigravity",
|
|
20692
|
-
"Api"
|
|
20718
|
+
"Api",
|
|
20719
|
+
"AiTcSdk"
|
|
20693
20720
|
]).meta({ id: "FindingProvider" });
|
|
20694
20721
|
var FindingCategory = external_exports.enum([
|
|
20695
20722
|
"secret",
|
|
@@ -21066,18 +21093,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21066
21093
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21067
21094
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21068
21095
|
"tool_use",
|
|
21069
|
-
// One row per model REFUSAL
|
|
21070
|
-
//
|
|
21071
|
-
//
|
|
21072
|
-
//
|
|
21073
|
-
//
|
|
21074
|
-
//
|
|
21096
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21097
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21098
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21099
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21100
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21101
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21102
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21103
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21104
|
+
// product exists to keep from travelling.
|
|
21075
21105
|
"model_refusal",
|
|
21106
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21107
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21108
|
+
// against that call's non-streamed response. A structural row like
|
|
21109
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21110
|
+
// which side, which seam, what action and which field are decided rides
|
|
21111
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21112
|
+
// travels.
|
|
21113
|
+
//
|
|
21114
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21115
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21116
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21117
|
+
// than splitting one governance concept across two event types. This
|
|
21118
|
+
// member carries every OTHER request-path decision.
|
|
21119
|
+
"request_decision",
|
|
21076
21120
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21077
21121
|
// fact the posture inspection findings reference (findings require an
|
|
21078
21122
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21079
21123
|
// surface renders.
|
|
21080
|
-
"config_scan"
|
|
21124
|
+
"config_scan",
|
|
21125
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21126
|
+
// session root. The durable home of what one tab's network interception
|
|
21127
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21128
|
+
// second process (aka extension status) and a restarted host both have
|
|
21129
|
+
// somewhere to read it back from.
|
|
21130
|
+
"capture_status"
|
|
21081
21131
|
]).meta({ id: "AuditEventType" });
|
|
21082
21132
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21083
21133
|
var HostAttributes = external_exports.object({
|
|
@@ -21237,6 +21287,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21237
21287
|
// repeated rather than referenced because a store reader opens this file.
|
|
21238
21288
|
redact_degraded_to: ActionTaken.optional()
|
|
21239
21289
|
}).catchall(external_exports.unknown());
|
|
21290
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21291
|
+
source_tool: external_exports.string().optional(),
|
|
21292
|
+
patched: external_exports.boolean().optional(),
|
|
21293
|
+
live: external_exports.boolean().optional(),
|
|
21294
|
+
blind: external_exports.boolean().optional(),
|
|
21295
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21296
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21297
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21298
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21299
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21300
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21301
|
+
closed: external_exports.boolean().optional(),
|
|
21302
|
+
enforcement: external_exports.string().optional()
|
|
21303
|
+
}).catchall(external_exports.unknown());
|
|
21240
21304
|
var ToolCallInspection = external_exports.object({
|
|
21241
21305
|
ruleId: external_exports.string().min(1),
|
|
21242
21306
|
ruleName: external_exports.string(),
|
|
@@ -22096,6 +22160,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22096
22160
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22097
22161
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22098
22162
|
});
|
|
22163
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22164
|
+
function unsafeEndpointReason(endpoint) {
|
|
22165
|
+
let parsed2;
|
|
22166
|
+
try {
|
|
22167
|
+
parsed2 = new URL(endpoint);
|
|
22168
|
+
} catch {
|
|
22169
|
+
return "unparseable";
|
|
22170
|
+
}
|
|
22171
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22172
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22173
|
+
if (parsed2.protocol === "https:") return null;
|
|
22174
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22175
|
+
}
|
|
22176
|
+
function isSafeEndpoint(endpoint) {
|
|
22177
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22178
|
+
}
|
|
22179
|
+
function originOnly(endpoint) {
|
|
22180
|
+
try {
|
|
22181
|
+
const parsed2 = new URL(endpoint);
|
|
22182
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22183
|
+
} catch {
|
|
22184
|
+
return "(unparseable endpoint)";
|
|
22185
|
+
}
|
|
22186
|
+
}
|
|
22099
22187
|
var MAX_DATE_MS = 253402300799999;
|
|
22100
22188
|
var MAX_INT4 = 2147483647;
|
|
22101
22189
|
var StorePosturePack = external_exports.object({
|
|
@@ -22250,6 +22338,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22250
22338
|
"rejected",
|
|
22251
22339
|
"unreachable"
|
|
22252
22340
|
]);
|
|
22341
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22342
|
+
"unauthorized",
|
|
22343
|
+
"forbidden",
|
|
22344
|
+
"unreachable"
|
|
22345
|
+
]);
|
|
22253
22346
|
var AttachDeviceRequest = external_exports.object({
|
|
22254
22347
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22255
22348
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22789,7 +22882,12 @@ var EventMetadata = external_exports.object({
|
|
|
22789
22882
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22790
22883
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22791
22884
|
// on every other capture path, which has no such id.
|
|
22792
|
-
|
|
22885
|
+
//
|
|
22886
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22887
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22888
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22889
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22890
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22793
22891
|
conversationId: external_exports.string().optional(),
|
|
22794
22892
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22795
22893
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23631,6 +23729,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23631
23729
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23632
23730
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23633
23731
|
);
|
|
23732
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23733
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23734
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23735
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23736
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23737
|
+
return map2;
|
|
23738
|
+
}
|
|
23739
|
+
function policyKey(policy) {
|
|
23740
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23741
|
+
}
|
|
23742
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23743
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23744
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23745
|
+
}
|
|
23746
|
+
function strongerOf(a, b) {
|
|
23747
|
+
if (a === null) return b;
|
|
23748
|
+
if (b === null) return a;
|
|
23749
|
+
return strongerAction(a, b);
|
|
23750
|
+
}
|
|
23751
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23752
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23753
|
+
const disabled = [];
|
|
23754
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23755
|
+
for (const policy of remotePolicies) {
|
|
23756
|
+
if (!policy.enabled) continue;
|
|
23757
|
+
if (!("category" in policy.target)) continue;
|
|
23758
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23759
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23760
|
+
remoteCategoryAction.set(
|
|
23761
|
+
policy.target.category,
|
|
23762
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23763
|
+
);
|
|
23764
|
+
}
|
|
23765
|
+
for (const policy of localPolicies) {
|
|
23766
|
+
if (!policy.enabled) {
|
|
23767
|
+
disabled.push(policy);
|
|
23768
|
+
continue;
|
|
23769
|
+
}
|
|
23770
|
+
const key = policyKey(policy);
|
|
23771
|
+
if (merged.has(key)) continue;
|
|
23772
|
+
let remoteFloor = null;
|
|
23773
|
+
if ("ruleId" in policy.target) {
|
|
23774
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23775
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23776
|
+
}
|
|
23777
|
+
merged.set(
|
|
23778
|
+
key,
|
|
23779
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23780
|
+
);
|
|
23781
|
+
}
|
|
23782
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23783
|
+
for (const policy of merged.values()) {
|
|
23784
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23785
|
+
}
|
|
23786
|
+
for (const policy of remotePolicies) {
|
|
23787
|
+
if (!policy.enabled) {
|
|
23788
|
+
disabled.push(policy);
|
|
23789
|
+
continue;
|
|
23790
|
+
}
|
|
23791
|
+
const key = policyKey(policy);
|
|
23792
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23793
|
+
let localFloor = null;
|
|
23794
|
+
if ("ruleId" in policy.target) {
|
|
23795
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23796
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23797
|
+
}
|
|
23798
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23799
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23800
|
+
const existing = merged.get(key);
|
|
23801
|
+
if (existing === void 0) {
|
|
23802
|
+
merged.set(key, clamped);
|
|
23803
|
+
continue;
|
|
23804
|
+
}
|
|
23805
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23806
|
+
merged.set(key, clamped);
|
|
23807
|
+
}
|
|
23808
|
+
}
|
|
23809
|
+
return [...merged.values(), ...disabled];
|
|
23810
|
+
}
|
|
23634
23811
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23635
23812
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23636
23813
|
);
|
|
@@ -23856,6 +24033,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23856
24033
|
payloadVersion: external_exports.number().int().positive(),
|
|
23857
24034
|
endpoint: external_exports.string()
|
|
23858
24035
|
});
|
|
24036
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24037
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24038
|
+
version: external_exports.number().int().positive()
|
|
24039
|
+
});
|
|
24040
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24041
|
+
var WebChatCapture = external_exports.object({
|
|
24042
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24043
|
+
account: external_exports.boolean().default(false),
|
|
24044
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24045
|
+
// isWebChatCaptureConsentValid.
|
|
24046
|
+
consent: WebChatCaptureConsent.optional()
|
|
24047
|
+
});
|
|
23859
24048
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23860
24049
|
var BodyRetention = external_exports.object({
|
|
23861
24050
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23914,6 +24103,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23914
24103
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23915
24104
|
// or an older payload no longer counts.
|
|
23916
24105
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24106
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24107
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24108
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24109
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24110
|
+
// webChatCaptureOf's answer, in one place.
|
|
24111
|
+
//
|
|
24112
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24113
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24114
|
+
// written down.
|
|
24115
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23917
24116
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23918
24117
|
// body never removes the row or its findings.
|
|
23919
24118
|
bodyRetention: BodyRetention.default({
|
|
@@ -24021,7 +24220,10 @@ function toCaptureAttributes(event) {
|
|
|
24021
24220
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24022
24221
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24023
24222
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24024
|
-
|
|
24223
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24224
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24225
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24226
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24025
24227
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24026
24228
|
};
|
|
24027
24229
|
}
|
|
@@ -24395,12 +24597,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24395
24597
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24396
24598
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24397
24599
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24600
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24398
24601
|
var SaveSettingsInput = external_exports.object({
|
|
24399
24602
|
historicalAccess: external_exports.string(),
|
|
24400
24603
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24401
24604
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24402
24605
|
vaultConsent: external_exports.string(),
|
|
24403
24606
|
vaultInlineReveal: external_exports.string(),
|
|
24607
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24404
24608
|
// Widened to `string` like its neighbours rather than typed as
|
|
24405
24609
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24406
24610
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24615,11 +24819,24 @@ var WebExchange = external_exports.object({
|
|
|
24615
24819
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24616
24820
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24617
24821
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24618
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24619
|
-
//
|
|
24822
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24823
|
+
// reply.
|
|
24620
24824
|
responseText: external_exports.string().optional(),
|
|
24825
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24826
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24827
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24828
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24829
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24830
|
+
// should branch as though it could.
|
|
24621
24831
|
truncated: external_exports.boolean().default(false)
|
|
24622
24832
|
});
|
|
24833
|
+
var WebEnforcementState = external_exports.enum([
|
|
24834
|
+
"watching",
|
|
24835
|
+
"composer-only",
|
|
24836
|
+
"button-only",
|
|
24837
|
+
"unattached",
|
|
24838
|
+
"unknown"
|
|
24839
|
+
]);
|
|
24623
24840
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24624
24841
|
var WebCaptureStatus = external_exports.object({
|
|
24625
24842
|
patched: external_exports.boolean(),
|
|
@@ -24631,8 +24848,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24631
24848
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24632
24849
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24633
24850
|
// the earliest signal that a site's contract moved.
|
|
24634
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24635
|
-
|
|
24851
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24852
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24853
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24854
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24855
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24856
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24857
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24858
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24859
|
+
// its `pagehide` report and nowhere else.
|
|
24860
|
+
//
|
|
24861
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24862
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24863
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24864
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24865
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24866
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24867
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24868
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24869
|
+
//
|
|
24870
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24871
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24872
|
+
// is not a final one.
|
|
24873
|
+
closed: external_exports.boolean().default(false),
|
|
24874
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24875
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24876
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24877
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24878
|
+
// predating the field is not read as reporting a healthy one.
|
|
24879
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24880
|
+
});
|
|
24881
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24882
|
+
if (!status.patched) return true;
|
|
24883
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24884
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24885
|
+
}
|
|
24886
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24887
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24888
|
+
}
|
|
24889
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24890
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24891
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24892
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24893
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24894
|
+
if (!parsedBag.success) return null;
|
|
24895
|
+
const b = parsedBag.data;
|
|
24896
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24897
|
+
patched: b.patched,
|
|
24898
|
+
live: b.live,
|
|
24899
|
+
blind: b.blind,
|
|
24900
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24901
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24902
|
+
parseFailures: b.parse_failures,
|
|
24903
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24904
|
+
shapeMisses: b.shape_misses,
|
|
24905
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24906
|
+
closed: b.closed,
|
|
24907
|
+
enforcement: b.enforcement
|
|
24908
|
+
});
|
|
24909
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24910
|
+
}
|
|
24636
24911
|
|
|
24637
24912
|
// ../../packages/persistence/src/paths.ts
|
|
24638
24913
|
import {
|
|
@@ -24743,17 +25018,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24743
25018
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24744
25019
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24745
25020
|
}
|
|
24746
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24747
|
-
function isSafeEndpoint(endpoint) {
|
|
24748
|
-
let parsed2;
|
|
24749
|
-
try {
|
|
24750
|
-
parsed2 = new URL(endpoint);
|
|
24751
|
-
} catch {
|
|
24752
|
-
return false;
|
|
24753
|
-
}
|
|
24754
|
-
if (parsed2.protocol === "https:") return true;
|
|
24755
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24756
|
-
}
|
|
24757
25021
|
function repairOrRefuseMode(file2) {
|
|
24758
25022
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24759
25023
|
if (link === void 0) return "absent";
|
|
@@ -26536,7 +26800,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26536
26800
|
var HAS_ACTIVITY = `EXISTS (
|
|
26537
26801
|
SELECT 1 FROM audit_events c
|
|
26538
26802
|
WHERE c.root_session_id = audit_events.id
|
|
26539
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26803
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26540
26804
|
var SqliteActivityRepository = class {
|
|
26541
26805
|
constructor(db, now = () => Date.now()) {
|
|
26542
26806
|
this.db = db;
|
|
@@ -26563,10 +26827,10 @@ var SqliteActivityRepository = class {
|
|
|
26563
26827
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26564
26828
|
UNION
|
|
26565
26829
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26566
|
-
WHERE started_at >= ?
|
|
26830
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26567
26831
|
UNION
|
|
26568
26832
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26569
|
-
WHERE ended_at >= ?)`,
|
|
26833
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26570
26834
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26571
26835
|
);
|
|
26572
26836
|
const toolCallsToday = countScalar(
|
|
@@ -26973,7 +27237,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
26973
27237
|
attributes = excluded.attributes,
|
|
26974
27238
|
ended_at = excluded.ended_at
|
|
26975
27239
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
26976
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27240
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27241
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27242
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27243
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
26977
27244
|
);
|
|
26978
27245
|
this.upsertSessionRootStmt = db.prepare(
|
|
26979
27246
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27241,6 +27508,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27241
27508
|
}
|
|
27242
27509
|
};
|
|
27243
27510
|
|
|
27511
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27512
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27513
|
+
var SqliteCaptureStatusRepository = class {
|
|
27514
|
+
constructor(db) {
|
|
27515
|
+
this.db = db;
|
|
27516
|
+
this.recentStmt = db.prepare(
|
|
27517
|
+
`SELECT a.started_at AS startedAt,
|
|
27518
|
+
a.attributes AS attributes,
|
|
27519
|
+
a.root_session_id AS rootSessionId
|
|
27520
|
+
FROM audit_events a
|
|
27521
|
+
WHERE a.event_type = 'capture_status'
|
|
27522
|
+
AND a.source_tool = ?
|
|
27523
|
+
AND a.started_at >= ?
|
|
27524
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27525
|
+
LIMIT ?`
|
|
27526
|
+
);
|
|
27527
|
+
}
|
|
27528
|
+
db;
|
|
27529
|
+
recentStmt;
|
|
27530
|
+
/**
|
|
27531
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27532
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27533
|
+
*
|
|
27534
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27535
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27536
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27537
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27538
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27539
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27540
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27541
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27542
|
+
* this package may not import it.
|
|
27543
|
+
*
|
|
27544
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27545
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27546
|
+
* the window without moving the wall clock.
|
|
27547
|
+
*
|
|
27548
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27549
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27550
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27551
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27552
|
+
* clear it.
|
|
27553
|
+
*/
|
|
27554
|
+
latest(now) {
|
|
27555
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27556
|
+
const documents = [];
|
|
27557
|
+
for (const tool of WebSourceTool.options) {
|
|
27558
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27559
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27560
|
+
for (const row of allRows(this.recentStmt, [
|
|
27561
|
+
tool,
|
|
27562
|
+
since,
|
|
27563
|
+
STATUS_LOOKBACK_ROWS
|
|
27564
|
+
])) {
|
|
27565
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27566
|
+
if (status === null) continue;
|
|
27567
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27568
|
+
const group = rows.get(row.rootSessionId);
|
|
27569
|
+
if (group === void 0) {
|
|
27570
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27571
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27572
|
+
} else {
|
|
27573
|
+
group.push(record2);
|
|
27574
|
+
}
|
|
27575
|
+
}
|
|
27576
|
+
for (const [root, candidates] of rows) {
|
|
27577
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27578
|
+
const last = lastWord.get(root);
|
|
27579
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27580
|
+
documents.push({
|
|
27581
|
+
...picked,
|
|
27582
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27583
|
+
lastReportAt: last.at,
|
|
27584
|
+
closed: last.closed
|
|
27585
|
+
});
|
|
27586
|
+
}
|
|
27587
|
+
}
|
|
27588
|
+
return documents;
|
|
27589
|
+
}
|
|
27590
|
+
};
|
|
27591
|
+
|
|
27244
27592
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27245
27593
|
var SqliteClassifiedDataRepository = class {
|
|
27246
27594
|
constructor(db) {
|
|
@@ -32818,6 +33166,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32818
33166
|
activity: new SqliteActivityRepository(db),
|
|
32819
33167
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32820
33168
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33169
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32821
33170
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32822
33171
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32823
33172
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32858,6 +33207,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32858
33207
|
activity,
|
|
32859
33208
|
sourceProject,
|
|
32860
33209
|
auditEvents,
|
|
33210
|
+
captureStatus,
|
|
32861
33211
|
classifiedData,
|
|
32862
33212
|
inspectionDefinitions,
|
|
32863
33213
|
inspectionFindings,
|
|
@@ -33075,6 +33425,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33075
33425
|
activity,
|
|
33076
33426
|
sourceProject,
|
|
33077
33427
|
auditEvents,
|
|
33428
|
+
captureStatus,
|
|
33078
33429
|
classifiedData,
|
|
33079
33430
|
inspectionDefinitions,
|
|
33080
33431
|
inspectionFindings,
|
|
@@ -33209,11 +33560,6 @@ function readFingerprintKey(dataDir2) {
|
|
|
33209
33560
|
// ../../packages/persistence/src/forward-health.ts
|
|
33210
33561
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33211
33562
|
import { join as join9 } from "path";
|
|
33212
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33213
|
-
"unauthorized",
|
|
33214
|
-
"forbidden",
|
|
33215
|
-
"unreachable"
|
|
33216
|
-
]);
|
|
33217
33563
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33218
33564
|
function parseForwardHealth(raw, nowMs) {
|
|
33219
33565
|
try {
|
|
@@ -33222,7 +33568,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33222
33568
|
const record2 = parsed2;
|
|
33223
33569
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33224
33570
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33225
|
-
const
|
|
33571
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33572
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33226
33573
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33227
33574
|
} catch {
|
|
33228
33575
|
return null;
|
|
@@ -34302,6 +34649,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34302
34649
|
}
|
|
34303
34650
|
];
|
|
34304
34651
|
|
|
34652
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
34653
|
+
var RULE_VERSION2 = "1";
|
|
34654
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
34655
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
34656
|
+
"blind",
|
|
34657
|
+
"degraded"
|
|
34658
|
+
]);
|
|
34659
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
34660
|
+
ruleId: "web-capture-drift",
|
|
34661
|
+
version: RULE_VERSION2,
|
|
34662
|
+
name: "Web chat capture is not reading the site",
|
|
34663
|
+
category: "config",
|
|
34664
|
+
severity: "medium",
|
|
34665
|
+
definition: JSON.stringify({
|
|
34666
|
+
kind: "web-capture-drift",
|
|
34667
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
34668
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
34669
|
+
})
|
|
34670
|
+
};
|
|
34671
|
+
var STATIC_COPY = {
|
|
34672
|
+
active: { headline: "turns are being observed on this site" },
|
|
34673
|
+
unreported: {
|
|
34674
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
34675
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
34676
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
34677
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
34678
|
+
// copy may not claim the stronger of them.
|
|
34679
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
34680
|
+
},
|
|
34681
|
+
standby: {
|
|
34682
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
34683
|
+
},
|
|
34684
|
+
unpatched: {
|
|
34685
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
34686
|
+
// that installed and hooked neither transport and for one that never ran
|
|
34687
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
34688
|
+
// assert one of them.
|
|
34689
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
34690
|
+
},
|
|
34691
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
34692
|
+
blind: {
|
|
34693
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
34694
|
+
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."
|
|
34695
|
+
},
|
|
34696
|
+
degraded: {
|
|
34697
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
34698
|
+
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."
|
|
34699
|
+
}
|
|
34700
|
+
};
|
|
34701
|
+
|
|
34305
34702
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34306
34703
|
var BUDGET_MS = 100;
|
|
34307
34704
|
var EXPONENTIAL_UNITS = [
|
|
@@ -36659,6 +37056,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
36659
37056
|
}
|
|
36660
37057
|
cause;
|
|
36661
37058
|
};
|
|
37059
|
+
var RemoteEndpointRefused = class extends Error {
|
|
37060
|
+
constructor(endpoint) {
|
|
37061
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
37062
|
+
this.name = "RemoteEndpointRefused";
|
|
37063
|
+
}
|
|
37064
|
+
};
|
|
36662
37065
|
var RemoteResponseInvalid = class extends Error {
|
|
36663
37066
|
constructor(route, detail) {
|
|
36664
37067
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -36811,14 +37214,15 @@ function parsed(schema, body, route) {
|
|
|
36811
37214
|
}
|
|
36812
37215
|
return result.data;
|
|
36813
37216
|
}
|
|
36814
|
-
function
|
|
37217
|
+
function resolveBaseUrl(endpoint) {
|
|
37218
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
36815
37219
|
let end = endpoint.length;
|
|
36816
37220
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
36817
37221
|
return endpoint.slice(0, end);
|
|
36818
37222
|
}
|
|
36819
37223
|
var SLASH2 = "/".charCodeAt(0);
|
|
36820
37224
|
function createRemoteClient(options) {
|
|
36821
|
-
const base =
|
|
37225
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
36822
37226
|
const url2 = (route) => `${base}${route}`;
|
|
36823
37227
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
36824
37228
|
const sendOne = async (event) => {
|
|
@@ -36948,6 +37352,7 @@ function classifyRemoteFailure(err) {
|
|
|
36948
37352
|
case "RemoteRouteAbsent":
|
|
36949
37353
|
return "route-absent";
|
|
36950
37354
|
case "RemoteRequestInvalid":
|
|
37355
|
+
case "RemoteEndpointRefused":
|
|
36951
37356
|
return "invalid-request";
|
|
36952
37357
|
case "RemoteResponseInvalid":
|
|
36953
37358
|
return "rejected";
|
|
@@ -37151,86 +37556,10 @@ function createForwardPolicy(deps) {
|
|
|
37151
37556
|
}
|
|
37152
37557
|
|
|
37153
37558
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
37154
|
-
|
|
37155
|
-
|
|
37156
|
-
|
|
37157
|
-
return
|
|
37158
|
-
}
|
|
37159
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
37160
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
37161
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
37162
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
37163
|
-
for (const pack of bundledDetections()) {
|
|
37164
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
37165
|
-
}
|
|
37166
|
-
return map2;
|
|
37167
|
-
}
|
|
37168
|
-
function policyKey(policy) {
|
|
37169
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
37170
|
-
}
|
|
37171
|
-
function floorFor(policy, categoryByRuleId) {
|
|
37172
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
37173
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
37174
|
-
}
|
|
37175
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
37176
|
-
const merged = /* @__PURE__ */ new Map();
|
|
37177
|
-
const disabled = [];
|
|
37178
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
37179
|
-
for (const policy of remotePolicies) {
|
|
37180
|
-
if (!policy.enabled) continue;
|
|
37181
|
-
if (!("category" in policy.target)) continue;
|
|
37182
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
37183
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
37184
|
-
remoteCategoryAction.set(
|
|
37185
|
-
policy.target.category,
|
|
37186
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
37187
|
-
);
|
|
37188
|
-
}
|
|
37189
|
-
for (const policy of localPolicies) {
|
|
37190
|
-
if (!policy.enabled) {
|
|
37191
|
-
disabled.push(policy);
|
|
37192
|
-
continue;
|
|
37193
|
-
}
|
|
37194
|
-
const key = policyKey(policy);
|
|
37195
|
-
if (merged.has(key)) continue;
|
|
37196
|
-
let remoteFloor = null;
|
|
37197
|
-
if ("ruleId" in policy.target) {
|
|
37198
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
37199
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
37200
|
-
}
|
|
37201
|
-
merged.set(
|
|
37202
|
-
key,
|
|
37203
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
37204
|
-
);
|
|
37205
|
-
}
|
|
37206
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
37207
|
-
for (const policy of merged.values()) {
|
|
37208
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
37209
|
-
}
|
|
37210
|
-
for (const policy of remotePolicies) {
|
|
37211
|
-
if (!policy.enabled) {
|
|
37212
|
-
disabled.push(policy);
|
|
37213
|
-
continue;
|
|
37214
|
-
}
|
|
37215
|
-
const key = policyKey(policy);
|
|
37216
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
37217
|
-
let localFloor = null;
|
|
37218
|
-
if ("ruleId" in policy.target) {
|
|
37219
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
37220
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
37221
|
-
}
|
|
37222
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
37223
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
37224
|
-
const existing = merged.get(key);
|
|
37225
|
-
if (existing === void 0) {
|
|
37226
|
-
merged.set(key, clamped);
|
|
37227
|
-
continue;
|
|
37228
|
-
}
|
|
37229
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
37230
|
-
merged.set(key, clamped);
|
|
37231
|
-
}
|
|
37232
|
-
}
|
|
37233
|
-
return [...merged.values(), ...disabled];
|
|
37559
|
+
var bundledRulesFlatCache;
|
|
37560
|
+
function bundledRulesFlat() {
|
|
37561
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
37562
|
+
return bundledRulesFlatCache;
|
|
37234
37563
|
}
|
|
37235
37564
|
var AttachedDataGateway = class {
|
|
37236
37565
|
constructor(deps) {
|
|
@@ -37550,6 +37879,9 @@ var AttachedDataGateway = class {
|
|
|
37550
37879
|
async readSessionProvider(sessionId) {
|
|
37551
37880
|
return this.deps.local.readSessionProvider(sessionId);
|
|
37552
37881
|
}
|
|
37882
|
+
async readCaptureStatuses() {
|
|
37883
|
+
return this.deps.local.readCaptureStatuses();
|
|
37884
|
+
}
|
|
37553
37885
|
async facets() {
|
|
37554
37886
|
return this.deps.local.facets();
|
|
37555
37887
|
}
|
|
@@ -37632,7 +37964,7 @@ var AttachedDataGateway = class {
|
|
|
37632
37964
|
policies: mergeRaiseOnly(
|
|
37633
37965
|
local.policies,
|
|
37634
37966
|
cached2.policies,
|
|
37635
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
37967
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
37636
37968
|
),
|
|
37637
37969
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
37638
37970
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -37848,10 +38180,15 @@ import { join as join27 } from "path";
|
|
|
37848
38180
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
37849
38181
|
import { rename as rename2 } from "fs/promises";
|
|
37850
38182
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
37851
|
-
var
|
|
38183
|
+
var IMMEDIATE_RETRIES = 8;
|
|
38184
|
+
var TIMED_RETRIES = 4;
|
|
38185
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
37852
38186
|
var delay = (ms) => new Promise((resolve2) => {
|
|
37853
38187
|
setTimeout(resolve2, ms);
|
|
37854
38188
|
});
|
|
38189
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
38190
|
+
setImmediate(resolve2);
|
|
38191
|
+
});
|
|
37855
38192
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
37856
38193
|
for (let attempt = 1; ; attempt += 1) {
|
|
37857
38194
|
try {
|
|
@@ -37860,7 +38197,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
37860
38197
|
} catch (err) {
|
|
37861
38198
|
const code = err.code;
|
|
37862
38199
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
37863
|
-
await delay(attempt * 10);
|
|
38200
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
37864
38201
|
}
|
|
37865
38202
|
}
|
|
37866
38203
|
}
|
|
@@ -38324,6 +38661,9 @@ var StandaloneDataGateway = class {
|
|
|
38324
38661
|
readSessionProvider(sessionId) {
|
|
38325
38662
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
38326
38663
|
}
|
|
38664
|
+
readCaptureStatuses() {
|
|
38665
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
38666
|
+
}
|
|
38327
38667
|
facets() {
|
|
38328
38668
|
return Promise.resolve(this.db.facets());
|
|
38329
38669
|
}
|