@openai/codex-security 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -36
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +1 -1
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/access-advisory.md +11 -0
- package/_bundled_plugin/references/core-scan.md +30 -77
- package/_bundled_plugin/references/final-report.md +45 -189
- package/_bundled_plugin/references/scan-contract.md +2 -0
- package/_bundled_plugin/references/scan-prologue.md +1 -1
- package/_bundled_plugin/references/scan-runtime.md +1 -5
- package/_bundled_plugin/references/threat-model.md +33 -41
- package/_bundled_plugin/schemas/coverage.schema.json +12 -1
- package/_bundled_plugin/schemas/scan-manifest.schema.json +1 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +38 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +39 -39
- package/_bundled_plugin/scripts/deep_scan_workbench.py +145 -85
- package/_bundled_plugin/scripts/finalize_scan_contract.py +189 -57
- package/_bundled_plugin/scripts/report_projection.py +44 -15
- package/_bundled_plugin/scripts/threat_model_projection.py +4 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -14
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +3218 -0
- package/_bundled_plugin/scripts/workbench/retained_records.py +627 -0
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +644 -1
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +72 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +712 -0
- package/_bundled_plugin/scripts/workbench_cli.py +3 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +479 -0
- package/_bundled_plugin/scripts/workbench_db.py +51 -22
- package/_bundled_plugin/scripts/workbench_feedback.py +0 -1
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +53 -9
- package/_bundled_plugin/scripts/workbench_native_indexes.py +56 -44
- package/_bundled_plugin/scripts/workbench_saved_results.py +641 -2387
- package/_bundled_plugin/scripts/workbench_scan_history.py +72 -7
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +4 -1
- package/_bundled_plugin/scripts/workbench_target.py +142 -17
- package/_bundled_plugin/scripts/workbench_validation.py +9 -2
- package/_bundled_plugin/shared/workbench-history-repairs.json +21 -0
- package/_bundled_plugin/shared/workbench-migrations.json +44 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +3 -14
- package/_bundled_plugin/skills/assess-patch-risk/references/windows-validation.md +14 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +38 -103
- package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +11 -73
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +57 -116
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +28 -51
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +9 -9
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +26 -140
- package/_bundled_plugin/skills/fix-finding/SKILL.md +19 -30
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +28 -218
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +29 -424
- package/_bundled_plugin/skills/publish-findings/SKILL.md +134 -0
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +6 -0
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +64 -0
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +12 -12
- package/_bundled_plugin/skills/security-scan/SKILL.md +28 -16
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +11 -17
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +52 -69
- package/_bundled_plugin/skills/threat-model/SKILL.md +16 -9
- package/_bundled_plugin/skills/triage-finding/SKILL.md +5 -15
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -6
- package/_bundled_plugin/skills/validation/SKILL.md +42 -104
- package/_bundled_plugin/skills/validation/references/validation-guidance.md +21 -106
- package/_bundled_plugin/skills/verify-fix/SKILL.md +8 -4
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +21 -159
- package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +18 -60
- package/dist/api.d.ts +8 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +414 -72
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -1
- package/dist/auth.js.map +1 -1
- package/dist/classify-severity-records.d.ts +5 -2
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +40 -34
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +5 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +20 -30
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +1 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +9 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +802 -149
- package/dist/cli.js.map +1 -1
- package/dist/cloud-endpoint.d.ts +6 -0
- package/dist/cloud-endpoint.d.ts.map +1 -0
- package/dist/cloud-endpoint.js +51 -0
- package/dist/cloud-endpoint.js.map +1 -0
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +7 -5
- package/dist/cloud-publish.js.map +1 -1
- package/dist/component-scan.d.ts +8 -2
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +2 -0
- package/dist/component-scan.js.map +1 -1
- package/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +67 -33
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts +18 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +107 -12
- package/dist/cost.js.map +1 -1
- package/dist/coverage-presentation.d.ts +6 -0
- package/dist/coverage-presentation.d.ts.map +1 -0
- package/dist/coverage-presentation.js +34 -0
- package/dist/coverage-presentation.js.map +1 -0
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +30 -4
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +3 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +7 -5
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +3 -0
- package/dist/default-severity-rubric.d.ts.map +1 -0
- package/dist/default-severity-rubric.js +67 -0
- package/dist/default-severity-rubric.js.map +1 -0
- package/dist/endor-findings.d.ts +8 -0
- package/dist/endor-findings.d.ts.map +1 -0
- package/dist/endor-findings.js +238 -0
- package/dist/endor-findings.js.map +1 -0
- package/dist/external-findings-import.d.ts +5 -0
- package/dist/external-findings-import.d.ts.map +1 -0
- package/dist/external-findings-import.js +46 -0
- package/dist/external-findings-import.js.map +1 -0
- package/dist/external-findings-local.d.ts +63 -0
- package/dist/external-findings-local.d.ts.map +1 -0
- package/dist/external-findings-local.js +344 -0
- package/dist/external-findings-local.js.map +1 -0
- package/dist/external-findings-publish.d.ts +73 -0
- package/dist/external-findings-publish.d.ts.map +1 -0
- package/dist/external-findings-publish.js +721 -0
- package/dist/external-findings-publish.js.map +1 -0
- package/dist/external-findings-read.d.ts +16 -0
- package/dist/external-findings-read.d.ts.map +1 -0
- package/dist/external-findings-read.js +97 -0
- package/dist/external-findings-read.js.map +1 -0
- package/dist/external-findings.d.ts +21 -0
- package/dist/external-findings.d.ts.map +1 -0
- package/dist/external-findings.js +2 -0
- package/dist/external-findings.js.map +1 -0
- package/dist/external-import-contract.d.ts +15 -0
- package/dist/external-import-contract.d.ts.map +1 -0
- package/dist/external-import-contract.js +262 -0
- package/dist/external-import-contract.js.map +1 -0
- package/dist/external-import-models.d.ts +362 -0
- package/dist/external-import-models.d.ts.map +1 -0
- package/dist/external-import-models.js +3 -0
- package/dist/external-import-models.js.map +1 -0
- package/dist/external-imports-feature.d.ts +6 -0
- package/dist/external-imports-feature.d.ts.map +1 -0
- package/dist/external-imports-feature.js +51 -0
- package/dist/external-imports-feature.js.map +1 -0
- package/dist/finding-workflow.d.ts +23 -6
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +23 -10
- package/dist/finding-workflow.js.map +1 -1
- package/dist/github-advisories.d.ts +386 -0
- package/dist/github-advisories.d.ts.map +1 -0
- package/dist/github-advisories.js +133 -0
- package/dist/github-advisories.js.map +1 -0
- package/dist/github-findings.d.ts +11 -0
- package/dist/github-findings.d.ts.map +1 -0
- package/dist/github-findings.js +258 -0
- package/dist/github-findings.js.map +1 -0
- package/dist/hosted-remediation-protocol.d.ts +2 -1
- package/dist/hosted-remediation-protocol.d.ts.map +1 -1
- package/dist/hosted-remediation-protocol.js +17 -11
- package/dist/hosted-remediation-protocol.js.map +1 -1
- package/dist/hosted-remediation.d.ts +4 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +22 -3
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/hosted-scan.d.ts +16 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +9 -2
- package/dist/hosted-scan.js.map +1 -1
- package/dist/import-scan.js +1 -1
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -0
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +17 -8
- package/dist/knowledge-base.js.map +1 -1
- package/dist/models.d.ts +1 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/owner-evidence.d.ts +2 -0
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -1
- package/dist/owner-evidence.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -0
- package/dist/project-config.js.map +1 -1
- package/dist/publish.d.ts +2 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/remediation.d.ts +7 -25
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +18 -28
- package/dist/remediation.js.map +1 -1
- package/dist/result.d.ts +4 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +10 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +10 -8
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts +5 -3
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +79 -26
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +8 -2
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-owner-suggestions.d.ts +8 -0
- package/dist/scan-owner-suggestions.d.ts.map +1 -0
- package/dist/scan-owner-suggestions.js +33 -0
- package/dist/scan-owner-suggestions.js.map +1 -0
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-usage-display.d.ts +8 -0
- package/dist/scan-usage-display.d.ts.map +1 -0
- package/dist/scan-usage-display.js +46 -0
- package/dist/scan-usage-display.js.map +1 -0
- package/dist/scanner-import.d.ts +20 -0
- package/dist/scanner-import.d.ts.map +1 -0
- package/dist/scanner-import.js +208 -0
- package/dist/scanner-import.js.map +1 -0
- package/dist/security-policy-diff.d.ts +2 -0
- package/dist/security-policy-diff.d.ts.map +1 -0
- package/dist/security-policy-diff.js +197 -0
- package/dist/security-policy-diff.js.map +1 -0
- package/dist/security-policy.d.ts +7 -3
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +11 -76
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +10 -0
- package/dist/semgrep-findings.d.ts.map +1 -0
- package/dist/semgrep-findings.js +293 -0
- package/dist/semgrep-findings.js.map +1 -0
- package/dist/severity-review.d.ts +3 -0
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +19 -0
- package/dist/severity-review.js.map +1 -1
- package/dist/severity-store.js +7 -2
- package/dist/severity-store.js.map +1 -1
- package/dist/skill-authentication.d.ts +18 -0
- package/dist/skill-authentication.d.ts.map +1 -0
- package/dist/skill-authentication.js +82 -0
- package/dist/skill-authentication.js.map +1 -0
- package/dist/snyk-findings.d.ts +10 -0
- package/dist/snyk-findings.d.ts.map +1 -0
- package/dist/snyk-findings.js +350 -0
- package/dist/snyk-findings.js.map +1 -0
- package/dist/suggest-owners.d.ts +4 -1
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +53 -21
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +2 -2
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +16 -3
- package/dist/targets.js.map +1 -1
- package/dist/wiz-csv.d.ts +9 -0
- package/dist/wiz-csv.d.ts.map +1 -0
- package/dist/wiz-csv.js +116 -0
- package/dist/wiz-csv.js.map +1 -0
- package/dist/wiz-findings.d.ts +5 -0
- package/dist/wiz-findings.d.ts.map +1 -0
- package/dist/wiz-findings.js +464 -0
- package/dist/wiz-findings.js.map +1 -0
- package/docs/classify-severity-records.md +30 -13
- package/docs/cli.md +835 -47
- package/docs/findings-service.md +119 -118
- package/docs/hosted-remediation.md +43 -24
- package/docs/hosted-scans.md +38 -0
- package/package.json +11 -9
- package/schemas/external-findings.schema.json +1421 -0
- package/schemas/project-config.schema.json +4 -0
- package/_bundled_plugin/scripts/generate_in_scope_files.py +0 -277
- package/_bundled_plugin/scripts/generate_rank_input.py +0 -350
- package/_bundled_plugin/scripts/rank_preview.py +0 -129
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-scan.d.ts","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,qFAAqF;AACrF,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"hosted-scan.d.ts","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAC5B,YA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CACjC,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,iBAAiB;;;;;;;;;;;aAwCf,CAAC;;;;;;;;;;;;;;;;;;;;;;YAiFA,WAAW;;;;;;;;;;;;;;;;;;aAjFZ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAsHb;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC"}
|
package/dist/hosted-scan.js
CHANGED
|
@@ -23,6 +23,7 @@ export const HostedScanInputSchema = z.strictObject({
|
|
|
23
23
|
stateDirectory: z.string().min(1),
|
|
24
24
|
model: z.string().min(1),
|
|
25
25
|
reasoningEffort: z.string(),
|
|
26
|
+
ownerSuggestions: z.boolean().optional(),
|
|
26
27
|
identity: z.strictObject({
|
|
27
28
|
runId: z.string().min(1),
|
|
28
29
|
attemptId: z.string().min(1),
|
|
@@ -179,6 +180,7 @@ export async function runHostedScan(value, options) {
|
|
|
179
180
|
mode: "standard",
|
|
180
181
|
outputDir: outputDirectory,
|
|
181
182
|
signal: options.signal,
|
|
183
|
+
ownerSuggestions: input.ownerSuggestions,
|
|
182
184
|
onOutputDirReady(path) {
|
|
183
185
|
outputDirectory = path;
|
|
184
186
|
},
|
|
@@ -194,8 +196,8 @@ export async function runHostedScan(value, options) {
|
|
|
194
196
|
},
|
|
195
197
|
});
|
|
196
198
|
if (result.manifest.scan.target.revision !== context.revision ||
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
// Owner cancellation cannot invalidate an already sealed base scan.
|
|
200
|
+
(await repositoryRevision(context.repository)) !== context.revision)
|
|
199
201
|
throw new Error("Checkout changed from the frozen revision during execution.");
|
|
200
202
|
if (!isDeepStrictEqual([...result.manifest.scan.scope.includePaths].sort(comparePaths), context.scope.paths) ||
|
|
201
203
|
result.manifest.scan.scope.excludePaths.length !== 0)
|
|
@@ -209,6 +211,8 @@ export async function runHostedScan(value, options) {
|
|
|
209
211
|
...result.manifest.scan.artifacts.map((artifact) => artifact.path),
|
|
210
212
|
...(isRecord(sources) ? Object.keys(sources) : []),
|
|
211
213
|
]);
|
|
214
|
+
if (result.ownerSuggestionsPath !== undefined)
|
|
215
|
+
names.add("owner-suggestions.json");
|
|
212
216
|
const artifacts = await Promise.all([...names].sort().map(async (path) => {
|
|
213
217
|
const contents = await readScanFile(outputDirectory, path, path);
|
|
214
218
|
return {
|
|
@@ -220,6 +224,9 @@ export async function runHostedScan(value, options) {
|
|
|
220
224
|
return {
|
|
221
225
|
...base(),
|
|
222
226
|
status: "completed",
|
|
227
|
+
...(result.ownerSuggestionsError === undefined
|
|
228
|
+
? {}
|
|
229
|
+
: { ownerSuggestionsError: result.ownerSuggestionsError }),
|
|
223
230
|
artifacts,
|
|
224
231
|
};
|
|
225
232
|
}
|
package/dist/hosted-scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-scan.js","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,GAKnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE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AQ,EAAE;oBACR,EAAE,EAAE,iBAAiB;oBACrB,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,QAAQ;oBAChB,WAAW,EAAE,+BAA+B,YAAY,CAAC,KAAK,CAAC,EAAE;oBACjE,KAAK,EAAE,EAAE;iBACV;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { readScanFile, safeScopePath } from \"./contract.js\";\nimport { isRecord } from \"./record.js\";\nimport { VERSION } from \"./version.js\";\nimport {\n ScanExecutionError,\n type ScanExecutor,\n type ScanExecutionResult,\n type ScanExecutionEvent,\n type ScanExecutionRequest,\n} from \"./scan-executor.js\";\nexport type { ScanExecutor, ScanExecutionRequest } from \"./scan-executor.js\";\nimport { realpath } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { CodexSecurity } from \"./api.js\";\nimport { ScanInterruptedError, errorMessage } from \"./errors.js\";\nimport { normalizeRepository, repositoryRevision } from \"./targets.js\";\nimport { isWithin } from \"./trusted-executable.js\";\n\n/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */\nexport const HostedScanInputSchema = z.strictObject({\n version: z.literal(2),\n repository: z.string().min(1),\n revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),\n scope: z\n .strictObject({ paths: z.array(z.string().min(1)).min(1) })\n .optional(),\n outputDirectory: z.string().min(1),\n stateDirectory: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.string(),\n identity: z.strictObject({\n runId: z.string().min(1),\n attemptId: z.string().min(1),\n buildId: z.string().min(1),\n }),\n});\n\nexport type HostedScanInput = z.infer<typeof HostedScanInputSchema>;\nexport class HostedScanPreparationError extends Error {\n constructor(\n readonly reason:\n | \"scope_syntax\"\n | \"scope_missing\"\n | \"scope_outside_repository\"\n | \"scope_alias\"\n | \"revision_mismatch\",\n message: string,\n ) {\n super(message);\n this.name = \"HostedScanPreparationError\";\n }\n}\n\nexport function normalizeHostedScope(path: string): string {\n const parts = path.split(process.platform === \"win32\" ? /[/\\\\]/ : \"/\");\n if (\n path.length === 0 ||\n path.includes(\"\\0\") ||\n isAbsolute(path) ||\n (process.platform === \"win32\" && /^[a-z]:/i.test(path)) ||\n parts.includes(\"..\")\n ) {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Use non-empty repository-relative folders or files without parent traversal or NUL characters.\",\n );\n }\n const normalized = parts\n .filter((part) => part !== \"\" && part !== \".\")\n .join(\"/\");\n try {\n return safeScopePath(normalized || \".\");\n } catch {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n `${JSON.stringify(path)} cannot be used as scan scope: the output contract requires UTF-8 repository-relative paths without drive prefixes, backslashes, or control characters.`,\n );\n }\n}\n\nfunction comparePaths(left: string, right: string): number {\n return Buffer.compare(Buffer.from(left), Buffer.from(right));\n}\n\nexport function normalizeHostedPaths(\n paths: readonly string[] = [\".\"],\n): string[] {\n if (paths.length === 0)\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"An explicit path scope must not be empty. Omit scope to scan the repository.\",\n );\n const normalized = [...new Set(paths.map(normalizeHostedScope))].sort(\n comparePaths,\n );\n if (normalized.length > 1 && normalized.includes(\".\"))\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Repository scope cannot be mixed with narrower paths.\",\n );\n return normalized;\n}\n\n/** Validate every path at the frozen commit before registering a scan/executing. */\nasync function prepareHostedScan(input: HostedScanInput, signal?: AbortSignal) {\n const scope = { paths: normalizeHostedPaths(input.scope?.paths) };\n const repository = await normalizeRepository(input.repository, signal);\n if ((await repositoryRevision(repository, signal)) !== input.revision)\n throw new HostedScanPreparationError(\n \"revision_mismatch\",\n \"Checkout does not match the frozen revision.\",\n );\n for (const path of scope.paths) {\n const selected = resolve(repository, path);\n let target: string;\n try {\n target = await realpath(selected);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n error.code !== \"ENOENT\"\n )\n throw error;\n throw new HostedScanPreparationError(\n \"scope_missing\",\n `${path} does not exist at the selected revision. Update the paths and start a new scan.`,\n );\n }\n if (!isWithin(repository, target))\n throw new HostedScanPreparationError(\n \"scope_outside_repository\",\n `${path} resolves outside the repository.`,\n );\n if (target !== selected) {\n const canonical =\n relative(repository, target).split(sep).join(\"/\") || \".\";\n throw new HostedScanPreparationError(\n \"scope_alias\",\n `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`,\n );\n }\n }\n return {\n repository,\n revision: input.revision,\n scope,\n identity: input.identity,\n };\n}\n\nfunction hostedScanEnvironment(stateDirectory: string): Record<string, string> {\n const environment: Record<string, string> = {\n PATH: process.env[\"PATH\"] ?? \"\",\n CODEX_SECURITY_STATE_DIR: resolve(stateDirectory),\n };\n for (const key of [\n \"SYSTEMROOT\",\n \"WINDIR\",\n \"PATHEXT\",\n \"TMPDIR\",\n \"TEMP\",\n \"TMP\",\n ])\n if (process.env[key] !== undefined) environment[key] = process.env[key]!;\n return environment;\n}\n\nexport interface HostedScanOptions {\n executor: ScanExecutor;\n signal?: AbortSignal;\n onEvent?: (event: ScanExecutionEvent) => void;\n}\n\n/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */\nexport async function runHostedScan(\n value: HostedScanInput,\n options: HostedScanOptions,\n) {\n const input = HostedScanInputSchema.parse(value);\n const context = await prepareHostedScan(input, options.signal);\n let execution: ScanExecutionResult | undefined;\n let request: ScanExecutionRequest | undefined;\n let scanId: string | undefined;\n const onEvent = (event: ScanExecutionEvent): void => {\n void Promise.resolve()\n .then(() => options.onEvent?.(event))\n .catch(() => {});\n };\n const client = new CodexSecurity(\n {\n codexOverrides: {\n model: input.model,\n model_reasoning_effort: input.reasoningEffort,\n },\n },\n {\n environment: hostedScanEnvironment(input.stateDirectory),\n hostedScan: {\n context,\n executor: {\n async run(value, runOptions) {\n request = value;\n execution = await options.executor.run(value, runOptions);\n return execution;\n },\n },\n onEvent,\n },\n createCodex() {\n throw new Error(\"Local inference is unavailable in hosted mode.\");\n },\n },\n { surface: \"sdk\" },\n );\n let outputDirectory = resolve(input.outputDirectory);\n const base = () => ({\n version: 2 as const,\n ...context,\n outputDirectory,\n ...(scanId === undefined ? {} : { scanId }),\n ...(request === undefined\n ? {}\n : {\n pluginVersion: request.runtime.pluginVersion,\n }),\n provenance: {\n cliVersion: VERSION,\n buildId: input.identity.buildId,\n ...(request === undefined\n ? {}\n : { pluginVersion: request.runtime.pluginVersion }),\n },\n ...(execution === undefined ? {} : { execution }),\n });\n try {\n const result = await client.run(context.repository, {\n target:\n context.scope.paths[0] === \".\"\n ? \"repository\"\n : context.scope.paths.map((path) => `./${path}`),\n mode: \"standard\",\n outputDir: outputDirectory,\n signal: options.signal,\n onOutputDirReady(path) {\n outputDirectory = path;\n },\n onScanRegistered(scan) {\n scanId = scan.scanId;\n outputDirectory = scan.scanDir;\n },\n onProgress(progress) {\n onEvent({ type: \"progress\", progress });\n },\n onActivity(activity) {\n onEvent({ type: \"activity\", activity });\n },\n });\n if (\n result.manifest.scan.target.revision !== context.revision ||\n (await repositoryRevision(context.repository, options.signal)) !==\n context.revision\n )\n throw new Error(\n \"Checkout changed from the frozen revision during execution.\",\n );\n if (\n !isDeepStrictEqual(\n [...result.manifest.scan.scope.includePaths].sort(comparePaths),\n context.scope.paths,\n ) ||\n result.manifest.scan.scope.excludePaths.length !== 0\n )\n throw new Error(\"Completed artifacts do not match the requested scope.\");\n const sources = result.manifest.scan[\"preservedSources\"];\n const names = new Set([\n \"scan-manifest.json\",\n \"findings.json\",\n \"coverage.json\",\n \"report.md\",\n ...result.manifest.scan.artifacts.map((artifact) => artifact.path),\n ...(isRecord(sources) ? Object.keys(sources) : []),\n ]);\n const artifacts = await Promise.all(\n [...names].sort().map(async (path) => {\n const contents = await readScanFile(outputDirectory, path, path);\n return {\n path,\n sha256: createHash(\"sha256\").update(contents).digest(\"hex\"),\n bytes: Buffer.byteLength(contents),\n };\n }),\n );\n return {\n ...base(),\n status: \"completed\" as const,\n artifacts,\n };\n } catch (error) {\n if (error instanceof ScanExecutionError) execution = error.result;\n return {\n ...base(),\n status:\n execution?.status === \"acceptance_unknown\"\n ? (\"acceptance_unknown\" as const)\n : options.signal?.aborted ||\n execution?.status === \"canceled\" ||\n error instanceof ScanInterruptedError\n ? (\"canceled\" as const)\n : (\"failed\" as const),\n error: errorMessage(error),\n artifacts: [],\n };\n } finally {\n try {\n await client.close();\n } catch (error) {\n onEvent({\n type: \"activity\",\n activity: {\n id: \"runtime.cleanup\",\n kind: \"message\",\n status: \"failed\",\n description: `Hosted scan cleanup failed: ${errorMessage(error)}`,\n paths: [],\n },\n });\n }\n }\n}\n\nexport type HostedScanResult = Awaited<ReturnType<typeof runHostedScan>>;\n"]}
|
|
1
|
+
{"version":3,"file":"hosted-scan.js","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,GAKnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,E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ACvC,CAAC,CAAE,UAAoB;oBACvB,CAAC,CAAE,QAAkB;YAC3B,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;YAC1B,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC;gBACN,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE;oBACR,EAAE,EAAE,iBAAiB;oBACrB,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,QAAQ;oBAChB,WAAW,EAAE,+BAA+B,YAAY,CAAC,KAAK,CAAC,EAAE;oBACjE,KAAK,EAAE,EAAE;iBACV;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { readScanFile, safeScopePath } from \"./contract.js\";\nimport { isRecord } from \"./record.js\";\nimport { VERSION } from \"./version.js\";\nimport {\n ScanExecutionError,\n type ScanExecutor,\n type ScanExecutionResult,\n type ScanExecutionEvent,\n type ScanExecutionRequest,\n} from \"./scan-executor.js\";\nexport type { ScanExecutor, ScanExecutionRequest } from \"./scan-executor.js\";\nimport { realpath } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { CodexSecurity } from \"./api.js\";\nimport { ScanInterruptedError, errorMessage } from \"./errors.js\";\nimport { normalizeRepository, repositoryRevision } from \"./targets.js\";\nimport { isWithin } from \"./trusted-executable.js\";\n\n/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */\nexport const HostedScanInputSchema = z.strictObject({\n version: z.literal(2),\n repository: z.string().min(1),\n revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),\n scope: z\n .strictObject({ paths: z.array(z.string().min(1)).min(1) })\n .optional(),\n outputDirectory: z.string().min(1),\n stateDirectory: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.string(),\n ownerSuggestions: z.boolean().optional(),\n identity: z.strictObject({\n runId: z.string().min(1),\n attemptId: z.string().min(1),\n buildId: z.string().min(1),\n }),\n});\n\nexport type HostedScanInput = z.infer<typeof HostedScanInputSchema>;\nexport class HostedScanPreparationError extends Error {\n constructor(\n readonly reason:\n | \"scope_syntax\"\n | \"scope_missing\"\n | \"scope_outside_repository\"\n | \"scope_alias\"\n | \"revision_mismatch\",\n message: string,\n ) {\n super(message);\n this.name = \"HostedScanPreparationError\";\n }\n}\n\nexport function normalizeHostedScope(path: string): string {\n const parts = path.split(process.platform === \"win32\" ? /[/\\\\]/ : \"/\");\n if (\n path.length === 0 ||\n path.includes(\"\\0\") ||\n isAbsolute(path) ||\n (process.platform === \"win32\" && /^[a-z]:/i.test(path)) ||\n parts.includes(\"..\")\n ) {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Use non-empty repository-relative folders or files without parent traversal or NUL characters.\",\n );\n }\n const normalized = parts\n .filter((part) => part !== \"\" && part !== \".\")\n .join(\"/\");\n try {\n return safeScopePath(normalized || \".\");\n } catch {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n `${JSON.stringify(path)} cannot be used as scan scope: the output contract requires UTF-8 repository-relative paths without drive prefixes, backslashes, or control characters.`,\n );\n }\n}\n\nfunction comparePaths(left: string, right: string): number {\n return Buffer.compare(Buffer.from(left), Buffer.from(right));\n}\n\nexport function normalizeHostedPaths(\n paths: readonly string[] = [\".\"],\n): string[] {\n if (paths.length === 0)\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"An explicit path scope must not be empty. Omit scope to scan the repository.\",\n );\n const normalized = [...new Set(paths.map(normalizeHostedScope))].sort(\n comparePaths,\n );\n if (normalized.length > 1 && normalized.includes(\".\"))\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Repository scope cannot be mixed with narrower paths.\",\n );\n return normalized;\n}\n\n/** Validate every path at the frozen commit before registering a scan/executing. */\nasync function prepareHostedScan(input: HostedScanInput, signal?: AbortSignal) {\n const scope = { paths: normalizeHostedPaths(input.scope?.paths) };\n const repository = await normalizeRepository(input.repository, signal);\n if ((await repositoryRevision(repository, signal)) !== input.revision)\n throw new HostedScanPreparationError(\n \"revision_mismatch\",\n \"Checkout does not match the frozen revision.\",\n );\n for (const path of scope.paths) {\n const selected = resolve(repository, path);\n let target: string;\n try {\n target = await realpath(selected);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n error.code !== \"ENOENT\"\n )\n throw error;\n throw new HostedScanPreparationError(\n \"scope_missing\",\n `${path} does not exist at the selected revision. Update the paths and start a new scan.`,\n );\n }\n if (!isWithin(repository, target))\n throw new HostedScanPreparationError(\n \"scope_outside_repository\",\n `${path} resolves outside the repository.`,\n );\n if (target !== selected) {\n const canonical =\n relative(repository, target).split(sep).join(\"/\") || \".\";\n throw new HostedScanPreparationError(\n \"scope_alias\",\n `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`,\n );\n }\n }\n return {\n repository,\n revision: input.revision,\n scope,\n identity: input.identity,\n };\n}\n\nfunction hostedScanEnvironment(stateDirectory: string): Record<string, string> {\n const environment: Record<string, string> = {\n PATH: process.env[\"PATH\"] ?? \"\",\n CODEX_SECURITY_STATE_DIR: resolve(stateDirectory),\n };\n for (const key of [\n \"SYSTEMROOT\",\n \"WINDIR\",\n \"PATHEXT\",\n \"TMPDIR\",\n \"TEMP\",\n \"TMP\",\n ])\n if (process.env[key] !== undefined) environment[key] = process.env[key]!;\n return environment;\n}\n\nexport interface HostedScanOptions {\n executor: ScanExecutor;\n /** @deprecated Automatic owner reports validate scan hints without additional inference. */\n ownerCodex?: {\n startThread(options: { model?: string; modelReasoningEffort?: string }): {\n run(\n input: string,\n options: { outputSchema?: unknown; signal?: AbortSignal },\n ): Promise<{ finalResponse: string }>;\n };\n };\n signal?: AbortSignal;\n onEvent?: (event: ScanExecutionEvent) => void;\n}\n\n/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */\nexport async function runHostedScan(\n value: HostedScanInput,\n options: HostedScanOptions,\n) {\n const input = HostedScanInputSchema.parse(value);\n const context = await prepareHostedScan(input, options.signal);\n let execution: ScanExecutionResult | undefined;\n let request: ScanExecutionRequest | undefined;\n let scanId: string | undefined;\n const onEvent = (event: ScanExecutionEvent): void => {\n void Promise.resolve()\n .then(() => options.onEvent?.(event))\n .catch(() => {});\n };\n const client = new CodexSecurity(\n {\n codexOverrides: {\n model: input.model,\n model_reasoning_effort: input.reasoningEffort,\n },\n },\n {\n environment: hostedScanEnvironment(input.stateDirectory),\n hostedScan: {\n context,\n executor: {\n async run(value, runOptions) {\n request = value;\n execution = await options.executor.run(value, runOptions);\n return execution;\n },\n },\n onEvent,\n },\n createCodex() {\n throw new Error(\"Local inference is unavailable in hosted mode.\");\n },\n },\n { surface: \"sdk\" },\n );\n let outputDirectory = resolve(input.outputDirectory);\n const base = () => ({\n version: 2 as const,\n ...context,\n outputDirectory,\n ...(scanId === undefined ? {} : { scanId }),\n ...(request === undefined\n ? {}\n : {\n pluginVersion: request.runtime.pluginVersion,\n }),\n provenance: {\n cliVersion: VERSION,\n buildId: input.identity.buildId,\n ...(request === undefined\n ? {}\n : { pluginVersion: request.runtime.pluginVersion }),\n },\n ...(execution === undefined ? {} : { execution }),\n });\n try {\n const result = await client.run(context.repository, {\n target:\n context.scope.paths[0] === \".\"\n ? \"repository\"\n : context.scope.paths.map((path) => `./${path}`),\n mode: \"standard\",\n outputDir: outputDirectory,\n signal: options.signal,\n ownerSuggestions: input.ownerSuggestions,\n onOutputDirReady(path) {\n outputDirectory = path;\n },\n onScanRegistered(scan) {\n scanId = scan.scanId;\n outputDirectory = scan.scanDir;\n },\n onProgress(progress) {\n onEvent({ type: \"progress\", progress });\n },\n onActivity(activity) {\n onEvent({ type: \"activity\", activity });\n },\n });\n if (\n result.manifest.scan.target.revision !== context.revision ||\n // Owner cancellation cannot invalidate an already sealed base scan.\n (await repositoryRevision(context.repository)) !== context.revision\n )\n throw new Error(\n \"Checkout changed from the frozen revision during execution.\",\n );\n if (\n !isDeepStrictEqual(\n [...result.manifest.scan.scope.includePaths].sort(comparePaths),\n context.scope.paths,\n ) ||\n result.manifest.scan.scope.excludePaths.length !== 0\n )\n throw new Error(\"Completed artifacts do not match the requested scope.\");\n const sources = result.manifest.scan[\"preservedSources\"];\n const names = new Set([\n \"scan-manifest.json\",\n \"findings.json\",\n \"coverage.json\",\n \"report.md\",\n ...result.manifest.scan.artifacts.map((artifact) => artifact.path),\n ...(isRecord(sources) ? Object.keys(sources) : []),\n ]);\n if (result.ownerSuggestionsPath !== undefined)\n names.add(\"owner-suggestions.json\");\n const artifacts = await Promise.all(\n [...names].sort().map(async (path) => {\n const contents = await readScanFile(outputDirectory, path, path);\n return {\n path,\n sha256: createHash(\"sha256\").update(contents).digest(\"hex\"),\n bytes: Buffer.byteLength(contents),\n };\n }),\n );\n return {\n ...base(),\n status: \"completed\" as const,\n ...(result.ownerSuggestionsError === undefined\n ? {}\n : { ownerSuggestionsError: result.ownerSuggestionsError }),\n artifacts,\n };\n } catch (error) {\n if (error instanceof ScanExecutionError) execution = error.result;\n return {\n ...base(),\n status:\n execution?.status === \"acceptance_unknown\"\n ? (\"acceptance_unknown\" as const)\n : options.signal?.aborted ||\n execution?.status === \"canceled\" ||\n error instanceof ScanInterruptedError\n ? (\"canceled\" as const)\n : (\"failed\" as const),\n error: errorMessage(error),\n artifacts: [],\n };\n } finally {\n try {\n await client.close();\n } catch (error) {\n onEvent({\n type: \"activity\",\n activity: {\n id: \"runtime.cleanup\",\n kind: \"message\",\n status: \"failed\",\n description: `Hosted scan cleanup failed: ${errorMessage(error)}`,\n paths: [],\n },\n });\n }\n }\n}\n\nexport type HostedScanResult = Awaited<ReturnType<typeof runHostedScan>>;\n"]}
|
package/dist/import-scan.js
CHANGED
|
@@ -231,7 +231,7 @@ export async function importScan(options, dependencies = {}) {
|
|
|
231
231
|
"fail-scan",
|
|
232
232
|
"--scan-id",
|
|
233
233
|
activeScan.id,
|
|
234
|
-
`--message=${errorMessage(error)
|
|
234
|
+
`--message=${errorMessage(error)}`,
|
|
235
235
|
]).catch(() => undefined);
|
|
236
236
|
}
|
|
237
237
|
if (signal?.aborted) {
|
package/dist/import-scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-scan.js","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,UAAU,EACV,cAAc,EACd,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,GA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iBACnB,IAAI,CAAC,GAAG,EAAE,CACT,YAAY,CAAC,SAAS,EAAE,CACtB,uDAAuD,YAAY,CAAC,KAAK,CAAC,EAAE,CAC7E,CACF;iBACA,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { workbenchArgs } from \"./workbench-arguments.js\";\nimport { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readFile,\n realpath,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexSecurityConfig } from \"./config.js\";\nimport { loadContract, sameCheckedFileDevice } from \"./contract.js\";\nimport {\n CodexSecurityError,\n ScanInterruptedError,\n errorMessage,\n} from \"./errors.js\";\nimport {\n bindImportedFindings,\n parseImportedFindings,\n} from \"./findings-import.js\";\nimport { ScanResult } from \"./result.js\";\nimport {\n bundledPluginRoot,\n cleanupSdkDirectory,\n codexSecurityStateDirectory,\n expandHome,\n pluginMetadata,\n prepareScanRegistrationOutput,\n preparePersistentOutputRoot,\n requireOutputOutsideRepository,\n requirePrivateOutputDirectory,\n requireSecureOutputAncestry,\n resolvePluginPath,\n resolvePluginPython,\n runWorkbench,\n validateOutputDir,\n type ProcessEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport interface ImportScanOptions {\n sourcePath: string;\n format: \"csv\" | \"json\";\n config?: CodexSecurityConfig;\n outputDir?: string;\n archiveExisting?: boolean;\n dryRun?: boolean;\n parentScanId?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportScanPreview {\n dryRun: true;\n inputPath: string;\n format: \"csv\" | \"json\";\n findingCount: number;\n}\n\nexport interface ImportScanDependencies {\n environment?: ProcessEnvironment;\n runWorkbench?: typeof runWorkbench;\n resolvePluginPython?: typeof resolvePluginPython;\n onWarning?: (warning: string) => void;\n}\n\nconst IMPORT_DESCRIPTION =\n \"Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.\";\n\nasync function readImportSource(\n inputPath: string,\n signal?: AbortSignal,\n): Promise<Buffer> {\n signal?.throwIfAborted();\n const selected = await lstat(inputPath, { bigint: true });\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Import source must be a regular file.\");\n }\n for (let parent = dirname(inputPath); ; parent = dirname(parent)) {\n signal?.throwIfAborted();\n if ((await lstat(parent)).isSymbolicLink()) {\n throw new CodexSecurityError(\n \"Import source must not traverse directory links. Use the direct filesystem path.\",\n );\n }\n if (dirname(parent) === parent) break;\n }\n const path = join(await realpath(dirname(inputPath)), basename(inputPath));\n const file = await open(\n path,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n signal?.throwIfAborted();\n const opened = await file.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (\n !opened.isFile() ||\n !current.isFile() ||\n current.dev !== selected.dev ||\n current.ino !== selected.ino ||\n !(await sameCheckedFileDevice(file, { path, metadata: selected }, opened))\n ) {\n throw new CodexSecurityError(\n \"Import source must remain the selected regular file.\",\n );\n }\n return await file.readFile({ signal });\n } finally {\n await file.close();\n }\n}\n\n/** Save supplied findings through the normal scan completion and indexing flow. */\nexport async function importScan(\n options: ImportScanOptions,\n dependencies: ImportScanDependencies = {},\n): Promise<ScanResult | ImportScanPreview> {\n const { signal } = options;\n const environment = dependencies.environment ?? process.env;\n const inputPath = resolve(expandHome(options.sourcePath, environment));\n const source = await readImportSource(inputPath, signal);\n const workspace = await mkdtemp(\n join(await realpath(tmpdir()), \"codex-security-import-\"),\n );\n const workbench = dependencies.runWorkbench ?? runWorkbench;\n let activeScan: { id: string; options: WorkbenchCommandOptions } | undefined;\n let scanDir = \"\";\n try {\n const pluginRoot = await resolvePluginPath(\n options.config?.pluginPath,\n workspace,\n signal,\n );\n const findings = await parseImportedFindings(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(source),\n options.format,\n pluginRoot,\n );\n const helper = (\n await import(\n pathToFileURL(join(await bundledPluginRoot(), \"mcp/helpers.mjs\")).href\n )\n ).default;\n try {\n helper.parseCurrentFindings(\n findings.map((finding) => {\n // Import assigns new identities and retains source metadata as provenance.\n const { findingId, occurrenceId, fingerprints, writeup, ...content } =\n finding;\n return {\n ...content,\n provenance: { source: `${options.format}_import` },\n };\n }),\n );\n } catch (error) {\n throw new CodexSecurityError(\n `Imported findings do not match the current scan-draft finding contract: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n signal?.throwIfAborted();\n await validateOutputDir(options.outputDir, options.archiveExisting);\n if (options.dryRun) {\n return {\n dryRun: true,\n inputPath,\n format: options.format,\n findingCount: findings.length,\n };\n }\n const plugin = await pluginMetadata(pluginRoot);\n const stateDirectory = codexSecurityStateDirectory(environment);\n const digest = createHash(\"sha256\")\n .update(options.format)\n .update(\"\\0\")\n .update(source)\n .digest(\"hex\");\n // A retained input directory is the scan target, independent of the caller's repository.\n const repository = await preparePersistentOutputRoot(\n stateDirectory,\n \"imports\",\n `${options.format}-${digest}`,\n );\n requirePrivateOutputDirectory(await lstat(repository), repository);\n await requireSecureOutputAncestry(repository);\n const sourcePath = join(repository, `source.${options.format}`);\n try {\n await writeFile(sourcePath, source, { flag: \"wx\", signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (!(await readFile(sourcePath, { signal })).equals(source)) {\n throw new CodexSecurityError(\"The retained import source has changed.\");\n }\n }\n const python = await (\n dependencies.resolvePluginPython ?? resolvePluginPython\n )({\n configuredPath: options.config?.pythonPath,\n environment,\n protectedRoot: repository,\n signal,\n });\n const outputRoot =\n options.outputDir === undefined\n ? await preparePersistentOutputRoot(stateDirectory, \"scans\", \"imports\")\n : undefined;\n scanDir = await prepareScanRegistrationOutput(\n options.outputDir,\n \"import\",\n outputRoot,\n (path) => requireOutputOutsideRepository(repository, path),\n options.archiveExisting,\n );\n const workbenchOptions: WorkbenchCommandOptions = {\n python,\n pluginRoot,\n environment: { ...environment, CODEX_SECURITY_STATE_DIR: stateDirectory },\n signal,\n failureMessage: \"Could not save the imported scan\",\n };\n signal?.throwIfAborted();\n const registration = await workbench(\n workbenchOptions,\n workbenchArgs(\"register-cli-scan\", {\n repository,\n scanDir,\n registrationJsonStdin: true,\n archiveExisting: Boolean(options.archiveExisting),\n parentScanId: options.parentScanId,\n }),\n JSON.stringify({\n recipe: {\n repository,\n target: { kind: \"repository\", paths: [] },\n mode: \"standard\",\n pluginVersion: plugin.version,\n config: {},\n import: { format: options.format, sourcePath },\n },\n }),\n );\n const scanId = registration[\"scanId\"];\n const targetId = registration[\"targetId\"];\n if (\n typeof scanId !== \"string\" ||\n typeof targetId !== \"string\" ||\n registration[\"scanDir\"] !== scanDir\n ) {\n throw new CodexSecurityError(\n \"The workbench returned an invalid import scan registration.\",\n );\n }\n activeScan = { id: scanId, options: workbenchOptions };\n signal?.throwIfAborted();\n const bound = bindImportedFindings(\n findings,\n options.format,\n scanId,\n targetId,\n );\n const sourceRef = `artifacts/import/source.${options.format}`;\n await mkdir(join(scanDir, \"artifacts\", \"import\"), { recursive: true });\n await writeFile(join(scanDir, sourceRef), source, { flag: \"wx\", signal });\n const documents: Record<string, unknown> = {\n \"scan-manifest.json\": {\n scan: {\n target: { kind: \"directory_snapshot\" },\n scope: {\n summary: IMPORT_DESCRIPTION,\n runtimeStatus: \"imported\",\n limitations: [IMPORT_DESCRIPTION],\n },\n extensions: {\n import: {\n format: options.format,\n sourceRef,\n findingCount: findings.length,\n },\n },\n },\n },\n \"findings.json\": { findings: bound },\n \"coverage.json\": {\n inventoryStrategy: \"custom\",\n surfaces: findings.length\n ? [\n {\n id: \"import\",\n label: basename(inputPath),\n disposition: \"reported\",\n receiptRefs: [sourceRef],\n notes: IMPORT_DESCRIPTION,\n },\n ]\n : [],\n explicitExclusions: [],\n deferred: [],\n },\n };\n for (const [name, document] of Object.entries(documents)) {\n await writeFile(\n join(scanDir, name),\n `${JSON.stringify(document, null, 2)}\\n`,\n { flag: \"wx\", signal },\n );\n }\n await workbench(\n workbenchOptions,\n workbenchArgs(\"prepare-scan-completion\", { scanId }),\n );\n // Finalization normally recovers partial output. An import must retain every supplied row.\n const contract = await loadContract(scanDir, {\n pluginRoot,\n expectedScanId: scanId,\n workbenchValidated: true,\n signal,\n });\n const expectedIds = new Set(bound.map((finding) => finding.findingId));\n if (\n contract.findings.findings.length !== findings.length ||\n contract.findings.findings.some(\n (finding) => !expectedIds.delete(finding.findingId),\n )\n ) {\n throw new CodexSecurityError(\n \"Import finalization did not preserve every input finding; the scan was not completed.\",\n );\n }\n await workbench(workbenchOptions, [\"complete-scan\", \"--scan-id\", scanId]);\n activeScan = undefined;\n return new ScanResult({\n ...contract,\n scanDir,\n threadId: \"\",\n turnResult: {\n status: \"completed\",\n imported: true,\n finalResponse: IMPORT_DESCRIPTION,\n },\n });\n } catch (error) {\n if (activeScan !== undefined) {\n await workbench({ ...activeScan.options, signal: undefined }, [\n \"fail-scan\",\n \"--scan-id\",\n activeScan.id,\n `--message=${errorMessage(error).slice(0, 2400)}`,\n ]).catch(() => undefined);\n }\n if (signal?.aborted) {\n throw new ScanInterruptedError(\n \"Codex Security import was interrupted.\",\n scanDir,\n { cause: error },\n );\n }\n throw error;\n } finally {\n await cleanupSdkDirectory(workspace).catch((error: unknown) => {\n void Promise.resolve()\n .then(() =>\n dependencies.onWarning?.(\n `Could not clean up after the Codex Security import: ${errorMessage(error)}`,\n ),\n )\n .catch(() => {});\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"import-scan.js","sourceRoot":"","sources":["../src/import-scan.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE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,WAAW;gBACnB,QAAQ,EAAE,IAAI;gBACd,aAAa,EAAE,kBAAkB;aAClC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,SAAS,CAAC,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;gBAC5D,WAAW;gBACX,WAAW;gBACX,UAAU,CAAC,EAAE;gBACb,aAAa,YAAY,CAAC,KAAK,CAAC,EAAE;aACnC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,CAC5B,wCAAwC,EACxC,OAAO,EACP,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5D,KAAK,OAAO,CAAC,OAAO,EAAE;iBACnB,IAAI,CAAC,GAAG,EAAE,CACT,YAAY,CAAC,SAAS,EAAE,CACtB,uDAAuD,YAAY,CAAC,KAAK,CAAC,EAAE,CAC7E,CACF;iBACA,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { workbenchArgs } from \"./workbench-arguments.js\";\nimport { createHash } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n open,\n readFile,\n realpath,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CodexSecurityConfig } from \"./config.js\";\nimport { loadContract, sameCheckedFileDevice } from \"./contract.js\";\nimport {\n CodexSecurityError,\n ScanInterruptedError,\n errorMessage,\n} from \"./errors.js\";\nimport {\n bindImportedFindings,\n parseImportedFindings,\n} from \"./findings-import.js\";\nimport { ScanResult } from \"./result.js\";\nimport {\n bundledPluginRoot,\n cleanupSdkDirectory,\n codexSecurityStateDirectory,\n expandHome,\n pluginMetadata,\n prepareScanRegistrationOutput,\n preparePersistentOutputRoot,\n requireOutputOutsideRepository,\n requirePrivateOutputDirectory,\n requireSecureOutputAncestry,\n resolvePluginPath,\n resolvePluginPython,\n runWorkbench,\n validateOutputDir,\n type ProcessEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport interface ImportScanOptions {\n sourcePath: string;\n format: \"csv\" | \"json\";\n config?: CodexSecurityConfig;\n outputDir?: string;\n archiveExisting?: boolean;\n dryRun?: boolean;\n parentScanId?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportScanPreview {\n dryRun: true;\n inputPath: string;\n format: \"csv\" | \"json\";\n findingCount: number;\n}\n\nexport interface ImportScanDependencies {\n environment?: ProcessEnvironment;\n runWorkbench?: typeof runWorkbench;\n resolvePluginPython?: typeof resolvePluginPython;\n onWarning?: (warning: string) => void;\n}\n\nconst IMPORT_DESCRIPTION =\n \"Imported findings; no security analysis was performed. Coverage is unknown. Source locations describe the imported reports.\";\n\nasync function readImportSource(\n inputPath: string,\n signal?: AbortSignal,\n): Promise<Buffer> {\n signal?.throwIfAborted();\n const selected = await lstat(inputPath, { bigint: true });\n if (!selected.isFile()) {\n throw new CodexSecurityError(\"Import source must be a regular file.\");\n }\n for (let parent = dirname(inputPath); ; parent = dirname(parent)) {\n signal?.throwIfAborted();\n if ((await lstat(parent)).isSymbolicLink()) {\n throw new CodexSecurityError(\n \"Import source must not traverse directory links. Use the direct filesystem path.\",\n );\n }\n if (dirname(parent) === parent) break;\n }\n const path = join(await realpath(dirname(inputPath)), basename(inputPath));\n const file = await open(\n path,\n constants.O_RDONLY |\n (constants.O_NOFOLLOW ?? 0) |\n (constants.O_NONBLOCK ?? 0),\n );\n try {\n signal?.throwIfAborted();\n const opened = await file.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (\n !opened.isFile() ||\n !current.isFile() ||\n current.dev !== selected.dev ||\n current.ino !== selected.ino ||\n !(await sameCheckedFileDevice(file, { path, metadata: selected }, opened))\n ) {\n throw new CodexSecurityError(\n \"Import source must remain the selected regular file.\",\n );\n }\n return await file.readFile({ signal });\n } finally {\n await file.close();\n }\n}\n\n/** Save supplied findings through the normal scan completion and indexing flow. */\nexport async function importScan(\n options: ImportScanOptions,\n dependencies: ImportScanDependencies = {},\n): Promise<ScanResult | ImportScanPreview> {\n const { signal } = options;\n const environment = dependencies.environment ?? process.env;\n const inputPath = resolve(expandHome(options.sourcePath, environment));\n const source = await readImportSource(inputPath, signal);\n const workspace = await mkdtemp(\n join(await realpath(tmpdir()), \"codex-security-import-\"),\n );\n const workbench = dependencies.runWorkbench ?? runWorkbench;\n let activeScan: { id: string; options: WorkbenchCommandOptions } | undefined;\n let scanDir = \"\";\n try {\n const pluginRoot = await resolvePluginPath(\n options.config?.pluginPath,\n workspace,\n signal,\n );\n const findings = await parseImportedFindings(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(source),\n options.format,\n pluginRoot,\n );\n const helper = (\n await import(\n pathToFileURL(join(await bundledPluginRoot(), \"mcp/helpers.mjs\")).href\n )\n ).default;\n try {\n helper.parseCurrentFindings(\n findings.map((finding) => {\n // Import assigns new identities and retains source metadata as provenance.\n const { findingId, occurrenceId, fingerprints, writeup, ...content } =\n finding;\n return {\n ...content,\n provenance: { source: `${options.format}_import` },\n };\n }),\n );\n } catch (error) {\n throw new CodexSecurityError(\n `Imported findings do not match the current scan-draft finding contract: ${errorMessage(error)}`,\n { cause: error },\n );\n }\n signal?.throwIfAborted();\n await validateOutputDir(options.outputDir, options.archiveExisting);\n if (options.dryRun) {\n return {\n dryRun: true,\n inputPath,\n format: options.format,\n findingCount: findings.length,\n };\n }\n const plugin = await pluginMetadata(pluginRoot);\n const stateDirectory = codexSecurityStateDirectory(environment);\n const digest = createHash(\"sha256\")\n .update(options.format)\n .update(\"\\0\")\n .update(source)\n .digest(\"hex\");\n // A retained input directory is the scan target, independent of the caller's repository.\n const repository = await preparePersistentOutputRoot(\n stateDirectory,\n \"imports\",\n `${options.format}-${digest}`,\n );\n requirePrivateOutputDirectory(await lstat(repository), repository);\n await requireSecureOutputAncestry(repository);\n const sourcePath = join(repository, `source.${options.format}`);\n try {\n await writeFile(sourcePath, source, { flag: \"wx\", signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (!(await readFile(sourcePath, { signal })).equals(source)) {\n throw new CodexSecurityError(\"The retained import source has changed.\");\n }\n }\n const python = await (\n dependencies.resolvePluginPython ?? resolvePluginPython\n )({\n configuredPath: options.config?.pythonPath,\n environment,\n protectedRoot: repository,\n signal,\n });\n const outputRoot =\n options.outputDir === undefined\n ? await preparePersistentOutputRoot(stateDirectory, \"scans\", \"imports\")\n : undefined;\n scanDir = await prepareScanRegistrationOutput(\n options.outputDir,\n \"import\",\n outputRoot,\n (path) => requireOutputOutsideRepository(repository, path),\n options.archiveExisting,\n );\n const workbenchOptions: WorkbenchCommandOptions = {\n python,\n pluginRoot,\n environment: { ...environment, CODEX_SECURITY_STATE_DIR: stateDirectory },\n signal,\n failureMessage: \"Could not save the imported scan\",\n };\n signal?.throwIfAborted();\n const registration = await workbench(\n workbenchOptions,\n workbenchArgs(\"register-cli-scan\", {\n repository,\n scanDir,\n registrationJsonStdin: true,\n archiveExisting: Boolean(options.archiveExisting),\n parentScanId: options.parentScanId,\n }),\n JSON.stringify({\n recipe: {\n repository,\n target: { kind: \"repository\", paths: [] },\n mode: \"standard\",\n pluginVersion: plugin.version,\n config: {},\n import: { format: options.format, sourcePath },\n },\n }),\n );\n const scanId = registration[\"scanId\"];\n const targetId = registration[\"targetId\"];\n if (\n typeof scanId !== \"string\" ||\n typeof targetId !== \"string\" ||\n registration[\"scanDir\"] !== scanDir\n ) {\n throw new CodexSecurityError(\n \"The workbench returned an invalid import scan registration.\",\n );\n }\n activeScan = { id: scanId, options: workbenchOptions };\n signal?.throwIfAborted();\n const bound = bindImportedFindings(\n findings,\n options.format,\n scanId,\n targetId,\n );\n const sourceRef = `artifacts/import/source.${options.format}`;\n await mkdir(join(scanDir, \"artifacts\", \"import\"), { recursive: true });\n await writeFile(join(scanDir, sourceRef), source, { flag: \"wx\", signal });\n const documents: Record<string, unknown> = {\n \"scan-manifest.json\": {\n scan: {\n target: { kind: \"directory_snapshot\" },\n scope: {\n summary: IMPORT_DESCRIPTION,\n runtimeStatus: \"imported\",\n limitations: [IMPORT_DESCRIPTION],\n },\n extensions: {\n import: {\n format: options.format,\n sourceRef,\n findingCount: findings.length,\n },\n },\n },\n },\n \"findings.json\": { findings: bound },\n \"coverage.json\": {\n inventoryStrategy: \"custom\",\n surfaces: findings.length\n ? [\n {\n id: \"import\",\n label: basename(inputPath),\n disposition: \"reported\",\n receiptRefs: [sourceRef],\n notes: IMPORT_DESCRIPTION,\n },\n ]\n : [],\n explicitExclusions: [],\n deferred: [],\n },\n };\n for (const [name, document] of Object.entries(documents)) {\n await writeFile(\n join(scanDir, name),\n `${JSON.stringify(document, null, 2)}\\n`,\n { flag: \"wx\", signal },\n );\n }\n await workbench(\n workbenchOptions,\n workbenchArgs(\"prepare-scan-completion\", { scanId }),\n );\n // Finalization normally recovers partial output. An import must retain every supplied row.\n const contract = await loadContract(scanDir, {\n pluginRoot,\n expectedScanId: scanId,\n workbenchValidated: true,\n signal,\n });\n const expectedIds = new Set(bound.map((finding) => finding.findingId));\n if (\n contract.findings.findings.length !== findings.length ||\n contract.findings.findings.some(\n (finding) => !expectedIds.delete(finding.findingId),\n )\n ) {\n throw new CodexSecurityError(\n \"Import finalization did not preserve every input finding; the scan was not completed.\",\n );\n }\n await workbench(workbenchOptions, [\"complete-scan\", \"--scan-id\", scanId]);\n activeScan = undefined;\n return new ScanResult({\n ...contract,\n scanDir,\n threadId: \"\",\n turnResult: {\n status: \"completed\",\n imported: true,\n finalResponse: IMPORT_DESCRIPTION,\n },\n });\n } catch (error) {\n if (activeScan !== undefined) {\n await workbench({ ...activeScan.options, signal: undefined }, [\n \"fail-scan\",\n \"--scan-id\",\n activeScan.id,\n `--message=${errorMessage(error)}`,\n ]).catch(() => undefined);\n }\n if (signal?.aborted) {\n throw new ScanInterruptedError(\n \"Codex Security import was interrupted.\",\n scanDir,\n { cause: error },\n );\n }\n throw error;\n } finally {\n await cleanupSdkDirectory(workspace).catch((error: unknown) => {\n void Promise.resolve()\n .then(() =>\n dependencies.onWarning?.(\n `Could not clean up after the Codex Security import: ${errorMessage(error)}`,\n ),\n )\n .catch(() => {});\n });\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { CodexSecurity, createSecurity } from "./api.js";
|
|
|
4
4
|
export { runHostedRemediation, HostedRemediationInputSchema, HostedRemediationPreparationError, } from "./hosted-remediation.js";
|
|
5
5
|
export type { HostedRemediationInput, HostedRemediationOptions, HostedRemediationResult, RemediationExecutor, RemediationExecutionRequest, RemediationExecutionResult, RemediationExecutionEvent, } from "./hosted-remediation.js";
|
|
6
6
|
export { runHostedRemediationProtocol } from "./hosted-remediation-protocol.js";
|
|
7
|
-
export type { FindingPatch, FindingVerification
|
|
7
|
+
export type { FindingPatch, FindingVerification } from "./remediation.js";
|
|
8
8
|
export { runHostedScan, HostedScanInputSchema, HostedScanPreparationError, } from "./hosted-scan.js";
|
|
9
9
|
export type { HostedScanInput, HostedScanOptions, HostedScanResult, } from "./hosted-scan.js";
|
|
10
10
|
export type { ScanExecutor, ScanExecutionRequest, ScanExecutionResult, ScanExecutionEvent, } from "./scan-executor.js";
|
|
@@ -13,7 +13,7 @@ export type { ResolvedProjectConfig, ProjectConfigProvenance, } from "./project-
|
|
|
13
13
|
export type { ProjectConfigInput, ProjectScope, } from "./project-config-schema.js";
|
|
14
14
|
export type { ScanSettings } from "./scan-settings.js";
|
|
15
15
|
export { classifySeverity } from "./classify-severity.js";
|
|
16
|
-
export { suggestOwners } from "./suggest-owners.js";
|
|
16
|
+
export { suggestOwners, suggestOwnersFromScan } from "./suggest-owners.js";
|
|
17
17
|
export type { OwnerFinding, CodeownerIdentity, OwnerIdentity, OwnerSuggestion, OwnerSuggestions, SuggestOwnersOptions, } from "./suggest-owners.js";
|
|
18
18
|
export type { ClassifySeverityOptions, SeverityClassificationFinding, SeverityClassification, SeverityAssessment, } from "./classify-severity.js";
|
|
19
19
|
export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
|
|
@@ -23,7 +23,7 @@ export type { ComponentDeduplicationSummary, ComponentReceipt, ComponentScanOpti
|
|
|
23
23
|
export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
24
24
|
export type { ComponentPlan, ComponentPlanningOptions, } from "./component-plan.js";
|
|
25
25
|
export { estimateScanCost } from "./cost.js";
|
|
26
|
-
export type { ScanCost, ScanSessionEvent, ScanWorkerEvent } from "./cost.js";
|
|
26
|
+
export type { ScanAccountRateLimit, ScanAccountRateLimitWindow, ScanCost, ScanSessionEvent, ScanUsageObservation, ScanWorkerEvent, } from "./cost.js";
|
|
27
27
|
export type { ScanTokenUsage } from "./cost-model.js";
|
|
28
28
|
export type { DeepScanProgress } from "./scan-progress.js";
|
|
29
29
|
export type { CustomValidationResult } from "./custom-validation.js";
|
|
@@ -55,6 +55,15 @@ export type { DeduplicationRefusal } from "./deduplication/deduplication.js";
|
|
|
55
55
|
export type { FindingEmbeddingBinding } from "./deduplication/local.js";
|
|
56
56
|
export type { DeduplicationDiagnostic, DeduplicationDiagnosticObserver, } from "./deduplication/diagnostics.js";
|
|
57
57
|
export type { FindingEmbedder } from "./server/embeddings.js";
|
|
58
|
+
export { ExternalPublicationError, prepareExternalPublication, prepareNormalizedExternalPublication, } from "./external-findings-publish.js";
|
|
59
|
+
export type { ExternalPublicationOptions, NormalizedExternalPublicationOptions, ExternalPublicationDependencies, ExternalPublicationPreview, ExternalPublicationProgress, ExternalPublicationResult, PreparedExternalPublication, } from "./external-findings-publish.js";
|
|
60
|
+
export { prepareNormalizedLocalImport, listLocalExternalFindings, } from "./external-findings-local.js";
|
|
61
|
+
export type { StoredExternalFinding, NormalizedLocalImportOptions, LocalExternalImportDependencies, LocalExternalImportPreview, LocalExternalImportResult, PreparedLocalExternalImport, } from "./external-findings-local.js";
|
|
62
|
+
export type { ExternalFinding, ExternalFindings, ExternalSourceRepository, } from "./external-findings.js";
|
|
63
|
+
export type { ExternalFindingEvidence, FindingImportRequest, FindingImportReceipt, ImportRepository, SourceReport, } from "./external-import-models.js";
|
|
64
|
+
export { normalizeGitHubCodeScanningAlerts, normalizeGitHubAdvisories, readGitHubFindings, } from "./github-findings.js";
|
|
65
|
+
export { importGitHubAdvisories } from "./github-advisories.js";
|
|
66
|
+
export type { GitHubAdvisoryImportOptions, ImportedGitHubAdvisory, } from "./github-advisories.js";
|
|
58
67
|
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
59
68
|
export type { GitHubCodeScanningImportOptions, ImportedGitHubCodeScanningAlert, } from "./github.js";
|
|
60
69
|
export type { CheckScanPublicationOptions, CheckScanPublicationResult, PublishScanOptions, PublishScanProgress, PublishScanResult, } from "./publish.js";
|
|
@@ -70,4 +79,8 @@ export { classifySeverityRecords, classifySeverityRecordsInputSchema, } from "./
|
|
|
70
79
|
export type { ClassifySeverityRecordsInput, ClassifySeverityRecordsOptions, ClassifySeverityRecordsResult, CanonicalSeverityAssessment, SeverityClassificationReviewRequest, } from "./classify-severity-records.js";
|
|
71
80
|
export { validateRecords } from "./validation-records.js";
|
|
72
81
|
export type { ValidateRecordsInput, ValidateRecordsOptions, ValidationReviewRequest, } from "./validation-records.js";
|
|
82
|
+
export { prepareLocalExternalImport } from "./external-findings-import.js";
|
|
83
|
+
export { normalizeSnykFindingsExport, normalizeSnykJson, normalizeSnykSarif, readSnykFindings, } from "./snyk-findings.js";
|
|
84
|
+
export { normalizeSemgrepFindings, normalizeSemgrepSarif, readSemgrepFindings, type SemgrepImportOptions, } from "./semgrep-findings.js";
|
|
85
|
+
export { normalizeEndorFindings, normalizeEndorSarif, readEndorFindings, } from "./endor-findings.js";
|
|
73
86
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA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AM,+BAA+B,CAAC;AAC3E,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { runHostedRemediationProtocol } from "./hosted-remediation-protocol.js";
|
|
|
5
5
|
export { runHostedScan, HostedScanInputSchema, HostedScanPreparationError, } from "./hosted-scan.js";
|
|
6
6
|
export { loadProjectConfig, resolveProjectConfig } from "./project-config.js";
|
|
7
7
|
export { classifySeverity } from "./classify-severity.js";
|
|
8
|
-
export { suggestOwners } from "./suggest-owners.js";
|
|
8
|
+
export { suggestOwners, suggestOwnersFromScan } from "./suggest-owners.js";
|
|
9
9
|
export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
|
|
10
10
|
export { runComponentScans } from "./component-scan.js";
|
|
11
11
|
export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
@@ -20,6 +20,10 @@ export { checkScanPublication, publishScan } from "./publish.js";
|
|
|
20
20
|
export { publishScanToCustom } from "./custom-publish.js";
|
|
21
21
|
export { deduplicateRecords } from "./deduplication/records.js";
|
|
22
22
|
export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
|
|
23
|
+
export { ExternalPublicationError, prepareExternalPublication, prepareNormalizedExternalPublication, } from "./external-findings-publish.js";
|
|
24
|
+
export { prepareNormalizedLocalImport, listLocalExternalFindings, } from "./external-findings-local.js";
|
|
25
|
+
export { normalizeGitHubCodeScanningAlerts, normalizeGitHubAdvisories, readGitHubFindings, } from "./github-findings.js";
|
|
26
|
+
export { importGitHubAdvisories } from "./github-advisories.js";
|
|
23
27
|
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
24
28
|
export { ScanResult } from "./result.js";
|
|
25
29
|
export { bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, createIsolatedHome, createMarketplace, extractPluginZip, importAmbientAuth, MARKETPLACE_NAME, pluginExecutionEnvironment, pluginMetadata, PLUGIN_NAME, prepareOutputDir, resolveCodexCommand, resolvePluginPath, resolvePluginPython, validateOutputDir, } from "./runtime.js";
|
|
@@ -27,4 +31,8 @@ export { DiffTarget, normalizeRepository, normalizeTarget, repositoryRevision, v
|
|
|
27
31
|
export { BUNDLED_PLUGIN_VERSION, VERSION } from "./version.js";
|
|
28
32
|
export { classifySeverityRecords, classifySeverityRecordsInputSchema, } from "./classify-severity-records.js";
|
|
29
33
|
export { validateRecords } from "./validation-records.js";
|
|
34
|
+
export { prepareLocalExternalImport } from "./external-findings-import.js";
|
|
35
|
+
export { normalizeSnykFindingsExport, normalizeSnykJson, normalizeSnykSarif, readSnykFindings, } from "./snyk-findings.js";
|
|
36
|
+
export { normalizeSemgrepFindings, normalizeSemgrepSarif, readSemgrepFindings, } from "./semgrep-findings.js";
|
|
37
|
+
export { normalizeEndorFindings, normalizeEndorSarif, readEndorFindings, } from "./endor-findings.js";
|
|
30
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAMhF,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,kB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AM,yBAAyB,CAAC;AAajC,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAY7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { exportArtifact } from \"./artifact-export.js\";\nexport type {\n ExportArtifactOptions,\n ArtifactExportResult,\n} from \"./artifact-export.js\";\nexport { CodexSecurity, createSecurity } from \"./api.js\";\nexport {\n runHostedRemediation,\n HostedRemediationInputSchema,\n HostedRemediationPreparationError,\n} from \"./hosted-remediation.js\";\nexport type {\n HostedRemediationInput,\n HostedRemediationOptions,\n HostedRemediationResult,\n RemediationExecutor,\n RemediationExecutionRequest,\n RemediationExecutionResult,\n RemediationExecutionEvent,\n} from \"./hosted-remediation.js\";\nexport { runHostedRemediationProtocol } from \"./hosted-remediation-protocol.js\";\nexport type {\n FindingPatch,\n FindingVerification,\n FindingVerificationCheck,\n} from \"./remediation.js\";\nexport {\n runHostedScan,\n HostedScanInputSchema,\n HostedScanPreparationError,\n} from \"./hosted-scan.js\";\nexport type {\n HostedScanInput,\n HostedScanOptions,\n HostedScanResult,\n} from \"./hosted-scan.js\";\nexport type {\n ScanExecutor,\n ScanExecutionRequest,\n ScanExecutionResult,\n ScanExecutionEvent,\n} from \"./scan-executor.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport { suggestOwners } from \"./suggest-owners.js\";\nexport type {\n OwnerFinding,\n CodeownerIdentity,\n OwnerIdentity,\n OwnerSuggestion,\n OwnerSuggestions,\n SuggestOwnersOptions,\n} from \"./suggest-owners.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent, ScanWorkerEvent } from \"./cost.js\";\nexport type { ScanTokenUsage } from \"./cost-model.js\";\nexport type { DeepScanProgress } from \"./scan-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n PatchOptions,\n PatchResult,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n LocalPluginBootstrapError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n SandboxUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport { deduplicateRecords } from \"./deduplication/records.js\";\nexport type {\n DeduplicateRecordsInput,\n DeduplicateRecordsOptions,\n DeduplicateRecordsResult,\n} from \"./deduplication/records.js\";\nexport type {\n DeduplicationReviewRequest,\n DeduplicationReviewAttribution,\n DeduplicationReviewRunner,\n} from \"./deduplication/review.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport type { FindingEmbeddingBinding } from \"./deduplication/local.js\";\nexport type {\n DeduplicationDiagnostic,\n DeduplicationDiagnosticObserver,\n} from \"./deduplication/diagnostics.js\";\nexport type { FindingEmbedder } from \"./server/embeddings.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n\nexport {\n classifySeverityRecords,\n classifySeverityRecordsInputSchema,\n} from \"./classify-severity-records.js\";\nexport type {\n ClassifySeverityRecordsInput,\n ClassifySeverityRecordsOptions,\n ClassifySeverityRecordsResult,\n CanonicalSeverityAssessment,\n SeverityClassificationReviewRequest,\n} from \"./classify-severity-records.js\";\nexport { validateRecords } from \"./validation-records.js\";\nexport type {\n ValidateRecordsInput,\n ValidateRecordsOptions,\n ValidationReviewRequest,\n} from \"./validation-records.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAEhF,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAY1B,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAU9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAe3E,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAa7C,OAAO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BAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAO1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC","sourcesContent":["export { exportArtifact } from \"./artifact-export.js\";\nexport type {\n ExportArtifactOptions,\n ArtifactExportResult,\n} from \"./artifact-export.js\";\nexport { CodexSecurity, createSecurity } from \"./api.js\";\nexport {\n runHostedRemediation,\n HostedRemediationInputSchema,\n HostedRemediationPreparationError,\n} from \"./hosted-remediation.js\";\nexport type {\n HostedRemediationInput,\n HostedRemediationOptions,\n HostedRemediationResult,\n RemediationExecutor,\n RemediationExecutionRequest,\n RemediationExecutionResult,\n RemediationExecutionEvent,\n} from \"./hosted-remediation.js\";\nexport { runHostedRemediationProtocol } from \"./hosted-remediation-protocol.js\";\nexport type { FindingPatch, FindingVerification } from \"./remediation.js\";\nexport {\n runHostedScan,\n HostedScanInputSchema,\n HostedScanPreparationError,\n} from \"./hosted-scan.js\";\nexport type {\n HostedScanInput,\n HostedScanOptions,\n HostedScanResult,\n} from \"./hosted-scan.js\";\nexport type {\n ScanExecutor,\n ScanExecutionRequest,\n ScanExecutionResult,\n ScanExecutionEvent,\n} from \"./scan-executor.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport { suggestOwners, suggestOwnersFromScan } from \"./suggest-owners.js\";\nexport type {\n OwnerFinding,\n CodeownerIdentity,\n OwnerIdentity,\n OwnerSuggestion,\n OwnerSuggestions,\n SuggestOwnersOptions,\n} from \"./suggest-owners.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type {\n ScanAccountRateLimit,\n ScanAccountRateLimitWindow,\n ScanCost,\n ScanSessionEvent,\n ScanUsageObservation,\n ScanWorkerEvent,\n} from \"./cost.js\";\nexport type { ScanTokenUsage } from \"./cost-model.js\";\nexport type { DeepScanProgress } from \"./scan-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n PatchOptions,\n PatchResult,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n LocalPluginBootstrapError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n SandboxUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport { deduplicateRecords } from \"./deduplication/records.js\";\nexport type {\n DeduplicateRecordsInput,\n DeduplicateRecordsOptions,\n DeduplicateRecordsResult,\n} from \"./deduplication/records.js\";\nexport type {\n DeduplicationReviewRequest,\n DeduplicationReviewAttribution,\n DeduplicationReviewRunner,\n} from \"./deduplication/review.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport type { FindingEmbeddingBinding } from \"./deduplication/local.js\";\nexport type {\n DeduplicationDiagnostic,\n DeduplicationDiagnosticObserver,\n} from \"./deduplication/diagnostics.js\";\nexport type { FindingEmbedder } from \"./server/embeddings.js\";\nexport {\n ExternalPublicationError,\n prepareExternalPublication,\n prepareNormalizedExternalPublication,\n} from \"./external-findings-publish.js\";\nexport type {\n ExternalPublicationOptions,\n NormalizedExternalPublicationOptions,\n ExternalPublicationDependencies,\n ExternalPublicationPreview,\n ExternalPublicationProgress,\n ExternalPublicationResult,\n PreparedExternalPublication,\n} from \"./external-findings-publish.js\";\nexport {\n prepareNormalizedLocalImport,\n listLocalExternalFindings,\n} from \"./external-findings-local.js\";\nexport type {\n StoredExternalFinding,\n NormalizedLocalImportOptions,\n LocalExternalImportDependencies,\n LocalExternalImportPreview,\n LocalExternalImportResult,\n PreparedLocalExternalImport,\n} from \"./external-findings-local.js\";\nexport type {\n ExternalFinding,\n ExternalFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nexport type {\n ExternalFindingEvidence,\n FindingImportRequest,\n FindingImportReceipt,\n ImportRepository,\n SourceReport,\n} from \"./external-import-models.js\";\nexport {\n normalizeGitHubCodeScanningAlerts,\n normalizeGitHubAdvisories,\n readGitHubFindings,\n} from \"./github-findings.js\";\nexport { importGitHubAdvisories } from \"./github-advisories.js\";\nexport type {\n GitHubAdvisoryImportOptions,\n ImportedGitHubAdvisory,\n} from \"./github-advisories.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n\nexport {\n classifySeverityRecords,\n classifySeverityRecordsInputSchema,\n} from \"./classify-severity-records.js\";\nexport type {\n ClassifySeverityRecordsInput,\n ClassifySeverityRecordsOptions,\n ClassifySeverityRecordsResult,\n CanonicalSeverityAssessment,\n SeverityClassificationReviewRequest,\n} from \"./classify-severity-records.js\";\nexport { validateRecords } from \"./validation-records.js\";\nexport type {\n ValidateRecordsInput,\n ValidateRecordsOptions,\n ValidationReviewRequest,\n} from \"./validation-records.js\";\n\nexport { prepareLocalExternalImport } from \"./external-findings-import.js\";\nexport {\n normalizeSnykFindingsExport,\n normalizeSnykJson,\n normalizeSnykSarif,\n readSnykFindings,\n} from \"./snyk-findings.js\";\nexport {\n normalizeSemgrepFindings,\n normalizeSemgrepSarif,\n readSemgrepFindings,\n type SemgrepImportOptions,\n} from \"./semgrep-findings.js\";\nexport {\n normalizeEndorFindings,\n normalizeEndorSarif,\n readEndorFindings,\n} from \"./endor-findings.js\";\n"]}
|
package/dist/knowledge-base.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export interface KnowledgeBaseSnapshot {
|
|
|
9
9
|
readonly protectedRoots?: readonly string[];
|
|
10
10
|
readonly documents: Readonly<Record<string, string>>;
|
|
11
11
|
}
|
|
12
|
+
export declare function knowledgeBaseProtectedRoots(snapshot: KnowledgeBaseSnapshot, signal?: AbortSignal): Promise<string[]>;
|
|
12
13
|
export declare function prepareKnowledgeBase(input: readonly string[] | KnowledgeBaseSnapshot, signal?: AbortSignal, directory?: string): Promise<PreparedKnowledgeBase>;
|
|
13
14
|
//# sourceMappingURL=knowledge-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;
|
|
1
|
+
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,qBAAqB,EAC/B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,EAAE,CAAC,CASnB;AAuFD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,qBAAqB,EAChD,MAAM,CAAC,EAAE,WAAW,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC,CAiChC"}
|
package/dist/knowledge-base.js
CHANGED
|
@@ -14,6 +14,11 @@ const DOCUMENT_EXTENSIONS = new Set([
|
|
|
14
14
|
".pdf",
|
|
15
15
|
".docx",
|
|
16
16
|
]);
|
|
17
|
+
export async function knowledgeBaseProtectedRoots(snapshot, signal) {
|
|
18
|
+
return snapshot.protectedRoots === undefined
|
|
19
|
+
? await Promise.all(snapshot.sources.map(async (source) => (await gitMarkerRoot(source, signal, "outermost")) ?? source))
|
|
20
|
+
: [...snapshot.protectedRoots];
|
|
21
|
+
}
|
|
17
22
|
/** @internal Extract once so campaign identity and workers use identical inputs. */
|
|
18
23
|
export async function readKnowledgeBaseSnapshot(paths, signal) {
|
|
19
24
|
try {
|
|
@@ -70,11 +75,14 @@ export async function readKnowledgeBaseSnapshot(paths, signal) {
|
|
|
70
75
|
extracted[filename] = text;
|
|
71
76
|
index++;
|
|
72
77
|
}
|
|
73
|
-
|
|
78
|
+
const snapshot = {
|
|
74
79
|
sources: [...sources],
|
|
75
|
-
protectedRoots: await Promise.all([...sources].map(async (source) => (await gitMarkerRoot(source, signal, "outermost")) ?? source)),
|
|
76
80
|
documents: extracted,
|
|
77
81
|
};
|
|
82
|
+
return {
|
|
83
|
+
...snapshot,
|
|
84
|
+
protectedRoots: await knowledgeBaseProtectedRoots(snapshot, signal),
|
|
85
|
+
};
|
|
78
86
|
}
|
|
79
87
|
catch (error) {
|
|
80
88
|
if (signal?.aborted || error instanceof ConfigurationError)
|
|
@@ -87,9 +95,7 @@ export async function prepareKnowledgeBase(input, signal, directory) {
|
|
|
87
95
|
const snapshot = "documents" in input
|
|
88
96
|
? input
|
|
89
97
|
: await readKnowledgeBaseSnapshot(input, signal);
|
|
90
|
-
const protectedRoots = snapshot
|
|
91
|
-
? await Promise.all(snapshot.sources.map(async (source) => (await gitMarkerRoot(source, signal, "outermost")) ?? source))
|
|
92
|
-
: [...snapshot.protectedRoots];
|
|
98
|
+
const protectedRoots = await knowledgeBaseProtectedRoots(snapshot, signal);
|
|
93
99
|
const path = await mkdtemp(join(directory ?? tmpdir(), "codex-security-knowledge-"));
|
|
94
100
|
try {
|
|
95
101
|
for (const [filename, text] of Object.entries(snapshot.documents)) {
|
|
@@ -196,10 +202,13 @@ async function extractPdf(path, bytes, signal) {
|
|
|
196
202
|
});
|
|
197
203
|
try {
|
|
198
204
|
const document = await loadingTask.promise;
|
|
205
|
+
signal?.throwIfAborted();
|
|
199
206
|
const pages = [];
|
|
200
207
|
for (let number = 1; number <= document.numPages; number++) {
|
|
201
208
|
signal?.throwIfAborted();
|
|
202
|
-
const
|
|
209
|
+
const page = await document.getPage(number);
|
|
210
|
+
signal?.throwIfAborted();
|
|
211
|
+
const content = await page.getTextContent();
|
|
203
212
|
signal?.throwIfAborted();
|
|
204
213
|
pages.push(content.items
|
|
205
214
|
.map((item) => ("str" in item ? item.str : ""))
|
|
@@ -209,11 +218,11 @@ async function extractPdf(path, bytes, signal) {
|
|
|
209
218
|
}
|
|
210
219
|
finally {
|
|
211
220
|
await loadingTask.destroy();
|
|
221
|
+
signal?.throwIfAborted();
|
|
212
222
|
}
|
|
213
223
|
}
|
|
214
224
|
catch (error) {
|
|
215
|
-
|
|
216
|
-
throw error;
|
|
225
|
+
signal?.throwIfAborted();
|
|
217
226
|
throw new Error(`Cannot extract text from knowledge base PDF: ${path}`, {
|
|
218
227
|
cause: error,
|
|
219
228
|
});
|