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
|
@@ -2,11 +2,30 @@
|
|
|
2
2
|
import { createRequire as __0CreateRequire } from "node:module";
|
|
3
3
|
const require = __0CreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
FEEDBACK_OPT_OUT_ENV,
|
|
6
|
+
PROVIDERS,
|
|
7
|
+
accountEnvPatch,
|
|
8
|
+
loadAccountStore,
|
|
9
|
+
loadGlobalSettings,
|
|
10
|
+
loadLayeredSettings,
|
|
11
|
+
maybeLoadCodexAuth,
|
|
12
|
+
normalizeSettings,
|
|
13
|
+
saveSettings,
|
|
14
|
+
submissionBlockedReason
|
|
15
|
+
} from "./chunk-GOEA3NW6.js";
|
|
16
|
+
import {
|
|
17
|
+
runSmolvmWorkbench
|
|
18
|
+
} from "./chunk-LGCASF2C.js";
|
|
19
|
+
import {
|
|
20
|
+
ANALYTICS_LEVEL_ENV,
|
|
21
|
+
getSmolvmWorkbenchStatus,
|
|
22
|
+
isAdmittedSmolvmWorkbench,
|
|
23
|
+
levelAtLeast,
|
|
24
|
+
resolveAnalyticsLevel
|
|
25
|
+
} from "./chunk-OHHCGDJ2.js";
|
|
7
26
|
import {
|
|
8
27
|
homeStateDir
|
|
9
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-KAU6NLGP.js";
|
|
10
29
|
import {
|
|
11
30
|
__commonJS,
|
|
12
31
|
__require,
|
|
@@ -3023,9 +3042,247 @@ var {
|
|
|
3023
3042
|
Help
|
|
3024
3043
|
} = import_index.default;
|
|
3025
3044
|
|
|
3045
|
+
// packages/cli/src/workbench.ts
|
|
3046
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
3047
|
+
import { homedir } from "node:os";
|
|
3048
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
3049
|
+
import { execFile } from "node:child_process";
|
|
3050
|
+
import { promisify } from "node:util";
|
|
3051
|
+
var execFileAsync = promisify(execFile);
|
|
3052
|
+
var WORKBENCH_INNER_ARGUMENT = "--workbench-inner";
|
|
3053
|
+
function workbenchConfigPath(home = process.env.HOME || homedir()) {
|
|
3054
|
+
return join(homeStateDir(home), "workbench.json");
|
|
3055
|
+
}
|
|
3056
|
+
function defaultWorkbenchStateRoot(home = process.env.HOME || homedir()) {
|
|
3057
|
+
return join(homeStateDir(home), "workbench");
|
|
3058
|
+
}
|
|
3059
|
+
function positiveInteger(value, maximum) {
|
|
3060
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= maximum;
|
|
3061
|
+
}
|
|
3062
|
+
function isPinnedWorkbenchImageReference(value) {
|
|
3063
|
+
return typeof value === "string" && /^[a-z0-9][a-z0-9._:/-]*@sha256:[a-f0-9]{64}$/.test(value) && !value.slice(0, value.indexOf("@")).slice(value.lastIndexOf("/") + 1).includes(":");
|
|
3064
|
+
}
|
|
3065
|
+
function normalizeWorkbenchConfig(raw) {
|
|
3066
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("Invalid workbench operator choices.");
|
|
3067
|
+
const config = raw;
|
|
3068
|
+
const approvedImages = [];
|
|
3069
|
+
if (config.approvedImages !== void 0) {
|
|
3070
|
+
if (!Array.isArray(config.approvedImages)) throw new Error("Invalid workbench sandbox image catalog.");
|
|
3071
|
+
const references = /* @__PURE__ */ new Set();
|
|
3072
|
+
for (const rawImage of config.approvedImages) {
|
|
3073
|
+
if (typeof rawImage !== "object" || rawImage === null || Array.isArray(rawImage)) throw new Error("Invalid workbench sandbox image catalog.");
|
|
3074
|
+
const image = rawImage;
|
|
3075
|
+
if (!isPinnedWorkbenchImageReference(image.reference) || typeof image.archive !== "string" || !isAbsolute(image.archive) || typeof image.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(image.digest) || references.has(image.reference)) throw new Error("Sandbox image grants require unique immutable repository@sha256 references and approved local archives.");
|
|
3076
|
+
references.add(image.reference);
|
|
3077
|
+
approvedImages.push({ reference: image.reference, archive: image.archive, digest: image.digest });
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
if (config.schemaVersion !== 1 || typeof config.image !== "string" || !isAbsolute(config.image) || typeof config.imageDigest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(config.imageDigest) || typeof config.stateRoot !== "string" || !isAbsolute(config.stateRoot) || config.workspaceRoot !== void 0 && (typeof config.workspaceRoot !== "string" || !isAbsolute(config.workspaceRoot)) || !Array.isArray(config.providers) || config.providers.some((id) => typeof id !== "string" || !PROVIDERS.some((provider) => provider.id === id)) || typeof config.github !== "boolean" || !positiveInteger(config.cpus, 64) || !positiveInteger(config.memoryMb, 262144) || !positiveInteger(config.storageGb, 1024)) {
|
|
3081
|
+
throw new Error("Invalid workbench operator choices.");
|
|
3082
|
+
}
|
|
3083
|
+
return {
|
|
3084
|
+
schemaVersion: 1,
|
|
3085
|
+
image: config.image,
|
|
3086
|
+
imageDigest: config.imageDigest,
|
|
3087
|
+
stateRoot: config.stateRoot,
|
|
3088
|
+
...config.workspaceRoot === void 0 ? {} : { workspaceRoot: config.workspaceRoot },
|
|
3089
|
+
providers: [...new Set(config.providers)],
|
|
3090
|
+
github: config.github,
|
|
3091
|
+
cpus: config.cpus,
|
|
3092
|
+
memoryMb: config.memoryMb,
|
|
3093
|
+
storageGb: config.storageGb,
|
|
3094
|
+
...approvedImages.length ? { approvedImages } : {}
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
function loadWorkbenchConfig(home) {
|
|
3098
|
+
const file = workbenchConfigPath(home);
|
|
3099
|
+
if (!existsSync(file)) return void 0;
|
|
3100
|
+
try {
|
|
3101
|
+
const stat = lstatSync(file);
|
|
3102
|
+
if (!stat.isFile() || stat.isSymbolicLink() || (stat.mode & 63) !== 0 || stat.uid !== process.getuid?.()) {
|
|
3103
|
+
throw new Error("Workbench configuration must be an operator-owned, private regular file (mode 0600).");
|
|
3104
|
+
}
|
|
3105
|
+
return normalizeWorkbenchConfig(JSON.parse(readFileSync(file, "utf8")));
|
|
3106
|
+
} catch (error) {
|
|
3107
|
+
if (error instanceof Error && error.message.startsWith("Workbench configuration must")) throw error;
|
|
3108
|
+
throw new Error(`Unreadable or invalid workbench configuration at ${file}. Repair the operator choices before setup or launch; no profile fallback is allowed.`);
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
function saveWorkbenchConfig(config, home) {
|
|
3112
|
+
const path = workbenchConfigPath(home);
|
|
3113
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
3114
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
3115
|
+
writeFileSync(temporary, `${JSON.stringify(normalizeWorkbenchConfig(config), null, 2)}
|
|
3116
|
+
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
3117
|
+
renameSync(temporary, path);
|
|
3118
|
+
chmodSync(path, 384);
|
|
3119
|
+
}
|
|
3120
|
+
var PROVIDER_CONFIGURATION = {
|
|
3121
|
+
"chatgpt-codex": ["ZERO_CHATGPT_ACCOUNT_ID", "ZERO_CHATGPT_BASE_URL"],
|
|
3122
|
+
deepseek: ["DEEPSEEK_BASE_URL"],
|
|
3123
|
+
openrouter: ["OPENROUTER_BASE_URL"],
|
|
3124
|
+
azure: ["AZURE_OPENAI_BASE_URL", "AZURE_OPENAI_API_VERSION", "AZURE_OPENAI_DEPLOYMENT", "OPENAI_BASE_URL"],
|
|
3125
|
+
openai: ["OPENAI_BASE_URL"],
|
|
3126
|
+
"z-ai": ["Z_AI_BASE_URL"],
|
|
3127
|
+
kimi: ["KIMI_BASE_URL"],
|
|
3128
|
+
qwen: ["QWEN_BASE_URL"],
|
|
3129
|
+
xai: ["XAI_BASE_URL"],
|
|
3130
|
+
opencode: ["OPENCODE_BASE_URL"],
|
|
3131
|
+
copilot: ["COPILOT_BASE_URL"],
|
|
3132
|
+
google: ["GOOGLE_CLOUD_PROJECT", "ZERO_GEMINI_PROJECT"],
|
|
3133
|
+
anthropic: ["ANTHROPIC_BASE_URL"]
|
|
3134
|
+
};
|
|
3135
|
+
function selectedWorkbenchEnvironment(config, env, accounts) {
|
|
3136
|
+
const selected = { version: 2, providers: {} };
|
|
3137
|
+
const result = {};
|
|
3138
|
+
for (const id of config.providers) {
|
|
3139
|
+
const provider = PROVIDERS.find((candidate) => candidate.id === id);
|
|
3140
|
+
if (!provider) throw new Error(`Unknown workbench provider grant: ${id}`);
|
|
3141
|
+
const account = accounts.providers[id];
|
|
3142
|
+
if (account) selected.providers[id] = account;
|
|
3143
|
+
for (const name of [...provider.envVars, ...PROVIDER_CONFIGURATION[id] ?? []]) {
|
|
3144
|
+
const value = env[name];
|
|
3145
|
+
if (value?.trim()) result[name] = value;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
Object.assign(result, accountEnvPatch(selected, result));
|
|
3149
|
+
if (config.github) {
|
|
3150
|
+
const token = env.GH_TOKEN?.trim() || env.GITHUB_TOKEN?.trim();
|
|
3151
|
+
if (token) result.GH_TOKEN = token;
|
|
3152
|
+
}
|
|
3153
|
+
for (const name of ["TERM", "COLORTERM", "NO_COLOR", "LANG", "LC_ALL"]) {
|
|
3154
|
+
const value = env[name];
|
|
3155
|
+
if (value !== void 0) result[name] = value;
|
|
3156
|
+
}
|
|
3157
|
+
return result;
|
|
3158
|
+
}
|
|
3159
|
+
async function integrationEnvironment(config, home) {
|
|
3160
|
+
const accounts = config.providers.length ? loadAccountStore(home) : { version: 2, providers: {} };
|
|
3161
|
+
const environment = selectedWorkbenchEnvironment(config, process.env, accounts);
|
|
3162
|
+
if (config.providers.includes("chatgpt-codex")) {
|
|
3163
|
+
const codexEnvironment = {
|
|
3164
|
+
...environment,
|
|
3165
|
+
ZERO_CHATGPT_AUTH_FILE: process.env.ZERO_CHATGPT_AUTH_FILE,
|
|
3166
|
+
ZERO_CODEX_AUTH_JSON_PATH: process.env.ZERO_CODEX_AUTH_JSON_PATH
|
|
3167
|
+
};
|
|
3168
|
+
maybeLoadCodexAuth({ env: codexEnvironment, home });
|
|
3169
|
+
for (const name of ["ZERO_CHATGPT_ACCESS_TOKEN", "ZERO_CHATGPT_OAUTH_REFRESH_TOKEN"]) {
|
|
3170
|
+
const value = codexEnvironment[name];
|
|
3171
|
+
if (value) environment[name] = value;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
if (config.github && !environment.GH_TOKEN) {
|
|
3175
|
+
try {
|
|
3176
|
+
const { stdout } = await execFileAsync("gh", ["auth", "token"], { encoding: "utf8", timeout: 1e4, maxBuffer: 65536 });
|
|
3177
|
+
if (stdout.trim()) environment.GH_TOKEN = stdout.trim();
|
|
3178
|
+
} catch {
|
|
3179
|
+
throw new Error("GitHub grant is enabled but no token is available. Connect gh on the host or run 0 workbench setup --no-github.");
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
return environment;
|
|
3183
|
+
}
|
|
3184
|
+
function resolveWorkbenchGuestSettings(settings, env = process.env) {
|
|
3185
|
+
const privacy = { [ANALYTICS_LEVEL_ENV]: env[ANALYTICS_LEVEL_ENV] ?? settings.analyticsLevel };
|
|
3186
|
+
for (const name of FEEDBACK_OPT_OUT_ENV) privacy[name] = env[name];
|
|
3187
|
+
const environmentLevel = resolveAnalyticsLevel(privacy);
|
|
3188
|
+
return normalizeSettings({
|
|
3189
|
+
...settings,
|
|
3190
|
+
executionProfile: "local",
|
|
3191
|
+
updatePolicy: "off",
|
|
3192
|
+
analyticsLevel: levelAtLeast(environmentLevel, settings.analyticsLevel) ? settings.analyticsLevel : environmentLevel,
|
|
3193
|
+
diagnosticReporting: submissionBlockedReason(privacy, { allowCloud: false }) === "opt-out" ? "off" : settings.diagnosticReporting
|
|
3194
|
+
});
|
|
3195
|
+
}
|
|
3196
|
+
function workbenchNetworkEnabled(env = process.env) {
|
|
3197
|
+
return submissionBlockedReason({ ZERO_OFFLINE: env.ZERO_OFFLINE }, { allowCloud: false }) !== "opt-out";
|
|
3198
|
+
}
|
|
3199
|
+
async function launchConfiguredWorkbench(args) {
|
|
3200
|
+
const home = process.env.HOME || homedir();
|
|
3201
|
+
if (args[0] === WORKBENCH_INNER_ARGUMENT) {
|
|
3202
|
+
if (process.platform !== "linux" || !isAdmittedSmolvmWorkbench()) {
|
|
3203
|
+
throw new Error("Missing authenticated SmolVM broker admission; refusing internal invocation.");
|
|
3204
|
+
}
|
|
3205
|
+
process.argv = [process.argv[0], process.argv[1], ...args.slice(1)];
|
|
3206
|
+
return void 0;
|
|
3207
|
+
}
|
|
3208
|
+
if (process.platform === "linux" && isAdmittedSmolvmWorkbench()) return void 0;
|
|
3209
|
+
if (args[0] === "workbench" || args[0] === "config") return void 0;
|
|
3210
|
+
const hostSettings = loadGlobalSettings(home, { requireExecutionProfile: existsSync(workbenchConfigPath(home)) });
|
|
3211
|
+
if (hostSettings.executionProfile !== "smolvm") return void 0;
|
|
3212
|
+
const config = loadWorkbenchConfig(home);
|
|
3213
|
+
if (!config) throw new Error("SmolVM profile is selected but no workbench is configured. Run 0 workbench setup --image <approved-archive>.");
|
|
3214
|
+
const workspaceRoot = realpathSync(config.workspaceRoot ?? process.cwd());
|
|
3215
|
+
if (!lstatSync(workspaceRoot).isDirectory()) throw new Error("The configured workbench workspace is not a directory.");
|
|
3216
|
+
const status = await getSmolvmWorkbenchStatus({ stateRoot: config.stateRoot, image: config.image });
|
|
3217
|
+
if (status.retainedRuns.length) throw new Error("SmolVM has retained admission from an unproven cleanup. Resolve it before launching another workbench.");
|
|
3218
|
+
if (!status.platformSupported || !status.runtimeReady || !status.imageApproved) {
|
|
3219
|
+
throw new Error(status.error ?? "SmolVM runtime or approved image is unavailable. Run 0 workbench setup; host fallback is refused.");
|
|
3220
|
+
}
|
|
3221
|
+
const environment = await integrationEnvironment(config, home);
|
|
3222
|
+
const network = workbenchNetworkEnabled();
|
|
3223
|
+
if (!network) environment.ZERO_OFFLINE = "1";
|
|
3224
|
+
const guestState = join(config.stateRoot, "guest-state");
|
|
3225
|
+
mkdirSync(guestState, { recursive: true, mode: 448 });
|
|
3226
|
+
if (!lstatSync(guestState).isDirectory() || lstatSync(guestState).isSymbolicLink()) throw new Error("Workbench guest-state must be a real private directory.");
|
|
3227
|
+
const settingsFile = join(guestState, "tui-settings.json");
|
|
3228
|
+
const temporarySettings = `${settingsFile}.${process.pid}.tmp`;
|
|
3229
|
+
writeFileSync(temporarySettings, `${JSON.stringify(resolveWorkbenchGuestSettings(hostSettings), null, 2)}
|
|
3230
|
+
`, { mode: 384, flag: "wx" });
|
|
3231
|
+
renameSync(temporarySettings, settingsFile);
|
|
3232
|
+
const controller = new AbortController();
|
|
3233
|
+
let signalCode;
|
|
3234
|
+
const interrupt = () => {
|
|
3235
|
+
signalCode = 130;
|
|
3236
|
+
controller.abort();
|
|
3237
|
+
};
|
|
3238
|
+
const terminate = () => {
|
|
3239
|
+
signalCode = 143;
|
|
3240
|
+
controller.abort();
|
|
3241
|
+
};
|
|
3242
|
+
const hangup = () => {
|
|
3243
|
+
signalCode = 129;
|
|
3244
|
+
controller.abort();
|
|
3245
|
+
};
|
|
3246
|
+
process.once("SIGINT", interrupt);
|
|
3247
|
+
process.once("SIGTERM", terminate);
|
|
3248
|
+
process.once("SIGHUP", hangup);
|
|
3249
|
+
let result;
|
|
3250
|
+
try {
|
|
3251
|
+
result = await runSmolvmWorkbench({
|
|
3252
|
+
image: config.image,
|
|
3253
|
+
workspaceRoot,
|
|
3254
|
+
stateRoot: config.stateRoot,
|
|
3255
|
+
command: ["/usr/local/bin/0", WORKBENCH_INNER_ARGUMENT, ...args],
|
|
3256
|
+
environment,
|
|
3257
|
+
network,
|
|
3258
|
+
tty: !!process.stdin.isTTY && !!process.stdout.isTTY,
|
|
3259
|
+
cpus: config.cpus,
|
|
3260
|
+
memoryMb: config.memoryMb,
|
|
3261
|
+
storageGb: config.storageGb,
|
|
3262
|
+
signal: controller.signal,
|
|
3263
|
+
approvedImages: config.approvedImages ?? []
|
|
3264
|
+
});
|
|
3265
|
+
} finally {
|
|
3266
|
+
process.removeListener("SIGINT", interrupt);
|
|
3267
|
+
process.removeListener("SIGTERM", terminate);
|
|
3268
|
+
process.removeListener("SIGHUP", hangup);
|
|
3269
|
+
}
|
|
3270
|
+
if (result.cleanupFailed) {
|
|
3271
|
+
process.stderr.write("[0] SmolVM cleanup could not be proven. Workbench admission/state is retained; host execution is refused.\n");
|
|
3272
|
+
return 125;
|
|
3273
|
+
}
|
|
3274
|
+
if (result.error) process.stderr.write(`[0] ${result.error}
|
|
3275
|
+
`);
|
|
3276
|
+
if (result.timedOut) return 124;
|
|
3277
|
+
return signalCode ?? result.exitCode ?? 125;
|
|
3278
|
+
}
|
|
3279
|
+
function selectWorkbenchProfile(profile, home) {
|
|
3280
|
+
if (!saveSettings({ ...loadGlobalSettings(home), executionProfile: profile }, home)) throw new Error("Could not persist the operator execution profile.");
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3026
3283
|
// packages/cli/src/utils/update-check.ts
|
|
3027
|
-
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
3028
|
-
import { join } from "node:path";
|
|
3284
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
3285
|
+
import { join as join2 } from "node:path";
|
|
3029
3286
|
import { spawn } from "node:child_process";
|
|
3030
3287
|
var REPO = "0sec-labs/0";
|
|
3031
3288
|
var INSTALL_URL = `https://raw.githubusercontent.com/${REPO}/main/install.sh`;
|
|
@@ -3080,7 +3337,7 @@ function recent(timestamp, now) {
|
|
|
3080
3337
|
}
|
|
3081
3338
|
function readCache() {
|
|
3082
3339
|
try {
|
|
3083
|
-
const raw = JSON.parse(
|
|
3340
|
+
const raw = JSON.parse(readFileSync2(join2(homeStateDir(), "last-update-check"), "utf8"));
|
|
3084
3341
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
3085
3342
|
const value = raw;
|
|
3086
3343
|
if (typeof value.lastCheckedAt !== "string") return null;
|
|
@@ -3096,8 +3353,8 @@ function readCache() {
|
|
|
3096
3353
|
}
|
|
3097
3354
|
function writeCache(cache) {
|
|
3098
3355
|
try {
|
|
3099
|
-
|
|
3100
|
-
|
|
3356
|
+
mkdirSync2(homeStateDir(), { recursive: true });
|
|
3357
|
+
writeFileSync2(join2(homeStateDir(), "last-update-check"), JSON.stringify(cache));
|
|
3101
3358
|
} catch {
|
|
3102
3359
|
}
|
|
3103
3360
|
}
|
|
@@ -3245,6 +3502,15 @@ export {
|
|
|
3245
3502
|
InvalidArgumentError,
|
|
3246
3503
|
Command,
|
|
3247
3504
|
Option,
|
|
3505
|
+
workbenchConfigPath,
|
|
3506
|
+
defaultWorkbenchStateRoot,
|
|
3507
|
+
isPinnedWorkbenchImageReference,
|
|
3508
|
+
loadWorkbenchConfig,
|
|
3509
|
+
saveWorkbenchConfig,
|
|
3510
|
+
resolveWorkbenchGuestSettings,
|
|
3511
|
+
workbenchNetworkEnabled,
|
|
3512
|
+
launchConfiguredWorkbench,
|
|
3513
|
+
selectWorkbenchProfile,
|
|
3248
3514
|
performAutoUpdate,
|
|
3249
3515
|
runStartupUpdate
|
|
3250
3516
|
};
|
|
@@ -4,7 +4,7 @@ const require = __0CreateRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
homeStateDir,
|
|
6
6
|
runStateDir
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KAU6NLGP.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-VCSFCHAJ.js";
|
|
@@ -409,6 +409,12 @@ var findings = sqliteTable("findings", {
|
|
|
409
409
|
* `verificationSpec`: the blob is read and written whole.
|
|
410
410
|
*/
|
|
411
411
|
verificationResult: text("verificationResult"),
|
|
412
|
+
/**
|
|
413
|
+
* JSON-stringified safe code-only source-verification summary. NULL when
|
|
414
|
+
* no scoped source workspace/spec was available or data is unusable; it
|
|
415
|
+
* never carries canonical replay status.
|
|
416
|
+
*/
|
|
417
|
+
sourceVerification: text("sourceVerification"),
|
|
412
418
|
/**
|
|
413
419
|
* JSON-stringified Finding["reviewAnnotation"] — the scoped source
|
|
414
420
|
* reference (`path` + line range, optional suggestion / knownMarker)
|
|
@@ -873,6 +879,9 @@ var osecDB = class {
|
|
|
873
879
|
if (!colNames.has("reviewAnnotation")) {
|
|
874
880
|
this.sqlite.exec("ALTER TABLE findings ADD COLUMN reviewAnnotation TEXT");
|
|
875
881
|
}
|
|
882
|
+
if (!colNames.has("sourceVerification")) {
|
|
883
|
+
this.sqlite.exec("ALTER TABLE findings ADD COLUMN sourceVerification TEXT");
|
|
884
|
+
}
|
|
876
885
|
this.sqlite.exec("UPDATE findings SET fingerprint = id WHERE fingerprint IS NULL OR fingerprint = ''");
|
|
877
886
|
this.sqlite.exec("UPDATE findings SET triageStatus = 'new' WHERE triageStatus IS NULL OR triageStatus = ''");
|
|
878
887
|
this.sqlite.exec(`
|
|
@@ -1364,6 +1373,7 @@ var osecDB = class {
|
|
|
1364
1373
|
const semanticDedupeJson = finding.semanticDedupe ? JSON.stringify(finding.semanticDedupe) : null;
|
|
1365
1374
|
const verificationResultJson = serializeFindingVerificationResult(finding.verification_result);
|
|
1366
1375
|
const reviewAnnotationJson = serializeFindingReviewAnnotation(finding.reviewAnnotation);
|
|
1376
|
+
const sourceVerificationJson = serializeFindingSourceVerification(finding.sourceVerification);
|
|
1367
1377
|
const candidateFindingRank = finding.findingRank;
|
|
1368
1378
|
const findingRank = typeof candidateFindingRank === "number" && Number.isSafeInteger(candidateFindingRank) && candidateFindingRank > 0 ? candidateFindingRank : null;
|
|
1369
1379
|
const derivedEvidence = deriveEvidenceFromPocSteps(finding);
|
|
@@ -1400,6 +1410,7 @@ var osecDB = class {
|
|
|
1400
1410
|
findingRank,
|
|
1401
1411
|
verificationResult: verificationResultJson,
|
|
1402
1412
|
reviewAnnotation: reviewAnnotationJson,
|
|
1413
|
+
sourceVerification: sourceVerificationJson,
|
|
1403
1414
|
timestamp: finding.timestamp
|
|
1404
1415
|
}).onConflictDoUpdate({
|
|
1405
1416
|
target: findings.id,
|
|
@@ -1431,6 +1442,7 @@ var osecDB = class {
|
|
|
1431
1442
|
findingRank,
|
|
1432
1443
|
verificationResult: verificationResultJson,
|
|
1433
1444
|
reviewAnnotation: reviewAnnotationJson,
|
|
1445
|
+
sourceVerification: sourceVerificationJson,
|
|
1434
1446
|
timestamp: finding.timestamp
|
|
1435
1447
|
}
|
|
1436
1448
|
}).run();
|
|
@@ -1440,11 +1452,10 @@ var osecDB = class {
|
|
|
1440
1452
|
return this.db.select().from(findings).where(eq(findings.id, findingId)).get();
|
|
1441
1453
|
}
|
|
1442
1454
|
/**
|
|
1443
|
-
* Read path for the
|
|
1444
|
-
* `
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
* `{ ...mapped, ...db.getFindingReviewFields(id) }`.
|
|
1455
|
+
* Read path for the persisted `verification_result`, `reviewAnnotation`,
|
|
1456
|
+
* and `sourceVerification` fields. The first two retain their existing
|
|
1457
|
+
* source-fix gate semantics; a source-only check is never replay evidence.
|
|
1458
|
+
* Each key is omitted when absent, including for pre-migration rows.
|
|
1448
1459
|
*/
|
|
1449
1460
|
getFindingReviewFields(findingId) {
|
|
1450
1461
|
return restoreFindingReviewFields(this.getFinding(findingId));
|
|
@@ -2169,6 +2180,38 @@ function parseFindingReviewAnnotation(value) {
|
|
|
2169
2180
|
return void 0;
|
|
2170
2181
|
return parsed;
|
|
2171
2182
|
}
|
|
2183
|
+
function parseFindingSourceVerification(value) {
|
|
2184
|
+
const parsed = parseJsonObjectColumn(value);
|
|
2185
|
+
if (!parsed)
|
|
2186
|
+
return void 0;
|
|
2187
|
+
const status = parsed.status;
|
|
2188
|
+
const totalPredicates = parsed.totalPredicates;
|
|
2189
|
+
const matchedPredicates = parsed.matchedPredicates;
|
|
2190
|
+
const notMatchedPredicates = parsed.notMatchedPredicates;
|
|
2191
|
+
const inconclusivePredicates = parsed.inconclusivePredicates;
|
|
2192
|
+
const behaviorPending = parsed.behaviorPending;
|
|
2193
|
+
if (status !== "matched" && status !== "not_confirmed" && status !== "inconclusive" || typeof totalPredicates !== "number" || !Number.isSafeInteger(totalPredicates) || totalPredicates < 0 || typeof matchedPredicates !== "number" || !Number.isSafeInteger(matchedPredicates) || matchedPredicates < 0 || typeof notMatchedPredicates !== "number" || !Number.isSafeInteger(notMatchedPredicates) || notMatchedPredicates < 0 || typeof inconclusivePredicates !== "number" || !Number.isSafeInteger(inconclusivePredicates) || inconclusivePredicates < 0 || typeof behaviorPending !== "boolean") {
|
|
2194
|
+
return void 0;
|
|
2195
|
+
}
|
|
2196
|
+
const countSum = matchedPredicates + notMatchedPredicates + inconclusivePredicates;
|
|
2197
|
+
if (!Number.isSafeInteger(countSum) || countSum !== totalPredicates)
|
|
2198
|
+
return void 0;
|
|
2199
|
+
if (status === "matched" && (totalPredicates === 0 || matchedPredicates !== totalPredicates || notMatchedPredicates !== 0 || inconclusivePredicates !== 0) || status === "not_confirmed" && (notMatchedPredicates === 0 || inconclusivePredicates !== 0) || status === "inconclusive" && inconclusivePredicates === 0 && totalPredicates !== 0) {
|
|
2200
|
+
return void 0;
|
|
2201
|
+
}
|
|
2202
|
+
return {
|
|
2203
|
+
status,
|
|
2204
|
+
totalPredicates,
|
|
2205
|
+
matchedPredicates,
|
|
2206
|
+
notMatchedPredicates,
|
|
2207
|
+
inconclusivePredicates,
|
|
2208
|
+
behaviorPending
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
function serializeFindingSourceVerification(value) {
|
|
2212
|
+
const usable = parseFindingSourceVerification(value);
|
|
2213
|
+
return usable ? JSON.stringify(usable) : null;
|
|
2214
|
+
}
|
|
2172
2215
|
function serializeFindingVerificationResult(value) {
|
|
2173
2216
|
const usable = parseFindingVerificationResult(value);
|
|
2174
2217
|
return usable ? JSON.stringify(usable) : null;
|
|
@@ -2182,9 +2225,11 @@ function restoreFindingReviewFields(row) {
|
|
|
2182
2225
|
return {};
|
|
2183
2226
|
const verificationResult = parseFindingVerificationResult(row.verificationResult);
|
|
2184
2227
|
const reviewAnnotation = parseFindingReviewAnnotation(row.reviewAnnotation);
|
|
2228
|
+
const sourceVerification = parseFindingSourceVerification(row.sourceVerification);
|
|
2185
2229
|
return {
|
|
2186
2230
|
...verificationResult ? { verification_result: verificationResult } : {},
|
|
2187
|
-
...reviewAnnotation ? { reviewAnnotation } : {}
|
|
2231
|
+
...reviewAnnotation ? { reviewAnnotation } : {},
|
|
2232
|
+
...sourceVerification ? { sourceVerification } : {}
|
|
2188
2233
|
};
|
|
2189
2234
|
}
|
|
2190
2235
|
function deriveEvidenceFromPocSteps(finding) {
|
|
@@ -2278,6 +2323,7 @@ CREATE TABLE IF NOT EXISTS findings (
|
|
|
2278
2323
|
findingRank INTEGER,
|
|
2279
2324
|
verificationResult TEXT,
|
|
2280
2325
|
reviewAnnotation TEXT,
|
|
2326
|
+
sourceVerification TEXT,
|
|
2281
2327
|
timestamp INTEGER NOT NULL
|
|
2282
2328
|
);
|
|
2283
2329
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __0CreateRequire } from "node:module";
|
|
3
3
|
const require = __0CreateRequire(import.meta.url);
|
|
4
|
-
import {
|
|
5
|
-
eventBus,
|
|
6
|
-
isCloudEventSinkActive
|
|
7
|
-
} from "./chunk-CXKDWFNO.js";
|
|
8
4
|
|
|
9
5
|
// packages/core/dist/runtime/process.js
|
|
10
6
|
import { spawn } from "node:child_process";
|
|
@@ -76,21 +72,6 @@ function buildOsecMcpCommandArgs(context) {
|
|
|
76
72
|
}
|
|
77
73
|
return args;
|
|
78
74
|
}
|
|
79
|
-
function numericField(obj, key) {
|
|
80
|
-
const v = obj[key];
|
|
81
|
-
if (typeof v === "number" && Number.isFinite(v))
|
|
82
|
-
return v;
|
|
83
|
-
if (typeof v === "string" && /^\d+$/.test(v))
|
|
84
|
-
return Number(v);
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
function safeJsonStringify(v) {
|
|
88
|
-
try {
|
|
89
|
-
return JSON.stringify(v) ?? "";
|
|
90
|
-
} catch {
|
|
91
|
-
return "(unserialisable)";
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
75
|
function buildClaudeMcpConfig(context) {
|
|
95
76
|
return JSON.stringify({
|
|
96
77
|
mcpServers: {
|
|
@@ -124,180 +105,6 @@ var ProcessRuntime = class {
|
|
|
124
105
|
const args = this.buildArgs(prompt, context);
|
|
125
106
|
const env = this.buildEnv(context);
|
|
126
107
|
const onToolCall = this.config.onToolCall;
|
|
127
|
-
const scanId = context?.scanId;
|
|
128
|
-
const emitScanEvents = this.type === "codex" && isCloudEventSinkActive();
|
|
129
|
-
const maxTurnsHint = 40;
|
|
130
|
-
let turnNumber = 0;
|
|
131
|
-
let toolCallSeq = 0;
|
|
132
|
-
let deltaSeq = 0;
|
|
133
|
-
let turnStartedAt = 0;
|
|
134
|
-
const toolCallStartedAt = /* @__PURE__ */ new Map();
|
|
135
|
-
const seenSequenceNumbers = /* @__PURE__ */ new Set();
|
|
136
|
-
const isSeenSequence = (event) => {
|
|
137
|
-
const seq = event.sequence_number;
|
|
138
|
-
if (typeof seq !== "number" && typeof seq !== "string")
|
|
139
|
-
return false;
|
|
140
|
-
const key = `${event.type ?? "?"}|${seq}`;
|
|
141
|
-
if (seenSequenceNumbers.has(key))
|
|
142
|
-
return true;
|
|
143
|
-
seenSequenceNumbers.add(key);
|
|
144
|
-
return false;
|
|
145
|
-
};
|
|
146
|
-
const emitCodexCloudEvents = (event) => {
|
|
147
|
-
if (isSeenSequence(event))
|
|
148
|
-
return;
|
|
149
|
-
const eventType = typeof event.type === "string" ? event.type : "";
|
|
150
|
-
switch (eventType) {
|
|
151
|
-
case "thread.started": {
|
|
152
|
-
eventBus.emit("llm_planner_invoked", {
|
|
153
|
-
turn: 0,
|
|
154
|
-
model: this.config.model,
|
|
155
|
-
role: "attack"
|
|
156
|
-
});
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
case "turn.started": {
|
|
160
|
-
turnNumber += 1;
|
|
161
|
-
turnStartedAt = Date.now();
|
|
162
|
-
deltaSeq = 0;
|
|
163
|
-
eventBus.emit("agent_turn_started", {
|
|
164
|
-
turn: turnNumber,
|
|
165
|
-
max_turns: maxTurnsHint,
|
|
166
|
-
role: "attack"
|
|
167
|
-
});
|
|
168
|
-
eventBus.emit("llm_planner_invoked", {
|
|
169
|
-
turn: turnNumber,
|
|
170
|
-
model: this.config.model,
|
|
171
|
-
role: "attack"
|
|
172
|
-
});
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
case "turn.completed": {
|
|
176
|
-
const usage = event.usage ?? {};
|
|
177
|
-
const inputTokens = numericField(usage, "input_tokens");
|
|
178
|
-
const cachedInputTokens = numericField(usage, "cached_input_tokens");
|
|
179
|
-
const outputTokens = numericField(usage, "output_tokens");
|
|
180
|
-
const reasoningTokens = numericField(usage, "reasoning_output_tokens");
|
|
181
|
-
const durationMs = turnStartedAt > 0 ? Date.now() - turnStartedAt : 0;
|
|
182
|
-
eventBus.emit("agent_turn_completed", {
|
|
183
|
-
turn: turnNumber,
|
|
184
|
-
duration_ms: durationMs,
|
|
185
|
-
reason: "continue",
|
|
186
|
-
role: "attack"
|
|
187
|
-
});
|
|
188
|
-
eventBus.emit("cost_update", {
|
|
189
|
-
turn: turnNumber,
|
|
190
|
-
cost_usd: 0,
|
|
191
|
-
input_tokens: inputTokens,
|
|
192
|
-
output_tokens: outputTokens,
|
|
193
|
-
token_input: inputTokens,
|
|
194
|
-
token_output: outputTokens,
|
|
195
|
-
cached_input_tokens: cachedInputTokens,
|
|
196
|
-
reasoning_output_tokens: reasoningTokens
|
|
197
|
-
});
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
case "item.started": {
|
|
201
|
-
const item = event.item ?? {};
|
|
202
|
-
const itemType = typeof item.type === "string" ? item.type : "";
|
|
203
|
-
if (itemType === "command_execution" && typeof item.command === "string") {
|
|
204
|
-
toolCallSeq += 1;
|
|
205
|
-
toolCallStartedAt.set(toolCallSeq, Date.now());
|
|
206
|
-
eventBus.emit("tool_call_started", {
|
|
207
|
-
tool: "shell",
|
|
208
|
-
turn: turnNumber,
|
|
209
|
-
args_preview: item.command.slice(0, 200),
|
|
210
|
-
ts: Date.now()
|
|
211
|
-
});
|
|
212
|
-
} else if (itemType === "mcp_tool_call") {
|
|
213
|
-
toolCallSeq += 1;
|
|
214
|
-
toolCallStartedAt.set(toolCallSeq, Date.now());
|
|
215
|
-
const server = typeof item.server === "string" ? item.server : "?";
|
|
216
|
-
const tool = typeof item.tool === "string" ? item.tool : "?";
|
|
217
|
-
const argsRaw = item.arguments ?? {};
|
|
218
|
-
const argsPreview = typeof argsRaw === "string" ? argsRaw : safeJsonStringify(argsRaw);
|
|
219
|
-
eventBus.emit("tool_call_started", {
|
|
220
|
-
tool: `${server}__${tool}`,
|
|
221
|
-
turn: turnNumber,
|
|
222
|
-
args_preview: argsPreview.slice(0, 200),
|
|
223
|
-
ts: Date.now()
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
case "item.completed": {
|
|
229
|
-
const item = event.item ?? {};
|
|
230
|
-
const itemType = typeof item.type === "string" ? item.type : "";
|
|
231
|
-
if (itemType === "command_execution") {
|
|
232
|
-
const startedAt = toolCallStartedAt.get(toolCallSeq);
|
|
233
|
-
const durationMs = startedAt != null ? Date.now() - startedAt : 0;
|
|
234
|
-
toolCallStartedAt.delete(toolCallSeq);
|
|
235
|
-
eventBus.emit("tool_call_completed", {
|
|
236
|
-
tool: "shell",
|
|
237
|
-
turn: turnNumber,
|
|
238
|
-
duration_ms: durationMs,
|
|
239
|
-
status: "ok",
|
|
240
|
-
ts: Date.now()
|
|
241
|
-
});
|
|
242
|
-
} else if (itemType === "mcp_tool_call") {
|
|
243
|
-
const startedAt = toolCallStartedAt.get(toolCallSeq);
|
|
244
|
-
const durationMs = startedAt != null ? Date.now() - startedAt : 0;
|
|
245
|
-
toolCallStartedAt.delete(toolCallSeq);
|
|
246
|
-
const server = typeof item.server === "string" ? item.server : "?";
|
|
247
|
-
const tool = typeof item.tool === "string" ? item.tool : "?";
|
|
248
|
-
const status = item.status === "success" || item.status === "completed" ? "ok" : "error";
|
|
249
|
-
const errorMsg = status === "error" ? typeof item.error === "string" ? item.error : safeJsonStringify(item.error ?? null) : void 0;
|
|
250
|
-
eventBus.emit("tool_call_completed", {
|
|
251
|
-
tool: `${server}__${tool}`,
|
|
252
|
-
turn: turnNumber,
|
|
253
|
-
duration_ms: durationMs,
|
|
254
|
-
status,
|
|
255
|
-
...errorMsg ? { error: errorMsg.slice(0, 400) } : {},
|
|
256
|
-
ts: Date.now()
|
|
257
|
-
});
|
|
258
|
-
} else if (itemType === "function_call" || itemType === "tool_call") {
|
|
259
|
-
toolCallSeq += 1;
|
|
260
|
-
const toolName = typeof item.tool_name === "string" && item.tool_name || typeof item.name === "string" && item.name || "mcp_tool";
|
|
261
|
-
const argsField = item.arguments ?? item.input ?? "";
|
|
262
|
-
const detail = typeof argsField === "string" ? argsField : safeJsonStringify(argsField);
|
|
263
|
-
eventBus.emit("tool_call_started", {
|
|
264
|
-
tool: toolName,
|
|
265
|
-
turn: turnNumber,
|
|
266
|
-
args_preview: detail.slice(0, 200),
|
|
267
|
-
ts: Date.now()
|
|
268
|
-
});
|
|
269
|
-
eventBus.emit("tool_call_completed", {
|
|
270
|
-
tool: toolName,
|
|
271
|
-
turn: turnNumber,
|
|
272
|
-
duration_ms: 0,
|
|
273
|
-
status: "ok",
|
|
274
|
-
ts: Date.now()
|
|
275
|
-
});
|
|
276
|
-
} else if (itemType === "reasoning") {
|
|
277
|
-
const reasoningText = typeof item.text === "string" && item.text || typeof item.summary === "string" && item.summary || "";
|
|
278
|
-
if (reasoningText.length > 0) {
|
|
279
|
-
eventBus.emit("reasoning_summary", {
|
|
280
|
-
turn: turnNumber,
|
|
281
|
-
summary: reasoningText.slice(0, 2e3)
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
} else if (itemType === "agent_message") {
|
|
285
|
-
const messageText = typeof item.text === "string" ? item.text : "";
|
|
286
|
-
if (messageText.length > 0) {
|
|
287
|
-
deltaSeq += 1;
|
|
288
|
-
eventBus.emit("delta", {
|
|
289
|
-
turn: turnNumber,
|
|
290
|
-
scope: "assistant_response",
|
|
291
|
-
text: messageText.slice(0, 2e3),
|
|
292
|
-
seq: deltaSeq,
|
|
293
|
-
role: "attack"
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
108
|
return new Promise((resolve2) => {
|
|
302
109
|
let stdout = "";
|
|
303
110
|
let stderr = "";
|
|
@@ -352,8 +159,6 @@ var ProcessRuntime = class {
|
|
|
352
159
|
} else if (event.item.type === "command_execution" && event.item.command) {
|
|
353
160
|
}
|
|
354
161
|
}
|
|
355
|
-
if (emitScanEvents)
|
|
356
|
-
emitCodexCloudEvents(event);
|
|
357
162
|
} catch {
|
|
358
163
|
}
|
|
359
164
|
}
|