blackveil-dns 2.10.16 → 2.12.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.
Files changed (636) hide show
  1. package/.claude/settings.json +61 -0
  2. package/.cursorrules +1 -0
  3. package/.devcontainer/Dockerfile +17 -0
  4. package/.devcontainer/devcontainer.json +18 -0
  5. package/.editorconfig +12 -0
  6. package/.gitattributes +24 -0
  7. package/.githooks/blocked-patterns +13 -0
  8. package/.githooks/pre-commit +127 -0
  9. package/.github/CODEOWNERS +11 -0
  10. package/.github/ISSUE_TEMPLATE/bug_report.yml +99 -0
  11. package/.github/ISSUE_TEMPLATE/config.yml +11 -0
  12. package/.github/ISSUE_TEMPLATE/feature_request.yml +51 -0
  13. package/.github/PULL_REQUEST_TEMPLATE.md +30 -0
  14. package/.github/copilot-instructions.md +73 -0
  15. package/.github/dependabot.yml +22 -0
  16. package/.github/instructions/scan-orchestration.instructions.md +56 -0
  17. package/.github/instructions/schemas.instructions.md +52 -0
  18. package/.github/instructions/security.instructions.md +77 -0
  19. package/.github/instructions/tests.instructions.md +31 -0
  20. package/.github/instructions/tools.instructions.md +55 -0
  21. package/.github/workflows/auto-deploy-main.yml.disabled +145 -0
  22. package/.github/workflows/ci-contract.yml +47 -0
  23. package/.github/workflows/ci.yml +53 -0
  24. package/.github/workflows/deploy-hook.yml +113 -0
  25. package/.github/workflows/dns-security.yml +32 -0
  26. package/.github/workflows/publish.yml +275 -0
  27. package/.github/workflows/repo-hygiene.yml +121 -0
  28. package/.github/workflows/security.yml +62 -0
  29. package/.github/workflows/triage-issues.yml +82 -0
  30. package/.gitleaks.toml +190 -0
  31. package/.intent/.gitignore +5 -0
  32. package/.intent/config.json +88 -0
  33. package/.nvmrc +1 -0
  34. package/.phase2-queue/baseline.txt +1 -0
  35. package/.prettierrc +6 -0
  36. package/CHANGELOG.md +793 -0
  37. package/CLAUDE.md +580 -0
  38. package/CODE_OF_CONDUCT.md +133 -0
  39. package/CONTRIBUTING.md +63 -0
  40. package/README.md +7 -3
  41. package/SECURITY.md +66 -0
  42. package/SUPPORT.md +17 -0
  43. package/assets/brave-score.png +0 -0
  44. package/assets/bv-logo-full.png +0 -0
  45. package/assets/bv-logo-mark.png +0 -0
  46. package/assets/our-listing-final.png +0 -0
  47. package/assets/smithery-listing.png +0 -0
  48. package/assets/smithery-score-2.png +0 -0
  49. package/assets/smithery-score-hover.png +0 -0
  50. package/assets/smithery-score.png +0 -0
  51. package/assets/supabase-score.png +0 -0
  52. package/conductor/index.md +1 -0
  53. package/conductor/registrar-commercial-models.md +64 -0
  54. package/crates/bv-wasm-core/Cargo.lock +177 -0
  55. package/crates/bv-wasm-core/Cargo.toml +12 -0
  56. package/crates/bv-wasm-core/src/compact.rs +60 -0
  57. package/crates/bv-wasm-core/src/lib.rs +116 -0
  58. package/crates/bv-wasm-core/src/permissions.rs +106 -0
  59. package/dist/index.d.ts +2 -2
  60. package/dist/index.js +106 -5
  61. package/dist/index.js.map +1 -1
  62. package/dist/stdio.js +1175 -434
  63. package/dist/stdio.js.map +1 -1
  64. package/docs/client-setup.md +587 -0
  65. package/docs/scoring.md +245 -0
  66. package/docs/style-guide.md +69 -0
  67. package/docs/tenant-Capacity-and-Discovery-Design.md +267 -0
  68. package/docs/tenant-Scalable-Architecture-Design.md +639 -0
  69. package/docs/tenant-ops-runbook.md +191 -0
  70. package/docs/troubleshooting.md +392 -0
  71. package/eslint.config.mjs +21 -0
  72. package/examples/slack-discord-webhook/README.md +38 -0
  73. package/examples/slack-discord-webhook/worker.ts +133 -0
  74. package/examples/slack-discord-webhook/wrangler.toml +11 -0
  75. package/extensions/vscode/.vscodeignore +2 -0
  76. package/extensions/vscode/CHANGELOG.md +8 -0
  77. package/extensions/vscode/LICENSE +76 -0
  78. package/extensions/vscode/README.md +105 -0
  79. package/extensions/vscode/icon.png +0 -0
  80. package/extensions/vscode/package.json +49 -0
  81. package/package.json +22 -74
  82. package/packages/dns-checks/LICENSE +76 -0
  83. package/packages/dns-checks/README.md +61 -0
  84. package/packages/dns-checks/package.json +39 -0
  85. package/packages/dns-checks/src/__tests__/check-utils.test.ts +188 -0
  86. package/packages/dns-checks/src/__tests__/checks/check-dkim.test.ts +54 -0
  87. package/packages/dns-checks/src/__tests__/checks/check-dmarc.test.ts +70 -0
  88. package/packages/dns-checks/src/__tests__/checks/check-dnssec.test.ts +56 -0
  89. package/packages/dns-checks/src/__tests__/checks/check-remaining.test.ts +244 -0
  90. package/packages/dns-checks/src/__tests__/checks/check-spf.test.ts +114 -0
  91. package/packages/dns-checks/src/__tests__/scoring/generic-engine.spec.ts +858 -0
  92. package/packages/dns-checks/src/__tests__/scoring/score-determinism.spec.ts +73 -0
  93. package/packages/dns-checks/src/__tests__/scoring/scoring-config.spec.ts +194 -0
  94. package/packages/dns-checks/src/__tests__/scoring/scoring-engine.spec.ts +137 -0
  95. package/packages/dns-checks/src/__tests__/scoring/scoring-model.spec.ts +46 -0
  96. package/packages/dns-checks/src/__tests__/scoring/scoring-profiles.spec.ts +316 -0
  97. package/packages/dns-checks/src/__tests__/scoring-schemas.test.ts +307 -0
  98. package/packages/dns-checks/src/check-utils.ts +44 -0
  99. package/packages/dns-checks/src/checks/caa-analysis.ts +126 -0
  100. package/packages/dns-checks/src/checks/check-bimi.ts +305 -0
  101. package/packages/dns-checks/src/checks/check-caa.ts +63 -0
  102. package/packages/dns-checks/src/checks/check-dane-https.ts +88 -0
  103. package/packages/dns-checks/src/checks/check-dane.ts +110 -0
  104. package/packages/dns-checks/src/checks/check-dkim.ts +261 -0
  105. package/packages/dns-checks/src/checks/check-dmarc.ts +370 -0
  106. package/packages/dns-checks/src/checks/check-dnssec.ts +131 -0
  107. package/packages/dns-checks/src/checks/check-http-security.ts +187 -0
  108. package/packages/dns-checks/src/checks/check-mta-sts.ts +195 -0
  109. package/packages/dns-checks/src/checks/check-mx.ts +130 -0
  110. package/packages/dns-checks/src/checks/check-ns.ts +133 -0
  111. package/packages/dns-checks/src/checks/check-spf.ts +271 -0
  112. package/packages/dns-checks/src/checks/check-ssl.ts +95 -0
  113. package/packages/dns-checks/src/checks/check-subdomailing.ts +77 -0
  114. package/packages/dns-checks/src/checks/check-subdomain-takeover.ts +45 -0
  115. package/packages/dns-checks/src/checks/check-svcb-https.ts +246 -0
  116. package/packages/dns-checks/src/checks/check-tlsrpt.ts +112 -0
  117. package/packages/dns-checks/src/checks/dane-analysis.ts +203 -0
  118. package/packages/dns-checks/src/checks/dkim-analysis.ts +102 -0
  119. package/packages/dns-checks/src/checks/dmarc-utils.ts +126 -0
  120. package/packages/dns-checks/src/checks/dnssec-analysis.ts +237 -0
  121. package/packages/dns-checks/src/checks/http-security-analysis.ts +230 -0
  122. package/packages/dns-checks/src/checks/index.ts +36 -0
  123. package/packages/dns-checks/src/checks/mta-sts-analysis.ts +259 -0
  124. package/packages/dns-checks/src/checks/mx-analysis.ts +63 -0
  125. package/packages/dns-checks/src/checks/ns-analysis.ts +171 -0
  126. package/packages/dns-checks/src/checks/spf-analysis.ts +211 -0
  127. package/packages/dns-checks/src/checks/spf-trust-surface.ts +141 -0
  128. package/packages/dns-checks/src/checks/ssl-analysis.ts +111 -0
  129. package/packages/dns-checks/src/checks/subdomailing-analysis.ts +262 -0
  130. package/packages/dns-checks/src/checks/subdomain-takeover-analysis.ts +217 -0
  131. package/packages/dns-checks/src/index.ts +73 -0
  132. package/packages/dns-checks/src/schemas/scoring.ts +52 -0
  133. package/packages/dns-checks/src/scoring/config.ts +346 -0
  134. package/packages/dns-checks/src/scoring/engine.ts +293 -0
  135. package/packages/dns-checks/src/scoring/generic.ts +317 -0
  136. package/packages/dns-checks/src/scoring/index.ts +56 -0
  137. package/packages/dns-checks/src/scoring/model.ts +133 -0
  138. package/packages/dns-checks/src/scoring/profiles.ts +332 -0
  139. package/packages/dns-checks/src/types.ts +172 -0
  140. package/packages/dns-checks/tsconfig.json +15 -0
  141. package/packages/dns-checks/tsup.config.ts +14 -0
  142. package/packages/dns-checks/vitest.config.ts +8 -0
  143. package/public/index.html +45 -0
  144. package/scripts/benchmark-doh.mjs +216 -0
  145. package/scripts/benchmark.sh +151 -0
  146. package/scripts/chaos/chaos-run.py +393 -0
  147. package/scripts/chaos/chaos-test-clients.py +884 -0
  148. package/scripts/chaos/chaos-test-msp.py +745 -0
  149. package/scripts/chaos/chaos-test-v205.py +829 -0
  150. package/scripts/chaos/chaos-test-v210.py +2038 -0
  151. package/scripts/chaos/chaos-test-wasm.py +65 -0
  152. package/scripts/chaos/chaos-test.py +952 -0
  153. package/scripts/chaos/score-stability-test.py +298 -0
  154. package/scripts/chaos/tenant-chaos-v3.py +119 -0
  155. package/scripts/context-usage-test.py +281 -0
  156. package/scripts/conversation-sim.py +421 -0
  157. package/scripts/deploy-private.mjs +22 -0
  158. package/scripts/generate-report.sh +42 -0
  159. package/scripts/inject-private-config.cjs +41 -0
  160. package/scripts/maintenance/dispatch_all.sh +26 -0
  161. package/scripts/maintenance/fix_wrangler.py +32 -0
  162. package/scripts/maintenance/run_rescan_prod.py +34 -0
  163. package/scripts/maintenance/run_sync_batches.py +56 -0
  164. package/scripts/maintenance/run_sync_test.py +27 -0
  165. package/scripts/maintenance/run_test_msg.py +22 -0
  166. package/scripts/maintenance/test_analytics_stream.js +3 -0
  167. package/scripts/maintenance/update_wrangler.cjs +22 -0
  168. package/scripts/maintenance/update_wrangler.js +22 -0
  169. package/scripts/maintenance/validate-internal-deps.mjs +49 -0
  170. package/scripts/oauth/README.md +101 -0
  171. package/scripts/oauth/prod-probe.py +329 -0
  172. package/scripts/output-usage-test.py +221 -0
  173. package/scripts/pressure-chaos-test.mjs +481 -0
  174. package/scripts/tenants/add_consumer.js +17 -0
  175. package/scripts/tenants/calibrate.mjs +206 -0
  176. package/scripts/tenants/provision-tenant.mjs +578 -0
  177. package/scripts/tenants/register_domains.py +27 -0
  178. package/scripts/tenants/sql/register_0.sql +1 -0
  179. package/scripts/tenants/sql/register_1.sql +1 -0
  180. package/scripts/tenants/sql/register_2.sql +1 -0
  181. package/scripts/tenants/sql/register_3.sql +1 -0
  182. package/scripts/tenants/sql/register_4.sql +1 -0
  183. package/scripts/tenants/sql/register_5.sql +1 -0
  184. package/scripts/tenants/sql/register_6.sql +1 -0
  185. package/scripts/tenants/sql/register_7.sql +1 -0
  186. package/scripts/tenants/sql/register_8.sql +1 -0
  187. package/scripts/tenants/sql/register_9.sql +1 -0
  188. package/scripts/tranco-deep-2026-04-05_12h42m.json +47002 -0
  189. package/scripts/tranco-deep-scan.mjs +307 -0
  190. package/scripts/tranco-scan-2026-04-05_12h14m.json +6002 -0
  191. package/scripts/tranco-scan-2026-04-06_02h49m.json +602 -0
  192. package/scripts/tranco-scan-2026-04-07_13h30m.json +1202 -0
  193. package/scripts/tranco-scan.mjs +253 -0
  194. package/scripts/trial-key.mjs +346 -0
  195. package/server.json +35 -0
  196. package/smithery.yaml +13 -0
  197. package/src/handlers/prompts.ts +279 -0
  198. package/src/handlers/resources.ts +283 -0
  199. package/src/handlers/tool-args.ts +150 -0
  200. package/src/handlers/tool-execution.ts +107 -0
  201. package/src/handlers/tool-formatters.ts +94 -0
  202. package/src/handlers/tool-schemas.ts +9 -0
  203. package/src/handlers/tools.ts +529 -0
  204. package/src/index.ts +794 -0
  205. package/src/internal.ts +666 -0
  206. package/src/lib/adaptive-weights.ts +246 -0
  207. package/src/lib/alerting.ts +103 -0
  208. package/src/lib/analytics-engine.ts +33 -0
  209. package/src/lib/analytics-queries.ts +399 -0
  210. package/src/lib/analytics.ts +310 -0
  211. package/src/lib/audit.ts +56 -0
  212. package/src/lib/auth.ts +52 -0
  213. package/src/lib/badge.ts +94 -0
  214. package/src/lib/cache.ts +310 -0
  215. package/src/lib/category-interactions.ts +154 -0
  216. package/src/lib/circuit-breaker.ts +101 -0
  217. package/src/lib/client-detection.ts +31 -0
  218. package/src/lib/config.ts +370 -0
  219. package/src/lib/context-profiles.ts +16 -0
  220. package/src/lib/db/schema.ts +77 -0
  221. package/src/lib/dns-multi-resolver.ts +218 -0
  222. package/src/lib/dns-query-adapter.ts +18 -0
  223. package/src/lib/dns-records.ts +233 -0
  224. package/src/lib/dns-transport.ts +237 -0
  225. package/src/lib/dns-types.ts +91 -0
  226. package/src/lib/dns.ts +27 -0
  227. package/src/lib/fuzzing-counter.ts +79 -0
  228. package/src/lib/fuzzing-detector.ts +115 -0
  229. package/src/lib/hooks/analytics-stream.ts +28 -0
  230. package/src/lib/ip-utils.ts +70 -0
  231. package/src/lib/json-rpc.ts +67 -0
  232. package/src/lib/legacy-sse.ts +185 -0
  233. package/src/lib/log.ts +113 -0
  234. package/src/lib/output-sanitize.ts +40 -0
  235. package/src/lib/profile-accumulator.ts +830 -0
  236. package/src/lib/provider-signature-source.ts +191 -0
  237. package/src/lib/provider-signatures.ts +134 -0
  238. package/src/lib/public-suffix.ts +131 -0
  239. package/src/lib/quota-coordinator.ts +446 -0
  240. package/src/lib/rate-limiter-memory.ts +163 -0
  241. package/src/lib/rate-limiter.ts +528 -0
  242. package/src/lib/safe-fetch.ts +42 -0
  243. package/src/lib/sanitize.ts +245 -0
  244. package/src/lib/scoring-config.ts +36 -0
  245. package/src/lib/scoring-engine.ts +15 -0
  246. package/src/lib/scoring-model.ts +26 -0
  247. package/src/lib/scoring.ts +58 -0
  248. package/src/lib/semaphore.ts +101 -0
  249. package/src/lib/server-version.ts +4 -0
  250. package/src/lib/session-memory.ts +177 -0
  251. package/src/lib/session.ts +295 -0
  252. package/src/lib/sse.ts +174 -0
  253. package/src/lib/tier-auth.ts +237 -0
  254. package/src/lib/trial-keys.ts +217 -0
  255. package/src/mcp/dispatch.ts +222 -0
  256. package/src/mcp/execute.ts +680 -0
  257. package/src/mcp/request.ts +152 -0
  258. package/src/mcp/route-gates.ts +119 -0
  259. package/src/oauth/authorize.ts +268 -0
  260. package/src/oauth/discovery.ts +48 -0
  261. package/src/oauth/entitlements.ts +77 -0
  262. package/src/oauth/jwt.ts +142 -0
  263. package/src/oauth/register.ts +72 -0
  264. package/src/oauth/storage.ts +66 -0
  265. package/src/oauth/token.ts +171 -0
  266. package/src/package.ts +59 -0
  267. package/src/scheduled.ts +310 -0
  268. package/src/schemas/alerting.ts +49 -0
  269. package/src/schemas/audit.ts +39 -0
  270. package/src/schemas/auth.ts +27 -0
  271. package/src/schemas/dns.ts +49 -0
  272. package/src/schemas/internal.ts +26 -0
  273. package/src/schemas/json-rpc.ts +20 -0
  274. package/src/schemas/oauth.ts +120 -0
  275. package/src/schemas/primitives.ts +58 -0
  276. package/src/schemas/session.ts +9 -0
  277. package/src/schemas/tenant-alerts.ts +118 -0
  278. package/src/schemas/tenant-internal.ts +143 -0
  279. package/src/schemas/tool-args.ts +270 -0
  280. package/src/schemas/tool-definitions.ts +452 -0
  281. package/src/stdio.ts +183 -0
  282. package/src/tenants/adapters/tenant-d1.ts +51 -0
  283. package/src/tenants/adapters/tenant-kv.ts +64 -0
  284. package/src/tenants/adapters/tenant-r2.ts +69 -0
  285. package/src/tenants/alerts/diff.ts +201 -0
  286. package/src/tenants/alerts/index.ts +12 -0
  287. package/src/tenants/alerts/webhook.ts +141 -0
  288. package/src/tenants/analytics-stream.ts +26 -0
  289. package/src/tenants/audit.ts +123 -0
  290. package/src/tenants/db/drizzle.registry.config.ts +18 -0
  291. package/src/tenants/db/drizzle.tenant.config.ts +21 -0
  292. package/src/tenants/db/index.ts +19 -0
  293. package/src/tenants/db/migrations/registry/0000_minor_skaar.sql +46 -0
  294. package/src/tenants/db/migrations/registry/0001_wet_warhawk.sql +23 -0
  295. package/src/tenants/db/migrations/registry/0002_big_speedball.sql +17 -0
  296. package/src/tenants/db/migrations/registry/meta/0000_snapshot.json +330 -0
  297. package/src/tenants/db/migrations/registry/meta/0001_snapshot.json +498 -0
  298. package/src/tenants/db/migrations/registry/meta/0002_snapshot.json +624 -0
  299. package/src/tenants/db/migrations/registry/meta/_journal.json +27 -0
  300. package/src/tenants/db/migrations/tenant/0000_clear_clea.sql +54 -0
  301. package/src/tenants/db/migrations/tenant/0001_clumsy_master_mold.sql +3 -0
  302. package/src/tenants/db/migrations/tenant/meta/0000_snapshot.json +375 -0
  303. package/src/tenants/db/migrations/tenant/meta/0001_snapshot.json +397 -0
  304. package/src/tenants/db/migrations/tenant/meta/_journal.json +20 -0
  305. package/src/tenants/db/schema/registry.ts +154 -0
  306. package/src/tenants/db/schema/tenant.ts +106 -0
  307. package/src/tenants/discovery/dkim-key-reuse.ts +250 -0
  308. package/src/tenants/discovery/dmarc-rua-miner.ts +186 -0
  309. package/src/tenants/discovery/index.ts +31 -0
  310. package/src/tenants/discovery/ns-correlator.ts +155 -0
  311. package/src/tenants/discovery/san-correlator.ts +212 -0
  312. package/src/tenants/dns-fingerprint.ts +313 -0
  313. package/src/tenants/monitoring/index.ts +17 -0
  314. package/src/tenants/per-tenant-rate-limit.ts +148 -0
  315. package/src/tenants/queue-consumer.ts +375 -0
  316. package/src/tenants/routes.ts +1014 -0
  317. package/src/tenants/scheduled-handlers.ts +550 -0
  318. package/src/tenants/tenant-resolver.ts +143 -0
  319. package/src/tools/analyze-drift.ts +235 -0
  320. package/src/tools/assess-spoofability.ts +224 -0
  321. package/src/tools/batch-scan.ts +163 -0
  322. package/src/tools/caa-analysis.ts +72 -0
  323. package/src/tools/check-bimi.ts +30 -0
  324. package/src/tools/check-caa.ts +23 -0
  325. package/src/tools/check-cymru-asn.ts +175 -0
  326. package/src/tools/check-dane-https.ts +29 -0
  327. package/src/tools/check-dane.ts +29 -0
  328. package/src/tools/check-dbl.ts +251 -0
  329. package/src/tools/check-dkim.ts +98 -0
  330. package/src/tools/check-dmarc.ts +25 -0
  331. package/src/tools/check-dnssec-chain.ts +284 -0
  332. package/src/tools/check-dnssec.ts +171 -0
  333. package/src/tools/check-fast-flux.ts +168 -0
  334. package/src/tools/check-http-security.ts +339 -0
  335. package/src/tools/check-lookalikes.ts +379 -0
  336. package/src/tools/check-mta-sts.ts +24 -0
  337. package/src/tools/check-mx-reputation.ts +174 -0
  338. package/src/tools/check-mx.ts +117 -0
  339. package/src/tools/check-ns.ts +30 -0
  340. package/src/tools/check-nsec-walkability.ts +173 -0
  341. package/src/tools/check-rbl.ts +235 -0
  342. package/src/tools/check-rdap-lookup.ts +333 -0
  343. package/src/tools/check-resolver-consistency.ts +151 -0
  344. package/src/tools/check-shadow-domains.ts +517 -0
  345. package/src/tools/check-spf.ts +48 -0
  346. package/src/tools/check-srv.ts +75 -0
  347. package/src/tools/check-ssl.ts +18 -0
  348. package/src/tools/check-subdomailing.ts +22 -0
  349. package/src/tools/check-subdomain-takeover.ts +24 -0
  350. package/src/tools/check-svcb-https.ts +22 -0
  351. package/src/tools/check-tlsrpt.ts +23 -0
  352. package/src/tools/check-txt-hygiene.ts +364 -0
  353. package/src/tools/check-zone-hygiene.ts +154 -0
  354. package/src/tools/compare-baseline.ts +199 -0
  355. package/src/tools/compare-domains.ts +182 -0
  356. package/src/tools/dane-analysis.ts +172 -0
  357. package/src/tools/discover-brand-domains.ts +377 -0
  358. package/src/tools/discover-subdomains.ts +487 -0
  359. package/src/tools/dkim-analysis.ts +86 -0
  360. package/src/tools/dmarc-utils.ts +114 -0
  361. package/src/tools/dnssec-analysis.ts +123 -0
  362. package/src/tools/explain-finding-data.ts +766 -0
  363. package/src/tools/explain-finding.ts +181 -0
  364. package/src/tools/generate-fix-plan.ts +196 -0
  365. package/src/tools/generate-records.ts +412 -0
  366. package/src/tools/generate-rollout-plan.ts +342 -0
  367. package/src/tools/http-security-analysis.ts +192 -0
  368. package/src/tools/intelligence.ts +331 -0
  369. package/src/tools/lookalike-analysis.ts +176 -0
  370. package/src/tools/map-compliance.ts +243 -0
  371. package/src/tools/map-supply-chain.ts +458 -0
  372. package/src/tools/mta-sts-analysis.ts +250 -0
  373. package/src/tools/mx-analysis.ts +55 -0
  374. package/src/tools/mx-reputation-analysis.ts +205 -0
  375. package/src/tools/ns-analysis.ts +162 -0
  376. package/src/tools/provider-guides.ts +404 -0
  377. package/src/tools/resolve-spf-chain.ts +254 -0
  378. package/src/tools/scan/format-report.ts +248 -0
  379. package/src/tools/scan/maturity-staging.ts +166 -0
  380. package/src/tools/scan/post-processing.ts +270 -0
  381. package/src/tools/scan-domain.ts +664 -0
  382. package/src/tools/simulate-attack-paths.ts +513 -0
  383. package/src/tools/spf-analysis.ts +203 -0
  384. package/src/tools/spf-trust-surface.ts +138 -0
  385. package/src/tools/srv-analysis.ts +118 -0
  386. package/src/tools/ssl-analysis.ts +102 -0
  387. package/src/tools/subdomain-takeover-analysis.ts +202 -0
  388. package/src/tools/txt-hygiene-analysis.ts +87 -0
  389. package/src/tools/validate-fix.ts +219 -0
  390. package/src/tools/zone-hygiene-analysis.ts +217 -0
  391. package/src/types/env.d.ts +6 -0
  392. package/test/.!52131!.DS_Store +0 -0
  393. package/test/adaptive-weights.spec.ts +359 -0
  394. package/test/alerting.spec.ts +91 -0
  395. package/test/analytics-ip-hash.spec.ts +90 -0
  396. package/test/analytics-queries.spec.ts +197 -0
  397. package/test/analytics-stream.spec.ts +32 -0
  398. package/test/analytics.spec.ts +205 -0
  399. package/test/analyze-drift.spec.ts +82 -0
  400. package/test/assess-spoofability.spec.ts +186 -0
  401. package/test/audit.spec.ts +250 -0
  402. package/test/audits/fuzzing-config.audit.test.ts +76 -0
  403. package/test/audits/no-tracked-secrets.audit.test.ts +166 -0
  404. package/test/audits/oauth-readiness-gate.audit.test.ts +83 -0
  405. package/test/audits/tenant-capacity-readiness.audit.test.ts +92 -0
  406. package/test/audits/tenant-scale-quota.audit.test.ts +35 -0
  407. package/test/audits/tool-quota-coverage.audit.test.ts +41 -0
  408. package/test/audits/workflow-secret-check.audit.test.ts +79 -0
  409. package/test/auth.spec.ts +94 -0
  410. package/test/badge.spec.ts +112 -0
  411. package/test/batch-scan.spec.ts +141 -0
  412. package/test/caa-analysis.spec.ts +24 -0
  413. package/test/cache.spec.ts +421 -0
  414. package/test/category-interactions.spec.ts +172 -0
  415. package/test/chaos/fuzzing-degradation.chaos.test.ts +50 -0
  416. package/test/chaos/invariants.spec.ts +181 -0
  417. package/test/chaos/oauth-misconfiguration.chaos.test.ts +132 -0
  418. package/test/chaos/tenant-cron.chaos.test.ts +276 -0
  419. package/test/chaos/tenant-queue.chaos.test.ts +272 -0
  420. package/test/check-bimi.spec.ts +160 -0
  421. package/test/check-caa.spec.ts +144 -0
  422. package/test/check-cymru-asn.spec.ts +239 -0
  423. package/test/check-dane-https.spec.ts +203 -0
  424. package/test/check-dane.spec.ts +234 -0
  425. package/test/check-dbl.spec.ts +214 -0
  426. package/test/check-dkim.spec.ts +413 -0
  427. package/test/check-dmarc.spec.ts +377 -0
  428. package/test/check-dnssec-catch.spec.ts +48 -0
  429. package/test/check-dnssec-chain.spec.ts +196 -0
  430. package/test/check-dnssec.spec.ts +271 -0
  431. package/test/check-fast-flux.spec.ts +201 -0
  432. package/test/check-http-security.spec.ts +420 -0
  433. package/test/check-lookalikes.spec.ts +860 -0
  434. package/test/check-mta-sts.spec.ts +196 -0
  435. package/test/check-mx-reputation.spec.ts +395 -0
  436. package/test/check-mx.spec.ts +183 -0
  437. package/test/check-ns.spec.ts +172 -0
  438. package/test/check-nsec-walkability.spec.ts +107 -0
  439. package/test/check-rbl.spec.ts +283 -0
  440. package/test/check-rdap-lookup.spec.ts +235 -0
  441. package/test/check-resolver-consistency.spec.ts +117 -0
  442. package/test/check-shadow-domains.spec.ts +883 -0
  443. package/test/check-spf.spec.ts +399 -0
  444. package/test/check-srv.spec.ts +160 -0
  445. package/test/check-ssl.spec.ts +192 -0
  446. package/test/check-subdomailing.spec.ts +308 -0
  447. package/test/check-subdomain-takeover.spec.ts +366 -0
  448. package/test/check-svcb-https.spec.ts +247 -0
  449. package/test/check-tlsrpt.spec.ts +70 -0
  450. package/test/check-txt-hygiene.spec.ts +414 -0
  451. package/test/check-zone-hygiene.spec.ts +234 -0
  452. package/test/circuit-breaker.spec.ts +171 -0
  453. package/test/client-detection.spec.ts +73 -0
  454. package/test/compare-baseline.spec.ts +221 -0
  455. package/test/compare-domains.spec.ts +46 -0
  456. package/test/config.spec.ts +216 -0
  457. package/test/context-profiles.spec.ts +215 -0
  458. package/test/contracts/fuzzing-alert.contract.test.ts +58 -0
  459. package/test/contracts/oauth-tier.contract.test.ts +53 -0
  460. package/test/contracts/tenant-alerts.contract.test.ts +79 -0
  461. package/test/dane-analysis.spec.ts +165 -0
  462. package/test/data/batch_test.json +1 -0
  463. package/test/data/domains.json +26976 -0
  464. package/test/data/rescan_batch.json +1 -0
  465. package/test/data/sync_test.json +1 -0
  466. package/test/data/temp_sync_batch.json +1 -0
  467. package/test/discover-brand-domains.spec.ts +215 -0
  468. package/test/discover-subdomains.spec.ts +382 -0
  469. package/test/dispatch-reinitialize.spec.ts +101 -0
  470. package/test/dkim-analysis.spec.ts +48 -0
  471. package/test/dmarc-utils.spec.ts +27 -0
  472. package/test/dns-multi-resolver.spec.ts +109 -0
  473. package/test/dns-records-new.spec.ts +244 -0
  474. package/test/dns-records.spec.ts +20 -0
  475. package/test/dns-semaphore.spec.ts +184 -0
  476. package/test/dns-transport.spec.ts +669 -0
  477. package/test/dns.spec.ts +118 -0
  478. package/test/dnssec-analysis.spec.ts +48 -0
  479. package/test/env.d.ts +3 -0
  480. package/test/explain-finding.spec.ts +578 -0
  481. package/test/format-report.spec.ts +273 -0
  482. package/test/format-scan-report.spec.ts +160 -0
  483. package/test/freemium-limits.spec.ts +102 -0
  484. package/test/freemium-model.spec.ts +143 -0
  485. package/test/fuzzing-alert-dedup.test.ts +82 -0
  486. package/test/fuzzing-counter.integration.test.ts +75 -0
  487. package/test/fuzzing-detector.test.ts +87 -0
  488. package/test/fuzzing-e2e.integration.test.ts +114 -0
  489. package/test/generate-discovery-report.spec.ts +337 -0
  490. package/test/generate-fix-plan.spec.ts +219 -0
  491. package/test/generate-records.spec.ts +241 -0
  492. package/test/generate-rollout-plan.spec.ts +261 -0
  493. package/test/handlers-prompts.spec.ts +96 -0
  494. package/test/handlers-resources.spec.ts +85 -0
  495. package/test/handlers-tools.spec.ts +1042 -0
  496. package/test/helpers/dns-mock.ts +155 -0
  497. package/test/http-security-analysis.spec.ts +242 -0
  498. package/test/index.spec.ts +1721 -0
  499. package/test/intelligence.spec.ts +217 -0
  500. package/test/internal-guard.spec.ts +34 -0
  501. package/test/internal-tools-analytics-auth.test.ts +102 -0
  502. package/test/internal-tools-call-body-limit.test.ts +45 -0
  503. package/test/internal-trial-keys-auth.spec.ts +99 -0
  504. package/test/internal.spec.ts +411 -0
  505. package/test/ip-utils.spec.ts +127 -0
  506. package/test/kv-fallback-logging.spec.ts +220 -0
  507. package/test/legacy-session-validation.spec.ts +113 -0
  508. package/test/legacy-sse.spec.ts +140 -0
  509. package/test/log-cf-ip-redaction.test.ts +30 -0
  510. package/test/log.spec.ts +189 -0
  511. package/test/lookalike-analysis.spec.ts +67 -0
  512. package/test/map-compliance.spec.ts +284 -0
  513. package/test/map-supply-chain.spec.ts +584 -0
  514. package/test/maturity-staging.spec.ts +312 -0
  515. package/test/mcp-dispatch.spec.ts +123 -0
  516. package/test/mcp-execute.spec.ts +1259 -0
  517. package/test/mcp-request.spec.ts +115 -0
  518. package/test/mcp-route-gates.spec.ts +88 -0
  519. package/test/mta-sts-analysis.spec.ts +74 -0
  520. package/test/mx-analysis.spec.ts +32 -0
  521. package/test/mx-reputation-analysis.spec.ts +116 -0
  522. package/test/ns-analysis.spec.ts +49 -0
  523. package/test/oauth/authorize-get.spec.ts +170 -0
  524. package/test/oauth/authorize-post.spec.ts +286 -0
  525. package/test/oauth/authorize-zod-leak.test.ts +40 -0
  526. package/test/oauth/bearer-jwt.spec.ts +152 -0
  527. package/test/oauth/discovery.spec.ts +51 -0
  528. package/test/oauth/e2e.spec.ts +141 -0
  529. package/test/oauth/entitlements.spec.ts +110 -0
  530. package/test/oauth/internal-grant.spec.ts +183 -0
  531. package/test/oauth/jwt.spec.ts +91 -0
  532. package/test/oauth/pkce.spec.ts +57 -0
  533. package/test/oauth/register.spec.ts +79 -0
  534. package/test/oauth/storage.spec.ts +74 -0
  535. package/test/oauth/token.spec.ts +270 -0
  536. package/test/output-sanitize.spec.ts +450 -0
  537. package/test/package-api.spec.ts +35 -0
  538. package/test/profile-accumulator.spec.ts +567 -0
  539. package/test/provider-guides.spec.ts +74 -0
  540. package/test/provider-signature-source.spec.ts +68 -0
  541. package/test/provider-signatures.spec.ts +112 -0
  542. package/test/public-suffix.spec.ts +197 -0
  543. package/test/queue-consumer-analytics.spec.ts +65 -0
  544. package/test/quota-coordinator.spec.ts +74 -0
  545. package/test/rate-limit-chaos.spec.ts +529 -0
  546. package/test/rate-limiter-kv-reset.test.ts +62 -0
  547. package/test/rate-limiter-memory.spec.ts +31 -0
  548. package/test/rate-limiter-ttl.spec.ts +100 -0
  549. package/test/rate-limiter.spec.ts +491 -0
  550. package/test/resolve-spf-chain.spec.ts +183 -0
  551. package/test/safe-fetch.test.ts +45 -0
  552. package/test/sanitize.spec.ts +233 -0
  553. package/test/scan-domain-cache-status.test.ts +128 -0
  554. package/test/scan-domain-provider-inference.spec.ts +93 -0
  555. package/test/scan-domain-safe-check.spec.ts +91 -0
  556. package/test/scan-domain.spec.ts +1063 -0
  557. package/test/scan-post-processing.spec.ts +663 -0
  558. package/test/scheduled.spec.ts +104 -0
  559. package/test/schemas/audit.test.ts +140 -0
  560. package/test/schemas/auth.spec.ts +36 -0
  561. package/test/schemas/dns.spec.ts +48 -0
  562. package/test/schemas/internal.spec.ts +50 -0
  563. package/test/schemas/json-rpc.spec.ts +63 -0
  564. package/test/schemas/oauth.spec.ts +104 -0
  565. package/test/schemas/primitives.spec.ts +131 -0
  566. package/test/schemas/session.spec.ts +21 -0
  567. package/test/schemas/tenant-alerts.test.ts +126 -0
  568. package/test/schemas/tenant-internal.test.ts +128 -0
  569. package/test/schemas/tool-args.spec.ts +166 -0
  570. package/test/schemas/tool-definitions.spec.ts +67 -0
  571. package/test/scoring-config-cached.spec.ts +63 -0
  572. package/test/scoring-config.spec.ts +177 -0
  573. package/test/scoring-determinism.spec.ts +162 -0
  574. package/test/scoring-engine.spec.ts +134 -0
  575. package/test/scoring-model.spec.ts +44 -0
  576. package/test/scoring-profiles.spec.ts +235 -0
  577. package/test/scoring.spec.ts +197 -0
  578. package/test/security-hardening.spec.ts +58 -0
  579. package/test/session-degradation-event.spec.ts +66 -0
  580. package/test/session-keepalive.spec.ts +347 -0
  581. package/test/session-kv-failure-logging.spec.ts +99 -0
  582. package/test/session-memory.spec.ts +111 -0
  583. package/test/session-recovery.spec.ts +260 -0
  584. package/test/session.spec.ts +266 -0
  585. package/test/simulate-attack-paths.spec.ts +888 -0
  586. package/test/spf-analysis.spec.ts +29 -0
  587. package/test/spf-trust-surface.spec.ts +62 -0
  588. package/test/srv-analysis.spec.ts +151 -0
  589. package/test/sse.spec.ts +44 -0
  590. package/test/ssl-analysis.spec.ts +27 -0
  591. package/test/stdio.spec.ts +71 -0
  592. package/test/streaming-sse.spec.ts +419 -0
  593. package/test/subdomain-takeover-analysis.spec.ts +104 -0
  594. package/test/tenants/alerts/diff.test.ts +127 -0
  595. package/test/tenants/alerts/webhook.test.ts +129 -0
  596. package/test/tenants/audit.test.ts +220 -0
  597. package/test/tenants/cron.integration.test.ts +117 -0
  598. package/test/tenants/db/registry-schema.spec.ts +254 -0
  599. package/test/tenants/db/tenant-schema.spec.ts +202 -0
  600. package/test/tenants/discovery/dkim-key-reuse.test.ts +213 -0
  601. package/test/tenants/discovery/dmarc-rua-miner.test.ts +179 -0
  602. package/test/tenants/discovery/ns-correlator.test.ts +186 -0
  603. package/test/tenants/discovery/san-correlator.test.ts +128 -0
  604. package/test/tenants/discovery-route.integration.test.ts +135 -0
  605. package/test/tenants/dns-fingerprint.test.ts +321 -0
  606. package/test/tenants/hammer-stress.integration.test.ts +136 -0
  607. package/test/tenants/per-tenant-rate-limit.test.ts +119 -0
  608. package/test/tenants/phase6-fingerprint.integration.test.ts +147 -0
  609. package/test/tenants/provision-tenant.test.ts +351 -0
  610. package/test/tenants/queue-consumer.integration.test.ts +355 -0
  611. package/test/tenants/queue-producer.integration.test.ts +219 -0
  612. package/test/tenants/routes.integration.test.ts +783 -0
  613. package/test/tenants/scheduled-handlers.integration.test.ts +713 -0
  614. package/test/tenants/tenant-d1.spec.ts +78 -0
  615. package/test/tenants/tenant-kv.spec.ts +104 -0
  616. package/test/tenants/tenant-r2.spec.ts +103 -0
  617. package/test/tier-auth-jwt-enum.test.ts +55 -0
  618. package/test/tier-auth-owner-jwt-ip.test.ts +80 -0
  619. package/test/tier-auth.spec.ts +191 -0
  620. package/test/tool-args.spec.ts +101 -0
  621. package/test/tool-execution.spec.ts +421 -0
  622. package/test/tool-formatters.spec.ts +84 -0
  623. package/test/tool-metadata.spec.ts +25 -0
  624. package/test/tool-schemas.spec.ts +113 -0
  625. package/test/trial-keys.spec.ts +367 -0
  626. package/test/tsconfig.json +8 -0
  627. package/test/txt-hygiene-analysis.spec.ts +118 -0
  628. package/test/validate-fix.spec.ts +71 -0
  629. package/test/validate-outbound-url.test.ts +63 -0
  630. package/test/wasm-integration.test.ts +32 -0
  631. package/test/zone-hygiene-analysis.spec.ts +172 -0
  632. package/tsconfig.json +40 -0
  633. package/tsup.config.ts +42 -0
  634. package/vitest.config.mts +33 -0
  635. package/wrangler.jsonc +70 -0
  636. package/wrangler.private.example.jsonc +31 -0
