@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/backfill.js
CHANGED
|
@@ -20485,7 +20485,17 @@ var UNPRICEABLE_PROVIDERS = Object.freeze([
|
|
|
20485
20485
|
"gateway",
|
|
20486
20486
|
"unknown",
|
|
20487
20487
|
"cli",
|
|
20488
|
-
"api"
|
|
20488
|
+
"api",
|
|
20489
|
+
// The browser extension's native host records these as `llm_call.provider`
|
|
20490
|
+
// for a web-chat turn — the web tool id, deliberately never the vendor id
|
|
20491
|
+
// (`openai`/`anthropic`) the session root carries. Subscription traffic
|
|
20492
|
+
// burns rate-limit budget, not dollar credits, and listing them here is
|
|
20493
|
+
// what keeps that true structurally: a later maintainer who wants to price
|
|
20494
|
+
// web-chat traffic at API rates has to delete this entry first, and meet
|
|
20495
|
+
// the reason on the way, rather than quietly adding one to
|
|
20496
|
+
// PROVIDER_PLATFORM.
|
|
20497
|
+
"chatgpt",
|
|
20498
|
+
"claude-ai"
|
|
20489
20499
|
]);
|
|
20490
20500
|
function platformForProvider(provider) {
|
|
20491
20501
|
return PROVIDER_PLATFORM.get(provider.trim().toLowerCase()) ?? null;
|
|
@@ -20628,7 +20638,12 @@ var HARNESS = {
|
|
|
20628
20638
|
ClaudeDesktop: "claudedesktop",
|
|
20629
20639
|
ChatGpt: "chatgpt",
|
|
20630
20640
|
ClaudeAi: "claudeai",
|
|
20631
|
-
Api: "api"
|
|
20641
|
+
Api: "api",
|
|
20642
|
+
// Not a coding assistant a person drives — an in-process SDK embedded in an
|
|
20643
|
+
// application, so it has no IDE/CLI/desktop/web surface of its own. Carries
|
|
20644
|
+
// the same id as its SOURCE_TOOL counterpart, unlike every capture-side tool
|
|
20645
|
+
// whose wire spelling differs from its display spelling.
|
|
20646
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20632
20647
|
};
|
|
20633
20648
|
var Harness = external_exports.enum(HARNESS).meta({ id: "Harness" });
|
|
20634
20649
|
var SOURCE_TOOL = {
|
|
@@ -20644,9 +20659,15 @@ var SOURCE_TOOL = {
|
|
|
20644
20659
|
// whose tool could not be identified both render through the read side's
|
|
20645
20660
|
// miss path rather than as a harness of their own.
|
|
20646
20661
|
Cli: "cli",
|
|
20647
|
-
Unknown: "unknown"
|
|
20662
|
+
Unknown: "unknown",
|
|
20663
|
+
// The wire id an in-process, request-path SDK stamps on its own structural
|
|
20664
|
+
// rows (`request_decision`) — never a capture of prompt/response/tool text,
|
|
20665
|
+
// since the SDK sits in front of a model call rather than inside a coding
|
|
20666
|
+
// assistant's own hook contract.
|
|
20667
|
+
AiTcSdk: "ai-tc-sdk"
|
|
20648
20668
|
};
|
|
20649
20669
|
var SourceTool = external_exports.enum(SOURCE_TOOL).meta({ id: "SourceTool" });
|
|
20670
|
+
var WebSourceTool = SourceTool.extract(["ChatGpt", "ClaudeAi"]);
|
|
20650
20671
|
var TOOL_TO_HARNESS = {
|
|
20651
20672
|
[SOURCE_TOOL.ClaudeCode]: HARNESS.ClaudeCode,
|
|
20652
20673
|
[SOURCE_TOOL.ClaudeDesktop]: HARNESS.ClaudeDesktop,
|
|
@@ -20655,7 +20676,12 @@ var TOOL_TO_HARNESS = {
|
|
|
20655
20676
|
[SOURCE_TOOL.ChatGpt]: HARNESS.ChatGpt,
|
|
20656
20677
|
[SOURCE_TOOL.Codex]: HARNESS.Codex,
|
|
20657
20678
|
[SOURCE_TOOL.Antigravity]: HARNESS.Antigravity,
|
|
20658
|
-
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi
|
|
20679
|
+
[SOURCE_TOOL.ClaudeAi]: HARNESS.ClaudeAi,
|
|
20680
|
+
// Wire and display id are the same string here, but the row still belongs:
|
|
20681
|
+
// both vocabularies carry the `AiTcSdk` member, and the join is exactly
|
|
20682
|
+
// their intersection — leaving a shared member out would read as an
|
|
20683
|
+
// uninstrumented tool on both surfaces, which this one is not.
|
|
20684
|
+
[SOURCE_TOOL.AiTcSdk]: HARNESS.AiTcSdk
|
|
20659
20685
|
};
|
|
20660
20686
|
function harnessFromTool(tool) {
|
|
20661
20687
|
return (Object.hasOwn(TOOL_TO_HARNESS, tool) ? TOOL_TO_HARNESS[tool] : void 0) ?? tool;
|
|
@@ -20692,7 +20718,8 @@ var FindingProvider = Harness.extract([
|
|
|
20692
20718
|
"ClaudeAi",
|
|
20693
20719
|
"Codex",
|
|
20694
20720
|
"Antigravity",
|
|
20695
|
-
"Api"
|
|
20721
|
+
"Api",
|
|
20722
|
+
"AiTcSdk"
|
|
20696
20723
|
]).meta({ id: "FindingProvider" });
|
|
20697
20724
|
var FindingCategory = external_exports.enum([
|
|
20698
20725
|
"secret",
|
|
@@ -21069,18 +21096,41 @@ var AuditEventType = external_exports.enum([
|
|
|
21069
21096
|
// 'tool_call' is the reconciler's structural row for every call, while
|
|
21070
21097
|
// 'tool_use' exists only where a hook enforced against the arguments.
|
|
21071
21098
|
"tool_use",
|
|
21072
|
-
// One row per model REFUSAL
|
|
21073
|
-
//
|
|
21074
|
-
//
|
|
21075
|
-
//
|
|
21076
|
-
//
|
|
21077
|
-
//
|
|
21099
|
+
// One row per model REFUSAL, across all four seams a prohibited model can be
|
|
21100
|
+
// stopped at: a switch onto it, a turn already running on it, a subagent
|
|
21101
|
+
// spawn asking for it, or a request-path refusal an embedded request-path
|
|
21102
|
+
// SDK makes in-process before the call leaves the application. Which seam
|
|
21103
|
+
// rides `attributes.refusal_seam`, never this member name. A structural row
|
|
21104
|
+
// like the ones above rather than a capture — it carries the model that was
|
|
21105
|
+
// refused and nothing the user typed, because what is worth recording about
|
|
21106
|
+
// a governance decision is the decision, and prompt text is the thing this
|
|
21107
|
+
// product exists to keep from travelling.
|
|
21078
21108
|
"model_refusal",
|
|
21109
|
+
// One row per request-path DECISION: a policy check an embedded request-path
|
|
21110
|
+
// SDK performs in-process before a model call leaves the application, or
|
|
21111
|
+
// against that call's non-streamed response. A structural row like
|
|
21112
|
+
// 'model_refusal' rather than a capture — content-free in the same way:
|
|
21113
|
+
// which side, which seam, what action and which field are decided rides
|
|
21114
|
+
// `attributes`, never this member name, and the matched text itself never
|
|
21115
|
+
// travels.
|
|
21116
|
+
//
|
|
21117
|
+
// A prohibited-model refusal on the request path is deliberately NOT this
|
|
21118
|
+
// member: it stays 'model_refusal' with `refusal_seam: 'request'`, so it
|
|
21119
|
+
// shares one bucket with the plugin's switch/turn/spawn refusals rather
|
|
21120
|
+
// than splitting one governance concept across two event types. This
|
|
21121
|
+
// member carries every OTHER request-path decision.
|
|
21122
|
+
"request_decision",
|
|
21079
21123
|
// One row per config-inventory scan, hung off the session root. It is the
|
|
21080
21124
|
// fact the posture inspection findings reference (findings require an
|
|
21081
21125
|
// audit_event_id), and its started_at is the "scanned Nm ago" the read
|
|
21082
21126
|
// surface renders.
|
|
21083
|
-
"config_scan"
|
|
21127
|
+
"config_scan",
|
|
21128
|
+
// One row per reported browser-extension capture status, hung off the web
|
|
21129
|
+
// session root. The durable home of what one tab's network interception
|
|
21130
|
+
// is doing — a write-through of the native host's in-memory tracker, so a
|
|
21131
|
+
// second process (aka extension status) and a restarted host both have
|
|
21132
|
+
// somewhere to read it back from.
|
|
21133
|
+
"capture_status"
|
|
21084
21134
|
]).meta({ id: "AuditEventType" });
|
|
21085
21135
|
var AttributeBag = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
21086
21136
|
var HostAttributes = external_exports.object({
|
|
@@ -21240,6 +21290,20 @@ var CaptureAttributes = external_exports.object({
|
|
|
21240
21290
|
// repeated rather than referenced because a store reader opens this file.
|
|
21241
21291
|
redact_degraded_to: ActionTaken.optional()
|
|
21242
21292
|
}).catchall(external_exports.unknown());
|
|
21293
|
+
var CaptureStatusAttributes = external_exports.object({
|
|
21294
|
+
source_tool: external_exports.string().optional(),
|
|
21295
|
+
patched: external_exports.boolean().optional(),
|
|
21296
|
+
live: external_exports.boolean().optional(),
|
|
21297
|
+
blind: external_exports.boolean().optional(),
|
|
21298
|
+
sends_seen_dom: external_exports.number().int().nonnegative().optional(),
|
|
21299
|
+
exchanges_seen_net: external_exports.number().int().nonnegative().optional(),
|
|
21300
|
+
parse_failures: external_exports.number().int().nonnegative().optional(),
|
|
21301
|
+
unparsed_bodies: external_exports.number().int().nonnegative().optional(),
|
|
21302
|
+
shape_misses: external_exports.array(external_exports.string()).optional(),
|
|
21303
|
+
conversation_endpoints: external_exports.number().int().nonnegative().optional(),
|
|
21304
|
+
closed: external_exports.boolean().optional(),
|
|
21305
|
+
enforcement: external_exports.string().optional()
|
|
21306
|
+
}).catchall(external_exports.unknown());
|
|
21243
21307
|
var ToolCallInspection = external_exports.object({
|
|
21244
21308
|
ruleId: external_exports.string().min(1),
|
|
21245
21309
|
ruleName: external_exports.string(),
|
|
@@ -22099,6 +22163,30 @@ var AttachedCredential = external_exports.object({
|
|
|
22099
22163
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22100
22164
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22101
22165
|
});
|
|
22166
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
22167
|
+
function unsafeEndpointReason(endpoint) {
|
|
22168
|
+
let parsed2;
|
|
22169
|
+
try {
|
|
22170
|
+
parsed2 = new URL(endpoint);
|
|
22171
|
+
} catch {
|
|
22172
|
+
return "unparseable";
|
|
22173
|
+
}
|
|
22174
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "userinfo";
|
|
22175
|
+
if (parsed2.search !== "" || parsed2.hash !== "") return "query-or-fragment";
|
|
22176
|
+
if (parsed2.protocol === "https:") return null;
|
|
22177
|
+
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname) ? null : "insecure";
|
|
22178
|
+
}
|
|
22179
|
+
function isSafeEndpoint(endpoint) {
|
|
22180
|
+
return unsafeEndpointReason(endpoint) === null;
|
|
22181
|
+
}
|
|
22182
|
+
function originOnly(endpoint) {
|
|
22183
|
+
try {
|
|
22184
|
+
const parsed2 = new URL(endpoint);
|
|
22185
|
+
return `${parsed2.protocol}//${parsed2.host}`;
|
|
22186
|
+
} catch {
|
|
22187
|
+
return "(unparseable endpoint)";
|
|
22188
|
+
}
|
|
22189
|
+
}
|
|
22102
22190
|
var MAX_DATE_MS = 253402300799999;
|
|
22103
22191
|
var MAX_INT4 = 2147483647;
|
|
22104
22192
|
var StorePosturePack = external_exports.object({
|
|
@@ -22253,6 +22341,11 @@ var RemoteFailureKind = external_exports.enum([
|
|
|
22253
22341
|
"rejected",
|
|
22254
22342
|
"unreachable"
|
|
22255
22343
|
]);
|
|
22344
|
+
var ControlPlaneFailure = RemoteFailureKind.extract([
|
|
22345
|
+
"unauthorized",
|
|
22346
|
+
"forbidden",
|
|
22347
|
+
"unreachable"
|
|
22348
|
+
]);
|
|
22256
22349
|
var AttachDeviceRequest = external_exports.object({
|
|
22257
22350
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22258
22351
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22792,7 +22885,12 @@ var EventMetadata = external_exports.object({
|
|
|
22792
22885
|
// in — set by the browser extension's network capture so a stored `response`
|
|
22793
22886
|
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
22794
22887
|
// on every other capture path, which has no such id.
|
|
22795
|
-
|
|
22888
|
+
//
|
|
22889
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
22890
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
22891
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
22892
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
22893
|
+
messageId: external_exports.string().min(1).optional(),
|
|
22796
22894
|
conversationId: external_exports.string().optional(),
|
|
22797
22895
|
// How long THIS capture's inspection blocked its caller, in whole
|
|
22798
22896
|
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
@@ -23639,6 +23737,85 @@ function policyIdIsReversible(policyId) {
|
|
|
23639
23737
|
var DEFAULT_ACTIONS = Object.fromEntries(
|
|
23640
23738
|
DetectionCategory.options.map((c) => [c, builtinPolicyToAction(severityFloorPolicy(c))])
|
|
23641
23739
|
);
|
|
23740
|
+
function ruleCategoryMap(wireRules, localRules, compiledRules) {
|
|
23741
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
23742
|
+
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
23743
|
+
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
23744
|
+
for (const rule of compiledRules) map2.set(rule.id, rule.category);
|
|
23745
|
+
return map2;
|
|
23746
|
+
}
|
|
23747
|
+
function policyKey(policy) {
|
|
23748
|
+
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
23749
|
+
}
|
|
23750
|
+
function floorFor(policy, categoryByRuleId) {
|
|
23751
|
+
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
23752
|
+
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
23753
|
+
}
|
|
23754
|
+
function strongerOf(a, b) {
|
|
23755
|
+
if (a === null) return b;
|
|
23756
|
+
if (b === null) return a;
|
|
23757
|
+
return strongerAction(a, b);
|
|
23758
|
+
}
|
|
23759
|
+
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
23760
|
+
const merged = /* @__PURE__ */ new Map();
|
|
23761
|
+
const disabled = [];
|
|
23762
|
+
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
23763
|
+
for (const policy of remotePolicies) {
|
|
23764
|
+
if (!policy.enabled) continue;
|
|
23765
|
+
if (!("category" in policy.target)) continue;
|
|
23766
|
+
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
23767
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23768
|
+
remoteCategoryAction.set(
|
|
23769
|
+
policy.target.category,
|
|
23770
|
+
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
23771
|
+
);
|
|
23772
|
+
}
|
|
23773
|
+
for (const policy of localPolicies) {
|
|
23774
|
+
if (!policy.enabled) {
|
|
23775
|
+
disabled.push(policy);
|
|
23776
|
+
continue;
|
|
23777
|
+
}
|
|
23778
|
+
const key = policyKey(policy);
|
|
23779
|
+
if (merged.has(key)) continue;
|
|
23780
|
+
let remoteFloor = null;
|
|
23781
|
+
if ("ruleId" in policy.target) {
|
|
23782
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23783
|
+
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
23784
|
+
}
|
|
23785
|
+
merged.set(
|
|
23786
|
+
key,
|
|
23787
|
+
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
23788
|
+
);
|
|
23789
|
+
}
|
|
23790
|
+
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
23791
|
+
for (const policy of merged.values()) {
|
|
23792
|
+
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
23793
|
+
}
|
|
23794
|
+
for (const policy of remotePolicies) {
|
|
23795
|
+
if (!policy.enabled) {
|
|
23796
|
+
disabled.push(policy);
|
|
23797
|
+
continue;
|
|
23798
|
+
}
|
|
23799
|
+
const key = policyKey(policy);
|
|
23800
|
+
const floor = floorFor(policy, categoryByRuleId);
|
|
23801
|
+
let localFloor = null;
|
|
23802
|
+
if ("ruleId" in policy.target) {
|
|
23803
|
+
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
23804
|
+
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
23805
|
+
}
|
|
23806
|
+
const effectiveFloor = strongerOf(floor, localFloor);
|
|
23807
|
+
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
23808
|
+
const existing = merged.get(key);
|
|
23809
|
+
if (existing === void 0) {
|
|
23810
|
+
merged.set(key, clamped);
|
|
23811
|
+
continue;
|
|
23812
|
+
}
|
|
23813
|
+
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
23814
|
+
merged.set(key, clamped);
|
|
23815
|
+
}
|
|
23816
|
+
}
|
|
23817
|
+
return [...merged.values(), ...disabled];
|
|
23818
|
+
}
|
|
23642
23819
|
var BUILTIN_POLICIES = Object.fromEntries(
|
|
23643
23820
|
KNOWN_BUILTIN_IDS.map((id) => [id, { id, ...BUILTIN_POLICY_SPECS[id] }])
|
|
23644
23821
|
);
|
|
@@ -23864,6 +24041,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
23864
24041
|
payloadVersion: external_exports.number().int().positive(),
|
|
23865
24042
|
endpoint: external_exports.string()
|
|
23866
24043
|
});
|
|
24044
|
+
var WebChatCaptureConsent = external_exports.object({
|
|
24045
|
+
acknowledgedAt: external_exports.iso.datetime(),
|
|
24046
|
+
version: external_exports.number().int().positive()
|
|
24047
|
+
});
|
|
24048
|
+
var WebChatResponseCapture = external_exports.enum(["with-findings", "always", "never"]);
|
|
24049
|
+
var WebChatCapture = external_exports.object({
|
|
24050
|
+
responses: WebChatResponseCapture.default("with-findings"),
|
|
24051
|
+
account: external_exports.boolean().default(false),
|
|
24052
|
+
// Absent until granted. Presence alone does not authorize anything — see
|
|
24053
|
+
// isWebChatCaptureConsentValid.
|
|
24054
|
+
consent: WebChatCaptureConsent.optional()
|
|
24055
|
+
});
|
|
23867
24056
|
var BODY_RETENTION_DEFAULT_DAYS = 30;
|
|
23868
24057
|
var BodyRetention = external_exports.object({
|
|
23869
24058
|
enabled: external_exports.boolean().default(false),
|
|
@@ -23922,6 +24111,16 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23922
24111
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23923
24112
|
// or an older payload no longer counts.
|
|
23924
24113
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24114
|
+
// What the browser extension may record from a web chat, and the grant that
|
|
24115
|
+
// authorizes it. Absent until the user answers: recording something that was
|
|
24116
|
+
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
24117
|
+
// block is optional rather than defaulted in. What an absent block means is
|
|
24118
|
+
// webChatCaptureOf's answer, in one place.
|
|
24119
|
+
//
|
|
24120
|
+
// Enforcement is NOT gated on this. A machine that has never answered still
|
|
24121
|
+
// blocks, redacts and warns on what a user sends; the grant covers what is
|
|
24122
|
+
// written down.
|
|
24123
|
+
webChatCapture: WebChatCapture.optional(),
|
|
23925
24124
|
// Local body expiry (see BodyRetention). Off until switched on; expiring a
|
|
23926
24125
|
// body never removes the row or its findings.
|
|
23927
24126
|
bodyRetention: BodyRetention.default({
|
|
@@ -24029,7 +24228,10 @@ function toCaptureAttributes(event) {
|
|
|
24029
24228
|
// `.catchall(z.unknown())` carries the long tail.
|
|
24030
24229
|
...metadata?.model !== void 0 ? { model: metadata.model } : {},
|
|
24031
24230
|
...metadata?.turnIndex !== void 0 ? { turn_index: metadata.turnIndex } : {},
|
|
24032
|
-
|
|
24231
|
+
// A blank id is omitted rather than stored: it is a join key and `''` joins
|
|
24232
|
+
// nothing. This runs on the local write path, which types the event but
|
|
24233
|
+
// never parses it, so EventMetadata's own `.min(1)` does not reach here.
|
|
24234
|
+
...metadata?.messageId !== void 0 && metadata.messageId !== "" ? { message_id: metadata.messageId } : {},
|
|
24033
24235
|
...metadata?.conversationId !== void 0 ? { conversation_id: metadata.conversationId } : {}
|
|
24034
24236
|
};
|
|
24035
24237
|
}
|
|
@@ -24403,12 +24605,14 @@ var RecommendedActionIdParam = external_exports.object({ id: external_exports.st
|
|
|
24403
24605
|
// ../../packages/schema/src/zod/settings-action.ts
|
|
24404
24606
|
var HistorySyncConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "HistorySyncConsentChoice" });
|
|
24405
24607
|
var ModelJudgeConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "ModelJudgeConsentChoice" });
|
|
24608
|
+
var WebChatCaptureConsentChoice = external_exports.enum(["granted", "revoked", "unchanged"]).meta({ id: "WebChatCaptureConsentChoice" });
|
|
24406
24609
|
var SaveSettingsInput = external_exports.object({
|
|
24407
24610
|
historicalAccess: external_exports.string(),
|
|
24408
24611
|
modelJudgeConsent: ModelJudgeConsentChoice,
|
|
24409
24612
|
historySyncConsent: HistorySyncConsentChoice,
|
|
24410
24613
|
vaultConsent: external_exports.string(),
|
|
24411
24614
|
vaultInlineReveal: external_exports.string(),
|
|
24615
|
+
webChatCaptureConsent: WebChatCaptureConsentChoice,
|
|
24412
24616
|
// Widened to `string` like its neighbours rather than typed as
|
|
24413
24617
|
// `RedactFallback`, on this module's own layering rule: shape here, VALUE at
|
|
24414
24618
|
// the call site, so the domain check receives the type it was written for.
|
|
@@ -24623,11 +24827,24 @@ var WebExchange = external_exports.object({
|
|
|
24623
24827
|
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24624
24828
|
toolCalls: external_exports.array(WebToolCall).default([]),
|
|
24625
24829
|
// Absent when the adapter recovered no text. Capped by the caller at
|
|
24626
|
-
// RESPONSE_TEXT_MAX_BYTES
|
|
24627
|
-
//
|
|
24830
|
+
// RESPONSE_TEXT_MAX_BYTES, so a short capture is never mistaken for a short
|
|
24831
|
+
// reply.
|
|
24628
24832
|
responseText: external_exports.string().optional(),
|
|
24833
|
+
// The stored text is short of the reply. It does NOT say which of the two
|
|
24834
|
+
// ceilings on this path cut it: the caller applies its own cap on the raw
|
|
24835
|
+
// bytes it reads off the wire, which can be reached by a stream whose
|
|
24836
|
+
// recovered text stays well under RESPONSE_TEXT_MAX_BYTES, and applies that
|
|
24837
|
+
// one to the text. A reader cannot tell them apart, and nothing downstream
|
|
24838
|
+
// should branch as though it could.
|
|
24629
24839
|
truncated: external_exports.boolean().default(false)
|
|
24630
24840
|
});
|
|
24841
|
+
var WebEnforcementState = external_exports.enum([
|
|
24842
|
+
"watching",
|
|
24843
|
+
"composer-only",
|
|
24844
|
+
"button-only",
|
|
24845
|
+
"unattached",
|
|
24846
|
+
"unknown"
|
|
24847
|
+
]);
|
|
24631
24848
|
var RESPONSE_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
24632
24849
|
var WebCaptureStatus = external_exports.object({
|
|
24633
24850
|
patched: external_exports.boolean(),
|
|
@@ -24639,8 +24856,66 @@ var WebCaptureStatus = external_exports.object({
|
|
|
24639
24856
|
unparsedBodies: external_exports.number().int().nonnegative(),
|
|
24640
24857
|
// The adapter-declared JSON key paths that were absent from a real payload —
|
|
24641
24858
|
// the earliest signal that a site's contract moved.
|
|
24642
|
-
shapeMisses: external_exports.array(external_exports.string()).default([])
|
|
24643
|
-
|
|
24859
|
+
shapeMisses: external_exports.array(external_exports.string()).default([]),
|
|
24860
|
+
// How many `kind: 'conversation'` endpoints the reporting tab's adapter
|
|
24861
|
+
// compiled. Zero means this build declares none for the site, so observing
|
|
24862
|
+
// nothing is the design rather than a fault — the one fact that separates a
|
|
24863
|
+
// site nobody has surveyed yet from one whose contract moved. Defaulted so a
|
|
24864
|
+
// build predating the field is read as declaring nothing rather than refused.
|
|
24865
|
+
conversationEndpoints: external_exports.number().int().nonnegative().default(0),
|
|
24866
|
+
// The document that sent this report is going away. The bridge sets it on
|
|
24867
|
+
// its `pagehide` report and nowhere else.
|
|
24868
|
+
//
|
|
24869
|
+
// A property of the REPORT rather than of capture health, which is why
|
|
24870
|
+
// nothing in `deriveWebCaptureState` reads it and why it stays out of the
|
|
24871
|
+
// bridge's own report signature — a closing tab's last word must not be
|
|
24872
|
+
// suppressed for carrying the same health as the report before it. What
|
|
24873
|
+
// reads it is the per-site fold: a document that said it was unloading stops
|
|
24874
|
+
// voting on the site's state, so the reload the `blind` remediation asks for
|
|
24875
|
+
// can actually clear the verdict it was shown. A document that dies without
|
|
24876
|
+
// sending one is covered by CAPTURE_STATUS_DOCUMENT_QUIET_MS instead.
|
|
24877
|
+
//
|
|
24878
|
+
// Defaulted so a build predating the field reads as a document that never
|
|
24879
|
+
// said it was closing — which keeps it voting, the same as every report that
|
|
24880
|
+
// is not a final one.
|
|
24881
|
+
closed: external_exports.boolean().default(false),
|
|
24882
|
+
// What the DOM enforcement path is doing, which none of the counters above
|
|
24883
|
+
// can say: `sendsSeenDom` rises only once a send has COMPLETED, so a tab
|
|
24884
|
+
// whose watcher never bound reports zero exactly like a tab nobody typed in.
|
|
24885
|
+
// Defaulted to 'unknown' rather than 'watching' so a status from a build
|
|
24886
|
+
// predating the field is not read as reporting a healthy one.
|
|
24887
|
+
enforcement: WebEnforcementState.default("unknown")
|
|
24888
|
+
});
|
|
24889
|
+
function webCaptureStatusObservedTurnPath(status) {
|
|
24890
|
+
if (!status.patched) return true;
|
|
24891
|
+
if (status.conversationEndpoints === 0) return true;
|
|
24892
|
+
return status.blind || status.shapeMisses.length > 0 || status.parseFailures > 0 || status.unparsedBodies > 0 || status.exchangesSeenNet > 0;
|
|
24893
|
+
}
|
|
24894
|
+
function pickReportedCaptureStatus(candidates) {
|
|
24895
|
+
return candidates.find((c) => webCaptureStatusObservedTurnPath(c.status)) ?? candidates[0];
|
|
24896
|
+
}
|
|
24897
|
+
var CAPTURE_STATUS_RECENCY_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
24898
|
+
var CAPTURE_STATUS_RECENCY_DAYS = CAPTURE_STATUS_RECENCY_MS / (24 * 60 * 60 * 1e3);
|
|
24899
|
+
var CAPTURE_STATUS_DOCUMENT_QUIET_MS = 12 * 60 * 60 * 1e3;
|
|
24900
|
+
function fromCaptureStatusAttributes(bag) {
|
|
24901
|
+
const parsedBag = CaptureStatusAttributes.safeParse(bag);
|
|
24902
|
+
if (!parsedBag.success) return null;
|
|
24903
|
+
const b = parsedBag.data;
|
|
24904
|
+
const parsedStatus = WebCaptureStatus.safeParse({
|
|
24905
|
+
patched: b.patched,
|
|
24906
|
+
live: b.live,
|
|
24907
|
+
blind: b.blind,
|
|
24908
|
+
sendsSeenDom: b.sends_seen_dom,
|
|
24909
|
+
exchangesSeenNet: b.exchanges_seen_net,
|
|
24910
|
+
parseFailures: b.parse_failures,
|
|
24911
|
+
unparsedBodies: b.unparsed_bodies,
|
|
24912
|
+
shapeMisses: b.shape_misses,
|
|
24913
|
+
conversationEndpoints: b.conversation_endpoints,
|
|
24914
|
+
closed: b.closed,
|
|
24915
|
+
enforcement: b.enforcement
|
|
24916
|
+
});
|
|
24917
|
+
return parsedStatus.success ? parsedStatus.data : null;
|
|
24918
|
+
}
|
|
24644
24919
|
|
|
24645
24920
|
// ../../packages/persistence/src/paths.ts
|
|
24646
24921
|
import {
|
|
@@ -24771,17 +25046,6 @@ function publishByLink(tmp, file2, data) {
|
|
|
24771
25046
|
function controlPlaneCredentialPath(settingsDir2) {
|
|
24772
25047
|
return join2(settingsDir2, ATTACHED_CREDENTIAL_FILENAME);
|
|
24773
25048
|
}
|
|
24774
|
-
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
24775
|
-
function isSafeEndpoint(endpoint) {
|
|
24776
|
-
let parsed2;
|
|
24777
|
-
try {
|
|
24778
|
-
parsed2 = new URL(endpoint);
|
|
24779
|
-
} catch {
|
|
24780
|
-
return false;
|
|
24781
|
-
}
|
|
24782
|
-
if (parsed2.protocol === "https:") return true;
|
|
24783
|
-
return parsed2.protocol === "http:" && LOOPBACK_HOSTS.has(parsed2.hostname);
|
|
24784
|
-
}
|
|
24785
25049
|
function repairOrRefuseMode(file2) {
|
|
24786
25050
|
const link = lstatSync2(file2, { throwIfNoEntry: false });
|
|
24787
25051
|
if (link === void 0) return "absent";
|
|
@@ -26574,7 +26838,7 @@ var SESSION_ROOT = `event_type = 'session'`;
|
|
|
26574
26838
|
var HAS_ACTIVITY = `EXISTS (
|
|
26575
26839
|
SELECT 1 FROM audit_events c
|
|
26576
26840
|
WHERE c.root_session_id = audit_events.id
|
|
26577
|
-
AND c.event_type NOT IN ('hook', 'config_scan'))`;
|
|
26841
|
+
AND c.event_type NOT IN ('hook', 'config_scan', 'capture_status'))`;
|
|
26578
26842
|
var SqliteActivityRepository = class {
|
|
26579
26843
|
constructor(db, now = () => Date.now()) {
|
|
26580
26844
|
this.db = db;
|
|
@@ -26601,10 +26865,10 @@ var SqliteActivityRepository = class {
|
|
|
26601
26865
|
SELECT id FROM audit_events WHERE event_type = 'session' AND started_at >= ?
|
|
26602
26866
|
UNION
|
|
26603
26867
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_started_at
|
|
26604
|
-
WHERE started_at >= ?
|
|
26868
|
+
WHERE started_at >= ? AND event_type <> 'capture_status'
|
|
26605
26869
|
UNION
|
|
26606
26870
|
SELECT root_session_id FROM audit_events INDEXED BY idx_audit_ended_at
|
|
26607
|
-
WHERE ended_at >= ?)`,
|
|
26871
|
+
WHERE ended_at >= ? AND event_type <> 'capture_status')`,
|
|
26608
26872
|
[liveThreshold, liveThreshold, liveThreshold]
|
|
26609
26873
|
);
|
|
26610
26874
|
const toolCallsToday = countScalar(
|
|
@@ -27011,7 +27275,10 @@ var SqliteAuditEventsRepository = class {
|
|
|
27011
27275
|
attributes = excluded.attributes,
|
|
27012
27276
|
ended_at = excluded.ended_at
|
|
27013
27277
|
WHERE COALESCE(json_extract(excluded.attributes, '$.output_tokens'), 0)
|
|
27014
|
-
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27278
|
+
> COALESCE(json_extract(audit_events.attributes, '$.output_tokens'), 0)
|
|
27279
|
+
OR (json_extract(excluded.attributes, '$.usage_source') IS NOT NULL
|
|
27280
|
+
AND json_extract(excluded.attributes, '$.output_tokens') IS NULL
|
|
27281
|
+
AND excluded.attributes <> audit_events.attributes)`
|
|
27015
27282
|
);
|
|
27016
27283
|
this.upsertSessionRootStmt = db.prepare(
|
|
27017
27284
|
`INSERT OR IGNORE INTO audit_events
|
|
@@ -27279,6 +27546,87 @@ var SqliteBodyRetentionRepository = class {
|
|
|
27279
27546
|
}
|
|
27280
27547
|
};
|
|
27281
27548
|
|
|
27549
|
+
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
27550
|
+
var STATUS_LOOKBACK_ROWS = 128;
|
|
27551
|
+
var SqliteCaptureStatusRepository = class {
|
|
27552
|
+
constructor(db) {
|
|
27553
|
+
this.db = db;
|
|
27554
|
+
this.recentStmt = db.prepare(
|
|
27555
|
+
`SELECT a.started_at AS startedAt,
|
|
27556
|
+
a.attributes AS attributes,
|
|
27557
|
+
a.root_session_id AS rootSessionId
|
|
27558
|
+
FROM audit_events a
|
|
27559
|
+
WHERE a.event_type = 'capture_status'
|
|
27560
|
+
AND a.source_tool = ?
|
|
27561
|
+
AND a.started_at >= ?
|
|
27562
|
+
ORDER BY a.started_at DESC, a.id DESC
|
|
27563
|
+
LIMIT ?`
|
|
27564
|
+
);
|
|
27565
|
+
}
|
|
27566
|
+
db;
|
|
27567
|
+
recentStmt;
|
|
27568
|
+
/**
|
|
27569
|
+
* Every document that reported for a site, in registry order by site, from
|
|
27570
|
+
* the last `CAPTURE_STATUS_RECENCY_MS`.
|
|
27571
|
+
*
|
|
27572
|
+
* SEVERAL per site, not one: a browser is many documents and each reports
|
|
27573
|
+
* for itself, so one row per site is a choice about which of them a user
|
|
27574
|
+
* sees — and the newest is the wrong one, since a healthy tab writing a
|
|
27575
|
+
* fresh report would hide a drifting tab's verdict, which is the whole
|
|
27576
|
+
* reason these rows exist. The pick WITHIN a document is made here (the
|
|
27577
|
+
* unchanged `pickReportedCaptureStatus`, over that document's own rows);
|
|
27578
|
+
* choosing between documents belongs where the state semantics live, and
|
|
27579
|
+
* that is `reportedCaptureDocumentForSite` in `@akasecurity/detections` —
|
|
27580
|
+
* this package may not import it.
|
|
27581
|
+
*
|
|
27582
|
+
* `now` is a required argument rather than a `Date.now()` read, so a caller
|
|
27583
|
+
* that already holds a render instant passes THAT one and a test can drive
|
|
27584
|
+
* the window without moving the wall clock.
|
|
27585
|
+
*
|
|
27586
|
+
* A site whose reports have all aged out contributes nothing, so it derives
|
|
27587
|
+
* to `unreported`. That is the point: nothing but the browser extension ever
|
|
27588
|
+
* writes these rows, so an uninstalled extension's last verdict would
|
|
27589
|
+
* otherwise stand as a live claim for ever with no later report able to
|
|
27590
|
+
* clear it.
|
|
27591
|
+
*/
|
|
27592
|
+
latest(now) {
|
|
27593
|
+
const since = now - CAPTURE_STATUS_RECENCY_MS;
|
|
27594
|
+
const documents = [];
|
|
27595
|
+
for (const tool of WebSourceTool.options) {
|
|
27596
|
+
const rows = /* @__PURE__ */ new Map();
|
|
27597
|
+
const lastWord = /* @__PURE__ */ new Map();
|
|
27598
|
+
for (const row of allRows(this.recentStmt, [
|
|
27599
|
+
tool,
|
|
27600
|
+
since,
|
|
27601
|
+
STATUS_LOOKBACK_ROWS
|
|
27602
|
+
])) {
|
|
27603
|
+
const status = fromCaptureStatusAttributes(parseJsonObject(row.attributes));
|
|
27604
|
+
if (status === null) continue;
|
|
27605
|
+
const record2 = { tool, observedAt: epochMillisToIso(row.startedAt), status };
|
|
27606
|
+
const group = rows.get(row.rootSessionId);
|
|
27607
|
+
if (group === void 0) {
|
|
27608
|
+
rows.set(row.rootSessionId, [record2]);
|
|
27609
|
+
lastWord.set(row.rootSessionId, { at: record2.observedAt, closed: status.closed });
|
|
27610
|
+
} else {
|
|
27611
|
+
group.push(record2);
|
|
27612
|
+
}
|
|
27613
|
+
}
|
|
27614
|
+
for (const [root, candidates] of rows) {
|
|
27615
|
+
const picked = pickReportedCaptureStatus(candidates);
|
|
27616
|
+
const last = lastWord.get(root);
|
|
27617
|
+
if (picked === void 0 || last === void 0) continue;
|
|
27618
|
+
documents.push({
|
|
27619
|
+
...picked,
|
|
27620
|
+
...root === null ? {} : { rootSessionId: root },
|
|
27621
|
+
lastReportAt: last.at,
|
|
27622
|
+
closed: last.closed
|
|
27623
|
+
});
|
|
27624
|
+
}
|
|
27625
|
+
}
|
|
27626
|
+
return documents;
|
|
27627
|
+
}
|
|
27628
|
+
};
|
|
27629
|
+
|
|
27282
27630
|
// ../../packages/persistence/src/repositories/classified-data.ts
|
|
27283
27631
|
var SqliteClassifiedDataRepository = class {
|
|
27284
27632
|
constructor(db) {
|
|
@@ -32856,6 +33204,7 @@ function openAndInitialize(file2, base, skipTags) {
|
|
|
32856
33204
|
activity: new SqliteActivityRepository(db),
|
|
32857
33205
|
sourceProject: new SqliteSourceProjectRepository(db),
|
|
32858
33206
|
auditEvents: new SqliteAuditEventsRepository(db),
|
|
33207
|
+
captureStatus: new SqliteCaptureStatusRepository(db),
|
|
32859
33208
|
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
32860
33209
|
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
32861
33210
|
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
@@ -32896,6 +33245,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
32896
33245
|
activity,
|
|
32897
33246
|
sourceProject,
|
|
32898
33247
|
auditEvents,
|
|
33248
|
+
captureStatus,
|
|
32899
33249
|
classifiedData,
|
|
32900
33250
|
inspectionDefinitions,
|
|
32901
33251
|
inspectionFindings,
|
|
@@ -33113,6 +33463,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
33113
33463
|
activity,
|
|
33114
33464
|
sourceProject,
|
|
33115
33465
|
auditEvents,
|
|
33466
|
+
captureStatus,
|
|
33116
33467
|
classifiedData,
|
|
33117
33468
|
inspectionDefinitions,
|
|
33118
33469
|
inspectionFindings,
|
|
@@ -33338,11 +33689,6 @@ function fingerprintValue(key, raw) {
|
|
|
33338
33689
|
// ../../packages/persistence/src/forward-health.ts
|
|
33339
33690
|
import { readFileSync as readFileSync7 } from "fs";
|
|
33340
33691
|
import { join as join9 } from "path";
|
|
33341
|
-
var FAILURES = /* @__PURE__ */ new Set([
|
|
33342
|
-
"unauthorized",
|
|
33343
|
-
"forbidden",
|
|
33344
|
-
"unreachable"
|
|
33345
|
-
]);
|
|
33346
33692
|
var BREAKER_COOLDOWN_MS = 3e4;
|
|
33347
33693
|
function parseForwardHealth(raw, nowMs) {
|
|
33348
33694
|
try {
|
|
@@ -33351,7 +33697,8 @@ function parseForwardHealth(raw, nowMs) {
|
|
|
33351
33697
|
const record2 = parsed2;
|
|
33352
33698
|
const failures = typeof record2.consecutiveFailures === "number" && record2.consecutiveFailures >= 0 ? record2.consecutiveFailures : 0;
|
|
33353
33699
|
const openedAtMs = typeof record2.openedAtMs === "number" && Number.isFinite(record2.openedAtMs) && record2.openedAtMs <= nowMs ? record2.openedAtMs : null;
|
|
33354
|
-
const
|
|
33700
|
+
const parsedFailure = ControlPlaneFailure.safeParse(record2.lastFailure);
|
|
33701
|
+
const lastFailure = parsedFailure.success ? parsedFailure.data : null;
|
|
33355
33702
|
return { consecutiveFailures: failures, openedAtMs, lastFailure };
|
|
33356
33703
|
} catch {
|
|
33357
33704
|
return null;
|
|
@@ -34431,6 +34778,56 @@ var CONFIG_POSTURE_RULES = [
|
|
|
34431
34778
|
}
|
|
34432
34779
|
];
|
|
34433
34780
|
|
|
34781
|
+
// ../../packages/detections/src/posture/web-capture-posture.ts
|
|
34782
|
+
var RULE_VERSION2 = "1";
|
|
34783
|
+
var DRIFT_MIN_PARSE_FAILURES = 2;
|
|
34784
|
+
var WEB_CAPTURE_DRIFT_STATES = /* @__PURE__ */ new Set([
|
|
34785
|
+
"blind",
|
|
34786
|
+
"degraded"
|
|
34787
|
+
]);
|
|
34788
|
+
var WEB_CAPTURE_DRIFT_RULE = {
|
|
34789
|
+
ruleId: "web-capture-drift",
|
|
34790
|
+
version: RULE_VERSION2,
|
|
34791
|
+
name: "Web chat capture is not reading the site",
|
|
34792
|
+
category: "config",
|
|
34793
|
+
severity: "medium",
|
|
34794
|
+
definition: JSON.stringify({
|
|
34795
|
+
kind: "web-capture-drift",
|
|
34796
|
+
states: [...WEB_CAPTURE_DRIFT_STATES],
|
|
34797
|
+
minParseFailures: DRIFT_MIN_PARSE_FAILURES
|
|
34798
|
+
})
|
|
34799
|
+
};
|
|
34800
|
+
var STATIC_COPY = {
|
|
34801
|
+
active: { headline: "turns are being observed on this site" },
|
|
34802
|
+
unreported: {
|
|
34803
|
+
// Says "recently" rather than "yet": the store read is bounded to
|
|
34804
|
+
// CAPTURE_STATUS_RECENCY_MS, so this state covers a site nothing has ever
|
|
34805
|
+
// reported for AND one whose last report has aged out. The two are the
|
|
34806
|
+
// same fact to a reader — nobody has confirmed anything lately — and the
|
|
34807
|
+
// copy may not claim the stronger of them.
|
|
34808
|
+
headline: `no report in the last ${String(CAPTURE_STATUS_RECENCY_DAYS)} days \u2014 open the site in Chrome with the extension loaded`
|
|
34809
|
+
},
|
|
34810
|
+
standby: {
|
|
34811
|
+
headline: "this build declares no endpoints for the site, so nothing is observed yet"
|
|
34812
|
+
},
|
|
34813
|
+
unpatched: {
|
|
34814
|
+
// Says what the flags say and no more. `patched` is false both for a tap
|
|
34815
|
+
// that installed and hooked neither transport and for one that never ran
|
|
34816
|
+
// at all — a page reports the same status either way, so the copy may not
|
|
34817
|
+
// assert one of them.
|
|
34818
|
+
headline: "the page tap captured neither fetch nor XHR \u2014 it may not have installed; reload the extension at chrome://extensions"
|
|
34819
|
+
},
|
|
34820
|
+
idle: { headline: "watching; no turn has been observed yet" },
|
|
34821
|
+
blind: {
|
|
34822
|
+
headline: "messages were sent in the page that the network capture never saw",
|
|
34823
|
+
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."
|
|
34824
|
+
},
|
|
34825
|
+
degraded: {
|
|
34826
|
+
headline: "the site's payloads no longer carry the fields the extension reads",
|
|
34827
|
+
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."
|
|
34828
|
+
}
|
|
34829
|
+
};
|
|
34830
|
+
|
|
34434
34831
|
// ../../packages/detections/src/security/redos-probe.ts
|
|
34435
34832
|
var BUDGET_MS = 100;
|
|
34436
34833
|
var EXPONENTIAL_UNITS = [
|
|
@@ -37878,6 +38275,12 @@ var RemoteRequestInvalid = class extends Error {
|
|
|
37878
38275
|
}
|
|
37879
38276
|
cause;
|
|
37880
38277
|
};
|
|
38278
|
+
var RemoteEndpointRefused = class extends Error {
|
|
38279
|
+
constructor(endpoint) {
|
|
38280
|
+
super(`refusing to talk to an unsafe control-plane endpoint: ${originOnly(endpoint)}`);
|
|
38281
|
+
this.name = "RemoteEndpointRefused";
|
|
38282
|
+
}
|
|
38283
|
+
};
|
|
37881
38284
|
var RemoteResponseInvalid = class extends Error {
|
|
37882
38285
|
constructor(route, detail) {
|
|
37883
38286
|
super(`control plane answered ${route} with ${detail}`);
|
|
@@ -38030,14 +38433,15 @@ function parsed(schema, body, route) {
|
|
|
38030
38433
|
}
|
|
38031
38434
|
return result.data;
|
|
38032
38435
|
}
|
|
38033
|
-
function
|
|
38436
|
+
function resolveBaseUrl(endpoint) {
|
|
38437
|
+
if (!isSafeEndpoint(endpoint)) throw new RemoteEndpointRefused(endpoint);
|
|
38034
38438
|
let end = endpoint.length;
|
|
38035
38439
|
while (end > 0 && endpoint.charCodeAt(end - 1) === SLASH2) end -= 1;
|
|
38036
38440
|
return endpoint.slice(0, end);
|
|
38037
38441
|
}
|
|
38038
38442
|
var SLASH2 = "/".charCodeAt(0);
|
|
38039
38443
|
function createRemoteClient(options) {
|
|
38040
|
-
const base =
|
|
38444
|
+
const base = resolveBaseUrl(options.endpoint);
|
|
38041
38445
|
const url2 = (route) => `${base}${route}`;
|
|
38042
38446
|
const common = { apiKey: options.apiKey, timeoutMs: options.timeoutMs };
|
|
38043
38447
|
const sendOne = async (event) => {
|
|
@@ -38167,6 +38571,7 @@ function classifyRemoteFailure(err) {
|
|
|
38167
38571
|
case "RemoteRouteAbsent":
|
|
38168
38572
|
return "route-absent";
|
|
38169
38573
|
case "RemoteRequestInvalid":
|
|
38574
|
+
case "RemoteEndpointRefused":
|
|
38170
38575
|
return "invalid-request";
|
|
38171
38576
|
case "RemoteResponseInvalid":
|
|
38172
38577
|
return "rejected";
|
|
@@ -38370,86 +38775,10 @@ function createForwardPolicy(deps) {
|
|
|
38370
38775
|
}
|
|
38371
38776
|
|
|
38372
38777
|
// ../../packages/plugin-runtime/src/attached/gateway.ts
|
|
38373
|
-
|
|
38374
|
-
|
|
38375
|
-
|
|
38376
|
-
return
|
|
38377
|
-
}
|
|
38378
|
-
function ruleCategoryMap(wireRules, localRules) {
|
|
38379
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
38380
|
-
for (const rule of wireRules ?? []) map2.set(rule.id, rule.category);
|
|
38381
|
-
for (const rule of localRules ?? []) map2.set(rule.id, rule.category);
|
|
38382
|
-
for (const pack of bundledDetections()) {
|
|
38383
|
-
for (const rule of pack.rules) map2.set(rule.id, rule.category);
|
|
38384
|
-
}
|
|
38385
|
-
return map2;
|
|
38386
|
-
}
|
|
38387
|
-
function policyKey(policy) {
|
|
38388
|
-
return "ruleId" in policy.target ? `rule:${policy.target.ruleId}` : `category:${policy.target.category}`;
|
|
38389
|
-
}
|
|
38390
|
-
function floorFor(policy, categoryByRuleId) {
|
|
38391
|
-
const category = "category" in policy.target ? policy.target.category : categoryByRuleId.get(policy.target.ruleId);
|
|
38392
|
-
return category === void 0 ? null : DEFAULT_ACTIONS[category];
|
|
38393
|
-
}
|
|
38394
|
-
function mergeRaiseOnly(localPolicies, remotePolicies, categoryByRuleId) {
|
|
38395
|
-
const merged = /* @__PURE__ */ new Map();
|
|
38396
|
-
const disabled = [];
|
|
38397
|
-
const remoteCategoryAction = /* @__PURE__ */ new Map();
|
|
38398
|
-
for (const policy of remotePolicies) {
|
|
38399
|
-
if (!policy.enabled) continue;
|
|
38400
|
-
if (!("category" in policy.target)) continue;
|
|
38401
|
-
if (remoteCategoryAction.has(policy.target.category)) continue;
|
|
38402
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38403
|
-
remoteCategoryAction.set(
|
|
38404
|
-
policy.target.category,
|
|
38405
|
-
floor !== null && !isActionAtLeast(policy.action, floor) ? floor : policy.action
|
|
38406
|
-
);
|
|
38407
|
-
}
|
|
38408
|
-
for (const policy of localPolicies) {
|
|
38409
|
-
if (!policy.enabled) {
|
|
38410
|
-
disabled.push(policy);
|
|
38411
|
-
continue;
|
|
38412
|
-
}
|
|
38413
|
-
const key = policyKey(policy);
|
|
38414
|
-
if (merged.has(key)) continue;
|
|
38415
|
-
let remoteFloor = null;
|
|
38416
|
-
if ("ruleId" in policy.target) {
|
|
38417
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38418
|
-
if (category !== void 0) remoteFloor = remoteCategoryAction.get(category) ?? null;
|
|
38419
|
-
}
|
|
38420
|
-
merged.set(
|
|
38421
|
-
key,
|
|
38422
|
-
remoteFloor !== null && !isActionAtLeast(policy.action, remoteFloor) ? { ...policy, action: remoteFloor } : policy
|
|
38423
|
-
);
|
|
38424
|
-
}
|
|
38425
|
-
const localCategoryAction = /* @__PURE__ */ new Map();
|
|
38426
|
-
for (const policy of merged.values()) {
|
|
38427
|
-
if ("category" in policy.target) localCategoryAction.set(policy.target.category, policy.action);
|
|
38428
|
-
}
|
|
38429
|
-
for (const policy of remotePolicies) {
|
|
38430
|
-
if (!policy.enabled) {
|
|
38431
|
-
disabled.push(policy);
|
|
38432
|
-
continue;
|
|
38433
|
-
}
|
|
38434
|
-
const key = policyKey(policy);
|
|
38435
|
-
const floor = floorFor(policy, categoryByRuleId);
|
|
38436
|
-
let localFloor = null;
|
|
38437
|
-
if ("ruleId" in policy.target) {
|
|
38438
|
-
const category = categoryByRuleId.get(policy.target.ruleId);
|
|
38439
|
-
if (category !== void 0) localFloor = localCategoryAction.get(category) ?? null;
|
|
38440
|
-
}
|
|
38441
|
-
const effectiveFloor = strongerOf(floor, localFloor);
|
|
38442
|
-
const clamped = effectiveFloor !== null && !isActionAtLeast(policy.action, effectiveFloor) ? { ...policy, action: effectiveFloor } : policy;
|
|
38443
|
-
const existing = merged.get(key);
|
|
38444
|
-
if (existing === void 0) {
|
|
38445
|
-
merged.set(key, clamped);
|
|
38446
|
-
continue;
|
|
38447
|
-
}
|
|
38448
|
-
if (actionRank(clamped.action) > actionRank(existing.action)) {
|
|
38449
|
-
merged.set(key, clamped);
|
|
38450
|
-
}
|
|
38451
|
-
}
|
|
38452
|
-
return [...merged.values(), ...disabled];
|
|
38778
|
+
var bundledRulesFlatCache;
|
|
38779
|
+
function bundledRulesFlat() {
|
|
38780
|
+
bundledRulesFlatCache ??= bundledDetections().flatMap((pack) => pack.rules);
|
|
38781
|
+
return bundledRulesFlatCache;
|
|
38453
38782
|
}
|
|
38454
38783
|
var AttachedDataGateway = class {
|
|
38455
38784
|
constructor(deps) {
|
|
@@ -38769,6 +39098,9 @@ var AttachedDataGateway = class {
|
|
|
38769
39098
|
async readSessionProvider(sessionId) {
|
|
38770
39099
|
return this.deps.local.readSessionProvider(sessionId);
|
|
38771
39100
|
}
|
|
39101
|
+
async readCaptureStatuses() {
|
|
39102
|
+
return this.deps.local.readCaptureStatuses();
|
|
39103
|
+
}
|
|
38772
39104
|
async facets() {
|
|
38773
39105
|
return this.deps.local.facets();
|
|
38774
39106
|
}
|
|
@@ -38851,7 +39183,7 @@ var AttachedDataGateway = class {
|
|
|
38851
39183
|
policies: mergeRaiseOnly(
|
|
38852
39184
|
local.policies,
|
|
38853
39185
|
cached2.policies,
|
|
38854
|
-
ruleCategoryMap(cached2.rules, local.rules)
|
|
39186
|
+
ruleCategoryMap(cached2.rules, local.rules, bundledRulesFlat())
|
|
38855
39187
|
),
|
|
38856
39188
|
customKeywords: [...local.customKeywords, ...cached2.customKeywords],
|
|
38857
39189
|
// TAKEN FROM THE CACHE, unlike the two fields below — and the asymmetry
|
|
@@ -39067,10 +39399,15 @@ import { join as join29 } from "path";
|
|
|
39067
39399
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
39068
39400
|
import { rename as rename2 } from "fs/promises";
|
|
39069
39401
|
var RETRYABLE = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
39070
|
-
var
|
|
39402
|
+
var IMMEDIATE_RETRIES = 8;
|
|
39403
|
+
var TIMED_RETRIES = 4;
|
|
39404
|
+
var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
39071
39405
|
var delay = (ms) => new Promise((resolve2) => {
|
|
39072
39406
|
setTimeout(resolve2, ms);
|
|
39073
39407
|
});
|
|
39408
|
+
var yieldToLoop = () => new Promise((resolve2) => {
|
|
39409
|
+
setImmediate(resolve2);
|
|
39410
|
+
});
|
|
39074
39411
|
async function publishByRename(tmp, file2, move = rename2) {
|
|
39075
39412
|
for (let attempt = 1; ; attempt += 1) {
|
|
39076
39413
|
try {
|
|
@@ -39079,7 +39416,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
39079
39416
|
} catch (err) {
|
|
39080
39417
|
const code = err.code;
|
|
39081
39418
|
if (attempt >= ATTEMPTS || code === void 0 || !RETRYABLE.has(code)) throw err;
|
|
39082
|
-
await delay(attempt * 10);
|
|
39419
|
+
await (attempt <= IMMEDIATE_RETRIES ? yieldToLoop() : delay((attempt - IMMEDIATE_RETRIES) * 10));
|
|
39083
39420
|
}
|
|
39084
39421
|
}
|
|
39085
39422
|
}
|
|
@@ -39543,6 +39880,9 @@ var StandaloneDataGateway = class {
|
|
|
39543
39880
|
readSessionProvider(sessionId) {
|
|
39544
39881
|
return Promise.resolve(this.db.auditEvents.sessionProvider(sessionId));
|
|
39545
39882
|
}
|
|
39883
|
+
readCaptureStatuses() {
|
|
39884
|
+
return Promise.resolve(this.db.captureStatus.latest(Date.now()));
|
|
39885
|
+
}
|
|
39546
39886
|
facets() {
|
|
39547
39887
|
return Promise.resolve(this.db.facets());
|
|
39548
39888
|
}
|