0sec-cli 0.18.0 → 0.21.4
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/{0sec.js → 0.js} +84 -76
- package/LICENSE +1 -1
- package/README.md +74 -43
- package/chunks/adapt-loop-IGBRQAXO.js +18 -0
- package/chunks/{adgraph-JLGA6RYI.js → adgraph-AUDQTBYA.js} +5 -5
- package/chunks/agent/skills/frameworks/entra-id.yaml +2 -2
- package/chunks/agent/skills/techniques/assumption-mining.yaml +2 -2
- package/chunks/agent/skills/techniques/cve-poc-adaptation.yaml +2 -2
- package/chunks/agent/skills/techniques/entra-attack-paths.yaml +1 -1
- package/chunks/agent/skills/techniques/kernel-weaponization.yaml +1 -1
- package/chunks/agent/skills/techniques/llm-prompt-injection.yaml +2 -2
- package/chunks/agent/skills/techniques/npm-ecosystem.yaml +1 -1
- package/chunks/agent/skills/techniques/poc-verification.yaml +1 -1
- package/chunks/agent/skills/techniques/seedless-depth-review.yaml +20 -38
- package/chunks/{artifact-scraper-HQ7HLP6V.js → artifact-scraper-LNQJUORS.js} +6 -6
- package/chunks/{assumption-mining-5SNIVVDN.js → assumption-mining-4MJTP6H5.js} +24 -26
- package/chunks/{chunk-P6WKNFWX.js → chunk-2OQOQ2FZ.js} +8 -8
- package/chunks/{chunk-5G3ZXFBW.js → chunk-2WNCI664.js} +3 -3
- package/chunks/{chunk-AHTBZC3E.js → chunk-2WSXFFJZ.js} +4 -4
- package/chunks/{chunk-DW5UWPFY.js → chunk-4VGLO2YS.js} +6 -5
- package/chunks/{chunk-3KPWWJCI.js → chunk-5T6D5BVY.js} +88 -88
- package/chunks/{chunk-OEFNRYI2.js → chunk-6GHSR47F.js} +3 -6
- package/chunks/chunk-6YNKRUMC.js +4474 -0
- package/chunks/{chunk-BZNEY2ZS.js → chunk-ANDKY54G.js} +22390 -19895
- package/chunks/{chunk-53G27VPS.js → chunk-AZ7L3HFD.js} +7 -2
- package/chunks/{chunk-UR4ELX2Y.js → chunk-BACXRTQ4.js} +633 -316
- package/chunks/{chunk-UCYRA73C.js → chunk-CAJJRUTV.js} +4 -4
- package/chunks/{chunk-57ZENEX2.js → chunk-CGHCEN7W.js} +3 -3
- package/chunks/{chunk-AD7WXDH6.js → chunk-CL5KAUM6.js} +16 -16
- package/chunks/{chunk-ADOLI6DT.js → chunk-CXKDWFNO.js} +6 -6
- package/chunks/{chunk-RWONANDA.js → chunk-DQTNI3KY.js} +5 -5
- package/chunks/{chunk-BFR2CDV5.js → chunk-E2UOY5PJ.js} +288 -100
- package/chunks/{chunk-ATATQACO.js → chunk-ER3SUMYJ.js} +40 -18
- package/chunks/{chunk-5JI7L7KV.js → chunk-FAH6V4QM.js} +30515 -32242
- package/chunks/{chunk-6LKRLK2R.js → chunk-FHC2B7LN.js} +3 -3
- package/chunks/{chunk-XM5NLHYU.js → chunk-FWAYJ2IV.js} +16 -16
- package/chunks/{chunk-WVTBZEQO.js → chunk-G34QP2XW.js} +8 -8
- package/chunks/{chunk-MYVT64FN.js → chunk-GHWODZMR.js} +2 -2
- package/chunks/{chunk-F3WBKITT.js → chunk-GIQKESMN.js} +10 -10
- package/chunks/{chunk-2RMLOJVB.js → chunk-GVD6SJGH.js} +2 -2
- package/chunks/{chunk-WXQ6BJ6A.js → chunk-HBKCGJAV.js} +7 -7
- package/chunks/{chunk-SF4KZ4O3.js → chunk-HLFS6WV2.js} +2 -2
- package/chunks/chunk-HPQZHOIU.js +67 -0
- package/chunks/{chunk-TSK2AG6J.js → chunk-IMGWPNQM.js} +231 -1308
- package/chunks/{chunk-3MOLBTLS.js → chunk-K2PWUPUI.js} +2 -2
- package/chunks/{chunk-N7BOUYEV.js → chunk-NDJU5ZZ7.js} +14 -14
- package/chunks/{chunk-BVAZO4WA.js → chunk-NOPBXZUV.js} +3 -3
- package/chunks/{chunk-2JCCA2JL.js → chunk-O6SD4A36.js} +3 -3
- package/chunks/{chunk-SAFFWQW4.js → chunk-P6YG6TEZ.js} +6 -6
- package/chunks/{chunk-6L26OBWI.js → chunk-PC6RCKQV.js} +198 -11
- package/chunks/{chunk-LP3HHYQU.js → chunk-PD2BBBKT.js} +2 -2
- package/chunks/{chunk-BKZFDZ23.js → chunk-QCUFBVIZ.js} +3 -3
- package/chunks/{chunk-KLTNTE2Z.js → chunk-QZVG3BG4.js} +14 -14
- package/chunks/{chunk-ASUR522M.js → chunk-RF5QGKLR.js} +9 -9
- package/chunks/{chunk-YYRBQVFE.js → chunk-SBMB4OL3.js} +9 -9
- package/chunks/{chunk-IOL7D5YV.js → chunk-SQCBHFWN.js} +3 -3
- package/chunks/{chunk-BFRB6HB2.js → chunk-TF46UWFU.js} +3 -3
- package/chunks/chunk-TH2LW437.js +7829 -0
- package/chunks/chunk-TRH2PJSN.js +547 -0
- package/chunks/{chunk-RJWOYEOG.js → chunk-UEX7PFSE.js} +5 -5
- package/chunks/{chunk-VQG4FT5D.js → chunk-UFHN6RIU.js} +2 -2
- package/chunks/{chunk-WU6AFRAZ.js → chunk-V36HVTUL.js} +12 -12
- package/chunks/{chunk-IR537GON.js → chunk-VCSFCHAJ.js} +2 -2
- package/chunks/{chunk-YLMN3N25.js → chunk-VIT5ALXF.js} +3 -3
- package/chunks/{chunk-U5FLXGHT.js → chunk-VOAXLO4A.js} +10 -10
- package/chunks/{chunk-WEBMRWEG.js → chunk-W4JOXE4N.js} +83 -75
- package/chunks/{chunk-C2WXWFBB.js → chunk-WF5W75WY.js} +25 -25
- package/chunks/{chunk-SVJEDVYK.js → chunk-WPQLBN4S.js} +5 -5
- package/chunks/{chunk-72CISA2D.js → chunk-WZISK5VC.js} +37 -35
- package/chunks/{chunk-CMKXP5RR.js → chunk-Y5H6E24H.js} +3 -3
- package/chunks/{chunk-BATRQBOR.js → chunk-YA4PUM4H.js} +41 -41
- package/chunks/{chunk-JQHOLLTD.js → chunk-YHWWF4QY.js} +9 -9
- package/chunks/{chunk-GMT2AZKM.js → chunk-YPOA3W4O.js} +28 -28
- package/chunks/{chunk-7DQEV5QI.js → chunk-Z3IKZX3X.js} +4 -4
- package/chunks/codex-models-TYYV4JNN.js +15 -0
- package/chunks/{commands-TBC2F5CE.js → commands-WF5RG4I2.js} +3834 -931
- package/chunks/corpus-v1.json +2 -2
- package/chunks/data/appsec-archetypes.json +2 -2
- package/chunks/data/chromium-archetypes.json +1 -1
- package/chunks/data/freebsd-archetypes.json +1 -1
- package/chunks/data/kernel-archetypes.json +2 -2
- package/chunks/db-U3WQZVAO.js +16 -0
- package/chunks/{disclose-EKTWSCGW.js → disclose-67GZCDBO.js} +5 -5
- package/chunks/{dist-FMGSR3DW.js → dist-ACC3DZUZ.js} +11 -5
- package/chunks/{dist-4MAW5X6L.js → dist-EVTN3UTT.js} +6 -6
- package/chunks/{dist-4YICS2J2.js → dist-F6X62TQK.js} +286 -327
- package/chunks/dist-KEULE5IQ.js +21914 -0
- package/chunks/dist-XZB53PS5.js +53 -0
- package/chunks/eval-runner-SA6OUGHZ.js +26 -0
- package/chunks/example-manifest.json +2 -2
- package/chunks/{exploit-agent-45YQOHPJ.js → exploit-agent-36Q7XQFP.js} +4 -4
- package/chunks/{exploit-autoclimb-UZGEMGYT.js → exploit-autoclimb-J4OTSTZ6.js} +6 -6
- package/chunks/{exploit-climb-SG23KB2G.js → exploit-climb-PYEJDIC4.js} +12 -12
- package/chunks/fix-J2KBRJDV.js +12 -0
- package/chunks/{github-issues-MJ6OYOOU.js → github-issues-IGTTWM7V.js} +7 -7
- package/chunks/harness-GDUMKGSE.js +22 -0
- package/chunks/http-conformance-U5F6GKYG.js +11 -0
- package/chunks/http-sender-I5XFFY35.js +10 -0
- package/chunks/hunt-scan-UDJSCISU.js +36 -0
- package/chunks/{identity-6ZAIIWOR.js → identity-JTIVJSV7.js} +5 -5
- package/chunks/{kernel-primitive-7U6CWHXD.js → kernel-primitive-F2IXUFAX.js} +6 -6
- package/chunks/{kernel-vm-runner-3JAU4O6J.js → kernel-vm-runner-276LHIOV.js} +6 -6
- package/chunks/memsafety-scan-NHUOGTEX.js +16 -0
- package/chunks/{native-loop-RJCJPOUS.js → native-loop-3BSYVDUI.js} +17 -18
- package/chunks/{npm-detectors-KB5Y5ZFX.js → npm-detectors-VIYJXKFQ.js} +6 -6
- package/chunks/npm-dynamic-discovery-5J7FT3XM.js +13 -0
- package/chunks/orchestrate-DHBFRTSI.js +59 -0
- package/chunks/{pre-recon-cve-66EB6G4M.js → pre-recon-cve-X2K2P5YQ.js} +4 -4
- package/chunks/prepare-KYHGFWCJ.js +13 -0
- package/chunks/process-PNMC36JI.js +15 -0
- package/chunks/{replay-runner-45G3VU7X.js → replay-runner-LK2XFIVG.js} +7 -7
- package/chunks/{run-D56MPDKY.js → run-CBGE6DRQ.js} +2201 -1694
- package/chunks/{runtime-G7YWIO3B.js → runtime-PXO5G6UV.js} +11 -11
- package/chunks/runtime-XFWJTBUO.js +12 -0
- package/chunks/{scan-stream-FHI2FYZE.js → scan-stream-BMOCPKQX.js} +7 -7
- package/chunks/{scope-BI7BF4ZY.js → scope-NJHIDDTN.js} +4 -4
- package/chunks/{session-store-GZ4A4KYT.js → session-store-46WBZM22.js} +6 -6
- package/chunks/source-files-REHOM44I.js +12 -0
- package/chunks/{specdrift-WCLH6TTQ.js → specdrift-AFS54WEJ.js} +5 -5
- package/chunks/token-KRWP5JYA.js +72 -0
- package/chunks/token-util-DWTL33S3.js +8 -0
- package/chunks/variant-candidates-UH2WC2HA.js +13 -0
- package/chunks/{web-recon-prepass-JJGPEOLE.js → web-recon-prepass-SFXU44SS.js} +9 -9
- package/dashboard/assets/desktop-BT7RkC4q.js +32 -0
- package/dashboard/assets/desktop-OaBI0E0e.css +1 -0
- package/dashboard/assets/{findings-page-CACW9nw2.js → findings-page-B4rwF6fZ.js} +2 -2
- package/dashboard/assets/{format-PoISqsES.js → format-LNQSSpn6.js} +1 -1
- package/dashboard/assets/live-page-DoNwpPAO.js +1 -0
- package/dashboard/assets/{meta-tile-CcskIV_o.js → meta-tile-BMtBC-Qq.js} +1 -1
- package/dashboard/assets/operations-CMFVrXEe.css +2 -0
- package/dashboard/assets/operations-app-ER0gg7GN.js +2 -0
- package/dashboard/assets/{operations-D8nUP5_m.js → operations-e2CGYKB1.js} +2 -2
- package/dashboard/assets/{overview-page-DTGS8dPo.js → overview-page-CmeWH17A.js} +1 -1
- package/dashboard/assets/{page-header-MFVvEtZW.js → page-header-CIJyycfz.js} +1 -1
- package/dashboard/assets/scans-page-CuhzWhHx.js +1 -0
- package/dashboard/assets/{table-BYS-nIVA.js → table-BgsSBdke.js} +1 -1
- package/dashboard/assets/{tabs-DivxbhQy.js → tabs-vn6v7Bk6.js} +1 -1
- package/dashboard/desktop.html +3 -3
- package/dashboard/index.html +3 -3
- package/package.json +11 -11
- package/chunks/adapt-loop-SMH6V4PD.js +0 -18
- package/chunks/appsec-catalog-CBWHGTEL.js +0 -24
- package/chunks/chunk-242TMK6G.js +0 -110
- package/chunks/chunk-H2FFLZNK.js +0 -3
- package/chunks/chunk-QI233I24.js +0 -333
- package/chunks/chunk-RRMJC3ZE.js +0 -105
- package/chunks/chunk-Z5FA2XOX.js +0 -2798
- package/chunks/cost-ledger-NU63MYZM.js +0 -13
- package/chunks/db-KFWOAUUB.js +0 -16
- package/chunks/eval-runner-7ZF472KV.js +0 -27
- package/chunks/fix-IG7LYXH3.js +0 -12
- package/chunks/harness-7ODOLOWU.js +0 -22
- package/chunks/http-conformance-DU66MZIU.js +0 -11
- package/chunks/http-sender-GWH2IYEA.js +0 -10
- package/chunks/hunt-scan-MMKUOETU.js +0 -38
- package/chunks/memsafety-scan-J7SECV5W.js +0 -16
- package/chunks/npm-dynamic-discovery-AHROOZDB.js +0 -13
- package/chunks/orchestrate-OC2VZN2X.js +0 -62
- package/chunks/pipeline-BZK5BLJR.js +0 -14
- package/chunks/prepare-MYY743TK.js +0 -13
- package/chunks/process-LQRCS5OY.js +0 -13
- package/chunks/runtime-J7PLXZNM.js +0 -12
- package/chunks/source-files-PWRQR6LY.js +0 -12
- package/chunks/variant-candidates-YERCYMPD.js +0 -13
- package/dashboard/assets/0sec-icon-66SreztZ.gif +0 -0
- package/dashboard/assets/desktop-CXTQonNm.js +0 -32
- package/dashboard/assets/desktop-NOekk4QS.css +0 -1
- package/dashboard/assets/live-page-DrgQqQK5.js +0 -1
- package/dashboard/assets/operations-BKE8T-vY.css +0 -2
- package/dashboard/assets/operations-app-CQQhG54n.js +0 -2
- package/dashboard/assets/scans-page-ChVtq8Us.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as
|
|
3
|
-
const require =
|
|
2
|
+
import { createRequire as __0CreateRequire } from "node:module";
|
|
3
|
+
const require = __0CreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
homeStateDir,
|
|
6
6
|
runStateDir
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PC6RCKQV.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VCSFCHAJ.js";
|
|
11
11
|
|
|
12
12
|
// packages/db/dist/wasm-shim.js
|
|
13
13
|
import { BetterSQLiteSession } from "drizzle-orm/better-sqlite3/session";
|
|
@@ -99,7 +99,7 @@ var ShimmedDatabase = class {
|
|
|
99
99
|
* only uses it as a setter ("journal_mode = WAL", "foreign_keys = ON"), so
|
|
100
100
|
* we just `exec()` the pragma and swallow errors — some PRAGMAs (notably
|
|
101
101
|
* WAL journal mode) are not supported by node-sqlite3-wasm's VFS and error
|
|
102
|
-
* here, but losing them is acceptable for
|
|
102
|
+
* here, but losing them is acceptable for 0's single-process workload.
|
|
103
103
|
*/
|
|
104
104
|
pragma(query, _opts) {
|
|
105
105
|
try {
|
|
@@ -112,7 +112,7 @@ var ShimmedDatabase = class {
|
|
|
112
112
|
* better-sqlite3's `db.transaction(fn)` returns a callable object with
|
|
113
113
|
* `.deferred`, `.immediate`, `.exclusive`, and `.default` methods, each
|
|
114
114
|
* running `fn` inside a BEGIN/COMMIT of the corresponding isolation level.
|
|
115
|
-
* All three variants are functionally equivalent for
|
|
115
|
+
* All three variants are functionally equivalent for 0's single-writer
|
|
116
116
|
* workload, so we wire them to the same underlying implementation.
|
|
117
117
|
*/
|
|
118
118
|
transaction(fn) {
|
|
@@ -357,29 +357,29 @@ var findings = sqliteTable("findings", {
|
|
|
357
357
|
evidenceResponse: text("evidenceResponse").notNull(),
|
|
358
358
|
evidenceAnalysis: text("evidenceAnalysis"),
|
|
359
359
|
/**
|
|
360
|
-
* JSON-stringified LayerVerdict[] (see @
|
|
360
|
+
* JSON-stringified LayerVerdict[] (see @0/shared types). NULL until
|
|
361
361
|
* the triage stage runs. Stored as text rather than a join table because
|
|
362
362
|
* the array is read-and-write together at finding-save time and we never
|
|
363
|
-
* query individual verdict rows. See
|
|
363
|
+
* query individual verdict rows. See 0#112.
|
|
364
364
|
*/
|
|
365
365
|
layerVerdicts: text("layerVerdicts"),
|
|
366
366
|
impactAssessment: text("impactAssessment"),
|
|
367
367
|
// JSON: ImpactAssessment (reachability/blast/weaponizability/business)
|
|
368
368
|
/**
|
|
369
|
-
* JSON-stringified PocStep[] (see @
|
|
369
|
+
* JSON-stringified PocStep[] (see @0/shared types). NULL when the
|
|
370
370
|
* agent only produced prose evidence (the legacy default). Stored as
|
|
371
371
|
* text rather than a join table because the array is read-and-write
|
|
372
372
|
* together at finding-save time and we never query individual steps.
|
|
373
|
-
* See
|
|
373
|
+
* See 0#170.
|
|
374
374
|
*/
|
|
375
375
|
pocSteps: text("pocSteps"),
|
|
376
376
|
/**
|
|
377
|
-
* JSON-stringified VerificationSpec (see @
|
|
377
|
+
* JSON-stringified VerificationSpec (see @0/shared types). NULL
|
|
378
378
|
* when the agent produced a finding without a deterministic re-check
|
|
379
379
|
* contract — every reader must continue to work in that case. Stored
|
|
380
380
|
* as text because the spec is an opaque blob that the verifier reads
|
|
381
|
-
* whole; we never query individual predicates. See
|
|
382
|
-
*
|
|
381
|
+
* whole; we never query individual predicates. See 0#193 /
|
|
382
|
+
* 0-cloud#111.
|
|
383
383
|
*/
|
|
384
384
|
verificationSpec: text("verificationSpec"),
|
|
385
385
|
/**
|
|
@@ -395,11 +395,11 @@ var findings = sqliteTable("findings", {
|
|
|
395
395
|
/**
|
|
396
396
|
* JSON-stringified PocExecutionReport written when `disclose --target-url`
|
|
397
397
|
* runs the step graph against a live target. NULL until that runs. See
|
|
398
|
-
*
|
|
398
|
+
* 0#171.
|
|
399
399
|
*/
|
|
400
400
|
pocExecution: text("pocExecution"),
|
|
401
401
|
/**
|
|
402
|
-
* JSON-stringified VerificationResult (see @
|
|
402
|
+
* JSON-stringified VerificationResult (see @0/shared
|
|
403
403
|
* `VerificationResultSchema`) — the last deterministic-replay result
|
|
404
404
|
* attached to the finding. NULL when the finding was never verified;
|
|
405
405
|
* readers MUST treat NULL / malformed / statusless payloads as
|
|
@@ -609,9 +609,9 @@ var trustGraphEdges = sqliteTable("trust_graph_edges", {
|
|
|
609
609
|
|
|
610
610
|
// packages/db/dist/database.js
|
|
611
611
|
var DEFAULT_DB_DIR = homeStateDir();
|
|
612
|
-
var DEFAULT_DB_PATH = join(DEFAULT_DB_DIR, "
|
|
612
|
+
var DEFAULT_DB_PATH = join(DEFAULT_DB_DIR, "0.db");
|
|
613
613
|
function resolveOsecDbPath(dbPath) {
|
|
614
|
-
const configuredPath = process.env["
|
|
614
|
+
const configuredPath = process.env["ZERO_DB_PATH"]?.trim();
|
|
615
615
|
return dbPath ?? (configuredPath ? configuredPath : DEFAULT_DB_PATH);
|
|
616
616
|
}
|
|
617
617
|
function resetOsecDatabase(dbPath) {
|
|
@@ -725,7 +725,7 @@ function migrateWalHeaderIfNeeded(path) {
|
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
if (hadWalData) {
|
|
728
|
-
console.warn(`[
|
|
728
|
+
console.warn(`[0] Migrated ${path} from WAL mode to rollback mode for WASM engine compatibility. A non-empty WAL sidecar was present and has been removed; any uncommitted transactions from a prior crashed run were discarded.`);
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
function clearStaleLockIfAny(path) {
|
|
@@ -744,7 +744,7 @@ function clearStaleLockIfAny(path) {
|
|
|
744
744
|
return;
|
|
745
745
|
try {
|
|
746
746
|
rmSync(lockPath, { recursive: true, force: true });
|
|
747
|
-
console.warn(`[
|
|
747
|
+
console.warn(`[0] Removed stale database lock at ${lockPath} (age ${Math.floor(ageMs / 1e3)}s \u2014 previous holder likely crashed).`);
|
|
748
748
|
} catch {
|
|
749
749
|
}
|
|
750
750
|
}
|
|
@@ -779,7 +779,7 @@ var osecDB = class {
|
|
|
779
779
|
throw error;
|
|
780
780
|
const backupPath = backupCorruptDatabase(path);
|
|
781
781
|
this.initializeDatabase(path);
|
|
782
|
-
console.warn(backupPath ? `[
|
|
782
|
+
console.warn(backupPath ? `[0] Recovered malformed database at ${path}. Backup saved to ${backupPath}.` : `[0] Recovered malformed database state at ${path} by recreating a fresh database.`);
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
785
|
initializeDatabase(path) {
|
|
@@ -787,9 +787,11 @@ var osecDB = class {
|
|
|
787
787
|
this.sqlite.pragma("foreign_keys = ON");
|
|
788
788
|
ensureDatabaseHealthy(this.sqlite);
|
|
789
789
|
this.db = createDrizzleFromShim(this.sqlite, { schema: schema_exports });
|
|
790
|
-
this.sqlite.
|
|
791
|
-
|
|
792
|
-
|
|
790
|
+
this.sqlite.transaction(() => {
|
|
791
|
+
this.sqlite.exec(SCHEMA_TABLES_SQL);
|
|
792
|
+
this.migrate();
|
|
793
|
+
this.sqlite.exec(SCHEMA_INDEXES_SQL);
|
|
794
|
+
})();
|
|
793
795
|
}
|
|
794
796
|
initializeReadOnlyDatabase(path) {
|
|
795
797
|
this.sqlite = createShimmedDatabase(path);
|
|
@@ -797,7 +799,7 @@ var osecDB = class {
|
|
|
797
799
|
this.db = createDrizzleFromShim(this.sqlite, { schema: schema_exports });
|
|
798
800
|
}
|
|
799
801
|
/**
|
|
800
|
-
* Upgrade databases created by older
|
|
802
|
+
* Upgrade databases created by older 0 versions.
|
|
801
803
|
*
|
|
802
804
|
* SCHEMA_TABLES_SQL (above) now contains every table and every column from
|
|
803
805
|
* the drizzle schema, so fresh installs need no patching. This method only
|
|
@@ -806,7 +808,7 @@ var osecDB = class {
|
|
|
806
808
|
* table_info is cached by SQLite) and the ALTERs are no-ops when the
|
|
807
809
|
* column is already present, so running on a fresh DB is harmless.
|
|
808
810
|
*
|
|
809
|
-
* See: https://github.com/0sec-labs/
|
|
811
|
+
* See: https://github.com/0sec-labs/0/issues/420
|
|
810
812
|
*/
|
|
811
813
|
migrate() {
|
|
812
814
|
const cols = this.sqlite.prepare("PRAGMA table_info(findings)").all();
|
|
@@ -1949,7 +1951,7 @@ var osecDB = class {
|
|
|
1949
1951
|
const result = this.sqlite.prepare(`DELETE FROM workers WHERE status IN (${placeholders})`).run(...values);
|
|
1950
1952
|
return result.changes;
|
|
1951
1953
|
}
|
|
1952
|
-
// ── Persistent credential store (
|
|
1954
|
+
// ── Persistent credential store (0#771) ──
|
|
1953
1955
|
/**
|
|
1954
1956
|
* Upsert a discovered foothold keyed by (credentialKind, valueHash). First
|
|
1955
1957
|
* write records the discovery attribution (target/finding/scan/turn);
|
|
@@ -2019,7 +2021,7 @@ var osecDB = class {
|
|
|
2019
2021
|
const limit = query.limit ?? 500;
|
|
2020
2022
|
return this.sqlite.prepare(`SELECT * FROM persistent_credentials ${whereSql} ORDER BY lastSeenAt DESC LIMIT ${limit}`).all(...params);
|
|
2021
2023
|
}
|
|
2022
|
-
// ── Trust graph edges (
|
|
2024
|
+
// ── Trust graph edges (0#771) ──
|
|
2023
2025
|
/**
|
|
2024
2026
|
* Upsert a directed trust edge keyed by
|
|
2025
2027
|
* (srcKind, srcId, dstKind, dstId, relation). Re-observing an edge refreshes
|
|
@@ -2484,24 +2486,24 @@ var STATE_DB_FILE = "state.db";
|
|
|
2484
2486
|
var REPORT_FILE = "report.json";
|
|
2485
2487
|
function normalizeRunId(value) {
|
|
2486
2488
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value)) {
|
|
2487
|
-
throw new Error(`Invalid
|
|
2489
|
+
throw new Error(`Invalid 0 run id ${JSON.stringify(value)}.`);
|
|
2488
2490
|
}
|
|
2489
2491
|
return value;
|
|
2490
2492
|
}
|
|
2491
2493
|
function resolveOsecRunStorage(options = {}) {
|
|
2492
2494
|
const env = options.env ?? process.env;
|
|
2493
|
-
const cloudRunId = env["
|
|
2495
|
+
const cloudRunId = env["ZERO_CLOUD_SCAN_ID"]?.trim() || void 0;
|
|
2494
2496
|
let runId = normalizeRunId(options.runId ?? cloudRunId ?? randomUUID2());
|
|
2495
2497
|
const stateDir = homeStateDir(options.homeDir);
|
|
2496
|
-
const configuredRunDir = env["
|
|
2497
|
-
const configuredDbPath = options.dbPath ?? (env["
|
|
2498
|
+
const configuredRunDir = env["ZERO_RUN_DIR"]?.trim() || void 0;
|
|
2499
|
+
const configuredDbPath = options.dbPath ?? (env["ZERO_DB_PATH"]?.trim() || void 0);
|
|
2498
2500
|
let runDir = configuredRunDir ? resolve(configuredRunDir) : runStateDir(runId, options.homeDir);
|
|
2499
2501
|
if (options.resume && !configuredRunDir && !configuredDbPath && !existsSync2(runDir)) {
|
|
2500
2502
|
const runsDir = join2(stateDir, "runs");
|
|
2501
2503
|
if (existsSync2(runsDir)) {
|
|
2502
2504
|
const matches = readdirSync(runsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith(runId));
|
|
2503
2505
|
if (matches.length > 1) {
|
|
2504
|
-
throw new Error(`
|
|
2506
|
+
throw new Error(`0 run id prefix '${runId}' is ambiguous.`);
|
|
2505
2507
|
}
|
|
2506
2508
|
const match = matches[0];
|
|
2507
2509
|
if (match) {
|
|
@@ -2511,13 +2513,13 @@ function resolveOsecRunStorage(options = {}) {
|
|
|
2511
2513
|
}
|
|
2512
2514
|
}
|
|
2513
2515
|
if (!isAbsolute(runDir)) {
|
|
2514
|
-
throw new Error(`
|
|
2516
|
+
throw new Error(`0 run directory must be absolute: ${JSON.stringify(runDir)}.`);
|
|
2515
2517
|
}
|
|
2516
2518
|
let dbPath = configuredDbPath ? configuredDbPath === ":memory:" ? configuredDbPath : resolve(configuredDbPath) : join2(runDir, STATE_DB_FILE);
|
|
2517
|
-
const configuredReportPath = env["
|
|
2519
|
+
const configuredReportPath = env["ZERO_REPORT_PATH"]?.trim() || void 0;
|
|
2518
2520
|
const reportPath = configuredReportPath ? resolve(configuredReportPath) : !configuredDbPath || configuredRunDir ? join2(runDir, REPORT_FILE) : void 0;
|
|
2519
2521
|
if (options.resume && !configuredDbPath && !existsSync2(dbPath)) {
|
|
2520
|
-
const legacyDbPath = join2(stateDir, "
|
|
2522
|
+
const legacyDbPath = join2(stateDir, "0.db");
|
|
2521
2523
|
if (existsSync2(legacyDbPath))
|
|
2522
2524
|
dbPath = legacyDbPath;
|
|
2523
2525
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as
|
|
3
|
-
const require =
|
|
2
|
+
import { createRequire as __0CreateRequire } from "node:module";
|
|
3
|
+
const require = __0CreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
jitterFor
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SBMB4OL3.js";
|
|
7
7
|
|
|
8
8
|
// packages/core/dist/scope/rate-limit.js
|
|
9
9
|
var TokenBucket = class {
|