@@ -0,0 +1,61 @@
1
+ {
2
+ "hooks": {
3
+ "PostToolUse": [
4
+ {
5
+ "matcher": "Write|Edit",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "jq -r '.tool_input.file_path // .tool_response.filePath // empty' | { read -r f; case \"$f\" in *.ts) npx eslint --no-error-on-unmatched-pattern \"$f\" 2>/dev/null || true;; esac; }",
10
+ "timeout": 15,
11
+ "statusMessage": "Linting..."
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "matcher": "Bash",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "if": "Bash(git commit:*)",
21
+ "command": "node -e \"const p=require('./package.json');const s=require('fs').readFileSync('src/lib/server-version.ts','utf8');const m=s.match(/SERVER_VERSION = '([^']+)'/);if(!m){console.log(JSON.stringify({systemMessage:'WARNING: Cannot parse SERVER_VERSION from src/lib/server-version.ts'}));}else if(p.version!==m[1]){console.log(JSON.stringify({continue:false,stopReason:'Version mismatch: package.json='+p.version+' server-version.ts='+m[1]+'. Fix with: npm version '+m[1]+' --no-git-tag-version'}));}\"",
22
+ "timeout": 5,
23
+ "statusMessage": "Checking version sync..."
24
+ },
25
+ {
26
+ "type": "command",
27
+ "if": "Bash(git commit:*)",
28
+ "command": "node -e \"const fs=require('fs');const a=fs.readFileSync('src/schemas/tool-args.ts','utf8');const d=fs.readFileSync('src/schemas/tool-definitions.ts','utf8');const sb=a.match(/TOOL_SCHEMA_MAP[^{]*\\{([^}]+)\\}/s)?.[1]||'';const sk=[...sb.matchAll(/^\\t(\\w+):/gm)].map(m=>m[1]);const db=d.match(/TOOL_DEFS[^{]*\\{([\\s\\S]+?)^\\};/m)?.[1]||'';const dk=[...db.matchAll(/^\\t(\\w+):\\s*\\{$/gm)].map(m=>m[1]);const ds=new Set(dk);const ss=new Set(sk);const md=sk.filter(k=>!ds.has(k));const ms=dk.filter(k=>!ss.has(k));if(md.length||ms.length){const msg=[];if(md.length)msg.push('In TOOL_SCHEMA_MAP but not TOOL_DEFS: '+md.join(', '));if(ms.length)msg.push('In TOOL_DEFS but not TOOL_SCHEMA_MAP: '+ms.join(', '));console.log(JSON.stringify({continue:false,stopReason:msg.join('. ')}));}\"",
29
+ "timeout": 5,
30
+ "statusMessage": "Checking tool definition sync..."
31
+ }
32
+ ]
33
+ }
34
+ ],
35
+ "PreToolUse": [
36
+ {
37
+ "matcher": "Bash",
38
+ "hooks": [
39
+ {
40
+ "type": "command",
41
+ "if": "Bash(git add -A:*)",
42
+ "command": "echo '{\"continue\":false,\"stopReason\":\"Use specific file paths with git add instead of -A to avoid staging sensitive files.\"}'",
43
+ "timeout": 2
44
+ },
45
+ {
46
+ "type": "command",
47
+ "if": "Bash(git add .:*)",
48
+ "command": "echo '{\"continue\":false,\"stopReason\":\"Use specific file paths with git add instead of . to avoid staging sensitive files.\"}'",
49
+ "timeout": 2
50
+ },
51
+ {
52
+ "type": "command",
53
+ "if": "Bash(git push --force:*)",
54
+ "command": "echo '{\"continue\":false,\"stopReason\":\"Force push blocked. This rewrites history and breaks clones/forks. Use git push (without --force) or discuss with the user first.\"}'",
55
+ "timeout": 2
56
+ }
57
+ ]
58
+ }
59
+ ]
60
+ }
61
+ }
package/.cursorrules ADDED
@@ -0,0 +1 @@
1
+ Always use the bv-context-engine MCP's codebase_search tool for any semantic search or architectural exploration. Prioritize this over grep to minimize context usage.
@@ -0,0 +1,17 @@
1
+ # bv-mcp DevContainer for Cloudflare Workers
2
+ FROM mcr.microsoft.com/devcontainers/typescript-node:latest
3
+
4
+ # Install Wrangler CLI globally
5
+ RUN npm install -g wrangler@latest
6
+
7
+ # Install Vitest and Cloudflare pool workers for testing
8
+ RUN npm install -g vitest @cloudflare/vitest-pool-workers
9
+
10
+ # Set working directory
11
+ WORKDIR /workspace
12
+
13
+ # Install additional tools (optional)
14
+ RUN apt-get update && apt-get install -y git curl
15
+
16
+ # Default shell
17
+ CMD ["zsh"]
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "bv-mcp Cloudflare Worker DevContainer",
3
+ "build": {
4
+ "dockerfile": "Dockerfile"
5
+ },
6
+ "postCreateCommand": "npm install",
7
+ "forwardPorts": [8787],
8
+ "features": {},
9
+ "settings": {
10
+ "terminal.integrated.defaultProfile.linux": "zsh"
11
+ },
12
+ "extensions": [
13
+ "esbenp.prettier-vscode",
14
+ "dbaeumer.vscode-eslint",
15
+ "cloudflare.cloudflare-vscode",
16
+ "ms-vscode.vscode-typescript-next"
17
+ ]
18
+ }
package/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = tab
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.yml]
12
+ indent_style = space
package/.gitattributes ADDED
@@ -0,0 +1,24 @@
1
+ # Auto detect text files and normalise line endings to LF
2
+ * text=auto eol=lf
3
+
4
+ # Explicit text files
5
+ *.ts text eol=lf
6
+ *.js text eol=lf
7
+ *.json text eol=lf
8
+ *.jsonc text eol=lf
9
+ *.md text eol=lf
10
+ *.yml text eol=lf
11
+ *.yaml text eol=lf
12
+ *.html text eol=lf
13
+ *.css text eol=lf
14
+ *.sh text eol=lf
15
+
16
+ # Denote binary files that should not be modified
17
+ *.png binary
18
+ *.jpg binary
19
+ *.ico binary
20
+ *.woff binary
21
+ *.woff2 binary
22
+
23
+ # Keep lock file line endings consistent
24
+ package-lock.json text eol=lf
@@ -0,0 +1,13 @@
1
+ # IP leakage patterns for pre-commit hook
2
+ #
3
+ # This file has been moved to .dev/blocked-patterns (gitignored) to avoid
4
+ # exposing internal hostnames and infrastructure identifiers in the public repo.
5
+ #
6
+ # To set up: copy .dev/blocked-patterns.example to .dev/blocked-patterns
7
+ # and add your organization-specific patterns.
8
+ #
9
+ # Each line is an extended regex. Lines starting with # are ignored.
10
+ # Example patterns:
11
+ # internal\.example\.com
12
+ # @my-org/
13
+ # deploy\.jsonc
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env bash
2
+ # Pre-commit hook: block sensitive paths, scan for secrets/PII, catch IP leakage patterns
3
+ set -euo pipefail
4
+
5
+ # ──�� 1. Blocked paths ──────────────────────────────���─────────────────
6
+ BLOCKED_PATTERNS=(
7
+ "docs/plans/"
8
+ "docs/code-review/"
9
+ "docs/superpowers/"
10
+ "docs/github-settings.md"
11
+ "docs/hn-show-post-draft.md"
12
+ "docs/mcp-directory-submissions.md"
13
+ "docs/enterprise-architecture.md"
14
+ ".dev/"
15
+ "*.env"
16
+ "*.env.*"
17
+ )
18
+
19
+ # Generated/compiled files that must never be committed
20
+ GENERATED_PATTERNS=(
21
+ "*.pyc"
22
+ "__pycache__/"
23
+ "worker-configuration.d.ts"
24
+ "*.wasm"
25
+ "*.sqlite"
26
+ "*.sqlite3"
27
+ "*.db"
28
+ )
29
+
30
+ staged=$(git diff --cached --name-only --diff-filter=ACR)
31
+ blocked=""
32
+
33
+ for file in $staged; do
34
+ for pattern in "${BLOCKED_PATTERNS[@]}"; do
35
+ case "$file" in
36
+ $pattern*|*/$pattern*)
37
+ blocked="$blocked\n $file"
38
+ ;;
39
+ esac
40
+ done
41
+ done
42
+
43
+ if [ -n "$blocked" ]; then
44
+ echo "BLOCKED: The following staged files are in protected paths:"
45
+ echo -e "$blocked"
46
+ echo ""
47
+ echo "These paths contain sensitive content and must not be committed."
48
+ echo "If this is intentional, use: git commit --no-verify"
49
+ exit 1
50
+ fi
51
+
52
+ # ─── 1b. Generated/compiled files ────────────────────────────────────
53
+ generated=""
54
+ for file in $staged; do
55
+ for pattern in "${GENERATED_PATTERNS[@]}"; do
56
+ case "$file" in
57
+ $pattern|*/$pattern|*.$pattern)
58
+ generated="$generated\n $file"
59
+ ;;
60
+ esac
61
+ # Also check by extension for glob patterns like *.pyc
62
+ case "$pattern" in
63
+ \*.*)
64
+ ext="${pattern#\*}"
65
+ case "$file" in
66
+ *"$ext")
67
+ generated="$generated\n $file"
68
+ ;;
69
+ esac
70
+ ;;
71
+ esac
72
+ done
73
+ done
74
+
75
+ # Deduplicate
76
+ if [ -n "$generated" ]; then
77
+ generated=$(echo -e "$generated" | sort -u)
78
+ echo "BLOCKED: Generated/compiled files should not be committed:"
79
+ echo -e "$generated"
80
+ echo ""
81
+ echo "These are build artifacts. Add them to .gitignore instead."
82
+ echo "To remove from staging: git restore --staged <file>"
83
+ exit 1
84
+ fi
85
+
86
+ # ─── 2. Gitleaks (secrets + PII) ──────���──────────────────────────────
87
+ if command -v gitleaks &>/dev/null; then
88
+ gitleaks protect --staged --config .gitleaks.toml --no-banner 2>&1 | head -20
89
+ if [ "${PIPESTATUS[0]}" -ne 0 ]; then
90
+ echo ""
91
+ echo "Gitleaks found secrets or PII in staged changes."
92
+ echo "Fix the findings above, or bypass with: git commit --no-verify"
93
+ exit 1
94
+ fi
95
+ fi
96
+
97
+ # ─── 3. IP leakage patterns ─────────��────────────────────────────────
98
+ # Patterns loaded from external file to avoid self-matching.
99
+ # Each line is an extended regex pattern. Lines starting with # are ignored.
100
+ # Loaded from .dev/ (gitignored) to avoid exposing internal hostnames in the public repo.
101
+ PATTERNS_FILE="$(git rev-parse --show-toplevel)/.dev/blocked-patterns"
102
+
103
+ if [ ! -f "$PATTERNS_FILE" ]; then
104
+ exit 0
105
+ fi
106
+
107
+ diff_content=$(git diff --cached --diff-filter=ACM -U0 -- ':!.githooks/' ':!.gitleaks.toml' | grep '^+' | grep -v '^+++' || true)
108
+
109
+ if [ -n "$diff_content" ]; then
110
+ ip_found=""
111
+ while IFS= read -r pattern; do
112
+ [[ "$pattern" =~ ^#.*$ || -z "$pattern" ]] && continue
113
+ matches=$(echo "$diff_content" | grep -iE "$pattern" || true)
114
+ if [ -n "$matches" ]; then
115
+ ip_found="$ip_found\n Pattern: $pattern\n$matches\n"
116
+ fi
117
+ done < "$PATTERNS_FILE"
118
+
119
+ if [ -n "$ip_found" ]; then
120
+ echo "BLOCKED: IP leakage patterns detected in staged changes:"
121
+ echo -e "$ip_found"
122
+ echo "These patterns indicate internal infrastructure, customer data,"
123
+ echo "or proprietary information that should not be in a public repo."
124
+ echo "If this is intentional, use: git commit --no-verify"
125
+ exit 1
126
+ fi
127
+ fi
@@ -0,0 +1,11 @@
1
+ # Baseline CODEOWNERS for bv-mcp
2
+
3
+ * @blackveil-security/engineering
4
+
5
+ # Core scanner and protocol behavior
6
+ src/ @blackveil-security/security-team
7
+ packages/ @blackveil-security/security-team
8
+
9
+ # CI/CD and release surface
10
+ .github/workflows/ @blackveil-security/devops
11
+ package.json @blackveil-security/devops
@@ -0,0 +1,99 @@
1
+ name: Bug report
2
+ description: Report a reproducible bug in Blackveil DNS
3
+ title: "[BUG]: "
4
+ labels: []
5
+ assignees: []
6
+ body:
7
+ - type: textarea
8
+ id: bug
9
+ attributes:
10
+ label: Describe the bug
11
+ description: Clear and concise summary of the problem.
12
+ validations:
13
+ required: true
14
+
15
+ - type: textarea
16
+ id: steps
17
+ attributes:
18
+ label: Steps to reproduce
19
+ value: |
20
+ 1.
21
+ 2.
22
+ 3.
23
+ validations:
24
+ required: true
25
+
26
+ - type: textarea
27
+ id: expected
28
+ attributes:
29
+ label: Expected behavior
30
+ validations:
31
+ required: true
32
+
33
+ - type: textarea
34
+ id: actual
35
+ attributes:
36
+ label: Actual behavior
37
+ validations:
38
+ required: true
39
+
40
+ - type: checkboxes
41
+ id: precheck
42
+ attributes:
43
+ label: Pre-submission checklist
44
+ options:
45
+ - label: I searched existing issues for duplicates.
46
+ required: true
47
+ - label: I confirmed this on the latest `main` branch or latest release.
48
+ required: true
49
+ - label: I redacted any secrets, tokens, and sensitive domains.
50
+ required: true
51
+
52
+ - type: textarea
53
+ id: request
54
+ attributes:
55
+ label: MCP request payload used
56
+ description: Paste JSON-RPC request body (redacted as needed).
57
+ render: json
58
+
59
+ - type: textarea
60
+ id: response
61
+ attributes:
62
+ label: Error response or logs
63
+ description: Paste relevant worker logs, stack traces, and error output.
64
+
65
+ - type: dropdown
66
+ id: auth_mode
67
+ attributes:
68
+ label: Authentication mode
69
+ options:
70
+ - Open mode (no BV_API_KEY)
71
+ - Bearer auth enabled (BV_API_KEY set)
72
+ validations:
73
+ required: true
74
+
75
+ - type: input
76
+ id: endpoint
77
+ attributes:
78
+ label: Endpoint type
79
+ placeholder: hosted / localhost
80
+
81
+ - type: input
82
+ id: os
83
+ attributes:
84
+ label: OS and version
85
+ placeholder: e.g. macOS 26.2
86
+ validations:
87
+ required: true
88
+
89
+ - type: textarea
90
+ id: client
91
+ attributes:
92
+ label: MCP client details
93
+ description: Client name/version (Claude, Copilot, Cursor, etc.) and how it was configured.
94
+
95
+ - type: textarea
96
+ id: additional
97
+ attributes:
98
+ label: Additional context
99
+ description: Any extra details that may help diagnose the issue.
@@ -0,0 +1,11 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: 💬 Community Discussion / Q&A
4
+ url: https://github.com/MadaBurns/bv-mcp/discussions
5
+ about: Questions, ideas, or general discussion — not a bug report.
6
+ - name: 🔒 Security vulnerability
7
+ url: https://github.com/MadaBurns/bv-mcp/security/advisories/new
8
+ about: Report a security vulnerability privately. Do NOT open a public issue for security bugs.
9
+ - name: ⚠️ Vendor pitch / partnership outreach
10
+ url: https://blackveilsecurity.com
11
+ about: Product integrations, partnership proposals, or marketing outreach belong in email — not the issue tracker. Issues matching promotional patterns will be auto-labeled.
@@ -0,0 +1,51 @@
1
+ name: Feature request
2
+ description: Suggest a new feature or improvement
3
+ title: "[FEATURE]: "
4
+ labels: []
5
+ assignees: []
6
+ body:
7
+ - type: textarea
8
+ id: problem
9
+ attributes:
10
+ label: Problem statement
11
+ description: What problem are you trying to solve?
12
+ validations:
13
+ required: true
14
+
15
+ - type: textarea
16
+ id: proposal
17
+ attributes:
18
+ label: Proposed solution
19
+ description: What behavior should be added or changed?
20
+ validations:
21
+ required: true
22
+
23
+ - type: textarea
24
+ id: alternatives
25
+ attributes:
26
+ label: Alternatives considered
27
+ description: Any alternatives or workarounds you've tried.
28
+
29
+ - type: checkboxes
30
+ id: impact
31
+ attributes:
32
+ label: Impact areas
33
+ options:
34
+ - label: MCP tool schema/API surface
35
+ - label: Scoring/reporting behavior
36
+ - label: Security hardening
37
+ - label: Performance/cache/rate limiting
38
+ - label: Documentation/developer experience
39
+
40
+ - type: textarea
41
+ id: examples
42
+ attributes:
43
+ label: Example request/response
44
+ description: If applicable, include sample MCP request/response that illustrates the need.
45
+ render: json
46
+
47
+ - type: textarea
48
+ id: context
49
+ attributes:
50
+ label: Additional context
51
+ description: Links, screenshots, prior art, or implementation notes.
@@ -0,0 +1,30 @@
1
+ ## Summary
2
+
3
+ <!-- Brief description of what this PR does and why -->
4
+
5
+ ## Type of change
6
+
7
+ - [ ] Bug fix
8
+ - [ ] New feature
9
+ - [ ] Security fix
10
+ - [ ] Refactor / cleanup
11
+ - [ ] Documentation
12
+ - [ ] CI / tooling
13
+
14
+ ## Security impact
15
+
16
+ <!-- Does this PR touch auth, validation, rate limiting, sanitization, or error handling? If yes, describe the changes and any implications. If no, write "None". -->
17
+
18
+ ## Test plan
19
+
20
+ - [ ] Unit tests added / updated
21
+ - [ ] Manual testing performed
22
+ - [ ] `npm test` passes
23
+ - [ ] `npm run typecheck` passes
24
+
25
+ ## Checklist
26
+
27
+ - [ ] Changes follow existing code conventions
28
+ - [ ] No secrets, credentials, or internal references included
29
+ - [ ] Error messages follow the safe-prefix convention (see CLAUDE.md)
30
+ - [ ] New tool? Followed the "Adding a New Tool" checklist in CLAUDE.md
@@ -0,0 +1,73 @@
1
+ # Project Guidelines
2
+
3
+ ## Build and Test
4
+ - Install dependencies: npm install
5
+ - Build package and CLI bundle: npm run build
6
+ - Build subpackage: npm -w packages/dns-checks run build
7
+ - Run local dev server: npm run dev
8
+ - Run tests (Workers runtime): npm test
9
+ - Run subpackage tests: npm -w packages/dns-checks run test
10
+ - Run single test file: npx vitest run test/check-spf.spec.ts
11
+ - Run chaos test (all 9 MCP client types): python3 scripts/chaos/chaos-test-clients.py
12
+ - Typecheck: npm run typecheck
13
+ - Typecheck subpackage: npm -w packages/dns-checks run typecheck
14
+ - Lint: npm run lint
15
+ - Auto-fix lint issues: npm run lint:fix
16
+ - Enable pre-commit hooks: git config core.hooksPath .githooks
17
+ - Deploy private worker config: npm run deploy:private
18
+
19
+ ## Runtime and Code Style
20
+ - Target Cloudflare Workers APIs only. Do not use Node-only APIs in runtime code.
21
+ - Keep TypeScript strict and preserve existing module/isolatedModules patterns.
22
+ - WASM Policy Engine: Integrated `bv-wasm-core` for high-performance, tamper-resistant permission checks and token estimation.
23
+ - For findings/results, use createFinding() and buildCheckResult() from src/lib/scoring.ts rather than manual object construction.
24
+ - Validate and normalize all domain input with validateDomain() and sanitizeDomain() from src/lib/sanitize.ts.
25
+ - Keep changes minimal and avoid unrelated refactors.
26
+
27
+ ## Architecture
28
+ - HTTP entrypoint and middleware: src/index.ts
29
+ - Internal service binding routes: src/internal.ts
30
+ - Shared MCP execution flow: src/mcp/execute.ts and src/mcp/dispatch.ts
31
+ - Tool handlers and schemas: src/handlers/tools.ts and src/handlers/tool-schemas.ts
32
+ - Individual DNS checks: src/tools/check-*.ts
33
+ - Parallel orchestration and scoring output: src/tools/scan-domain.ts
34
+ - Core DNS/cache/session/rate-limit utilities: src/lib/
35
+ - Monorepo structure: Root Cloudflare Worker + packages/dns-checks runtime-agnostic subpackage
36
+
37
+ ## Project Conventions
38
+ - Keep versions synchronized between package.json version and src/lib/server-version.ts SERVER_VERSION.
39
+ - Error messages intended for clients must start with safe prefixes (for example: Missing required, Invalid, Domain validation failed, Resource not found).
40
+ - Rate limiting for MCP should return HTTP 429 with JSON-RPC error code -32029.
41
+ - Respect output format behavior:
42
+ - format=compact for interactive clients
43
+ - format=full for non-interactive clients
44
+ - scan is a supported alias for scan_domain.
45
+
46
+ ## Caching and Performance
47
+ - Per-check cache key pattern: cache:<domain>:check:<name>
48
+ - Scan-level cache key pattern: cache:<domain>
49
+ - Profile cache key pattern: cache:<domain>:profile:<profile>
50
+ - For force_refresh flows, propagate skipCache through runWithCache().
51
+
52
+ ## Testing Patterns
53
+ - Use test/helpers/dns-mock.ts utilities for DNS mocking.
54
+ - Restore fetch mocks in afterEach.
55
+ - In tests that need mock isolation for check_mx, use dynamic imports inside test bodies.
56
+ - Clear both scan-level and per-check cache entries between relevant test cases.
57
+ - Chaos testing: Run `python3 scripts/chaos/chaos-test-clients.py` to validate behavior across all 9 MCP client types.
58
+
59
+ ## Security and Internal Routes
60
+ - Keep SSRF protections and domain sanitization paths intact.
61
+ - Public traffic must not access /internal/* routes.
62
+ - Do not expose secrets in code, logs, or committed files.
63
+ - Do not hardcode API keys in scripts or client config examples; load from environment variables (for example `BV_API_KEY`).
64
+
65
+ ## Documentation Map (Link, Do Not Duplicate)
66
+ - Canonical architecture and repository conventions: CLAUDE.md
67
+ - User-facing overview and quick start: README.md
68
+ - Contributor workflow and expectations: CONTRIBUTING.md
69
+ - Client setup and transport details: docs/client-setup.md
70
+ - Scoring model details: docs/scoring.md
71
+ - Enterprise architecture notes: docs/enterprise-architecture.md
72
+ - Troubleshooting guide: docs/troubleshooting.md
73
+ - Security policy and disclosure process: SECURITY.md
@@ -0,0 +1,22 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 10
8
+ groups:
9
+ cloudflare:
10
+ patterns:
11
+ - "@cloudflare/*"
12
+ - "wrangler"
13
+ vitest:
14
+ patterns:
15
+ - "vitest"
16
+ - "@vitest/*"
17
+
18
+ - package-ecosystem: github-actions
19
+ directory: /
20
+ schedule:
21
+ interval: weekly
22
+ open-pull-requests-limit: 5
@@ -0,0 +1,56 @@
1
+ ---
2
+ description: Use when modifying scan_domain orchestration, maturity staging, post-processing adjustments, partial timeout handling, or scan report formatting in this repository.
3
+ name: Scan Orchestration
4
+ applyTo: src/tools/scan-domain.ts
5
+ ---
6
+ # Scan Orchestration
7
+
8
+ ## Parallel execution
9
+
10
+ `scan_domain` runs **16 checks** in parallel via `Promise.allSettled`:
11
+ `checkSpf`, `checkDmarc`, `checkDkim`, `checkDnssec`, `checkSsl`, `checkMtaSts`, `checkNs`, `checkCaa`, `checkBimi`, `checkTlsrpt`, `checkSubdomainTakeover`, `checkMx`, `checkHttpSecurity`, `checkDane`, `checkDaneHttps`, `checkSvcbHttps`, `checkSubdomailing`
12
+
13
+ All checks are **static imports** — no dynamic imports in scan context (unlike `check_mx` in `handlers/tools.ts`).
14
+
15
+ ## Timeouts and partial results
16
+
17
+ - Per-check timeout: `PER_CHECK_TIMEOUT_MS = 8_000` (8s)
18
+ - Total scan timeout: `SCAN_TIMEOUT_MS = 12_000` (12s)
19
+ - Completed checks are preserved on timeout; missing checks get timeout findings
20
+ - Scan context skips secondary DNS confirmation for speed
21
+
22
+ ## Post-processing adjustments
23
+
24
+ `applyScanPostProcessing()` in `src/tools/scan/post-processing.ts` applies three adjustments after all checks complete:
25
+
26
+ 1. **Non-mail domains** (no MX): queries parent DMARC `sp=`/`p=` → downgrades email-auth findings to `info`
27
+ 2. **No-send signal** (SPF `noSendPolicy` metadata): downgrades DKIM/MTA-STS/BIMI missing-record findings to `info`
28
+ 3. **BIMI**: rewritten for non-mail domains
29
+
30
+ ## Maturity staging
31
+
32
+ `computeMaturityStage()` in `src/tools/scan/maturity-staging.ts` classifies domains into stages 0-4:
33
+ - Stage 0: Unprotected
34
+ - Stage 1-2: Basic/Configured
35
+ - Stage 3: Enforcing (does not require DKIM)
36
+ - Stage 4: Hardened (requires CAA + DKIM-discovered + BIMI + DANE + MTA-STS strict)
37
+
38
+ `capMaturityStage()` applies score-based caps: F (<50) → max Stage 2, D/D+ (<63) → max Stage 3.
39
+
40
+ ## Caching
41
+
42
+ - Each check cached at `cache:<domain>:check:<name>` (5 min default, `cacheTtlSeconds` override)
43
+ - Top-level scan cached at `cache:<domain>`
44
+ - Profile-specific: `cache:<domain>:profile:<profile>`
45
+ - `force_refresh` propagates via `skipCache` in `runWithCache()`
46
+
47
+ ## Output structure
48
+
49
+ - `formatScanReport()` in `src/tools/scan/format-report.ts` → human-readable text
50
+ - `buildToolContent()` wraps text + structured JSON for `format=full` clients
51
+ - `StructuredScanResult` interface defined in `src/tools/scan/format-report.ts`
52
+
53
+ ## Reference docs
54
+
55
+ - Scoring model: [docs/scoring.md](../../docs/scoring.md)
56
+ - Request flow: `src/index.ts` (Hono app) → `src/mcp/dispatch.ts` (JSON-RPC routing) → `src/handlers/tools.ts` (TOOL_REGISTRY) → individual checks under `src/tools/`. Trace the imports directly; the standalone architecture-diagram doc was removed in 2026-05-08 to keep this open-source repo focused on customer-facing material.