0sec-cli 0.21.4 → 0.22.1
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/0.js +56 -56
- package/README.md +48 -63
- package/chunks/{adapt-loop-IGBRQAXO.js → adapt-loop-J6QCZZTB.js} +4 -4
- package/chunks/{artifact-scraper-LNQJUORS.js → artifact-scraper-MFKT6OI4.js} +2 -2
- package/chunks/{assumption-mining-4MJTP6H5.js → assumption-mining-646LYSJY.js} +16 -16
- package/chunks/{chunk-Z3IKZX3X.js → chunk-23DG5YKS.js} +1 -1
- package/chunks/{chunk-2WSXFFJZ.js → chunk-3E2KALZ5.js} +2 -2
- package/chunks/{chunk-TF46UWFU.js → chunk-4G7OVYJX.js} +1 -1
- package/chunks/{chunk-E2UOY5PJ.js → chunk-5BTJMINS.js} +12 -70
- package/chunks/{chunk-QZVG3BG4.js → chunk-5IBCBQEH.js} +1 -2
- package/chunks/{chunk-YA4PUM4H.js → chunk-7XCKYNLO.js} +1 -1
- package/chunks/{chunk-BACXRTQ4.js → chunk-AV2LG2L7.js} +87 -767
- package/chunks/{chunk-IMGWPNQM.js → chunk-BCSRRQG5.js} +76 -593
- package/chunks/{chunk-NOPBXZUV.js → chunk-BOUGKEKA.js} +1 -1
- package/chunks/{chunk-RF5QGKLR.js → chunk-CPWA6RWE.js} +3 -3
- package/chunks/{chunk-P6YG6TEZ.js → chunk-DKSCN2AB.js} +1 -1
- package/chunks/{chunk-YPOA3W4O.js → chunk-GOEA3NW6.js} +877 -110
- package/chunks/{chunk-ANDKY54G.js → chunk-HHPWRY2M.js} +4019 -7299
- package/chunks/{chunk-NDJU5ZZ7.js → chunk-IFME676H.js} +3 -3
- package/chunks/{chunk-HBKCGJAV.js → chunk-IVQV574Y.js} +1 -1
- package/chunks/{chunk-W4JOXE4N.js → chunk-IXT64DV5.js} +709 -1929
- package/chunks/{chunk-PC6RCKQV.js → chunk-KAU6NLGP.js} +59 -26
- package/chunks/{chunk-FAH6V4QM.js → chunk-LGCASF2C.js} +1117 -2291
- package/chunks/{chunk-CAJJRUTV.js → chunk-NLH4LMWH.js} +1 -1
- package/chunks/chunk-OHHCGDJ2.js +5523 -0
- package/chunks/{chunk-YHWWF4QY.js → chunk-OSBPGWTE.js} +3 -3
- package/chunks/{chunk-G34QP2XW.js → chunk-TM74SSHC.js} +1 -1
- package/chunks/{chunk-VOAXLO4A.js → chunk-TO35Y326.js} +5 -721
- package/chunks/{chunk-FWAYJ2IV.js → chunk-TV27OWIW.js} +8 -8
- package/chunks/chunk-UELXHK2Y.js +1950 -0
- package/chunks/{chunk-CL5KAUM6.js → chunk-V6GHX34G.js} +274 -8
- package/chunks/{chunk-WZISK5VC.js → chunk-VWITLWXB.js} +53 -7
- package/chunks/{chunk-ER3SUMYJ.js → chunk-W6UWZFKL.js} +0 -195
- package/chunks/chunk-WSDDGFA6.js +114 -0
- package/chunks/{chunk-5T6D5BVY.js → chunk-WZRVS7SB.js} +1 -1
- package/chunks/chunk-X7LAEEUW.js +2143 -0
- package/chunks/chunk-XA2O4WXA.js +1228 -0
- package/chunks/{chunk-Y5H6E24H.js → chunk-XCISCI4T.js} +1 -1
- package/chunks/{chunk-WPQLBN4S.js → chunk-XDKB2P5X.js} +1 -1
- package/chunks/{chunk-SBMB4OL3.js → chunk-YL6YAGLL.js} +62 -8
- package/chunks/{chunk-O6SD4A36.js → chunk-ZKQ2I3S2.js} +1 -1
- package/chunks/{codex-models-TYYV4JNN.js → codex-models-NHQW45SO.js} +5 -3
- package/chunks/{commands-WF5RG4I2.js → commands-N6GN5SBF.js} +2152 -3643
- package/chunks/{db-U3WQZVAO.js → db-5IWEJUYV.js} +3 -3
- package/chunks/{disclose-67GZCDBO.js → disclose-LDNKAVRH.js} +10 -8
- package/chunks/{dist-ACC3DZUZ.js → dist-BS4CY4RG.js} +3 -1
- package/chunks/{dist-EVTN3UTT.js → dist-FSS7MBDF.js} +2 -2
- package/chunks/{dist-F6X62TQK.js → dist-L3XJWWZ6.js} +225 -192
- package/chunks/{eval-runner-SA6OUGHZ.js → eval-runner-EMEGF24P.js} +11 -11
- package/chunks/{exploit-agent-36Q7XQFP.js → exploit-agent-KW4EB7BE.js} +1 -1
- package/chunks/{exploit-autoclimb-J4OTSTZ6.js → exploit-autoclimb-CXJ2ERRO.js} +1 -1
- package/chunks/{exploit-climb-PYEJDIC4.js → exploit-climb-TJWLY4XC.js} +2 -2
- package/chunks/fix-UUKPXCFB.js +26 -0
- package/chunks/{harness-GDUMKGSE.js → harness-C5HOKIEV.js} +3 -3
- package/chunks/{hunt-scan-UDJSCISU.js → hunt-scan-KZZ444V2.js} +14 -14
- package/chunks/{identity-JTIVJSV7.js → identity-62SVRW4H.js} +1 -1
- package/chunks/{kernel-primitive-F2IXUFAX.js → kernel-primitive-Z77IR7YS.js} +2 -2
- package/chunks/{kernel-vm-runner-276LHIOV.js → kernel-vm-runner-JW77P276.js} +2 -2
- package/chunks/{memsafety-scan-NHUOGTEX.js → memsafety-scan-FCPAXIZE.js} +2 -2
- package/chunks/{native-loop-3BSYVDUI.js → native-loop-P6P5GYVJ.js} +10 -10
- package/chunks/{npm-detectors-VIYJXKFQ.js → npm-detectors-Z2ZIQCN4.js} +2 -2
- package/chunks/orchestrate-DWWUT5RC.js +58 -0
- package/chunks/{process-PNMC36JI.js → process-N245QIQG.js} +1 -4
- package/chunks/{run-CBGE6DRQ.js → run-GAFKBCTN.js} +14935 -17598
- package/chunks/{runtime-PXO5G6UV.js → runtime-H7YBR5IZ.js} +4 -5
- package/chunks/{scope-NJHIDDTN.js → scope-QWY4VQZ7.js} +4 -1
- package/chunks/{session-store-46WBZM22.js → session-store-XIDFGG7K.js} +2 -2
- package/chunks/{variant-candidates-UH2WC2HA.js → variant-candidates-7D4F5E4H.js} +3 -3
- package/chunks/{web-recon-prepass-SFXU44SS.js → web-recon-prepass-VXXBPDAV.js} +3 -3
- package/cli-path-traversal-fixture.js +352 -0
- package/dashboard/assets/bot-Bg1Tp9_d.js +1 -0
- package/dashboard/assets/dist-B_dDCPbu.js +1 -0
- package/dashboard/assets/findings-page-mayGhNx6.js +5 -0
- package/dashboard/assets/format--susmHX7.js +1 -0
- package/dashboard/assets/input-TuVPR3Zl.js +1 -0
- package/dashboard/assets/jsx-runtime-MGseXjj5.js +3 -0
- package/dashboard/assets/live-page-HWWHX99U.js +1 -0
- package/dashboard/assets/meta-tile-ckHo-w7k.js +1 -0
- package/dashboard/assets/operations-BxZ0OoXO.js +10 -0
- package/dashboard/assets/operations-app-D3d35rgo.js +46 -0
- package/dashboard/assets/overview-page-W_4IteEr.js +1 -0
- package/dashboard/assets/page-header-Bw9AJgBV.js +1 -0
- package/dashboard/assets/scans-page-CgzVXHnn.js +1 -0
- package/dashboard/assets/siren-KQj8QAnJ.js +1 -0
- package/dashboard/assets/table-8EDklulN.js +1 -0
- package/dashboard/assets/tabs-CFHPOwg8.js +1 -0
- package/dashboard/index.html +2 -3
- package/node_modules/node-addon-api/LICENSE.md +9 -0
- package/node_modules/node-addon-api/README.md +95 -0
- package/node_modules/node-addon-api/common.gypi +21 -0
- package/node_modules/node-addon-api/except.gypi +25 -0
- package/node_modules/node-addon-api/index.js +14 -0
- package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/node_modules/node-addon-api/napi-inl.h +7250 -0
- package/node_modules/node-addon-api/napi.h +3463 -0
- package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
- package/node_modules/node-addon-api/node_api.gyp +9 -0
- package/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/node_modules/node-addon-api/nothing.c +0 -0
- package/node_modules/node-addon-api/package-support.json +21 -0
- package/node_modules/node-addon-api/package.json +481 -0
- package/node_modules/node-addon-api/tools/README.md +73 -0
- package/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/node_modules/node-gyp-build/LICENSE +21 -0
- package/node_modules/node-gyp-build/README.md +58 -0
- package/node_modules/node-gyp-build/SECURITY.md +5 -0
- package/node_modules/node-gyp-build/bin.js +84 -0
- package/node_modules/node-gyp-build/build-test.js +19 -0
- package/node_modules/node-gyp-build/index.js +6 -0
- package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
- package/node_modules/node-gyp-build/optional.js +7 -0
- package/node_modules/node-gyp-build/package.json +43 -0
- package/node_modules/tree-sitter/LICENSE +21 -0
- package/node_modules/tree-sitter/README.md +90 -0
- package/node_modules/tree-sitter/binding.gyp +76 -0
- package/node_modules/tree-sitter/index.js +895 -0
- package/node_modules/tree-sitter/package.json +62 -0
- package/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/src/addon_data.h +47 -0
- package/node_modules/tree-sitter/src/binding.cc +35 -0
- package/node_modules/tree-sitter/src/conversions.cc +140 -0
- package/node_modules/tree-sitter/src/conversions.h +22 -0
- package/node_modules/tree-sitter/src/language.cc +106 -0
- package/node_modules/tree-sitter/src/language.h +17 -0
- package/node_modules/tree-sitter/src/logger.cc +70 -0
- package/node_modules/tree-sitter/src/logger.h +19 -0
- package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
- package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
- package/node_modules/tree-sitter/src/node.cc +1056 -0
- package/node_modules/tree-sitter/src/node.h +30 -0
- package/node_modules/tree-sitter/src/parser.cc +298 -0
- package/node_modules/tree-sitter/src/parser.h +35 -0
- package/node_modules/tree-sitter/src/query.cc +383 -0
- package/node_modules/tree-sitter/src/query.h +39 -0
- package/node_modules/tree-sitter/src/tree.cc +307 -0
- package/node_modules/tree-sitter/src/tree.h +45 -0
- package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
- package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
- package/node_modules/tree-sitter/tree-sitter.d.ts +211 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/LICENSE +21 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/README.md +21 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/README.md +6 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1266 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +290 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +501 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +221 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +299 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +419 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +49 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +14 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +774 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2151 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +230 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +62 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4134 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +899 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1060 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +382 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +165 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +714 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +50 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +23 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +109 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1294 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1823 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/test/fixtures/grammars/.gitkeep +0 -0
- package/node_modules/tree-sitter-c/LICENSE +21 -0
- package/node_modules/tree-sitter-c/README.md +18 -0
- package/node_modules/tree-sitter-c/binding.gyp +20 -0
- package/node_modules/tree-sitter-c/bindings/node/binding.cc +20 -0
- package/node_modules/tree-sitter-c/bindings/node/index.d.ts +28 -0
- package/node_modules/tree-sitter-c/bindings/node/index.js +7 -0
- package/node_modules/tree-sitter-c/grammar.js +1463 -0
- package/node_modules/tree-sitter-c/package.json +108 -0
- package/node_modules/tree-sitter-c/prebuilds/darwin-arm64/tree-sitter-c.node +0 -0
- package/node_modules/tree-sitter-c/prebuilds/darwin-x64/tree-sitter-c.node +0 -0
- package/node_modules/tree-sitter-c/prebuilds/linux-x64/tree-sitter-c.node +0 -0
- package/node_modules/tree-sitter-c/prebuilds/win32-x64/tree-sitter-c.node +0 -0
- package/node_modules/tree-sitter-c/queries/highlights.scm +81 -0
- package/node_modules/tree-sitter-c/queries/tags.scm +9 -0
- package/node_modules/tree-sitter-c/src/grammar.json +9682 -0
- package/node_modules/tree-sitter-c/src/node-types.json +4556 -0
- package/node_modules/tree-sitter-c/src/parser.c +113852 -0
- package/node_modules/tree-sitter-c/src/tree_sitter/alloc.h +54 -0
- package/node_modules/tree-sitter-c/src/tree_sitter/array.h +290 -0
- package/node_modules/tree-sitter-c/src/tree_sitter/parser.h +265 -0
- package/package.json +10 -3
- package/vendor/tree-sitter-0.21.1-node24.json +16 -0
- package/vendor/tree-sitter-0.21.1-node24.tgz +0 -0
- package/chunks/chunk-CGHCEN7W.js +0 -169
- package/chunks/chunk-CXKDWFNO.js +0 -102
- package/chunks/chunk-GIQKESMN.js +0 -687
- package/chunks/chunk-HPQZHOIU.js +0 -67
- package/chunks/chunk-PD2BBBKT.js +0 -245
- package/chunks/chunk-WF5W75WY.js +0 -1070
- package/chunks/fix-J2KBRJDV.js +0 -12
- package/chunks/orchestrate-DHBFRTSI.js +0 -59
- package/chunks/replay-runner-LK2XFIVG.js +0 -39
- package/dashboard/assets/bot-yILPnRgD.js +0 -1
- package/dashboard/assets/chevron-down-BeDJ-Vka.js +0 -1
- package/dashboard/assets/circle-alert-BEnMBMT-.js +0 -1
- package/dashboard/assets/client-DRYsuOGl.js +0 -9
- package/dashboard/assets/copy-Bi5vzoF9.js +0 -1
- package/dashboard/assets/desktop-BT7RkC4q.js +0 -32
- package/dashboard/assets/desktop-OaBI0E0e.css +0 -1
- package/dashboard/assets/dist-CmX-h7a4.js +0 -1
- package/dashboard/assets/dist-DAwYQmf_.js +0 -45
- package/dashboard/assets/findings-page-B4rwF6fZ.js +0 -5
- package/dashboard/assets/format-LNQSSpn6.js +0 -1
- package/dashboard/assets/jsx-runtime-C7oxC63R.js +0 -1
- package/dashboard/assets/live-page-DoNwpPAO.js +0 -1
- package/dashboard/assets/meta-tile-BMtBC-Qq.js +0 -1
- package/dashboard/assets/operations-app-ER0gg7GN.js +0 -2
- package/dashboard/assets/operations-e2CGYKB1.js +0 -4
- package/dashboard/assets/overview-page-CmeWH17A.js +0 -1
- package/dashboard/assets/page-header-CIJyycfz.js +0 -1
- package/dashboard/assets/play-Dwo-9xt6.js +0 -1
- package/dashboard/assets/scans-page-CuhzWhHx.js +0 -1
- package/dashboard/assets/search-CiooTLck.js +0 -1
- package/dashboard/assets/siren-CCBwTSuk.js +0 -1
- package/dashboard/assets/table-BgsSBdke.js +0 -1
- package/dashboard/assets/tabs-vn6v7Bk6.js +0 -1
- package/dashboard/desktop.html +0 -21
package/chunks/chunk-CGHCEN7W.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __0CreateRequire } from "node:module";
|
|
3
|
-
const require = __0CreateRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
// packages/core/dist/scope/scope.js
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
import { isIP } from "node:net";
|
|
8
|
-
var ScopePolicy = class _ScopePolicy {
|
|
9
|
-
inScope;
|
|
10
|
-
outOfScope;
|
|
11
|
-
/**
|
|
12
|
-
* Original JSON the policy was constructed from. Exposed read-only so
|
|
13
|
-
* downstream features (0#216 attribution headers) can pull their
|
|
14
|
-
* own optional blocks out of the same file without re-reading it.
|
|
15
|
-
*/
|
|
16
|
-
raw;
|
|
17
|
-
constructor(json) {
|
|
18
|
-
this.inScope = (json.in_scope ?? []).map(parseRule);
|
|
19
|
-
this.outOfScope = (json.out_of_scope ?? []).map(parseRule);
|
|
20
|
-
this.raw = json;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Load a policy from a JSON file on disk.
|
|
24
|
-
*
|
|
25
|
-
* Bubbles up the underlying ENOENT/JSON-parse error to the caller; the
|
|
26
|
-
* scan CLI is responsible for translating these into a user-facing
|
|
27
|
-
* "scope file not found / malformed" message and exiting non-zero before
|
|
28
|
-
* the agent ever boots.
|
|
29
|
-
*/
|
|
30
|
-
static fromJsonFile(path) {
|
|
31
|
-
const raw = readFileSync(path, "utf-8");
|
|
32
|
-
let parsed;
|
|
33
|
-
try {
|
|
34
|
-
parsed = JSON.parse(raw);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
37
|
-
throw new Error(`Scope file ${path} is not valid JSON: ${msg}`);
|
|
38
|
-
}
|
|
39
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
40
|
-
throw new Error(`Scope file ${path} must be a JSON object with in_scope/out_of_scope arrays`);
|
|
41
|
-
}
|
|
42
|
-
return _ScopePolicy.fromJson(parsed);
|
|
43
|
-
}
|
|
44
|
-
static fromJson(obj) {
|
|
45
|
-
return new _ScopePolicy(obj);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Decide whether a URL is allowed by this policy.
|
|
49
|
-
*
|
|
50
|
-
* The contract used by every call site:
|
|
51
|
-
* - allowed=true → URL is in scope, callers may proceed.
|
|
52
|
-
* - allowed=false → URL is out of scope; callers MUST surface this as
|
|
53
|
-
* a hard error (`ToolResult.error`), not a warning.
|
|
54
|
-
*
|
|
55
|
-
* `reason` is human-readable and meant to be embedded in the error
|
|
56
|
-
* message returned to the agent so it can self-correct.
|
|
57
|
-
*/
|
|
58
|
-
match(url) {
|
|
59
|
-
let host;
|
|
60
|
-
try {
|
|
61
|
-
host = normalizeScopeHostname(new URL(url).hostname);
|
|
62
|
-
} catch {
|
|
63
|
-
return { allowed: false, reason: `out-of-scope: not a valid URL (${url})` };
|
|
64
|
-
}
|
|
65
|
-
const denyHit = this.outOfScope.find((rule) => matches(rule, host));
|
|
66
|
-
if (denyHit) {
|
|
67
|
-
return { allowed: false, reason: `out-of-scope: host '${host}' matches deny rule '${denyHit.raw}'` };
|
|
68
|
-
}
|
|
69
|
-
if (this.inScope.length === 0) {
|
|
70
|
-
return { allowed: false, reason: `out-of-scope: host '${host}' (no in_scope rules defined)` };
|
|
71
|
-
}
|
|
72
|
-
const allowHit = this.inScope.find((rule) => matches(rule, host));
|
|
73
|
-
if (allowHit) {
|
|
74
|
-
return { allowed: true, reason: `in-scope: host '${host}' matches '${allowHit.raw}'` };
|
|
75
|
-
}
|
|
76
|
-
return { allowed: false, reason: `out-of-scope: host '${host}' did not match any in_scope rule` };
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
function extractUrls(text) {
|
|
80
|
-
const re = /https?:\/\/[^\s'"`<>|]+/gi;
|
|
81
|
-
const out = [];
|
|
82
|
-
let m;
|
|
83
|
-
while ((m = re.exec(text)) !== null) {
|
|
84
|
-
let url = m[0];
|
|
85
|
-
while (url.length > 0 && /[.,;:)\]}]$/.test(url)) {
|
|
86
|
-
url = url.slice(0, -1);
|
|
87
|
-
}
|
|
88
|
-
if (url.length > 0)
|
|
89
|
-
out.push(url);
|
|
90
|
-
}
|
|
91
|
-
return out;
|
|
92
|
-
}
|
|
93
|
-
function loadScope(path) {
|
|
94
|
-
return ScopePolicy.fromJsonFile(path);
|
|
95
|
-
}
|
|
96
|
-
function matchUrl(url, policy) {
|
|
97
|
-
return policy.match(url);
|
|
98
|
-
}
|
|
99
|
-
function normalizeScopeHostname(hostname) {
|
|
100
|
-
const normalized = hostname.toLowerCase().replace(/\.+$/, "");
|
|
101
|
-
const address = normalized.startsWith("[") && normalized.endsWith("]") ? normalized.slice(1, -1) : normalized;
|
|
102
|
-
return isIP(address) === 6 ? new URL(`http://[${address}]/`).hostname : normalized;
|
|
103
|
-
}
|
|
104
|
-
function parseRule(raw) {
|
|
105
|
-
if (typeof raw !== "string" || raw.trim().length === 0) {
|
|
106
|
-
throw new Error(`Invalid scope rule: ${JSON.stringify(raw)} (must be a non-empty string)`);
|
|
107
|
-
}
|
|
108
|
-
const rule = raw.trim().toLowerCase();
|
|
109
|
-
if (rule.includes("/")) {
|
|
110
|
-
const parts = rule.split("/");
|
|
111
|
-
if (parts.length !== 2) {
|
|
112
|
-
throw new Error(`Invalid CIDR '${raw}': expected exactly one '/'`);
|
|
113
|
-
}
|
|
114
|
-
const [ip, prefixStr] = parts;
|
|
115
|
-
if (!/^\d+$/.test(prefixStr)) {
|
|
116
|
-
throw new Error(`Invalid CIDR prefix in '${raw}': must be a non-negative integer 0-32`);
|
|
117
|
-
}
|
|
118
|
-
const prefix = Number(prefixStr);
|
|
119
|
-
if (prefix < 0 || prefix > 32) {
|
|
120
|
-
throw new Error(`Invalid CIDR prefix in '${raw}': must be 0-32`);
|
|
121
|
-
}
|
|
122
|
-
if (isIP(ip) !== 4) {
|
|
123
|
-
throw new Error(`Invalid CIDR '${raw}': only IPv4 CIDR is supported`);
|
|
124
|
-
}
|
|
125
|
-
return { raw, kind: "cidr", cidr: { network: ipv4ToInt(ip), prefix } };
|
|
126
|
-
}
|
|
127
|
-
if (rule.startsWith("*.")) {
|
|
128
|
-
const suffix = normalizeScopeHostname(rule.slice(2));
|
|
129
|
-
if (suffix.length === 0 || suffix.includes("*")) {
|
|
130
|
-
throw new Error(`Invalid wildcard rule '${raw}': must be of the form '*.domain.tld'`);
|
|
131
|
-
}
|
|
132
|
-
return { raw, kind: "wildcard", suffix };
|
|
133
|
-
}
|
|
134
|
-
if (rule.includes("*")) {
|
|
135
|
-
throw new Error(`Invalid scope rule '${raw}': only leading '*.' wildcards are supported`);
|
|
136
|
-
}
|
|
137
|
-
return { raw, kind: "exact", host: normalizeScopeHostname(rule) };
|
|
138
|
-
}
|
|
139
|
-
function matches(rule, host) {
|
|
140
|
-
switch (rule.kind) {
|
|
141
|
-
case "exact":
|
|
142
|
-
return rule.host === host;
|
|
143
|
-
case "wildcard": {
|
|
144
|
-
const suffix = "." + rule.suffix;
|
|
145
|
-
return host !== rule.suffix && host.endsWith(suffix);
|
|
146
|
-
}
|
|
147
|
-
case "cidr": {
|
|
148
|
-
if (isIP(host) !== 4)
|
|
149
|
-
return false;
|
|
150
|
-
const { network, prefix } = rule.cidr;
|
|
151
|
-
if (prefix === 0)
|
|
152
|
-
return true;
|
|
153
|
-
const mask = prefix === 32 ? 4294967295 : ~((1 << 32 - prefix) - 1) >>> 0;
|
|
154
|
-
return (ipv4ToInt(host) & mask) >>> 0 === (network & mask) >>> 0;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function ipv4ToInt(ip) {
|
|
159
|
-
const parts = ip.split(".").map((p) => Number(p));
|
|
160
|
-
return (parts[0] << 24 | parts[1] << 16 | parts[2] << 8 | parts[3]) >>> 0;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export {
|
|
164
|
-
ScopePolicy,
|
|
165
|
-
extractUrls,
|
|
166
|
-
loadScope,
|
|
167
|
-
matchUrl,
|
|
168
|
-
normalizeScopeHostname
|
|
169
|
-
};
|
package/chunks/chunk-CXKDWFNO.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __0CreateRequire } from "node:module";
|
|
3
|
-
const require = __0CreateRequire(import.meta.url);
|
|
4
|
-
import {
|
|
5
|
-
createPresentationEvent
|
|
6
|
-
} from "./chunk-PC6RCKQV.js";
|
|
7
|
-
|
|
8
|
-
// packages/core/dist/events/bus.js
|
|
9
|
-
function presentationEventSink(sink, options = {}) {
|
|
10
|
-
let sequence = 0;
|
|
11
|
-
const source = options.source ?? "core";
|
|
12
|
-
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
13
|
-
return {
|
|
14
|
-
emit(type, payload) {
|
|
15
|
-
const scanId = typeof payload["scan_id"] === "string" ? payload["scan_id"] : typeof payload["scanId"] === "string" ? payload["scanId"] : void 0;
|
|
16
|
-
const sessionId = typeof payload["session_id"] === "string" ? payload["session_id"] : typeof payload["sessionId"] === "string" ? payload["sessionId"] : void 0;
|
|
17
|
-
sink.emit(createPresentationEvent({
|
|
18
|
-
source,
|
|
19
|
-
sequence: ++sequence,
|
|
20
|
-
at: now(),
|
|
21
|
-
eventType: type,
|
|
22
|
-
payload,
|
|
23
|
-
...scanId ? { scanId } : {},
|
|
24
|
-
...sessionId ? { sessionId } : {}
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
var EventBus = class {
|
|
30
|
-
sinks = [];
|
|
31
|
-
/** Subscribe a sink. Returns an unsubscribe function. */
|
|
32
|
-
subscribe(sink) {
|
|
33
|
-
this.sinks.push(sink);
|
|
34
|
-
return () => {
|
|
35
|
-
const idx = this.sinks.indexOf(sink);
|
|
36
|
-
if (idx >= 0)
|
|
37
|
-
this.sinks.splice(idx, 1);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/** Remove every subscriber — primarily useful in tests. */
|
|
41
|
-
clear() {
|
|
42
|
-
this.sinks = [];
|
|
43
|
-
}
|
|
44
|
-
/** Returns a read-only snapshot of the current sinks (for tests). */
|
|
45
|
-
get size() {
|
|
46
|
-
return this.sinks.length;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Fan out a single event to every subscribed sink. Exceptions thrown by
|
|
50
|
-
* any sink are swallowed — one misbehaving consumer must never abort a
|
|
51
|
-
* scan. Diagnostic is written to stderr so the failure is visible.
|
|
52
|
-
*/
|
|
53
|
-
emit(type, payload) {
|
|
54
|
-
const snapshot = this.sinks.slice();
|
|
55
|
-
for (const sink of snapshot) {
|
|
56
|
-
try {
|
|
57
|
-
sink.emit(type, payload);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
60
|
-
try {
|
|
61
|
-
process.stderr.write(`[0 event-bus] sink threw on ${type}: ${msg}
|
|
62
|
-
`);
|
|
63
|
-
} catch {
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var eventBus = new EventBus();
|
|
70
|
-
var cloudEventSink = {
|
|
71
|
-
emit(type, payload) {
|
|
72
|
-
const prefix = `ZERO_EVENT_${type.toUpperCase()}`;
|
|
73
|
-
let line;
|
|
74
|
-
try {
|
|
75
|
-
line = `${prefix} ${JSON.stringify(payload)}`;
|
|
76
|
-
} catch {
|
|
77
|
-
line = `${prefix} {"_unserializable":true}`;
|
|
78
|
-
}
|
|
79
|
-
process.stdout.write(line + "\n");
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var cloudSinkSubscribed = false;
|
|
83
|
-
function maybeSubscribeCloudEventSink() {
|
|
84
|
-
if (cloudSinkSubscribed)
|
|
85
|
-
return;
|
|
86
|
-
const flag = process.env["ZERO_CLOUD_EVENTS"];
|
|
87
|
-
if (flag && flag !== "0" && flag.toLowerCase() !== "false") {
|
|
88
|
-
eventBus.subscribe(cloudEventSink);
|
|
89
|
-
cloudSinkSubscribed = true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function isCloudEventSinkActive() {
|
|
93
|
-
return cloudSinkSubscribed;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export {
|
|
97
|
-
presentationEventSink,
|
|
98
|
-
eventBus,
|
|
99
|
-
cloudEventSink,
|
|
100
|
-
maybeSubscribeCloudEventSink,
|
|
101
|
-
isCloudEventSinkActive
|
|
102
|
-
};
|