@webdecoy/node 0.25.1 → 0.26.0
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/README.md +37 -1
- package/dist/{chunk-ABIJ7NMX.mjs → chunk-2SIFEEYE.mjs} +167 -13
- package/dist/{chunk-5VMXAH64.mjs → chunk-CFJ7R2CG.mjs} +52 -52
- package/dist/{detect-and-gate-CEpuKXTE.d.ts → detect-and-gate-Ay294Lr2.d.ts} +1 -1
- package/dist/{detect-and-gate-DhKYwcQ1.d.mts → detect-and-gate-NBeqXdH6.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +219 -64
- package/dist/index.mjs +4 -2
- package/dist/{sdk-D8Cn_xRm.d.mts → sdk-Dh8Jj07-.d.mts} +87 -7
- package/dist/{sdk-D8Cn_xRm.d.ts → sdk-Dh8Jj07-.d.ts} +87 -7
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +170 -13
- package/dist/testing.mjs +1 -1
- package/dist/vercel.d.mts +2 -2
- package/dist/vercel.d.ts +2 -2
- package/dist/vercel.js +221 -64
- package/dist/vercel.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,6 +103,33 @@ credential is sent. A presentation request is made only when the candidate is
|
|
|
103
103
|
an exact local match for the inert token. Retrieval alone remains an ordinary
|
|
104
104
|
decoy event, and this API never blocks or grants access.
|
|
105
105
|
|
|
106
|
+
### Correlate an offensive model toolchain
|
|
107
|
+
|
|
108
|
+
Instrument an authorized model/MCP gateway with the reviewed helper. It maps
|
|
109
|
+
known tool names into generic families and sends only bounded counts and
|
|
110
|
+
digests. Raw prompts, arguments, results, targets, credentials, and run IDs are
|
|
111
|
+
not included. Use a deployment-held random secret of at least 32 characters for
|
|
112
|
+
`correlationSecret`; do not reuse an API key.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const result = await wd.reportOffensiveToolchain({
|
|
116
|
+
sensor: 'mcp-gateway',
|
|
117
|
+
runId: internalRunId,
|
|
118
|
+
correlationSecret: process.env.WEBDECOY_CORRELATION_SECRET!,
|
|
119
|
+
invocations: [
|
|
120
|
+
{ tool: 'nmap_scan', redactedArgumentCount: 2 },
|
|
121
|
+
{ tool: 'nuclei_scan', redactedArgumentCount: 1 },
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
One tool family is retained for coverage but does not create a correlation.
|
|
127
|
+
Two or more reviewed families can create a generic toolchain association. Set
|
|
128
|
+
`orchestrator: 'hexstrike_ai'` only inside an integration that has independently
|
|
129
|
+
verified the official `hexstrike-ai-mcp` orchestrator; common Nmap or Nuclei use
|
|
130
|
+
alone never becomes HexStrike attribution. This API records evidence and never
|
|
131
|
+
blocks or grants access.
|
|
132
|
+
|
|
106
133
|
### Monitor first
|
|
107
134
|
|
|
108
135
|
`protect()` only returns a decision. It never writes a response, so nothing is blocked until your code acts on `decision.allowed`. The framework adapters and `createFetchGuard()` follow the same rule: they start in **monitor mode** (`mode: 'monitor'`), record the decision and serve every request. Set `mode: 'enforce'` only after you have reviewed what would have been blocked.
|
|
@@ -237,7 +264,8 @@ const wd = new WebDecoy({
|
|
|
237
264
|
apiKey: process.env.WEBDECOY_API_KEY, // optional; without it, local rules only
|
|
238
265
|
rules: [tripwire()], // optional; default [tripwire()], [] to opt out
|
|
239
266
|
apiUrl: 'https://in.webdecoy.com', // optional (default shown)
|
|
240
|
-
|
|
267
|
+
decisionMode: 'legacy', // use 'unified_v1' to opt in
|
|
268
|
+
threatScoreThreshold: 80, // optional minimum confidence, default 80 in legacy mode
|
|
241
269
|
timeout: 5000, // optional, ms (default 5000)
|
|
242
270
|
enableTLSFingerprinting: true, // optional (default true)
|
|
243
271
|
tlsRejectUnauthorized: true, // optional (default true)
|
|
@@ -250,6 +278,14 @@ Also accepted: `characteristics` (what identifies the same caller for rate limit
|
|
|
250
278
|
|
|
251
279
|
`protect()` also takes per-request options: `threshold`, `skipLocalAnalysis` and `metadata`.
|
|
252
280
|
|
|
281
|
+
### Unified cloud decisions
|
|
282
|
+
|
|
283
|
+
Set `decisionMode: 'unified_v1'` on `WebDecoy`, `createFetchGuard()`, or the Express, Fastify, Hono, and Next.js adapters. Adapter monitor mode exposes the verdict on `webdecoyDecision` while serving the request. `decision.detection.unified_score` is the score at request time. Later enrichment can update the detection in the dashboard.
|
|
284
|
+
|
|
285
|
+
Ingest applies its own confidence gates. An explicit `threshold`, `threatScoreThreshold`, or Next.js Pages `blockThreshold` can add a minimum confidence. Cloud-eligible requests each get their own unified verdict, including repeats from the same caller. During a cloud outage or an invalid response, the request proceeds with an `ERROR` decision.
|
|
286
|
+
|
|
287
|
+
Local rules decide first. The cloud gate forwards requests with a local bot signal, TLS material, or an explicit `skipLocalAnalysis` bypass. A datacenter IP or a missing Sec-CH-UA alone stays local. With `tracer` configured, count `webdecoy.cloud.admission` by `webdecoy.cloud.decision_mode`. The `local_gate` outcome includes two booleans for the datacenter and missing Sec-CH-UA observations. `cloud` records requests handed to the client and `backoff` records calls skipped during an outage. These attributes contain only bounded outcomes and booleans.
|
|
288
|
+
|
|
253
289
|
Without an API key no request leaves your server. With one, a request goes to WebDecoy only when local analysis flags it as needing verification (or carries TLS details); that call is awaited, bounded by `timeout`, and fails open on error.
|
|
254
290
|
|
|
255
291
|
## Client IP behind a proxy
|
|
@@ -17,6 +17,7 @@ var BOT_CATEGORIES = [
|
|
|
17
17
|
"none"
|
|
18
18
|
];
|
|
19
19
|
var BOT_REGISTRY = [
|
|
20
|
+
{ id: "hunyuan", name: "Hunyuan", category: "training_crawler", organization: "Unknown", baseScore: 70, respectsRobots: false, uaPatterns: ["hunyuan/"] },
|
|
20
21
|
{ id: "speridlabsresearchcrawler", name: "SperidLabsResearchCrawler", category: "training_crawler", organization: "Speridlabs", baseScore: 75, respectsRobots: false, uaPatterns: ["speridlabsresearchcrawler"] },
|
|
21
22
|
{ id: "abliterantbot", name: "AbliterantBot", category: "training_crawler", organization: "Abliterant", baseScore: 75, respectsRobots: false, uaPatterns: ["abliterantbot"] },
|
|
22
23
|
{ id: "tokenfoundrybot", name: "TokenFoundryBot", category: "training_crawler", organization: "Unknown", baseScore: 75, respectsRobots: false, uaPatterns: ["tokenfoundrybot"] },
|
|
@@ -87,6 +88,8 @@ var BOT_REGISTRY = [
|
|
|
87
88
|
{ id: "manus-user", name: "Manus-User", category: "ai_agent", organization: "Manus", baseScore: 70, respectsRobots: false, uaPatterns: ["manus-user"] },
|
|
88
89
|
{ id: "multion", name: "MultiOn", category: "ai_agent", organization: "MultiOn", baseScore: 70, respectsRobots: false, uaPatterns: ["multion"] },
|
|
89
90
|
{ id: "opencode-user", name: "OpenCode-User", category: "ai_agent", organization: "OpenCode", baseScore: 75, respectsRobots: false, uaPatterns: ["opencode-user"] },
|
|
91
|
+
{ id: "360spider", name: "360Spider", category: "search_crawler", organization: "Qihoo 360", baseScore: 40, respectsRobots: true, uaPatterns: ["360spider"] },
|
|
92
|
+
{ id: "cgmsearchbot", name: "CGMSearchBot", category: "search_crawler", organization: "CGMIMM", baseScore: 40, respectsRobots: true, uaPatterns: ["cgmsearchbot"] },
|
|
90
93
|
{ id: "iboubot", name: "IbouBot", category: "search_crawler", organization: "Ibou", baseScore: 30, respectsRobots: true, uaPatterns: ["iboubot", "ibou-search"] },
|
|
91
94
|
{ id: "googlebot", name: "Googlebot", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["googlebot"] },
|
|
92
95
|
{ id: "google-inspectiontool", name: "Google-InspectionTool", category: "search_crawler", organization: "Google", baseScore: 30, respectsRobots: true, uaPatterns: ["google-inspectiontool"] },
|
|
@@ -234,6 +237,9 @@ var BOT_REGISTRY = [
|
|
|
234
237
|
{ id: "miniflux", name: "Miniflux", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["miniflux"] },
|
|
235
238
|
{ id: "freshrss", name: "FreshRSS", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["freshrss"] },
|
|
236
239
|
{ id: "commafeed", name: "CommaFeed", category: "feed_reader", organization: "Open Source", baseScore: 25, respectsRobots: true, uaPatterns: ["commafeed"] },
|
|
240
|
+
{ id: "spiderling", name: "SpiderLing", category: "commercial_scraper", organization: "Lexical Computing", baseScore: 55, respectsRobots: true, uaPatterns: ["spiderling", "sketchengine"] },
|
|
241
|
+
{ id: "netapi", name: "NetAPI Bot", category: "commercial_scraper", organization: "NetAPI", baseScore: 50, respectsRobots: true, uaPatterns: ["netapi/"] },
|
|
242
|
+
{ id: "anticlonebot", name: "AntiCloneBot", category: "commercial_scraper", organization: "AntiClone", baseScore: 45, respectsRobots: true, uaPatterns: ["anticlonebot"] },
|
|
237
243
|
{ id: "terncrawler", name: "TernCrawler", category: "commercial_scraper", organization: "Unknown", baseScore: 60, respectsRobots: false, uaPatterns: ["terncrawler"] },
|
|
238
244
|
{ id: "diffbot", name: "Diffbot", category: "commercial_scraper", organization: "Diffbot", baseScore: 70, respectsRobots: true, uaPatterns: ["diffbot"] },
|
|
239
245
|
{ id: "import-io", name: "Import.io", category: "commercial_scraper", organization: "Import.io", baseScore: 65, respectsRobots: true, uaPatterns: ["import.io"] },
|
|
@@ -2630,6 +2636,100 @@ function isTestTriggerUserAgent(userAgent) {
|
|
|
2630
2636
|
return userAgent.trimStart().toLowerCase().startsWith(TEST_TRIGGER_UA_PREFIX.toLowerCase());
|
|
2631
2637
|
}
|
|
2632
2638
|
|
|
2639
|
+
// src/offensive-toolchain.ts
|
|
2640
|
+
var TOOLCHAIN_REGISTRY_REVISION = 1;
|
|
2641
|
+
var FRAMEWORK_REGISTRY_REVISION = 5;
|
|
2642
|
+
var reviewedTools = Object.freeze({
|
|
2643
|
+
nmap_scan: "network_reconnaissance",
|
|
2644
|
+
nmap_advanced_scan: "network_reconnaissance",
|
|
2645
|
+
masscan_scan: "network_reconnaissance",
|
|
2646
|
+
nuclei_scan: "vulnerability_scanning",
|
|
2647
|
+
sqlmap_scan: "injection_testing",
|
|
2648
|
+
metasploit_run: "exploitation"
|
|
2649
|
+
});
|
|
2650
|
+
async function createOffensiveToolchainEvidence(input) {
|
|
2651
|
+
const sensor = input.sensor.trim();
|
|
2652
|
+
if (!/^[a-z0-9][a-z0-9_.-]{0,127}$/i.test(sensor)) {
|
|
2653
|
+
throw new Error("sensor must be a 1-128 character stable identifier");
|
|
2654
|
+
}
|
|
2655
|
+
if (!input.runId || input.runId.length > 1024) {
|
|
2656
|
+
throw new Error("runId must be 1-1024 characters");
|
|
2657
|
+
}
|
|
2658
|
+
if (input.correlationSecret.length < 32 || input.correlationSecret.length > 4096) {
|
|
2659
|
+
throw new Error("correlationSecret must be 32-4096 characters");
|
|
2660
|
+
}
|
|
2661
|
+
if (!Array.isArray(input.invocations) || input.invocations.length === 0 || input.invocations.length > 256) {
|
|
2662
|
+
throw new Error("invocations must contain 1-256 entries");
|
|
2663
|
+
}
|
|
2664
|
+
const sequence = [];
|
|
2665
|
+
let redactedArgumentCount = 0;
|
|
2666
|
+
let droppedToolCount = 0;
|
|
2667
|
+
for (const invocation of input.invocations) {
|
|
2668
|
+
if (!invocation.tool || invocation.tool.length > 128) {
|
|
2669
|
+
throw new Error("tool must be 1-128 characters");
|
|
2670
|
+
}
|
|
2671
|
+
const redacted = invocation.redactedArgumentCount ?? 0;
|
|
2672
|
+
if (!Number.isInteger(redacted) || redacted < 0 || redacted > 1024) {
|
|
2673
|
+
throw new Error("redactedArgumentCount must be an integer from 0 through 1024");
|
|
2674
|
+
}
|
|
2675
|
+
const family = reviewedTools[invocation.tool.trim().toLowerCase()];
|
|
2676
|
+
if (!family) {
|
|
2677
|
+
droppedToolCount++;
|
|
2678
|
+
continue;
|
|
2679
|
+
}
|
|
2680
|
+
sequence.push(family);
|
|
2681
|
+
redactedArgumentCount += redacted;
|
|
2682
|
+
if (redactedArgumentCount > 1024) throw new Error("redacted argument count exceeds 1024");
|
|
2683
|
+
}
|
|
2684
|
+
if (sequence.length === 0) throw new Error("no reviewed offensive tools were observed");
|
|
2685
|
+
const families = [...new Set(sequence)].sort();
|
|
2686
|
+
const offensive_toolchain = {
|
|
2687
|
+
schema_version: 1,
|
|
2688
|
+
registry_revision: TOOLCHAIN_REGISTRY_REVISION,
|
|
2689
|
+
plane: "model_api",
|
|
2690
|
+
sensor,
|
|
2691
|
+
run_correlation_id: await hmacSha256Hex(input.correlationSecret, input.runId),
|
|
2692
|
+
tool_families: families,
|
|
2693
|
+
invocation_count: sequence.length,
|
|
2694
|
+
family_set_sha256: await fingerprintIDs(families),
|
|
2695
|
+
sequence_sha256: await sha256Hex(sequence.join("\n")),
|
|
2696
|
+
redacted_argument_count: redactedArgumentCount,
|
|
2697
|
+
dropped_tool_count: droppedToolCount
|
|
2698
|
+
};
|
|
2699
|
+
const evidence = { offensive_toolchain };
|
|
2700
|
+
if (input.orchestrator === "hexstrike_ai") {
|
|
2701
|
+
evidence.framework_evidence = await hexStrikeEvidence();
|
|
2702
|
+
}
|
|
2703
|
+
return evidence;
|
|
2704
|
+
}
|
|
2705
|
+
async function hexStrikeEvidence() {
|
|
2706
|
+
const family = {
|
|
2707
|
+
family_id: "orchestrator_identity",
|
|
2708
|
+
count: 1,
|
|
2709
|
+
sha256: await fingerprintIDs(["hexstrike-ai-mcp"])
|
|
2710
|
+
};
|
|
2711
|
+
return {
|
|
2712
|
+
schema_version: 1,
|
|
2713
|
+
registry_revision: FRAMEWORK_REGISTRY_REVISION,
|
|
2714
|
+
framework: "hexstrike_ai",
|
|
2715
|
+
plane: "model_api",
|
|
2716
|
+
evidence: [family],
|
|
2717
|
+
observation_sha256: await fingerprintEvidence([family])
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
async function fingerprintIDs(values) {
|
|
2721
|
+
const canonical = [
|
|
2722
|
+
...new Set(values.map((value) => value.trim().toLowerCase()).filter(Boolean))
|
|
2723
|
+
].sort();
|
|
2724
|
+
return sha256Hex(canonical.join("\n"));
|
|
2725
|
+
}
|
|
2726
|
+
async function fingerprintEvidence(evidence) {
|
|
2727
|
+
const canonical = evidence.map(
|
|
2728
|
+
(value) => `${value.family_id.trim().toLowerCase()}\0${value.count}\0${value.sha256.trim().toLowerCase()}`
|
|
2729
|
+
);
|
|
2730
|
+
return fingerprintIDs(canonical);
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2633
2733
|
// src/report-headers.ts
|
|
2634
2734
|
var CREDENTIAL_HEADER = /cookie|auth|token|secret|passw|session|credential|csrf|xsrf|api[-_]?key|access[-_]?key|private[-_]?key/i;
|
|
2635
2735
|
var CLEARANCE_COOKIE = "wd_clearance";
|
|
@@ -2779,7 +2879,11 @@ var WebDecoyClient = class {
|
|
|
2779
2879
|
}
|
|
2780
2880
|
throw new Error(`API request failed: HTTP ${response.status}`);
|
|
2781
2881
|
}
|
|
2782
|
-
|
|
2882
|
+
const detection = response.data;
|
|
2883
|
+
if (request.decision_mode === "unified_v1" && (detection?.decision_mode !== "unified_v1" || !(typeof detection.unified_score === "number" && Number.isInteger(detection.unified_score) && detection.unified_score >= 0 && detection.unified_score <= 100) || !(Number.isInteger(detection.confidence) && detection.confidence >= 0 && detection.confidence <= 100) || !["allow", "challenge", "block"].includes(detection.decision) || typeof detection.detection_id !== "string" || !detection.detection_id)) {
|
|
2884
|
+
throw new Error("WebDecoy did not return a valid unified decision");
|
|
2885
|
+
}
|
|
2886
|
+
return detection;
|
|
2783
2887
|
}
|
|
2784
2888
|
async createSSRFCanary(options) {
|
|
2785
2889
|
const response = await this.request("POST", "/api/v1/sdk/ssrf/markers", {
|
|
@@ -3384,7 +3488,8 @@ var WebDecoy = class {
|
|
|
3384
3488
|
apiKey: config.apiKey,
|
|
3385
3489
|
apiUrl: config.apiUrl || "https://in.webdecoy.com",
|
|
3386
3490
|
enableTLSFingerprinting: config.enableTLSFingerprinting ?? true,
|
|
3387
|
-
|
|
3491
|
+
decisionMode: config.decisionMode ?? "legacy",
|
|
3492
|
+
threatScoreThreshold: config.threatScoreThreshold,
|
|
3388
3493
|
timeout: config.timeout ?? 5e3,
|
|
3389
3494
|
debug: config.debug ?? false,
|
|
3390
3495
|
tlsRejectUnauthorized: config.tlsRejectUnauthorized ?? true,
|
|
@@ -3406,7 +3511,7 @@ var WebDecoy = class {
|
|
|
3406
3511
|
}
|
|
3407
3512
|
this.webBotAuthOptions = config.webBotAuth;
|
|
3408
3513
|
this.characteristics = config.characteristics ?? DEFAULT_CHARACTERISTICS;
|
|
3409
|
-
this.decisionCache = config.decisionCache === false ? null : new DecisionCache(config.decisionCache ?? {});
|
|
3514
|
+
this.decisionCache = config.decisionCache === false || this.config.decisionMode === "unified_v1" ? null : new DecisionCache(config.decisionCache ?? {});
|
|
3410
3515
|
const rules = config.rules ?? [tripwire()];
|
|
3411
3516
|
if (rules.length > 0) {
|
|
3412
3517
|
this.ruleEngine = new RuleEngine(rules);
|
|
@@ -3629,6 +3734,38 @@ var WebDecoy = class {
|
|
|
3629
3734
|
honeyCredentialFingerprint(tokenId, bearer) {
|
|
3630
3735
|
return hmacSha256Hex(this.config.apiKey, `webdecoy/honey-credential/v1\0${tokenId}\0${bearer}`);
|
|
3631
3736
|
}
|
|
3737
|
+
/**
|
|
3738
|
+
* Report a privacy-bounded model-plane tool run. The helper sends only
|
|
3739
|
+
* reviewed generic families, counts, and digests; it never sends prompts,
|
|
3740
|
+
* arguments, results, credentials, targets, or the raw run ID.
|
|
3741
|
+
*/
|
|
3742
|
+
async reportOffensiveToolchain(input) {
|
|
3743
|
+
if (!this.client) {
|
|
3744
|
+
throw new Error("An apiKey is required to report an offensive toolchain");
|
|
3745
|
+
}
|
|
3746
|
+
const evidence = await createOffensiveToolchainEvidence(input);
|
|
3747
|
+
return this.client.detect({
|
|
3748
|
+
request_metadata: {
|
|
3749
|
+
method: "MODEL",
|
|
3750
|
+
path: "/model-toolchain",
|
|
3751
|
+
// The existing SDK route requires an address. Model-plane evidence has
|
|
3752
|
+
// no target client IP, so use the unspecified address rather than
|
|
3753
|
+
// inventing an identity that could enter actor correlation.
|
|
3754
|
+
ip: "0.0.0.0",
|
|
3755
|
+
headers: {},
|
|
3756
|
+
timestamp: Date.now()
|
|
3757
|
+
},
|
|
3758
|
+
local_analysis: {
|
|
3759
|
+
suspicious_headers: false,
|
|
3760
|
+
missing_sec_ch_ua: false,
|
|
3761
|
+
datacenter_ip: false,
|
|
3762
|
+
local_score: 0,
|
|
3763
|
+
needs_verification: true,
|
|
3764
|
+
flags: ["model_plane_toolchain"]
|
|
3765
|
+
},
|
|
3766
|
+
...evidence
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3632
3769
|
/**
|
|
3633
3770
|
* Whether this SDK instance has filter rules that need async enrichment
|
|
3634
3771
|
*/
|
|
@@ -3655,7 +3792,8 @@ var WebDecoy = class {
|
|
|
3655
3792
|
this.referralCounter?.observe(metadata);
|
|
3656
3793
|
const span = startSpan(this.tracer, "webdecoy.protect");
|
|
3657
3794
|
try {
|
|
3658
|
-
|
|
3795
|
+
setAttribute(span, "webdecoy.cloud.decision_mode", this.config.decisionMode);
|
|
3796
|
+
const decision = (await this.decide(metadata, options, span)).withEdge(edge);
|
|
3659
3797
|
setAttribute(span, "webdecoy.decision.id", decision.id);
|
|
3660
3798
|
setAttribute(span, "webdecoy.decision.conclusion", decision.conclusion);
|
|
3661
3799
|
setAttribute(span, "webdecoy.decision.allowed", decision.allowed);
|
|
@@ -3679,7 +3817,7 @@ var WebDecoy = class {
|
|
|
3679
3817
|
endSpan(span);
|
|
3680
3818
|
}
|
|
3681
3819
|
}
|
|
3682
|
-
async decide(metadata, options
|
|
3820
|
+
async decide(metadata, options, span) {
|
|
3683
3821
|
const id = newDecisionId();
|
|
3684
3822
|
let key = metadata.ip || "unknown";
|
|
3685
3823
|
try {
|
|
@@ -3690,6 +3828,7 @@ var WebDecoy = class {
|
|
|
3690
3828
|
metadata.timestamp = Date.now();
|
|
3691
3829
|
}
|
|
3692
3830
|
if (isTestTriggerUserAgent(metadata.user_agent)) {
|
|
3831
|
+
setAttribute(span, "webdecoy.cloud.admission", "test_trigger");
|
|
3693
3832
|
return this.reportTestTrigger(metadata, id);
|
|
3694
3833
|
}
|
|
3695
3834
|
const needsAsync = this._hasFilterRules || this._hasAgentRules || this._preparingRules.length > 0;
|
|
@@ -3698,6 +3837,7 @@ var WebDecoy = class {
|
|
|
3698
3837
|
const agentVerdict = context.agent;
|
|
3699
3838
|
const ruleResult = this.ruleEngine ? this.runRules(context) : null;
|
|
3700
3839
|
if (ruleResult && ruleResult.action !== "ALLOW") {
|
|
3840
|
+
setAttribute(span, "webdecoy.cloud.admission", "local_rule");
|
|
3701
3841
|
const throttled = ruleResult.action === "THROTTLE";
|
|
3702
3842
|
return new Decision({
|
|
3703
3843
|
conclusion: "DENY",
|
|
@@ -3718,6 +3858,7 @@ var WebDecoy = class {
|
|
|
3718
3858
|
});
|
|
3719
3859
|
}
|
|
3720
3860
|
if (!this.client) {
|
|
3861
|
+
setAttribute(span, "webdecoy.cloud.admission", "no_api_key");
|
|
3721
3862
|
return new Decision({
|
|
3722
3863
|
conclusion: "ALLOW",
|
|
3723
3864
|
detection: {
|
|
@@ -3736,7 +3877,10 @@ var WebDecoy = class {
|
|
|
3736
3877
|
});
|
|
3737
3878
|
}
|
|
3738
3879
|
const cached = this.decisionCache?.get(key);
|
|
3739
|
-
if (cached)
|
|
3880
|
+
if (cached) {
|
|
3881
|
+
setAttribute(span, "webdecoy.cloud.admission", "cached");
|
|
3882
|
+
return cached.asCached();
|
|
3883
|
+
}
|
|
3740
3884
|
const localAnalysis = options.skipLocalAnalysis ? {
|
|
3741
3885
|
suspicious_headers: false,
|
|
3742
3886
|
missing_sec_ch_ua: false,
|
|
@@ -3746,12 +3890,11 @@ var WebDecoy = class {
|
|
|
3746
3890
|
flags: ["local_analysis_skipped"]
|
|
3747
3891
|
} : analyzeRequest(metadata);
|
|
3748
3892
|
this.log.debug("Local analysis", { ...localAnalysis });
|
|
3749
|
-
const detectionRequest = {
|
|
3750
|
-
request_metadata: metadata,
|
|
3751
|
-
local_analysis: localAnalysis
|
|
3752
|
-
};
|
|
3753
3893
|
const shouldCallServer = localAnalysis.needs_verification || this.config.enableTLSFingerprinting && metadata.tls_info;
|
|
3754
3894
|
if (!shouldCallServer) {
|
|
3895
|
+
setAttribute(span, "webdecoy.cloud.admission", "local_gate");
|
|
3896
|
+
setAttribute(span, "webdecoy.cloud.gate_datacenter_ip", localAnalysis.datacenter_ip);
|
|
3897
|
+
setAttribute(span, "webdecoy.cloud.gate_missing_sec_ch_ua", localAnalysis.missing_sec_ch_ua);
|
|
3755
3898
|
return new Decision({
|
|
3756
3899
|
conclusion: "ALLOW",
|
|
3757
3900
|
detection: {
|
|
@@ -3769,8 +3912,14 @@ var WebDecoy = class {
|
|
|
3769
3912
|
key
|
|
3770
3913
|
});
|
|
3771
3914
|
}
|
|
3772
|
-
const
|
|
3773
|
-
|
|
3915
|
+
const unified = this.config.decisionMode === "unified_v1";
|
|
3916
|
+
setAttribute(span, "webdecoy.cloud.admission", "cloud");
|
|
3917
|
+
const detection = await this.client.detect({
|
|
3918
|
+
request_metadata: metadata,
|
|
3919
|
+
local_analysis: localAnalysis,
|
|
3920
|
+
...unified && { decision_mode: "unified_v1" }
|
|
3921
|
+
});
|
|
3922
|
+
const threshold = options.threshold ?? this.config.threatScoreThreshold ?? (unified ? 0 : 80);
|
|
3774
3923
|
const allowed = detection.decision === "allow" || detection.confidence < threshold;
|
|
3775
3924
|
this.log.debug("Server detection", {
|
|
3776
3925
|
decision: detection.decision,
|
|
@@ -3780,7 +3929,7 @@ var WebDecoy = class {
|
|
|
3780
3929
|
const conclusion = allowed ? "ALLOW" : detection.decision === "challenge" ? "CHALLENGE" : "DENY";
|
|
3781
3930
|
const decision = new Decision({
|
|
3782
3931
|
conclusion,
|
|
3783
|
-
reason: allowed ? void 0 : `Threat score ${detection.confidence} (threshold ${threshold})`,
|
|
3932
|
+
reason: allowed ? void 0 : unified ? `Unified verdict ${detection.decision} (score ${detection.unified_score}, confidence ${detection.confidence})` : `Threat score ${detection.confidence} (threshold ${threshold})`,
|
|
3784
3933
|
detection,
|
|
3785
3934
|
id,
|
|
3786
3935
|
results: ruleResult?.results ?? [],
|
|
@@ -3792,6 +3941,9 @@ var WebDecoy = class {
|
|
|
3792
3941
|
if (this.decisionCache) this.decisionCache.set(key, decision);
|
|
3793
3942
|
return decision;
|
|
3794
3943
|
} catch (error) {
|
|
3944
|
+
if (error instanceof WebDecoyUnavailableError) {
|
|
3945
|
+
setAttribute(span, "webdecoy.cloud.admission", "backoff");
|
|
3946
|
+
}
|
|
3795
3947
|
const log = error instanceof WebDecoyUnavailableError ? this.log.debug.bind(this.log) : this.log.error.bind(this.log);
|
|
3796
3948
|
log("Protection error", {
|
|
3797
3949
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -3845,6 +3997,7 @@ var WebDecoy = class {
|
|
|
3845
3997
|
try {
|
|
3846
3998
|
const detection = await this.client.detect({
|
|
3847
3999
|
request_metadata: metadata,
|
|
4000
|
+
...this.config.decisionMode === "unified_v1" && { decision_mode: "unified_v1" },
|
|
3848
4001
|
local_analysis: {
|
|
3849
4002
|
suspicious_headers: false,
|
|
3850
4003
|
missing_sec_ch_ua: false,
|
|
@@ -3992,5 +4145,6 @@ export {
|
|
|
3992
4145
|
TEST_TRIGGER_UA_PREFIX,
|
|
3993
4146
|
TEST_TRIGGER_USER_AGENT,
|
|
3994
4147
|
isTestTriggerUserAgent,
|
|
4148
|
+
createOffensiveToolchainEvidence,
|
|
3995
4149
|
WebDecoy
|
|
3996
4150
|
};
|