avorelo 0.1.0 → 0.3.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/LICENSE +23 -16
- package/README.md +90 -51
- package/bin/avorelo.mjs +7 -0
- package/dist/avorelo.mjs +19741 -0
- package/package.json +135 -120
- package/bin/avorelo +0 -9
- package/scripts/README.md +0 -40
- package/scripts/cco-dashboard.js +0 -252
- package/scripts/cco-status.js +0 -430
- package/scripts/lib/activation/account-state.js +0 -37
- package/scripts/lib/activation/activation-runner.js +0 -546
- package/scripts/lib/activation/activation-self-healing.js +0 -480
- package/scripts/lib/activation/activation-state.js +0 -83
- package/scripts/lib/activation/activation-summary.js +0 -191
- package/scripts/lib/activation/adapters/claude-code.js +0 -77
- package/scripts/lib/activation/adapters/codex-cli.js +0 -52
- package/scripts/lib/activation/adapters/cursor.js +0 -37
- package/scripts/lib/activation/adapters/github-agent.js +0 -39
- package/scripts/lib/activation/adapters/terminal.js +0 -42
- package/scripts/lib/activation/adapters/vscode.js +0 -39
- package/scripts/lib/activation/adapters/windsurf.js +0 -37
- package/scripts/lib/activation/ai-surface-detector.js +0 -151
- package/scripts/lib/activation/connect-account.js +0 -145
- package/scripts/lib/activation/detect-environment.js +0 -75
- package/scripts/lib/activation/detect-hosts.js +0 -62
- package/scripts/lib/activation/format-activation-output.js +0 -109
- package/scripts/lib/activation/next-action.js +0 -43
- package/scripts/lib/activation/repair-engine.js +0 -219
- package/scripts/lib/activation-distribution-readiness.js +0 -507
- package/scripts/lib/adapter-conformance.js +0 -176
- package/scripts/lib/adapter-readiness.js +0 -417
- package/scripts/lib/adapter-safety-boundaries.js +0 -335
- package/scripts/lib/adapter-technical-readiness-gate.js +0 -205
- package/scripts/lib/agent-access-governance.js +0 -455
- package/scripts/lib/agent-enforcement.js +0 -765
- package/scripts/lib/agent-policy-profile.js +0 -210
- package/scripts/lib/agent-security/action-evaluator.js +0 -507
- package/scripts/lib/agent-security/adapter-registry.js +0 -98
- package/scripts/lib/agent-security/auto-policy.js +0 -139
- package/scripts/lib/agent-security/bounded-scan.js +0 -93
- package/scripts/lib/agent-security/enforcement-adapter.js +0 -174
- package/scripts/lib/agent-security/enforcement-engine.js +0 -1129
- package/scripts/lib/agent-security/file-write-adapter.js +0 -183
- package/scripts/lib/agent-security/file-write-rules.js +0 -178
- package/scripts/lib/agent-security/index.js +0 -3342
- package/scripts/lib/agent-security/instruction-risk.js +0 -181
- package/scripts/lib/agent-security/mcp-action-adapter.js +0 -185
- package/scripts/lib/agent-security/mcp-action-rules.js +0 -184
- package/scripts/lib/agent-security/package-action-adapter.js +0 -175
- package/scripts/lib/agent-security/package-action-rules.js +0 -233
- package/scripts/lib/agent-security/performance.js +0 -148
- package/scripts/lib/agent-security/permission-minimizer.js +0 -403
- package/scripts/lib/agent-security/scan-cache.js +0 -74
- package/scripts/lib/agent-security/source-trust.js +0 -146
- package/scripts/lib/ai-install-prompt.js +0 -288
- package/scripts/lib/ai-workspace-hygiene.js +0 -1499
- package/scripts/lib/alpha-activation.js +0 -520
- package/scripts/lib/alpha-feedback.js +0 -263
- package/scripts/lib/alpha-readiness-gate.js +0 -332
- package/scripts/lib/anti-gaming.js +0 -169
- package/scripts/lib/artifact-health.js +0 -431
- package/scripts/lib/attribution.js +0 -180
- package/scripts/lib/audit.js +0 -289
- package/scripts/lib/avorelo-skill-registry.js +0 -810
- package/scripts/lib/batch-jobs.js +0 -71
- package/scripts/lib/brain-pack.js +0 -578
- package/scripts/lib/brand-boundary.js +0 -424
- package/scripts/lib/brand.js +0 -74
- package/scripts/lib/browser-capability.js +0 -1048
- package/scripts/lib/browser-proof-preflight.js +0 -321
- package/scripts/lib/cache-readiness.js +0 -187
- package/scripts/lib/canonical-reentry.js +0 -162
- package/scripts/lib/capability-packs.js +0 -314
- package/scripts/lib/capability-recommender.js +0 -512
- package/scripts/lib/capability-registry.js +0 -1059
- package/scripts/lib/carry-forward-surfacing.js +0 -194
- package/scripts/lib/ccusage-adapter.js +0 -188
- package/scripts/lib/company-loop.js +0 -1149
- package/scripts/lib/config.js +0 -637
- package/scripts/lib/context-acquisition-plan.js +0 -287
- package/scripts/lib/context-budget-guard.js +0 -170
- package/scripts/lib/context-budget-scanner.js +0 -257
- package/scripts/lib/context-optimizer.js +0 -715
- package/scripts/lib/context-reduction-plan.js +0 -178
- package/scripts/lib/context-safety.js +0 -88
- package/scripts/lib/context-savings-engine.js +0 -158
- package/scripts/lib/cost-evidence.js +0 -254
- package/scripts/lib/cross-host-install-plan.js +0 -308
- package/scripts/lib/cross-host-install-readiness.js +0 -237
- package/scripts/lib/cross-host-value-flow.js +0 -268
- package/scripts/lib/dashboard.js +0 -900
- package/scripts/lib/design-partner-feedback.js +0 -346
- package/scripts/lib/entitlements.js +0 -100
- package/scripts/lib/execution-packet.js +0 -559
- package/scripts/lib/experimentation-events.js +0 -547
- package/scripts/lib/external-capability-compliance.js +0 -107
- package/scripts/lib/external-user-simulation.js +0 -166
- package/scripts/lib/failure-recovery-readiness.js +0 -81
- package/scripts/lib/failure-recovery.js +0 -419
- package/scripts/lib/feedback-intelligence.js +0 -537
- package/scripts/lib/feedback-signals.js +0 -205
- package/scripts/lib/file-integrity.js +0 -68
- package/scripts/lib/fsx.js +0 -127
- package/scripts/lib/full-readiness-gate.js +0 -451
- package/scripts/lib/guidance-builder.js +0 -174
- package/scripts/lib/hook-apply.js +0 -1019
- package/scripts/lib/hook-baseline.js +0 -310
- package/scripts/lib/hook-config-preview.js +0 -275
- package/scripts/lib/hook-contracts.js +0 -290
- package/scripts/lib/hook-safety-boundary-readiness.js +0 -80
- package/scripts/lib/host-capability-matrix.js +0 -351
- package/scripts/lib/host-support-context.js +0 -254
- package/scripts/lib/http-hook-action.js +0 -538
- package/scripts/lib/install-ai-readiness.js +0 -84
- package/scripts/lib/install-intake-risk.js +0 -1037
- package/scripts/lib/install-journey-intelligence.js +0 -329
- package/scripts/lib/intervention-guidance.js +0 -57
- package/scripts/lib/known-limitations.js +0 -115
- package/scripts/lib/l8-path-truth.js +0 -146
- package/scripts/lib/launch-hardening-gate.js +0 -436
- package/scripts/lib/launch-readiness.js +0 -628
- package/scripts/lib/learning-memory.js +0 -686
- package/scripts/lib/lifecycle-hooks.js +0 -802
- package/scripts/lib/local-package-smoke.js +0 -423
- package/scripts/lib/local-pricing.js +0 -299
- package/scripts/lib/mcp-enforcement.js +0 -311
- package/scripts/lib/mcp-least-privilege-policy.js +0 -303
- package/scripts/lib/mcp-tool-inventory.js +0 -388
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +0 -335
- package/scripts/lib/metrics.js +0 -699
- package/scripts/lib/micro-proof.js +0 -133
- package/scripts/lib/next-run-context.js +0 -436
- package/scripts/lib/operating-value.js +0 -1648
- package/scripts/lib/optimization-v3.js +0 -122
- package/scripts/lib/orchestration/adapters/_shared.js +0 -49
- package/scripts/lib/orchestration/adapters/aider.js +0 -18
- package/scripts/lib/orchestration/adapters/claude-code.js +0 -35
- package/scripts/lib/orchestration/adapters/codex.js +0 -35
- package/scripts/lib/orchestration/adapters/gemini-cli.js +0 -18
- package/scripts/lib/orchestration/adapters/git.js +0 -25
- package/scripts/lib/orchestration/adapters/index.js +0 -31
- package/scripts/lib/orchestration/adapters/lm-studio.js +0 -18
- package/scripts/lib/orchestration/adapters/ollama.js +0 -18
- package/scripts/lib/orchestration/adapters/opencode.js +0 -18
- package/scripts/lib/orchestration/adapters/openrouter.js +0 -18
- package/scripts/lib/orchestration/adapters/test-runner.js +0 -25
- package/scripts/lib/orchestration/cli.js +0 -438
- package/scripts/lib/orchestration/execution-manager.js +0 -279
- package/scripts/lib/orchestration/handoff.js +0 -314
- package/scripts/lib/orchestration/index.js +0 -456
- package/scripts/lib/orchestration/inventory.js +0 -47
- package/scripts/lib/orchestration/model-discovery.js +0 -498
- package/scripts/lib/orchestration/model-profiler.js +0 -170
- package/scripts/lib/orchestration/model-profiles.js +0 -252
- package/scripts/lib/orchestration/model-refresh-policy.js +0 -72
- package/scripts/lib/orchestration/proof-writer.js +0 -349
- package/scripts/lib/orchestration/provider-discovery/aider.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +0 -56
- package/scripts/lib/orchestration/provider-discovery/codex.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/common.js +0 -186
- package/scripts/lib/orchestration/provider-discovery/gemini.js +0 -106
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +0 -118
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +0 -12
- package/scripts/lib/orchestration/provider-discovery/ollama.js +0 -100
- package/scripts/lib/orchestration/provider-discovery/opencode.js +0 -47
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +0 -44
- package/scripts/lib/orchestration/risk-classifier.js +0 -130
- package/scripts/lib/orchestration/routing-policy.js +0 -486
- package/scripts/lib/orchestration/settings.js +0 -112
- package/scripts/lib/orchestration/state.js +0 -165
- package/scripts/lib/orchestration/verification-manager.js +0 -138
- package/scripts/lib/output-profiles.js +0 -146
- package/scripts/lib/package-content-audit.js +0 -368
- package/scripts/lib/package-runtime.js +0 -278
- package/scripts/lib/plan-surface.js +0 -53
- package/scripts/lib/plans.js +0 -2318
- package/scripts/lib/policy-provider.js +0 -27
- package/scripts/lib/prelaunch-activation-readiness.js +0 -409
- package/scripts/lib/prelaunch-evidence-store.js +0 -816
- package/scripts/lib/prelaunch-intelligence.js +0 -869
- package/scripts/lib/pricing-experiment.js +0 -118
- package/scripts/lib/pro-moment-events.js +0 -77
- package/scripts/lib/pro-moment-state.js +0 -227
- package/scripts/lib/pro-moments.js +0 -1216
- package/scripts/lib/product-learning-events.js +0 -629
- package/scripts/lib/project-profile.js +0 -555
- package/scripts/lib/prompt-compiler.js +0 -280
- package/scripts/lib/prompt-lint.js +0 -32
- package/scripts/lib/prompt-suggestions.js +0 -52
- package/scripts/lib/proof-canonical.js +0 -398
- package/scripts/lib/proof-drilldown.js +0 -383
- package/scripts/lib/proof-events.js +0 -342
- package/scripts/lib/proof-history.js +0 -243
- package/scripts/lib/proof-metrics.js +0 -296
- package/scripts/lib/proof-outcome-evidence.js +0 -134
- package/scripts/lib/proof-receipt.js +0 -335
- package/scripts/lib/proof-record.js +0 -461
- package/scripts/lib/public-activation-distribution-gate.js +0 -258
- package/scripts/lib/public-cli.js +0 -3891
- package/scripts/lib/public-distribution-truth.js +0 -211
- package/scripts/lib/public-install-claim-checker.js +0 -294
- package/scripts/lib/publish-provenance-readiness.js +0 -283
- package/scripts/lib/readiness-delta.js +0 -218
- package/scripts/lib/readiness-evidence-closure.js +0 -196
- package/scripts/lib/reentry-memory-capture.js +0 -241
- package/scripts/lib/reentry-memory-retrieval.js +0 -302
- package/scripts/lib/reentry-memory-status.js +0 -146
- package/scripts/lib/reentry-memory-store.js +0 -178
- package/scripts/lib/reentry-state.js +0 -66
- package/scripts/lib/release-candidate-bundle.js +0 -166
- package/scripts/lib/remediation.js +0 -81
- package/scripts/lib/repo-map.js +0 -391
- package/scripts/lib/run-improvements-lifecycle.js +0 -330
- package/scripts/lib/run-improvements.js +0 -789
- package/scripts/lib/runtime-decision-policy.js +0 -387
- package/scripts/lib/safe-path-engine.js +0 -705
- package/scripts/lib/safe-run-controller.js +0 -887
- package/scripts/lib/score.js +0 -262
- package/scripts/lib/seamless-enforcement.js +0 -329
- package/scripts/lib/seamless-outcome.js +0 -689
- package/scripts/lib/seamless-reality-gate.js +0 -5043
- package/scripts/lib/security-risk-classifier.js +0 -511
- package/scripts/lib/security-scan.js +0 -384
- package/scripts/lib/session-context-optimizer.js +0 -1211
- package/scripts/lib/session-timing.js +0 -315
- package/scripts/lib/skill-hygiene.js +0 -805
- package/scripts/lib/skill-packs.js +0 -161
- package/scripts/lib/skills-operating-layer.js +0 -580
- package/scripts/lib/smart-work-routing.js +0 -768
- package/scripts/lib/source-catalog.js +0 -700
- package/scripts/lib/status-value-summary.js +0 -32
- package/scripts/lib/support-bundle.js +0 -578
- package/scripts/lib/task-continuation.js +0 -440
- package/scripts/lib/test-helpers.js +0 -15
- package/scripts/lib/tier.js +0 -38
- package/scripts/lib/token-context-quality-gate.js +0 -370
- package/scripts/lib/token-cost-capture.js +0 -187
- package/scripts/lib/token-cost-intelligence.js +0 -358
- package/scripts/lib/token-efficiency-evidence.js +0 -213
- package/scripts/lib/token-evidence.js +0 -699
- package/scripts/lib/tokenish.js +0 -17
- package/scripts/lib/tool-output-sandbox.js +0 -304
- package/scripts/lib/trust-audit.js +0 -136
- package/scripts/lib/unified-events.js +0 -396
- package/scripts/lib/upgrade-interruption-recovery.js +0 -407
- package/scripts/lib/usage-ledger.js +0 -201
- package/scripts/lib/value-ledger.js +0 -130
- package/scripts/lib/value-proof-calibration.js +0 -531
- package/scripts/lib/visual-qa.js +0 -231
- package/scripts/lib/voice-alpha.js +0 -29
- package/scripts/lib/work-aware-orchestration.js +0 -976
- package/scripts/lib/work-control-receipts.js +0 -577
- package/scripts/lib/work-ledger.js +0 -1123
- package/scripts/lib/work-panel-preview.js +0 -352
- package/scripts/lib/workflow-discipline.js +0 -280
- package/scripts/lib/workflow-signals.js +0 -419
- package/scripts/lib/workspace-map.js +0 -281
- package/scripts/lib/workspace-registry.js +0 -1367
- package/scripts/lib/workspace-resolver.js +0 -480
|
@@ -1,1048 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const crypto = require("crypto");
|
|
6
|
-
|
|
7
|
-
const SCHEMA_VERSION = 2;
|
|
8
|
-
|
|
9
|
-
// ── Capability constants ───────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
const CAPABILITY = {
|
|
12
|
-
BROWSER_READ: "browser_read",
|
|
13
|
-
BROWSER_WRITE: "browser_write",
|
|
14
|
-
AUTHENTICATED_SESSION_ACCESS: "authenticated_session_access",
|
|
15
|
-
SENSITIVE_FORM_ACTION: "sensitive_form_action",
|
|
16
|
-
FILE_TRANSFER: "file_transfer",
|
|
17
|
-
JAVASCRIPT_OR_CDP_EXECUTION: "javascript_or_cdp_execution",
|
|
18
|
-
REMOTE_BROWSER_OR_PROXY: "remote_browser_or_proxy",
|
|
19
|
-
SELF_MODIFYING_HELPER: "self_modifying_helper",
|
|
20
|
-
DEPENDENCY_BOOTSTRAP: "dependency_bootstrap",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const RISK_TIER = {
|
|
24
|
-
NONE: "none",
|
|
25
|
-
LOW: "low",
|
|
26
|
-
MEDIUM: "medium",
|
|
27
|
-
HIGH: "high",
|
|
28
|
-
CRITICAL: "critical",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const TIER_ORDER = {
|
|
32
|
-
none: 0,
|
|
33
|
-
low: 1,
|
|
34
|
-
medium: 2,
|
|
35
|
-
high: 3,
|
|
36
|
-
critical: 4,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const DOMAIN_POLICY_READINESS = {
|
|
40
|
-
MISSING: "missing",
|
|
41
|
-
PARTIAL: "partial",
|
|
42
|
-
CONFIGURED: "configured",
|
|
43
|
-
STRONG: "strong",
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// ── Known-tool registry ────────────────────────────────────────────────────────
|
|
47
|
-
// Each entry: names[] matched case-insensitively against dep names and MCP server names/commands.
|
|
48
|
-
|
|
49
|
-
const BROWSER_TOOL_REGISTRY = [
|
|
50
|
-
{
|
|
51
|
-
id: "browser-use",
|
|
52
|
-
names: ["browser-use", "browseruse", "browser_use"],
|
|
53
|
-
capabilities: [
|
|
54
|
-
CAPABILITY.BROWSER_READ,
|
|
55
|
-
CAPABILITY.BROWSER_WRITE,
|
|
56
|
-
CAPABILITY.AUTHENTICATED_SESSION_ACCESS,
|
|
57
|
-
],
|
|
58
|
-
riskTier: RISK_TIER.HIGH,
|
|
59
|
-
reasons: [
|
|
60
|
-
"browser-use gives agents direct browser control including navigation, form fill, and click.",
|
|
61
|
-
"May interact with logged-in sessions via persistent browser profiles.",
|
|
62
|
-
],
|
|
63
|
-
recommendedActions: [
|
|
64
|
-
"Use an isolated browser profile.",
|
|
65
|
-
"Prefer a test/staging account.",
|
|
66
|
-
"Require approval before form submission or account-changing actions.",
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: "browser-harness",
|
|
71
|
-
names: ["browser-harness", "browser-harness-js", "@browser-harness/core", "browser_harness"],
|
|
72
|
-
capabilities: [
|
|
73
|
-
CAPABILITY.BROWSER_READ,
|
|
74
|
-
CAPABILITY.BROWSER_WRITE,
|
|
75
|
-
CAPABILITY.JAVASCRIPT_OR_CDP_EXECUTION,
|
|
76
|
-
CAPABILITY.SELF_MODIFYING_HELPER,
|
|
77
|
-
CAPABILITY.DEPENDENCY_BOOTSTRAP,
|
|
78
|
-
],
|
|
79
|
-
riskTier: RISK_TIER.CRITICAL,
|
|
80
|
-
reasons: [
|
|
81
|
-
"browser-harness-js uses direct Chrome DevTools Protocol with possible self-modifying domain skill generation.",
|
|
82
|
-
"Can generate and save site-specific helper scripts, install dependencies (Bun/Node), and execute arbitrary JavaScript via CDP.",
|
|
83
|
-
],
|
|
84
|
-
recommendedActions: [
|
|
85
|
-
"Use an isolated browser profile.",
|
|
86
|
-
"Disable self-modifying domain skill generation unless explicitly reviewed.",
|
|
87
|
-
"Pin all dependency installs and review before running.",
|
|
88
|
-
"Require approval before CDP execution in authenticated sessions.",
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: "playwright-mcp",
|
|
93
|
-
names: ["playwright-mcp", "@playwright/mcp", "@playwright/mcp-server"],
|
|
94
|
-
capabilities: [
|
|
95
|
-
CAPABILITY.BROWSER_READ,
|
|
96
|
-
CAPABILITY.BROWSER_WRITE,
|
|
97
|
-
],
|
|
98
|
-
riskTier: RISK_TIER.MEDIUM,
|
|
99
|
-
reasons: [
|
|
100
|
-
"Playwright MCP allows agents to navigate pages, click buttons, fill forms, and read page content.",
|
|
101
|
-
],
|
|
102
|
-
recommendedActions: [
|
|
103
|
-
"Use an isolated browser profile.",
|
|
104
|
-
"Prefer a test/staging account for any form actions.",
|
|
105
|
-
"Add a domain allowlist to restrict which URLs the agent can visit.",
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: "chrome-devtools-mcp",
|
|
110
|
-
names: ["chrome-devtools-mcp", "cdp-mcp", "mcp-cdp", "chrome-mcp", "mcp-chrome-devtools"],
|
|
111
|
-
capabilities: [
|
|
112
|
-
CAPABILITY.BROWSER_READ,
|
|
113
|
-
CAPABILITY.BROWSER_WRITE,
|
|
114
|
-
CAPABILITY.JAVASCRIPT_OR_CDP_EXECUTION,
|
|
115
|
-
CAPABILITY.AUTHENTICATED_SESSION_ACCESS,
|
|
116
|
-
],
|
|
117
|
-
riskTier: RISK_TIER.HIGH,
|
|
118
|
-
reasons: [
|
|
119
|
-
"Chrome DevTools Protocol MCP gives the agent direct low-level browser control.",
|
|
120
|
-
"Can execute JavaScript, inspect network traffic, and interact with authenticated sessions.",
|
|
121
|
-
],
|
|
122
|
-
recommendedActions: [
|
|
123
|
-
"Use an isolated browser profile.",
|
|
124
|
-
"Disable JavaScript execution unless explicitly needed.",
|
|
125
|
-
"Require approval before any CDP action on a logged-in session.",
|
|
126
|
-
],
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: "mcp-chrome",
|
|
130
|
-
names: ["mcp-chrome", "chrome-extension-mcp", "chrome-mcp-server"],
|
|
131
|
-
capabilities: [
|
|
132
|
-
CAPABILITY.BROWSER_READ,
|
|
133
|
-
CAPABILITY.BROWSER_WRITE,
|
|
134
|
-
CAPABILITY.AUTHENTICATED_SESSION_ACCESS,
|
|
135
|
-
],
|
|
136
|
-
riskTier: RISK_TIER.HIGH,
|
|
137
|
-
reasons: [
|
|
138
|
-
"mcp-chrome connects to Chrome with possible access to existing logged-in sessions.",
|
|
139
|
-
],
|
|
140
|
-
recommendedActions: [
|
|
141
|
-
"Use an isolated browser profile.",
|
|
142
|
-
"Disable persistent session reuse.",
|
|
143
|
-
],
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
id: "agent-browser",
|
|
147
|
-
names: ["agent-browser", "agent-chrome", "ai-browser"],
|
|
148
|
-
capabilities: [
|
|
149
|
-
CAPABILITY.BROWSER_READ,
|
|
150
|
-
CAPABILITY.BROWSER_WRITE,
|
|
151
|
-
CAPABILITY.AUTHENTICATED_SESSION_ACCESS,
|
|
152
|
-
],
|
|
153
|
-
riskTier: RISK_TIER.HIGH,
|
|
154
|
-
reasons: [
|
|
155
|
-
"Agent-browser tools give AI agents direct browser control.",
|
|
156
|
-
],
|
|
157
|
-
recommendedActions: [
|
|
158
|
-
"Use an isolated browser profile.",
|
|
159
|
-
"Require approval before form submission or account actions.",
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
id: "puppeteer",
|
|
164
|
-
names: ["puppeteer", "puppeteer-core"],
|
|
165
|
-
capabilities: [
|
|
166
|
-
CAPABILITY.BROWSER_READ,
|
|
167
|
-
CAPABILITY.BROWSER_WRITE,
|
|
168
|
-
CAPABILITY.JAVASCRIPT_OR_CDP_EXECUTION,
|
|
169
|
-
],
|
|
170
|
-
riskTier: RISK_TIER.MEDIUM,
|
|
171
|
-
reasons: [
|
|
172
|
-
"Puppeteer provides programmatic browser control via Chrome DevTools Protocol.",
|
|
173
|
-
],
|
|
174
|
-
recommendedActions: [
|
|
175
|
-
"Use an isolated browser profile.",
|
|
176
|
-
"Add a domain allowlist.",
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
id: "selenium",
|
|
181
|
-
names: ["selenium-webdriver", "selenium"],
|
|
182
|
-
capabilities: [
|
|
183
|
-
CAPABILITY.BROWSER_READ,
|
|
184
|
-
CAPABILITY.BROWSER_WRITE,
|
|
185
|
-
],
|
|
186
|
-
riskTier: RISK_TIER.MEDIUM,
|
|
187
|
-
reasons: [
|
|
188
|
-
"Selenium WebDriver allows programmatic browser control.",
|
|
189
|
-
],
|
|
190
|
-
recommendedActions: [
|
|
191
|
-
"Use an isolated browser profile or dedicated test account.",
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
];
|
|
195
|
-
|
|
196
|
-
// ── Text-pattern registry ─────────────────────────────────────────────────────
|
|
197
|
-
// Used to scan package.json scripts sections and MCP config text.
|
|
198
|
-
// Each pattern must be specific enough to avoid firing on unrelated content.
|
|
199
|
-
|
|
200
|
-
const PATTERN_REGISTRY = [
|
|
201
|
-
{
|
|
202
|
-
id: "pat-remote-browser",
|
|
203
|
-
pattern: /\b(remote[\s_-]?browser|cloud[\s_-]?browser|proxy[\s_-]?browser|stealth[\s_-]?browser|captcha[\s_-]?solv|anti[\s_-]?bot|bypass[\s_-]?captcha)\b/i,
|
|
204
|
-
capabilities: [CAPABILITY.REMOTE_BROWSER_OR_PROXY],
|
|
205
|
-
riskTier: RISK_TIER.CRITICAL,
|
|
206
|
-
confidence: 0.9,
|
|
207
|
-
reason: "Remote/proxy/CAPTCHA-solving browser pattern detected. This is high-risk and should be reviewed.",
|
|
208
|
-
recommendedActions: [
|
|
209
|
-
"Disable remote browser or CAPTCHA-solving unless there is a reviewed, legitimate testing need.",
|
|
210
|
-
"Remote browser access may expose authenticated session data to third-party infrastructure.",
|
|
211
|
-
],
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
id: "pat-dep-bootstrap",
|
|
215
|
-
pattern: /\b(install[\s_-]?bun|install[\s_-]?browser|npx\s+skills\s+add|npx\s+playwright\s+install|chromium[\s_-]?install|playwright\s+install)\b/i,
|
|
216
|
-
capabilities: [CAPABILITY.DEPENDENCY_BOOTSTRAP],
|
|
217
|
-
riskTier: RISK_TIER.HIGH,
|
|
218
|
-
confidence: 0.85,
|
|
219
|
-
reason: "Dependency bootstrap pattern detected: agent may install browsers, runtimes, or packages during run.",
|
|
220
|
-
recommendedActions: [
|
|
221
|
-
"Pin dependency versions and require manual review before agent installs runtimes or browsers.",
|
|
222
|
-
],
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
id: "pat-self-modifying",
|
|
226
|
-
pattern: /\b(domain[\s_-]?skills?|self[\s_-]?healing[\s_-]?harness|generate[\s_-]?helper|save[\s_-]?helper|create[\s_-]?helper[\s_-]?file)\b/i,
|
|
227
|
-
capabilities: [CAPABILITY.SELF_MODIFYING_HELPER],
|
|
228
|
-
riskTier: RISK_TIER.HIGH,
|
|
229
|
-
confidence: 0.8,
|
|
230
|
-
reason: "Self-modifying helper pattern: agent may generate or save site-specific automation scripts.",
|
|
231
|
-
recommendedActions: [
|
|
232
|
-
"Keep generated domain skills inside reviewable project-local folders.",
|
|
233
|
-
"Require review before generated helpers are executed.",
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
id: "pat-persistent-session",
|
|
238
|
-
pattern: /\b(persistent[\s_-]?session|reuse[\s_-]?session|existing[\s_-]?profile|logged[\s_-]?in[\s_-]?session|user[\s_-]?cookies|local[\s_-]?storage[\s_-]?access)\b/i,
|
|
239
|
-
capabilities: [CAPABILITY.AUTHENTICATED_SESSION_ACCESS],
|
|
240
|
-
riskTier: RISK_TIER.HIGH,
|
|
241
|
-
confidence: 0.85,
|
|
242
|
-
reason: "Persistent/authenticated session access pattern detected.",
|
|
243
|
-
recommendedActions: [
|
|
244
|
-
"Use a dedicated test account instead of a personal logged-in session.",
|
|
245
|
-
"Disable persistent session reuse.",
|
|
246
|
-
],
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: "pat-cdp",
|
|
250
|
-
pattern: /\b(chrome[\s_-]?devtools[\s_-]?protocol|(?<![a-zA-Z])CDP(?![a-zA-Z])|page\.evaluate|page\.addScriptTag|Runtime\.evaluate)\b/i,
|
|
251
|
-
capabilities: [CAPABILITY.JAVASCRIPT_OR_CDP_EXECUTION],
|
|
252
|
-
riskTier: RISK_TIER.HIGH,
|
|
253
|
-
confidence: 0.85,
|
|
254
|
-
reason: "Chrome DevTools Protocol or JavaScript execution pattern detected.",
|
|
255
|
-
recommendedActions: [
|
|
256
|
-
"Require approval before JavaScript execution in authenticated sessions.",
|
|
257
|
-
],
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
id: "pat-browser-automation",
|
|
261
|
-
pattern: /\b(browser[\s_-]?automation|browser[\s_-]?control|browser[\s_-]?harness|automated[\s_-]?browsing|automate[\s_-]?browser)\b/i,
|
|
262
|
-
capabilities: [CAPABILITY.BROWSER_READ, CAPABILITY.BROWSER_WRITE],
|
|
263
|
-
riskTier: RISK_TIER.MEDIUM,
|
|
264
|
-
confidence: 0.75,
|
|
265
|
-
reason: "Browser automation pattern detected in configuration or script.",
|
|
266
|
-
recommendedActions: [
|
|
267
|
-
"Use an isolated browser profile.",
|
|
268
|
-
"Restrict to test/staging environments.",
|
|
269
|
-
],
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
id: "pat-file-transfer",
|
|
273
|
-
pattern: /\b(file[\s_-]?upload|file[\s_-]?download|attach[\s_-]?file)\b/i,
|
|
274
|
-
capabilities: [CAPABILITY.FILE_TRANSFER],
|
|
275
|
-
riskTier: RISK_TIER.HIGH,
|
|
276
|
-
confidence: 0.75,
|
|
277
|
-
reason: "File transfer capability pattern detected in browser automation context.",
|
|
278
|
-
recommendedActions: [
|
|
279
|
-
"Require explicit approval before file upload or download actions.",
|
|
280
|
-
],
|
|
281
|
-
},
|
|
282
|
-
];
|
|
283
|
-
|
|
284
|
-
// ── MCP config file locations (project-relative) ──────────────────────────────
|
|
285
|
-
|
|
286
|
-
const MCP_CONFIG_REL_PATHS = [
|
|
287
|
-
".cursor/mcp.json",
|
|
288
|
-
".claude/mcp.json",
|
|
289
|
-
"mcp.json",
|
|
290
|
-
".mcp.json",
|
|
291
|
-
".claude/settings.json",
|
|
292
|
-
".claude/settings.local.json",
|
|
293
|
-
];
|
|
294
|
-
|
|
295
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
296
|
-
|
|
297
|
-
function safeReadFile(absPath) {
|
|
298
|
-
try {
|
|
299
|
-
return fs.readFileSync(absPath, "utf8").replace(/^/, "");
|
|
300
|
-
} catch {
|
|
301
|
-
return null;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function safeParseJson(text) {
|
|
306
|
-
try {
|
|
307
|
-
return JSON.parse(text);
|
|
308
|
-
} catch {
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function nowIso() {
|
|
314
|
-
return new Date().toISOString();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function shortId(prefix, seed) {
|
|
318
|
-
const hash = crypto.createHash("sha256").update(String(seed || "")).digest("hex").slice(0, 8);
|
|
319
|
-
return `${prefix}-${hash}`;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function maxTier(a, b) {
|
|
323
|
-
return (TIER_ORDER[a] || 0) >= (TIER_ORDER[b] || 0) ? a : b;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function confidenceLabel(score) {
|
|
327
|
-
if (score >= 0.8) return "high";
|
|
328
|
-
if (score >= 0.65) return "medium";
|
|
329
|
-
return "low";
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// ── Registry lookup ───────────────────────────────────────────────────────────
|
|
333
|
-
|
|
334
|
-
function findRegistryEntry(name) {
|
|
335
|
-
if (!name || typeof name !== "string") return null;
|
|
336
|
-
// Strip npm scope for comparison
|
|
337
|
-
const lower = name.toLowerCase();
|
|
338
|
-
return BROWSER_TOOL_REGISTRY.find((entry) =>
|
|
339
|
-
entry.names.some((n) => {
|
|
340
|
-
const nLower = n.toLowerCase();
|
|
341
|
-
// Exact match, or the dep name ends with the bare name (handles scoped pkgs)
|
|
342
|
-
return lower === nLower || lower.endsWith(`/${nLower}`) || nLower.endsWith(`/${lower}`);
|
|
343
|
-
})
|
|
344
|
-
) || null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// ── package.json scanner ──────────────────────────────────────────────────────
|
|
348
|
-
|
|
349
|
-
function scanPackageJson(cwd, scannedFiles) {
|
|
350
|
-
const absPath = path.join(cwd, "package.json");
|
|
351
|
-
const text = safeReadFile(absPath);
|
|
352
|
-
if (!text) return [];
|
|
353
|
-
|
|
354
|
-
const pkg = safeParseJson(text);
|
|
355
|
-
if (!pkg) return [];
|
|
356
|
-
|
|
357
|
-
scannedFiles.push("package.json");
|
|
358
|
-
const findings = [];
|
|
359
|
-
|
|
360
|
-
const allDeps = Object.assign(
|
|
361
|
-
{},
|
|
362
|
-
pkg.dependencies || {},
|
|
363
|
-
pkg.devDependencies || {},
|
|
364
|
-
pkg.optionalDependencies || {}
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
Object.keys(allDeps).forEach((depName) => {
|
|
368
|
-
const entry = findRegistryEntry(depName);
|
|
369
|
-
if (!entry) return;
|
|
370
|
-
const key = `${entry.id}:package.json`;
|
|
371
|
-
findings.push({
|
|
372
|
-
id: shortId("bcf", key),
|
|
373
|
-
name: depName,
|
|
374
|
-
sourceType: "package_json",
|
|
375
|
-
sourcePath: "package.json",
|
|
376
|
-
matchedText: depName,
|
|
377
|
-
matchedPattern: `dependency:${depName}`,
|
|
378
|
-
confidence: "high",
|
|
379
|
-
capabilities: entry.capabilities.slice(),
|
|
380
|
-
riskTier: entry.riskTier,
|
|
381
|
-
reasons: entry.reasons.slice(),
|
|
382
|
-
recommendedActions: entry.recommendedActions.slice(),
|
|
383
|
-
_registryId: entry.id,
|
|
384
|
-
_dedupeKey: key,
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
// Pattern scan on scripts section only (not full package.json to avoid README-style content)
|
|
389
|
-
const scripts = pkg.scripts && typeof pkg.scripts === "object" ? pkg.scripts : {};
|
|
390
|
-
const scriptText = Object.values(scripts).join("\n");
|
|
391
|
-
if (scriptText) {
|
|
392
|
-
const patternFindings = scanTextForPatterns(scriptText, "package.json#scripts", "script");
|
|
393
|
-
findings.push(...patternFindings);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return findings;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// ── MCP config scanner ────────────────────────────────────────────────────────
|
|
400
|
-
|
|
401
|
-
function extractMcpServerEntries(json) {
|
|
402
|
-
if (!json || typeof json !== "object") return [];
|
|
403
|
-
const results = [];
|
|
404
|
-
|
|
405
|
-
// Standard: { mcpServers: { serverName: { command, args } } }
|
|
406
|
-
const servers = json.mcpServers || json.mcp_servers || json.servers || {};
|
|
407
|
-
if (typeof servers === "object" && !Array.isArray(servers)) {
|
|
408
|
-
Object.entries(servers).forEach(([serverName, serverDef]) => {
|
|
409
|
-
results.push({ name: serverName, def: serverDef });
|
|
410
|
-
// Also inspect command + first args element for package names
|
|
411
|
-
if (serverDef && typeof serverDef === "object") {
|
|
412
|
-
const cmd = String(serverDef.command || "");
|
|
413
|
-
const args = Array.isArray(serverDef.args) ? serverDef.args.map(String) : [];
|
|
414
|
-
[cmd, ...args.slice(0, 3)].forEach((token) => {
|
|
415
|
-
if (token && token !== serverName) results.push({ name: token, def: null });
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return results;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
function scanMcpConfigs(cwd, scannedFiles) {
|
|
425
|
-
const findings = [];
|
|
426
|
-
const seenDedupeKeys = new Set();
|
|
427
|
-
|
|
428
|
-
MCP_CONFIG_REL_PATHS.forEach((relP) => {
|
|
429
|
-
const absPath = path.join(cwd, relP);
|
|
430
|
-
const text = safeReadFile(absPath);
|
|
431
|
-
if (!text) return;
|
|
432
|
-
|
|
433
|
-
const json = safeParseJson(text);
|
|
434
|
-
if (!json) return;
|
|
435
|
-
|
|
436
|
-
// Only track file as scanned if it had parseable content
|
|
437
|
-
if (!scannedFiles.includes(relP)) scannedFiles.push(relP);
|
|
438
|
-
|
|
439
|
-
const serverEntries = extractMcpServerEntries(json);
|
|
440
|
-
serverEntries.forEach(({ name }) => {
|
|
441
|
-
const entry = findRegistryEntry(name);
|
|
442
|
-
if (!entry) return;
|
|
443
|
-
const key = `${entry.id}:${relP}`;
|
|
444
|
-
if (seenDedupeKeys.has(key)) return;
|
|
445
|
-
seenDedupeKeys.add(key);
|
|
446
|
-
|
|
447
|
-
findings.push({
|
|
448
|
-
id: shortId("bcf", key),
|
|
449
|
-
name,
|
|
450
|
-
sourceType: "mcp_config",
|
|
451
|
-
sourcePath: relP,
|
|
452
|
-
matchedText: name,
|
|
453
|
-
matchedPattern: `mcp_server:${name}`,
|
|
454
|
-
confidence: "high",
|
|
455
|
-
capabilities: entry.capabilities.slice(),
|
|
456
|
-
riskTier: entry.riskTier,
|
|
457
|
-
reasons: entry.reasons.slice(),
|
|
458
|
-
recommendedActions: entry.recommendedActions.slice(),
|
|
459
|
-
_registryId: entry.id,
|
|
460
|
-
_dedupeKey: key,
|
|
461
|
-
});
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
// Pattern scan on full MCP config text to catch inline descriptions
|
|
465
|
-
const patternFindings = scanTextForPatterns(text, relP, "mcp_config");
|
|
466
|
-
findings.push(...patternFindings);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
return findings;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// ── Skill/command file scanner ────────────────────────────────────────────────
|
|
473
|
-
// Only registry-name matching (no pattern scanning) to keep false positives low.
|
|
474
|
-
|
|
475
|
-
const SKILL_EXTENSIONS = new Set([".md", ".json", ".yaml", ".yml", ".txt"]);
|
|
476
|
-
const SKILL_SCAN_ROOTS = ["skills", ".claude/skills", ".claude/commands"];
|
|
477
|
-
|
|
478
|
-
function scanSkillFiles(cwd, scannedFiles) {
|
|
479
|
-
const findings = [];
|
|
480
|
-
const seenDedupeKeys = new Set();
|
|
481
|
-
|
|
482
|
-
SKILL_SCAN_ROOTS.forEach((rootRel) => {
|
|
483
|
-
const absRoot = path.join(cwd, rootRel);
|
|
484
|
-
if (!fs.existsSync(absRoot)) return;
|
|
485
|
-
|
|
486
|
-
const walkDir = (dir) => {
|
|
487
|
-
let entries;
|
|
488
|
-
try { entries = fs.readdirSync(dir, { withFileTypes: true }); }
|
|
489
|
-
catch { return; }
|
|
490
|
-
|
|
491
|
-
entries.forEach((entry) => {
|
|
492
|
-
const entryAbs = path.join(dir, entry.name);
|
|
493
|
-
if (entry.isDirectory()) { walkDir(entryAbs); return; }
|
|
494
|
-
if (!entry.isFile()) return;
|
|
495
|
-
if (!SKILL_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) return;
|
|
496
|
-
|
|
497
|
-
const text = safeReadFile(entryAbs);
|
|
498
|
-
if (!text) return;
|
|
499
|
-
|
|
500
|
-
const relP = path.relative(cwd, entryAbs).replace(/\\/g, "/");
|
|
501
|
-
if (!scannedFiles.includes(relP)) scannedFiles.push(relP);
|
|
502
|
-
|
|
503
|
-
BROWSER_TOOL_REGISTRY.forEach((toolEntry) => {
|
|
504
|
-
const namePat = new RegExp(
|
|
505
|
-
`\\b(${toolEntry.names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`,
|
|
506
|
-
"i"
|
|
507
|
-
);
|
|
508
|
-
if (!namePat.test(text)) return;
|
|
509
|
-
const matchResult = text.match(namePat);
|
|
510
|
-
const matchedText = matchResult ? matchResult[0] : toolEntry.names[0];
|
|
511
|
-
|
|
512
|
-
const key = `${toolEntry.id}:${relP}`;
|
|
513
|
-
if (seenDedupeKeys.has(key)) return;
|
|
514
|
-
seenDedupeKeys.add(key);
|
|
515
|
-
|
|
516
|
-
findings.push({
|
|
517
|
-
id: shortId("bcf", key),
|
|
518
|
-
name: toolEntry.names[0],
|
|
519
|
-
sourceType: "skill_manifest",
|
|
520
|
-
sourcePath: relP,
|
|
521
|
-
matchedText,
|
|
522
|
-
matchedPattern: namePat.source,
|
|
523
|
-
confidence: "medium",
|
|
524
|
-
capabilities: toolEntry.capabilities.slice(),
|
|
525
|
-
riskTier: toolEntry.riskTier,
|
|
526
|
-
reasons: toolEntry.reasons.slice(),
|
|
527
|
-
recommendedActions: toolEntry.recommendedActions.slice(),
|
|
528
|
-
_registryId: toolEntry.id,
|
|
529
|
-
_dedupeKey: key,
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
walkDir(absRoot);
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
return findings;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// ── Pattern scanner ───────────────────────────────────────────────────────────
|
|
542
|
-
|
|
543
|
-
function scanTextForPatterns(text, sourcePath, sourceType) {
|
|
544
|
-
if (!text || typeof text !== "string") return [];
|
|
545
|
-
const findings = [];
|
|
546
|
-
|
|
547
|
-
PATTERN_REGISTRY.forEach((entry) => {
|
|
548
|
-
// Reset lastIndex for global flags (none here, but defensive)
|
|
549
|
-
entry.pattern.lastIndex = 0;
|
|
550
|
-
if (!entry.pattern.test(text)) return;
|
|
551
|
-
entry.pattern.lastIndex = 0;
|
|
552
|
-
const matchResult = text.match(entry.pattern);
|
|
553
|
-
const matchedText = matchResult ? matchResult[0] : "";
|
|
554
|
-
const key = `${entry.id}:${sourcePath}`;
|
|
555
|
-
|
|
556
|
-
findings.push({
|
|
557
|
-
id: shortId("bcf", key),
|
|
558
|
-
name: `pattern:${entry.id}`,
|
|
559
|
-
sourceType,
|
|
560
|
-
sourcePath,
|
|
561
|
-
matchedText,
|
|
562
|
-
matchedPattern: entry.pattern.source,
|
|
563
|
-
confidence: confidenceLabel(entry.confidence),
|
|
564
|
-
capabilities: entry.capabilities.slice(),
|
|
565
|
-
riskTier: entry.riskTier,
|
|
566
|
-
reasons: [entry.reason],
|
|
567
|
-
recommendedActions: entry.recommendedActions.slice(),
|
|
568
|
-
_patternId: entry.id,
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
return findings;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
// ── Deduplication ─────────────────────────────────────────────────────────────
|
|
576
|
-
// For registry findings: keep the highest-confidence source (package.json > mcp_config > skill_manifest).
|
|
577
|
-
// For pattern findings: keep one per pattern per source file.
|
|
578
|
-
|
|
579
|
-
const SOURCE_PRIORITY = { package_json: 3, script: 2, mcp_config: 2, skill_manifest: 1, config: 1, unknown: 0 };
|
|
580
|
-
|
|
581
|
-
function deduplicateFindings(findings) {
|
|
582
|
-
// Group registry findings by registryId
|
|
583
|
-
const registryGroups = new Map();
|
|
584
|
-
const patternFindings = [];
|
|
585
|
-
|
|
586
|
-
findings.forEach((f) => {
|
|
587
|
-
if (f._registryId) {
|
|
588
|
-
const existing = registryGroups.get(f._registryId);
|
|
589
|
-
if (!existing || (SOURCE_PRIORITY[f.sourceType] || 0) > (SOURCE_PRIORITY[existing.sourceType] || 0)) {
|
|
590
|
-
registryGroups.set(f._registryId, f);
|
|
591
|
-
}
|
|
592
|
-
} else {
|
|
593
|
-
patternFindings.push(f);
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
// Deduplicate pattern findings by _patternId + sourcePath
|
|
598
|
-
const seenPatterns = new Set();
|
|
599
|
-
const dedupedPatterns = patternFindings.filter((f) => {
|
|
600
|
-
const key = `${f._patternId || f.id}:${f.sourcePath}`;
|
|
601
|
-
if (seenPatterns.has(key)) return false;
|
|
602
|
-
seenPatterns.add(key);
|
|
603
|
-
return true;
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
return [...registryGroups.values(), ...dedupedPatterns];
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// ── Tier computation ──────────────────────────────────────────────────────────
|
|
610
|
-
|
|
611
|
-
function computeOverallTier(findings) {
|
|
612
|
-
if (!findings.length) return RISK_TIER.NONE;
|
|
613
|
-
return findings.reduce((tier, f) => maxTier(tier, f.riskTier), RISK_TIER.NONE);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// ── Summary and recommended actions ──────────────────────────────────────────
|
|
617
|
-
|
|
618
|
-
function buildSummaryText(findings, overallTier) {
|
|
619
|
-
if (!findings.length) {
|
|
620
|
-
return "No browser-capability tools detected.";
|
|
621
|
-
}
|
|
622
|
-
const toolNames = [...new Set(findings.filter((f) => f._registryId).map((f) => f.name))];
|
|
623
|
-
const allCaps = [...new Set(findings.flatMap((f) => f.capabilities))];
|
|
624
|
-
const capStr = allCaps.slice(0, 3).map((c) => c.replace(/_/g, " ")).join(", ");
|
|
625
|
-
|
|
626
|
-
switch (overallTier) {
|
|
627
|
-
case RISK_TIER.CRITICAL:
|
|
628
|
-
return `Critical browser capability detected${toolNames.length ? `: ${toolNames.slice(0, 2).join(", ")}` : ""}. Agent may have broad browser control including CDP, remote browser, or self-modifying capabilities.`;
|
|
629
|
-
case RISK_TIER.HIGH:
|
|
630
|
-
return `High-risk browser capability detected${toolNames.length ? `: ${toolNames.slice(0, 2).join(", ")}` : ""}. Agent may access authenticated sessions, execute JavaScript, or perform file transfers.`;
|
|
631
|
-
case RISK_TIER.MEDIUM:
|
|
632
|
-
return `Browser capability detected${toolNames.length ? `: ${toolNames.slice(0, 2).join(", ")}` : ""}. Capabilities: ${capStr || "browser read/write"}. Use an isolated profile for logged-in apps.`;
|
|
633
|
-
default:
|
|
634
|
-
return `Low-risk browser capability detected. Capabilities: ${capStr || "browser read"}.`;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
function buildRecommendedActions(findings, overallTier) {
|
|
639
|
-
const actions = new Set();
|
|
640
|
-
|
|
641
|
-
if (findings.length) {
|
|
642
|
-
actions.add("Use an isolated browser profile.");
|
|
643
|
-
actions.add("Prefer a test/staging account.");
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
findings.forEach((f) => {
|
|
647
|
-
(f.recommendedActions || []).forEach((a) => actions.add(a));
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
if (overallTier === RISK_TIER.HIGH || overallTier === RISK_TIER.CRITICAL) {
|
|
651
|
-
actions.add("Require approval before form submission, file upload, or account-changing actions.");
|
|
652
|
-
actions.add("Add a domain allowlist for approved URLs.");
|
|
653
|
-
actions.add("Add a denylist for production, admin, and billing domains.");
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (overallTier === RISK_TIER.CRITICAL) {
|
|
657
|
-
actions.add("Block or warn on remote browser/proxy mode by default.");
|
|
658
|
-
actions.add("Pin all dependencies and avoid auto-install during agent runs.");
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
return [...actions].slice(0, 8);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// ── Domain policy ─────────────────────────────────────────────────────────────
|
|
665
|
-
|
|
666
|
-
function isValidHostname(str) {
|
|
667
|
-
if (!str || str.length > 253) return false;
|
|
668
|
-
// Labels separated by dots; each label: letters/digits/hyphens, not starting/ending with hyphen
|
|
669
|
-
return /^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/.test(str);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
function validateDomainPattern(str) {
|
|
673
|
-
if (!str || typeof str !== "string") {
|
|
674
|
-
return { valid: false, warning: "Empty or non-string domain pattern." };
|
|
675
|
-
}
|
|
676
|
-
const trimmed = str.trim();
|
|
677
|
-
if (!trimmed) {
|
|
678
|
-
return { valid: false, warning: "Empty domain pattern after trimming." };
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// Reject full URLs with scheme
|
|
682
|
-
if (/^https?:\/\//i.test(trimmed)) {
|
|
683
|
-
return {
|
|
684
|
-
valid: false,
|
|
685
|
-
warning: `"${trimmed}" looks like a full URL; use a hostname like example.com or *.example.com instead.`,
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// Reject paths (slash after first label segment)
|
|
690
|
-
if (/^[^/]+\//.test(trimmed)) {
|
|
691
|
-
return {
|
|
692
|
-
valid: false,
|
|
693
|
-
warning: `"${trimmed}" contains a path; use a hostname pattern, not a URL with a path.`,
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// Allow localhost and loopback
|
|
698
|
-
if (trimmed === "localhost" || trimmed === "127.0.0.1" || trimmed === "::1") {
|
|
699
|
-
return { valid: true };
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// Allow *.example.com wildcard prefix
|
|
703
|
-
if (trimmed.startsWith("*.")) {
|
|
704
|
-
const rest = trimmed.slice(2);
|
|
705
|
-
if (isValidHostname(rest)) return { valid: true };
|
|
706
|
-
return { valid: false, warning: `"${trimmed}" has an invalid wildcard pattern.` };
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// Reject other wildcard positions
|
|
710
|
-
if (trimmed.includes("*")) {
|
|
711
|
-
return {
|
|
712
|
-
valid: false,
|
|
713
|
-
warning: `"${trimmed}" uses a wildcard in an unsupported position. Use *.example.com format.`,
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
if (isValidHostname(trimmed)) return { valid: true };
|
|
718
|
-
|
|
719
|
-
return { valid: false, warning: `"${trimmed}" is not a valid hostname or domain pattern.` };
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
function normalizeDomainList(list) {
|
|
723
|
-
if (!Array.isArray(list)) return { domains: [], warnings: [] };
|
|
724
|
-
|
|
725
|
-
const seen = new Set();
|
|
726
|
-
const domains = [];
|
|
727
|
-
const warnings = [];
|
|
728
|
-
|
|
729
|
-
list.forEach((entry) => {
|
|
730
|
-
if (typeof entry !== "string") {
|
|
731
|
-
if (entry !== null && entry !== undefined) {
|
|
732
|
-
warnings.push(`Non-string domain entry ignored: ${JSON.stringify(entry)}`);
|
|
733
|
-
}
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
const trimmed = entry.trim();
|
|
737
|
-
if (!trimmed) return;
|
|
738
|
-
|
|
739
|
-
const result = validateDomainPattern(trimmed);
|
|
740
|
-
if (!result.valid) {
|
|
741
|
-
warnings.push(result.warning);
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
const lower = trimmed.toLowerCase();
|
|
746
|
-
if (seen.has(lower)) return; // dedupe
|
|
747
|
-
seen.add(lower);
|
|
748
|
-
domains.push(trimmed);
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
return { domains, warnings };
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
function buildDomainPolicy(domainConfig, hasFindings) {
|
|
755
|
-
const rawAllowed = Array.isArray(domainConfig?.allowedDomains) ? domainConfig.allowedDomains : [];
|
|
756
|
-
const rawBlocked = Array.isArray(domainConfig?.blockedDomains) ? domainConfig.blockedDomains : [];
|
|
757
|
-
const rawSensitive = Array.isArray(domainConfig?.sensitiveDomains) ? domainConfig.sensitiveDomains : [];
|
|
758
|
-
const requireApproval = domainConfig?.requireApprovalForUnlistedDomains === true;
|
|
759
|
-
|
|
760
|
-
const allowedResult = normalizeDomainList(rawAllowed);
|
|
761
|
-
const blockedResult = normalizeDomainList(rawBlocked);
|
|
762
|
-
const sensitiveResult = normalizeDomainList(rawSensitive);
|
|
763
|
-
|
|
764
|
-
const allWarnings = [
|
|
765
|
-
...allowedResult.warnings,
|
|
766
|
-
...blockedResult.warnings,
|
|
767
|
-
...sensitiveResult.warnings,
|
|
768
|
-
];
|
|
769
|
-
|
|
770
|
-
const hasAny = rawAllowed.length > 0 || rawBlocked.length > 0 || rawSensitive.length > 0;
|
|
771
|
-
|
|
772
|
-
if (!hasFindings) {
|
|
773
|
-
return {
|
|
774
|
-
configured: hasAny,
|
|
775
|
-
readiness: null,
|
|
776
|
-
allowedDomains: allowedResult.domains,
|
|
777
|
-
blockedDomains: blockedResult.domains,
|
|
778
|
-
sensitiveDomains: sensitiveResult.domains,
|
|
779
|
-
requireApprovalForUnlistedDomains: requireApproval,
|
|
780
|
-
validationWarnings: allWarnings,
|
|
781
|
-
summary: "No browser-capability findings; domain policy not evaluated.",
|
|
782
|
-
recommendedActions: [],
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
// Determine readiness
|
|
787
|
-
const hasValidAllowed = allowedResult.domains.length > 0;
|
|
788
|
-
const hasValidBlocked = blockedResult.domains.length > 0;
|
|
789
|
-
|
|
790
|
-
let readiness;
|
|
791
|
-
if (!hasAny) {
|
|
792
|
-
readiness = DOMAIN_POLICY_READINESS.MISSING;
|
|
793
|
-
} else if (hasValidAllowed && hasValidBlocked && requireApproval && allWarnings.length === 0) {
|
|
794
|
-
readiness = DOMAIN_POLICY_READINESS.STRONG;
|
|
795
|
-
} else if (hasValidAllowed || hasValidBlocked) {
|
|
796
|
-
readiness = DOMAIN_POLICY_READINESS.PARTIAL;
|
|
797
|
-
} else {
|
|
798
|
-
// Has entries but all invalid
|
|
799
|
-
readiness = DOMAIN_POLICY_READINESS.PARTIAL;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
// Summary and recommendations
|
|
803
|
-
let summary = "";
|
|
804
|
-
const recommendations = [];
|
|
805
|
-
|
|
806
|
-
switch (readiness) {
|
|
807
|
-
case DOMAIN_POLICY_READINESS.MISSING:
|
|
808
|
-
summary = "No domain policy configured for browser-capable tools.";
|
|
809
|
-
recommendations.push("Add allowedDomains for local/staging/test environments.");
|
|
810
|
-
recommendations.push("Add blockedDomains for production, admin, and billing domains.");
|
|
811
|
-
recommendations.push("Set requireApprovalForUnlistedDomains: true for unlisted domains.");
|
|
812
|
-
break;
|
|
813
|
-
case DOMAIN_POLICY_READINESS.PARTIAL:
|
|
814
|
-
if (allWarnings.length > 0 && !hasValidAllowed && !hasValidBlocked) {
|
|
815
|
-
summary = "Domain policy has only invalid entries.";
|
|
816
|
-
recommendations.push("Fix malformed domain patterns; prefer hostnames or *.example.com wildcard prefixes.");
|
|
817
|
-
recommendations.push("Add allowedDomains for local/staging/test environments.");
|
|
818
|
-
recommendations.push("Add blockedDomains for production, admin, and billing domains.");
|
|
819
|
-
} else if (!hasValidAllowed && hasValidBlocked) {
|
|
820
|
-
summary = "Domain policy configured: blocked domains set, no allowed domains.";
|
|
821
|
-
recommendations.push("Add allowedDomains for safe local/staging targets.");
|
|
822
|
-
} else if (hasValidAllowed && !hasValidBlocked) {
|
|
823
|
-
summary = "Domain policy configured: allowed domains set, no blocked domains.";
|
|
824
|
-
recommendations.push("Add blockedDomains for production, admin, and billing domains.");
|
|
825
|
-
} else {
|
|
826
|
-
summary = "Domain policy configured with validation warnings.";
|
|
827
|
-
recommendations.push("Fix malformed domain patterns; prefer hostnames or *.example.com wildcard prefixes.");
|
|
828
|
-
}
|
|
829
|
-
if (!requireApproval) {
|
|
830
|
-
recommendations.push("Set requireApprovalForUnlistedDomains: true to require approval for unlisted domains.");
|
|
831
|
-
}
|
|
832
|
-
break;
|
|
833
|
-
case DOMAIN_POLICY_READINESS.CONFIGURED:
|
|
834
|
-
summary = "Domain boundaries configured for browser-capable tools.";
|
|
835
|
-
if (!requireApproval) {
|
|
836
|
-
recommendations.push("Set requireApprovalForUnlistedDomains: true for stronger boundaries.");
|
|
837
|
-
}
|
|
838
|
-
break;
|
|
839
|
-
case DOMAIN_POLICY_READINESS.STRONG:
|
|
840
|
-
summary = "Domain boundaries are fully configured for browser-capable tools.";
|
|
841
|
-
recommendations.push("Keep the domain policy reviewed as browser-capable tools change.");
|
|
842
|
-
break;
|
|
843
|
-
default:
|
|
844
|
-
summary = "Domain policy status unknown.";
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
return {
|
|
848
|
-
configured: hasAny,
|
|
849
|
-
readiness,
|
|
850
|
-
allowedDomains: allowedResult.domains,
|
|
851
|
-
blockedDomains: blockedResult.domains,
|
|
852
|
-
sensitiveDomains: sensitiveResult.domains,
|
|
853
|
-
requireApprovalForUnlistedDomains: requireApproval,
|
|
854
|
-
validationWarnings: allWarnings,
|
|
855
|
-
summary,
|
|
856
|
-
recommendedActions: recommendations,
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function readBrowserDomainConfig(cwd) {
|
|
861
|
-
try {
|
|
862
|
-
// Lazy require to avoid load-time issues if config module is unavailable
|
|
863
|
-
const { readProjectConfig } = require("./config");
|
|
864
|
-
const cfg = readProjectConfig(cwd);
|
|
865
|
-
return cfg.browserCapability || {};
|
|
866
|
-
} catch {
|
|
867
|
-
return {};
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
// ── Status line formatter ─────────────────────────────────────────────────────
|
|
872
|
-
|
|
873
|
-
function formatBrowserCapabilityStatusLine(report) {
|
|
874
|
-
const tier = report.overallTier;
|
|
875
|
-
|
|
876
|
-
if (tier === RISK_TIER.NONE) {
|
|
877
|
-
return "Browser capability: none — no browser-control tools detected.";
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
const toolNames = [...new Set(
|
|
881
|
-
(report.findings || []).filter((f) => f._registryId).map((f) => f.name)
|
|
882
|
-
)].slice(0, 2);
|
|
883
|
-
const toolLabel = toolNames.length ? ` — ${toolNames.join(", ")} detected` : "";
|
|
884
|
-
|
|
885
|
-
// Domain policy phrase (when domain policy is provided)
|
|
886
|
-
const dp = report.domainPolicy;
|
|
887
|
-
if (dp && dp.readiness !== null) {
|
|
888
|
-
switch (dp.readiness) {
|
|
889
|
-
case DOMAIN_POLICY_READINESS.MISSING:
|
|
890
|
-
return `Browser capability: ${tier}${toolLabel}; no domain policy configured.`;
|
|
891
|
-
case DOMAIN_POLICY_READINESS.PARTIAL:
|
|
892
|
-
return `Browser capability: ${tier}${toolLabel}; domain policy partial: ${dp.summary.toLowerCase()}`;
|
|
893
|
-
case DOMAIN_POLICY_READINESS.CONFIGURED:
|
|
894
|
-
return `Browser capability: ${tier}${toolLabel}; domain policy configured.`;
|
|
895
|
-
case DOMAIN_POLICY_READINESS.STRONG:
|
|
896
|
-
return `Browser capability: ${tier}${toolLabel}; domain policy strong.`;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
// Fallback: show first recommended action (backward-compatible)
|
|
901
|
-
const action = (report.recommendedActions || [])[0] || "Review browser capability settings.";
|
|
902
|
-
return `Browser capability: ${tier}${toolLabel}; ${action}`;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
// ── Main scan ─────────────────────────────────────────────────────────────────
|
|
906
|
-
|
|
907
|
-
function scanProjectForBrowserCapabilities(cwd) {
|
|
908
|
-
const scannedFiles = [];
|
|
909
|
-
|
|
910
|
-
const rawFindings = [
|
|
911
|
-
...scanPackageJson(cwd, scannedFiles),
|
|
912
|
-
...scanMcpConfigs(cwd, scannedFiles),
|
|
913
|
-
...scanSkillFiles(cwd, scannedFiles),
|
|
914
|
-
];
|
|
915
|
-
|
|
916
|
-
const deduped = deduplicateFindings(rawFindings);
|
|
917
|
-
|
|
918
|
-
// Strip internal tracking keys from public output
|
|
919
|
-
const findings = deduped.map(({ _registryId, _dedupeKey, _patternId, ...clean }) => clean);
|
|
920
|
-
|
|
921
|
-
// Re-attach _registryId for status line (read-only usage post-dedup); kept on the surface object only
|
|
922
|
-
const findingsWithMeta = deduped.map(({ _dedupeKey, _patternId, ...rest }) => rest);
|
|
923
|
-
|
|
924
|
-
const uniqueScannedFiles = [...new Set(scannedFiles)];
|
|
925
|
-
const overallTier = computeOverallTier(findingsWithMeta);
|
|
926
|
-
const summary = buildSummaryText(findingsWithMeta, overallTier);
|
|
927
|
-
const recommendedActions = buildRecommendedActions(findingsWithMeta, overallTier);
|
|
928
|
-
|
|
929
|
-
return {
|
|
930
|
-
schemaVersion: SCHEMA_VERSION,
|
|
931
|
-
generatedAt: nowIso(),
|
|
932
|
-
projectRoot: cwd,
|
|
933
|
-
scannedFiles: uniqueScannedFiles,
|
|
934
|
-
findings,
|
|
935
|
-
_findingsWithMeta: findingsWithMeta, // internal; stripped before evidence write
|
|
936
|
-
overallTier,
|
|
937
|
-
summary,
|
|
938
|
-
recommendedActions,
|
|
939
|
-
evidenceId: shortId("bce", `${cwd}:${scannedFiles.join(",")}:${overallTier}`),
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// ── Evidence artifact writer ──────────────────────────────────────────────────
|
|
944
|
-
|
|
945
|
-
function writeBrowserCapabilityEvidence(cwd, report, domainPolicy) {
|
|
946
|
-
const absDir = path.join(cwd, ".claude", "cco", "security");
|
|
947
|
-
try {
|
|
948
|
-
fs.mkdirSync(absDir, { recursive: true });
|
|
949
|
-
// Strip internal meta before writing
|
|
950
|
-
const { _findingsWithMeta, ...publicReport } = report;
|
|
951
|
-
const artifact = {
|
|
952
|
-
...publicReport,
|
|
953
|
-
...(domainPolicy !== undefined ? { domainPolicy } : {}),
|
|
954
|
-
};
|
|
955
|
-
const absPath = path.join(absDir, "browser-capability-report.json");
|
|
956
|
-
fs.writeFileSync(absPath, JSON.stringify(artifact, null, 2), "utf8");
|
|
957
|
-
return ".claude/cco/security/browser-capability-report.json";
|
|
958
|
-
} catch {
|
|
959
|
-
return null;
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// ── Dashboard surface builder ─────────────────────────────────────────────────
|
|
964
|
-
|
|
965
|
-
function buildBrowserCapabilitySurface(cwd) {
|
|
966
|
-
let report;
|
|
967
|
-
try {
|
|
968
|
-
report = scanProjectForBrowserCapabilities(cwd);
|
|
969
|
-
} catch {
|
|
970
|
-
return null;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
// Build domain policy from project config
|
|
974
|
-
const domainConfig = readBrowserDomainConfig(cwd);
|
|
975
|
-
const hasFindings = report.overallTier !== RISK_TIER.NONE;
|
|
976
|
-
const domainPolicy = buildDomainPolicy(domainConfig, hasFindings);
|
|
977
|
-
|
|
978
|
-
// Best-effort evidence write; only when findings exist (no artifact for clean projects)
|
|
979
|
-
if (hasFindings) {
|
|
980
|
-
try { writeBrowserCapabilityEvidence(cwd, report, domainPolicy); } catch { /* intentional */ }
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
const tier = report.overallTier;
|
|
984
|
-
const findings = report._findingsWithMeta || report.findings;
|
|
985
|
-
|
|
986
|
-
const toolFindings = findings.filter((f) =>
|
|
987
|
-
f.sourceType === "package_json" || f.sourceType === "mcp_config"
|
|
988
|
-
);
|
|
989
|
-
|
|
990
|
-
// Top risk is the most severe capability across all findings
|
|
991
|
-
const capPriority = [
|
|
992
|
-
CAPABILITY.REMOTE_BROWSER_OR_PROXY,
|
|
993
|
-
CAPABILITY.SELF_MODIFYING_HELPER,
|
|
994
|
-
CAPABILITY.DEPENDENCY_BOOTSTRAP,
|
|
995
|
-
CAPABILITY.JAVASCRIPT_OR_CDP_EXECUTION,
|
|
996
|
-
CAPABILITY.AUTHENTICATED_SESSION_ACCESS,
|
|
997
|
-
CAPABILITY.FILE_TRANSFER,
|
|
998
|
-
CAPABILITY.SENSITIVE_FORM_ACTION,
|
|
999
|
-
CAPABILITY.BROWSER_WRITE,
|
|
1000
|
-
CAPABILITY.BROWSER_READ,
|
|
1001
|
-
];
|
|
1002
|
-
const allCaps = new Set(findings.flatMap((f) => f.capabilities || []));
|
|
1003
|
-
const topRisk = capPriority.find((c) => allCaps.has(c)) || null;
|
|
1004
|
-
|
|
1005
|
-
// Public findings strip internal meta
|
|
1006
|
-
const publicFindings = report.findings.slice(0, 10);
|
|
1007
|
-
|
|
1008
|
-
return {
|
|
1009
|
-
showInStatus: tier !== RISK_TIER.NONE,
|
|
1010
|
-
showInDashboard: tier !== RISK_TIER.NONE,
|
|
1011
|
-
statusLine: formatBrowserCapabilityStatusLine({
|
|
1012
|
-
overallTier: tier,
|
|
1013
|
-
findings,
|
|
1014
|
-
recommendedActions: report.recommendedActions,
|
|
1015
|
-
domainPolicy,
|
|
1016
|
-
}),
|
|
1017
|
-
overallTier: tier,
|
|
1018
|
-
detectedBrowserToolsCount: toolFindings.length,
|
|
1019
|
-
topRisk,
|
|
1020
|
-
recommendedAction: report.recommendedActions[0] || null,
|
|
1021
|
-
summary: report.summary,
|
|
1022
|
-
findings: publicFindings,
|
|
1023
|
-
evidenceArtifact: ".claude/cco/security/browser-capability-report.json",
|
|
1024
|
-
domainPolicy,
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
// ── Exports ───────────────────────────────────────────────────────────────────
|
|
1029
|
-
|
|
1030
|
-
module.exports = {
|
|
1031
|
-
CAPABILITY,
|
|
1032
|
-
RISK_TIER,
|
|
1033
|
-
TIER_ORDER,
|
|
1034
|
-
DOMAIN_POLICY_READINESS,
|
|
1035
|
-
BROWSER_TOOL_REGISTRY,
|
|
1036
|
-
PATTERN_REGISTRY,
|
|
1037
|
-
findRegistryEntry,
|
|
1038
|
-
computeOverallTier,
|
|
1039
|
-
maxTier,
|
|
1040
|
-
isValidHostname,
|
|
1041
|
-
validateDomainPattern,
|
|
1042
|
-
normalizeDomainList,
|
|
1043
|
-
buildDomainPolicy,
|
|
1044
|
-
scanProjectForBrowserCapabilities,
|
|
1045
|
-
writeBrowserCapabilityEvidence,
|
|
1046
|
-
buildBrowserCapabilitySurface,
|
|
1047
|
-
formatBrowserCapabilityStatusLine,
|
|
1048
|
-
};
|