@openai/codex-security 0.1.24 → 0.1.26
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 +399 -27
- package/_bundled_plugin/.app.json +0 -5
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- package/_bundled_plugin/.mcp.json +1 -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/references/config-preflight.md +2 -2
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/scan-artifacts.md +5 -1
- package/_bundled_plugin/references/scan-contract.md +7 -3
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +27 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +6 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +2 -5
- package/_bundled_plugin/scripts/rank_preview.py +11 -1
- package/_bundled_plugin/scripts/report_projection.py +1 -1
- package/_bundled_plugin/scripts/workbench_cli.py +11 -1
- package/_bundled_plugin/scripts/workbench_db.py +55 -4
- package/_bundled_plugin/scripts/workbench_saved_results.py +41 -22
- package/_bundled_plugin/scripts/workbench_scan_history.py +374 -66
- package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -6
- package/_bundled_plugin/scripts/workbench_schema.py +46 -0
- package/_bundled_plugin/scripts/workbench_severity.py +119 -0
- package/_bundled_plugin/scripts/workbench_target.py +86 -12
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +5 -3
- package/_bundled_plugin/skills/verify-fix/SKILL.md +5 -1
- package/dist/api.d.ts +15 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +333 -32
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +35 -3
- package/dist/auth.js.map +1 -1
- package/dist/classify-scan-severity.d.ts +16 -0
- package/dist/classify-scan-severity.d.ts.map +1 -0
- package/dist/classify-scan-severity.js +96 -0
- package/dist/classify-scan-severity.js.map +1 -0
- package/dist/classify-severity.d.ts +38 -0
- package/dist/classify-severity.d.ts.map +1 -0
- package/dist/classify-severity.js +185 -0
- package/dist/classify-severity.js.map +1 -0
- package/dist/cli.d.ts +7 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +403 -116
- package/dist/cli.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +4 -2
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +21 -6
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +46 -2
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts +1 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +43 -17
- package/dist/cost.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +2 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +3 -0
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +122 -36
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -3
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +18 -9
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +2 -7
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +47 -25
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +186 -23
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/scan.d.ts +9 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -1
- package/dist/finding-catalogue.d.ts +11 -0
- package/dist/finding-catalogue.d.ts.map +1 -0
- package/dist/finding-catalogue.js +150 -0
- package/dist/finding-catalogue.js.map +1 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/mock-scan.d.ts +4 -0
- package/dist/mock-scan.d.ts.map +1 -0
- package/dist/mock-scan.js +210 -0
- package/dist/mock-scan.js.map +1 -0
- package/dist/patch-tui.js +1 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +9 -4
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +9 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +45 -5
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -2
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +4 -4
- package/dist/publish.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +49 -14
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts +44 -30
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +673 -101
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +3 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +70 -3
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +26 -0
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/server/api.d.ts +6 -0
- package/dist/server/api.d.ts.map +1 -0
- package/dist/server/api.js +4 -0
- package/dist/server/api.js.map +1 -0
- package/dist/server/dashboard/app.css +1 -1
- package/dist/server/embeddings.d.ts +2 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +8 -3
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/server/serve.js +1 -1
- package/dist/server/serve.js.map +1 -1
- package/dist/severity-store.d.ts +2 -0
- package/dist/severity-store.d.ts.map +1 -0
- package/dist/severity-store.js +111 -0
- package/dist/severity-store.js.map +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +3 -5
- package/dist/targets.js.map +1 -1
- package/dist/thread-source.d.ts +1 -0
- package/dist/thread-source.d.ts.map +1 -1
- package/dist/thread-source.js +1 -0
- package/dist/thread-source.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +11 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/deduplication/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,mBAAmB,EACnB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAgBlC,8FAA8F;AAC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F,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,GAAG,CACrC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAC/D,CAAC;QACF,MAAM,WAAW,EAAE,qBAAqB,EAAE,CAAC;QAC3C,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,MAAM,MAAM,GAA0B,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC3E,MAAM,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;QAC1E,MAAM,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACvD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import { loadContractWithScanDirectory } from \"../contract.js\";\nimport {\n bundledPluginRoot,\n codexSecurityStateDirectory,\n resolvePluginPython,\n runWorkbench,\n} from \"../runtime.js\";\nimport {\n resolveCompletedScan,\n type SavedScanDependencies,\n} from \"../saved-scan.js\";\nimport { CodexReviewRunner } from \"./codex-review.js\";\nimport {\n FindingDeduplicator,\n type DeduplicationResult,\n} from \"./deduplication.js\";\nimport {\n CodexDeduplicationReviewer,\n type DeduplicationReviewer,\n} from \"./deduplication-reviewer.js\";\nimport { FindingsClient, type FindingsRequest } from \"../findings-client.js\";\nimport type { FindingSearchScope } from \"../finding-retrieval.js\";\nimport {\n FindingWorkflow,\n workflowDestination,\n workflowDigest,\n} from \"../finding-workflow.js\";\nimport { publishScanToCustomInternal } from \"../custom-publish.js\";\nimport {\n CheckpointedReviewRunner,\n reviewSettingsDigest,\n} from \"./checkpointed-review.js\";\n\nexport interface DeduplicateScanOptions {\n /** Resume the named local findings workflow, including custom publication. */\n workflowId?: string;\n /** Findings API base URL. The scan's findings must already be indexed there. */\n findingsUrl: string;\n /** Search all repositories instead of the saved scan's targetId. Defaults to false. */\n allRepositories?: boolean;\n signal?: AbortSignal;\n}\n\nexport interface DeduplicateScanResult extends DeduplicationResult {\n scanId: string;\n}\n\n/** Review a saved scan against embedding candidates and persist accepted duplicate groups. */\nexport async function deduplicateScan(\n scanId: string,\n options: DeduplicateScanOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanInternal(scanId, options);\n}\n\n/** @internal */\nexport async function deduplicateScanInternal(\n scanId: string,\n options: DeduplicateScanOptions,\n dependencies: Partial<SavedScanDependencies> & {\n environment?: NodeJS.ProcessEnv;\n reviewer?: DeduplicationReviewer;\n reviewRunner?: Pick<CodexReviewRunner, \"run\">;\n fetch?: FindingsRequest;\n } = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n const environment = dependencies.environment ?? process.env;\n const pluginRoot = await bundledPluginRoot();\n const scan = await resolveCompletedScan(scanId, {\n currentDirectory: dependencies.currentDirectory ?? (() => process.cwd()),\n runWorkbench:\n dependencies.runWorkbench ??\n (async (args) => {\n const stateEnvironment = {\n ...environment,\n CODEX_SECURITY_STATE_DIR: codexSecurityStateDirectory(environment),\n };\n return await runWorkbench(\n {\n environment: stateEnvironment,\n pluginRoot,\n python: await resolvePluginPython({\n environment: stateEnvironment,\n }),\n signal: options.signal,\n failureMessage: \"Could not read Codex Security scan history\",\n },\n args,\n );\n }),\n });\n const { contract, scanDirectory } = await loadContractWithScanDirectory(\n scan.scanDir,\n {\n pluginRoot,\n expectedScanId: scan.scanId,\n signal: options.signal,\n },\n );\n const client = new FindingsClient(\n options.findingsUrl,\n options.signal,\n dependencies.fetch,\n );\n const scope: FindingSearchScope =\n options.allRepositories === true\n ? { allRepositories: true }\n : { repositoryId: contract.manifest.scan.target.targetId };\n const workflow =\n options.workflowId === undefined\n ? undefined\n : new FindingWorkflow(\n options.workflowId,\n environment,\n dependencies.runWorkbench === undefined\n ? undefined\n : (_options, args, input) =>\n dependencies.runWorkbench!(args, input),\n );\n if (workflow) {\n await workflow.protectArtifacts(scanDirectory);\n await workflow.bind({\n scanId: scan.scanId,\n scanDir: scanDirectory,\n artifactDigest: workflowDigest(contract),\n destination: workflowDestination(options.findingsUrl),\n scope,\n });\n await workflow.complete(\"scan\", null);\n await publishScanToCustomInternal(\n scanDirectory,\n {\n findingsUrl: options.findingsUrl,\n workflowId: options.workflowId,\n expectedScanId: scan.scanId,\n signal: options.signal,\n },\n {\n environment,\n fetch: dependencies.fetch,\n runWorkbench:\n dependencies.runWorkbench === undefined\n ? undefined\n : (_options, args, input) =>\n dependencies.runWorkbench!(args, input),\n },\n );\n }\n const dedupe = async (): Promise<DeduplicateScanResult> => {\n const saved = (await workflow?.get())?.stages.dedupe;\n if (saved?.pendingWrite) {\n await client.storeDedupeGroups(saved.pendingWrite.groups);\n return saved.result as DeduplicateScanResult;\n }\n const runner =\n dependencies.reviewRunner ??\n new CodexReviewRunner(\n environment,\n undefined,\n options.signal,\n scan[\"targetPath\"] as string,\n );\n const checkpoints = workflow\n ? new CheckpointedReviewRunner(\n workflow,\n runner,\n await workflow.sourceSnapshot(scan[\"targetPath\"] as string),\n scope,\n await reviewSettingsDigest(environment),\n )\n : undefined;\n const deduplicator = new FindingDeduplicator(\n {\n potentialDuplicates: (findingId) =>\n client.potentialDuplicates(findingId, scope),\n },\n dependencies.reviewer ??\n new CodexDeduplicationReviewer(checkpoints ?? runner),\n options.signal,\n );\n const reviewed = await deduplicator.run(\n contract.findings.findings.map((finding) => finding.findingId),\n );\n await checkpoints?.assertSourceUnchanged();\n options.signal?.throwIfAborted();\n const result: DeduplicateScanResult = { scanId: scan.scanId, ...reviewed };\n await workflow?.prepareDedupe(result, { groups: result.duplicateGroups });\n await client.storeDedupeGroups(result.duplicateGroups);\n return result;\n };\n return workflow ? await workflow.run(\"dedupe\", dedupe) : await dedupe();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/deduplication/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,mBAAmB,EACnB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAwBpD,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,OAA+B;IAE/B,OAAO,MAAM,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,aAAqB,EACrB,OAAwC;IAExC,OAAO,MAAM,gCAAgC,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AASD,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,aAAqB,EACrB,OAAwC,EACxC,eAA4C,EAAE;IAE9C,OAAO,CAAC,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,MAAM,MAAM,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import { loadContractWithScanDirectory } from \"../contract.js\";\nimport {\n bundledPluginRoot,\n codexSecurityStateDirectory,\n resolvePluginPython,\n runWorkbench,\n} from \"../runtime.js\";\nimport {\n resolveCompletedScan,\n type SavedScanDependencies,\n} from \"../saved-scan.js\";\nimport { CodexReviewRunner } from \"./codex-review.js\";\nimport {\n FindingDeduplicator,\n type DeduplicationResult,\n} from \"./deduplication.js\";\nimport {\n CodexDeduplicationReviewer,\n type DeduplicationReviewer,\n} from \"./deduplication-reviewer.js\";\nimport { FindingsClient, type FindingsRequest } from \"../findings-client.js\";\nimport type { FindingSearchScope } from \"../finding-retrieval.js\";\nimport {\n FindingWorkflow,\n workflowDestination,\n workflowDigest,\n} from \"../finding-workflow.js\";\nimport { publishScanToCustomInternal } from \"../custom-publish.js\";\nimport {\n CheckpointedReviewRunner,\n reviewSettingsDigest,\n} from \"./checkpointed-review.js\";\nimport { normalizeRepository } from \"../targets.js\";\n\nexport interface DeduplicateScanOptions {\n /** Resume the named local findings workflow, including custom publication. */\n workflowId?: string;\n /** Findings API base URL. The scan's findings must already be indexed there. */\n findingsUrl: string;\n /** Search all repositories instead of the scan's targetId. Defaults to false. */\n allRepositories?: boolean;\n signal?: AbortSignal;\n}\n\nexport interface DeduplicateScanDirectoryOptions\n extends DeduplicateScanOptions {\n /** Local repository checkout used to review duplicate candidates. */\n repository: string;\n /** Require the sealed artifacts to belong to this scan. */\n expectedScanId?: string;\n}\n\nexport interface DeduplicateScanResult extends DeduplicationResult {\n scanId: string;\n}\n\n/** Review a saved scan against embedding candidates and persist accepted duplicate groups. */\nexport async function deduplicateScan(\n scanId: string,\n options: DeduplicateScanOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanInternal(scanId, options);\n}\n\n/** Review a complete, sealed scan directory without resolving local scan history. */\nexport async function deduplicateScanDirectory(\n scanDirectory: string,\n options: DeduplicateScanDirectoryOptions,\n): Promise<DeduplicateScanResult> {\n return await deduplicateScanDirectoryInternal(scanDirectory, options);\n}\n\ntype DeduplicateScanDependencies = Partial<SavedScanDependencies> & {\n environment?: NodeJS.ProcessEnv;\n reviewer?: DeduplicationReviewer;\n reviewRunner?: Pick<CodexReviewRunner, \"run\">;\n fetch?: FindingsRequest;\n};\n\n/** @internal */\nexport async function deduplicateScanDirectoryInternal(\n scanDirectory: string,\n options: DeduplicateScanDirectoryOptions,\n dependencies: DeduplicateScanDependencies = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n const repository = await normalizeRepository(\n options.repository,\n options.signal,\n );\n return await deduplicateResolvedScan(\n scanDirectory,\n repository,\n options.expectedScanId,\n options,\n dependencies,\n await bundledPluginRoot(),\n true,\n );\n}\n\n/** @internal */\nexport async function deduplicateScanInternal(\n scanId: string,\n options: DeduplicateScanOptions,\n dependencies: DeduplicateScanDependencies = {},\n): Promise<DeduplicateScanResult> {\n options.signal?.throwIfAborted();\n const environment = dependencies.environment ?? process.env;\n const pluginRoot = await bundledPluginRoot();\n const scan = await resolveCompletedScan(scanId, {\n currentDirectory: dependencies.currentDirectory ?? (() => process.cwd()),\n runWorkbench:\n dependencies.runWorkbench ??\n (async (args) => {\n const stateEnvironment = {\n ...environment,\n CODEX_SECURITY_STATE_DIR: codexSecurityStateDirectory(environment),\n };\n return await runWorkbench(\n {\n environment: stateEnvironment,\n pluginRoot,\n python: await resolvePluginPython({\n environment: stateEnvironment,\n }),\n signal: options.signal,\n failureMessage: \"Could not read Codex Security scan history\",\n },\n args,\n );\n }),\n });\n return await deduplicateResolvedScan(\n scan.scanDir,\n scan[\"targetPath\"] as string,\n scan.scanId,\n options,\n dependencies,\n pluginRoot,\n false,\n );\n}\n\nasync function deduplicateResolvedScan(\n selectedDirectory: string,\n repositoryPath: string,\n expectedScanId: string | undefined,\n options: DeduplicateScanOptions,\n dependencies: DeduplicateScanDependencies,\n pluginRoot: string,\n bindRepository: boolean,\n): Promise<DeduplicateScanResult> {\n const environment = dependencies.environment ?? process.env;\n const { contract, scanDirectory } = await loadContractWithScanDirectory(\n selectedDirectory,\n {\n pluginRoot,\n expectedScanId,\n signal: options.signal,\n },\n );\n const scanId = contract.manifest.scan.id;\n const client = new FindingsClient(\n options.findingsUrl,\n options.signal,\n dependencies.fetch,\n );\n const scope: FindingSearchScope =\n options.allRepositories === true\n ? { allRepositories: true }\n : { repositoryId: contract.manifest.scan.target.targetId };\n const workflow =\n options.workflowId === undefined\n ? undefined\n : new FindingWorkflow(\n options.workflowId,\n environment,\n dependencies.runWorkbench === undefined\n ? undefined\n : (_options, args, input) =>\n dependencies.runWorkbench!(args, input),\n );\n if (workflow) {\n await workflow.protectArtifacts(scanDirectory);\n await workflow.bind({\n ...(bindRepository ? { repositoryPath } : {}),\n scanId,\n scanDir: scanDirectory,\n artifactDigest: workflowDigest(contract),\n destination: workflowDestination(options.findingsUrl),\n scope,\n });\n await workflow.complete(\"scan\", null);\n await publishScanToCustomInternal(\n scanDirectory,\n {\n findingsUrl: options.findingsUrl,\n workflowId: options.workflowId,\n expectedScanId: scanId,\n signal: options.signal,\n },\n {\n environment,\n fetch: dependencies.fetch,\n runWorkbench:\n dependencies.runWorkbench === undefined\n ? undefined\n : (_options, args, input) =>\n dependencies.runWorkbench!(args, input),\n },\n );\n }\n const dedupe = async (): Promise<DeduplicateScanResult> => {\n const saved = (await workflow?.get())?.stages.dedupe;\n if (saved?.pendingWrite) {\n await client.storeDedupeGroups(saved.pendingWrite.groups);\n return saved.result as DeduplicateScanResult;\n }\n const runner =\n dependencies.reviewRunner ??\n new CodexReviewRunner(\n environment,\n undefined,\n options.signal,\n repositoryPath,\n );\n const checkpoints = workflow\n ? new CheckpointedReviewRunner(\n workflow,\n runner,\n await workflow.sourceSnapshot(repositoryPath),\n scope,\n await reviewSettingsDigest(environment),\n )\n : undefined;\n const deduplicator = new FindingDeduplicator(\n {\n potentialDuplicates: (findingId) =>\n client.potentialDuplicates(findingId, scope),\n },\n dependencies.reviewer ??\n new CodexDeduplicationReviewer(checkpoints ?? runner),\n options.signal,\n );\n const reviewed = await deduplicator.run(\n contract.findings.findings.map((finding) => finding.findingId),\n );\n await checkpoints?.assertSourceUnchanged();\n options.signal?.throwIfAborted();\n const result: DeduplicateScanResult = { scanId, ...reviewed };\n await workflow?.prepareDedupe(result, { groups: result.duplicateGroups });\n await client.storeDedupeGroups(result.duplicateGroups);\n return result;\n };\n return workflow ? await workflow.run(\"dedupe\", dedupe) : await dedupe();\n}\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -7,6 +7,19 @@ export declare function safeErrorMessage(error: unknown): string;
|
|
|
7
7
|
export declare class CodexSecurityError extends Error {
|
|
8
8
|
constructor(message: string, options?: ErrorOptions);
|
|
9
9
|
}
|
|
10
|
+
export type DeduplicationReviewStage = "screening" | "pair-review";
|
|
11
|
+
export type DeduplicationReviewFailureCategory = "validation" | "no-submission" | "model" | "transport";
|
|
12
|
+
export interface DeduplicationReviewFailureMetadata {
|
|
13
|
+
stage: DeduplicationReviewStage;
|
|
14
|
+
model: string;
|
|
15
|
+
category: DeduplicationReviewFailureCategory;
|
|
16
|
+
attempts: number;
|
|
17
|
+
reason: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class DeduplicationReviewError extends CodexSecurityError {
|
|
20
|
+
readonly metadata: Readonly<DeduplicationReviewFailureMetadata>;
|
|
21
|
+
constructor(metadata: Readonly<DeduplicationReviewFailureMetadata>, displayReason?: string);
|
|
22
|
+
}
|
|
10
23
|
export declare class ConfigurationError extends CodexSecurityError {
|
|
11
24
|
}
|
|
12
25
|
export declare class AuthenticationRequiredError extends CodexSecurityError {
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3D,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,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B,SAAQ,kBAAkB;CAAG;AAC7D,qBAAa,oBAAqB,SAAQ,kBAAkB;CAAG;AAC/D,qBAAa,4BAA6B,SAAQ,oBAAoB;aAElD,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM,EACjC,SAAS,GAAE,MAAM,GAAG,QAAiB;CAQxC;AACD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAEvE,qBAAa,8BAA+B,SAAQ,oBAAoB;aAEpD,eAAe,EAAE,MAAM;aACvB,aAAa,EAAE,MAAM;aACrB,QAAQ,EAAE,qBAAqB;gBAF/B,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,qBAAgC;CAM7D;AACD,qBAAa,mBAAoB,SAAQ,kBAAkB;CAAG;AAC9D,qBAAa,uBAAwB,SAAQ,kBAAkB;CAAG;AAClE,qBAAa,oBAAqB,SAAQ,kBAAkB;IAC1D,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAI5E;AAED,qBAAa,0BAA2B,SAAQ,oBAAoB;IAClE,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAGvC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACxB,OAAO,EAAE,MAAM;CASlB"}
|
package/dist/errors.js
CHANGED
|
@@ -18,6 +18,13 @@ export class CodexSecurityError extends Error {
|
|
|
18
18
|
this.name = new.target.name;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
export class DeduplicationReviewError extends CodexSecurityError {
|
|
22
|
+
metadata;
|
|
23
|
+
constructor(metadata, displayReason = metadata.reason) {
|
|
24
|
+
super(`Codex did not complete a validated deduplication review. Findings are unchanged; retry the command. Reason: ${displayReason}`);
|
|
25
|
+
this.metadata = metadata;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
21
28
|
export class ConfigurationError extends CodexSecurityError {
|
|
22
29
|
}
|
|
23
30
|
export class AuthenticationRequiredError extends CodexSecurityError {
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAE3D,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,sBAAsB,GAC1B,iKAAiK,CAAC,IAAI,CACpK,OAAO,CACR,CAAC;IACJ,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAClC,8DAA8D,CAC/D,CAAC;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAC9D,uPAAuP,CAAC,IAAI,CAC1P,KAAK,CACN,CACF,CAAC;IACF,OAAO,sBAAsB,IAAI,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3E,CAAC;AAED,kDAAkD;AAClD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAmB,OAAe,EAAE,OAAsB;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC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,IAAI,CAAqB;IAEzC,YACE,UAAkB,EAClB,IAAwB,EACxB,OAAe;QAEf,KAAK,CACH,gCAAgC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,SAAS,CAAC,UAAU,CAAC,qCAAqC,OAAO,GAAG,EACjJ,OAAO,CACR,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { formatUsd, type ScanCost } from \"./cost-model.js\";\n\n/** Returns the original error message without altering its contents. */\nexport function errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** Omit credential-bearing messages at persistence and display boundaries. */\nexport function safeErrorMessage(error: unknown): string {\n const message = errorMessage(error);\n const recognizableCredential =\n /(?:\\b(?:sk-(?:proj-)?|github_pat_|gh[pousr]_|npm_)\\S+|\\b(?:bearer|basic|token)(?:\\s|%20|\\+)+\\S+|:\\/\\/[^\\s/@]+@|-----BEGIN [A-Z ]*PRIVATE KEY(?: BLOCK)?-----)/iu.test(\n message,\n );\n const assignments = message.matchAll(\n /(?<![\\w%.-])[\\w%.-]+(?:\\\\*[\"']|\\]|%5d)*\\s*(?:[:=]|%3[ad])/giu,\n );\n const sensitiveField = Array.from(assignments).some(([field]) =>\n /(?:api(?:[_-]|%5f|%2d)?key|access(?:[_-]|%5f|%2d)?key|private(?:[_-]|%5f|%2d)?key|authorization|auth(?!or)|token|secret|credential|signature|sig(?=[^A-Za-z0-9]|value|data|token|secret|credential|password|header|field|id|key|$)|password|passwd)/iu.test(\n field,\n ),\n );\n return recognizableCredential || sensitiveField ? \"[redacted]\" : message;\n}\n\n/** Base error for Codex Security SDK failures. */\nexport class CodexSecurityError extends Error {\n public constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = new.target.name;\n }\n}\n\nexport class ConfigurationError extends CodexSecurityError {}\nexport class AuthenticationRequiredError extends CodexSecurityError {}\nexport class PluginBootstrapError extends CodexSecurityError {}\nexport class PluginPythonUnavailableError extends PluginBootstrapError {}\nexport class InvalidTargetError extends CodexSecurityError {}\nexport class OutputDirectoryError extends CodexSecurityError {}\nexport class OutputDirectoryNotEmptyError extends OutputDirectoryError {\n public constructor(\n public readonly directory: string,\n operation: \"scan\" | \"policy\" = \"scan\",\n ) {\n super(\n operation === \"policy\"\n ? `Policy output directory is not empty: ${directory}. Choose a new or empty directory.`\n : `Scan output directory is not empty: ${directory}. To keep the existing results and start a new scan, add --archive-existing.`,\n );\n }\n}\nexport type ProtectedScanPathKind = \"output\" | \"temporary\" | \"runtime\";\n\nexport class OutputInsideProtectedRootError extends OutputDirectoryError {\n public constructor(\n public readonly outputDirectory: string,\n public readonly protectedRoot: string,\n public readonly pathKind: ProtectedScanPathKind = \"output\",\n ) {\n super(\n `Scan ${pathKind} directory must be outside the protected scan root: ${outputDirectory}`,\n );\n }\n}\nexport class IncompleteScanError extends CodexSecurityError {}\nexport class ContractValidationError extends CodexSecurityError {}\nexport class ScanInterruptedError extends CodexSecurityError {\n public readonly scanDir: string;\n\n public constructor(message: string, scanDir: string, options?: ErrorOptions) {\n super(message, options);\n this.scanDir = scanDir;\n }\n}\n\nexport class ScanCostLimitExceededError extends ScanInterruptedError {\n public readonly maxCostUsd: number;\n public readonly cost: Readonly<ScanCost>;\n\n public constructor(\n maxCostUsd: number,\n cost: Readonly<ScanCost>,\n scanDir: string,\n ) {\n super(\n `Scan stopped: estimated cost ${formatUsd(cost.estimatedUsd)} exceeded the ${formatUsd(maxCostUsd)} limit; partial output remains at ${scanDir}.`,\n scanDir,\n );\n this.maxCostUsd = maxCostUsd;\n this.cost = cost;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAE3D,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO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,OAAO,CACR,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { formatUsd, type ScanCost } from \"./cost-model.js\";\n\n/** Returns the original error message without altering its contents. */\nexport function errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** Omit credential-bearing messages at persistence and display boundaries. */\nexport function safeErrorMessage(error: unknown): string {\n const message = errorMessage(error);\n const recognizableCredential =\n /(?:\\b(?:sk-(?:proj-)?|github_pat_|gh[pousr]_|npm_)\\S+|\\b(?:bearer|basic|token)(?:\\s|%20|\\+)+\\S+|:\\/\\/[^\\s/@]+@|-----BEGIN [A-Z ]*PRIVATE KEY(?: BLOCK)?-----)/iu.test(\n message,\n );\n const assignments = message.matchAll(\n /(?<![\\w%.-])[\\w%.-]+(?:\\\\*[\"']|\\]|%5d)*\\s*(?:[:=]|%3[ad])/giu,\n );\n const sensitiveField = Array.from(assignments).some(([field]) =>\n /(?:api(?:[_-]|%5f|%2d)?key|access(?:[_-]|%5f|%2d)?key|private(?:[_-]|%5f|%2d)?key|authorization|auth(?!or)|token|secret|credential|signature|sig(?=[^A-Za-z0-9]|value|data|token|secret|credential|password|header|field|id|key|$)|password|passwd)/iu.test(\n field,\n ),\n );\n return recognizableCredential || sensitiveField ? \"[redacted]\" : message;\n}\n\n/** Base error for Codex Security SDK failures. */\nexport class CodexSecurityError extends Error {\n public constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = new.target.name;\n }\n}\n\nexport type DeduplicationReviewStage = \"screening\" | \"pair-review\";\nexport type DeduplicationReviewFailureCategory =\n | \"validation\"\n | \"no-submission\"\n | \"model\"\n | \"transport\";\n\nexport interface DeduplicationReviewFailureMetadata {\n stage: DeduplicationReviewStage;\n model: string;\n category: DeduplicationReviewFailureCategory;\n attempts: number;\n reason: string;\n}\n\nexport class DeduplicationReviewError extends CodexSecurityError {\n public constructor(\n public readonly metadata: Readonly<DeduplicationReviewFailureMetadata>,\n displayReason: string = metadata.reason,\n ) {\n super(\n `Codex did not complete a validated deduplication review. Findings are unchanged; retry the command. Reason: ${displayReason}`,\n );\n }\n}\n\nexport class ConfigurationError extends CodexSecurityError {}\nexport class AuthenticationRequiredError extends CodexSecurityError {}\nexport class PluginBootstrapError extends CodexSecurityError {}\nexport class PluginPythonUnavailableError extends PluginBootstrapError {}\nexport class InvalidTargetError extends CodexSecurityError {}\nexport class OutputDirectoryError extends CodexSecurityError {}\nexport class OutputDirectoryNotEmptyError extends OutputDirectoryError {\n public constructor(\n public readonly directory: string,\n operation: \"scan\" | \"policy\" = \"scan\",\n ) {\n super(\n operation === \"policy\"\n ? `Policy output directory is not empty: ${directory}. Choose a new or empty directory.`\n : `Scan output directory is not empty: ${directory}. To keep the existing results and start a new scan, add --archive-existing.`,\n );\n }\n}\nexport type ProtectedScanPathKind = \"output\" | \"temporary\" | \"runtime\";\n\nexport class OutputInsideProtectedRootError extends OutputDirectoryError {\n public constructor(\n public readonly outputDirectory: string,\n public readonly protectedRoot: string,\n public readonly pathKind: ProtectedScanPathKind = \"output\",\n ) {\n super(\n `Scan ${pathKind} directory must be outside the protected scan root: ${outputDirectory}`,\n );\n }\n}\nexport class IncompleteScanError extends CodexSecurityError {}\nexport class ContractValidationError extends CodexSecurityError {}\nexport class ScanInterruptedError extends CodexSecurityError {\n public readonly scanDir: string;\n\n public constructor(message: string, scanDir: string, options?: ErrorOptions) {\n super(message, options);\n this.scanDir = scanDir;\n }\n}\n\nexport class ScanCostLimitExceededError extends ScanInterruptedError {\n public readonly maxCostUsd: number;\n public readonly cost: Readonly<ScanCost>;\n\n public constructor(\n maxCostUsd: number,\n cost: Readonly<ScanCost>,\n scanDir: string,\n ) {\n super(\n `Scan stopped: estimated cost ${formatUsd(cost.estimatedUsd)} exceeded the ${formatUsd(maxCostUsd)} limit; partial output remains at ${scanDir}.`,\n scanDir,\n );\n this.maxCostUsd = maxCostUsd;\n this.cost = cost;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ComparisonFinding = {
|
|
2
|
+
occurrenceId: string;
|
|
3
|
+
} & Record<string, unknown>;
|
|
4
|
+
export interface CatalogueEntry {
|
|
5
|
+
card: ComparisonFinding;
|
|
6
|
+
occurrences: readonly ComparisonFinding[];
|
|
7
|
+
}
|
|
8
|
+
export declare function groupFindings(findings: readonly ComparisonFinding[], knownFindingGroups?: readonly (readonly string[])[], occurrenceGroups?: readonly (readonly string[])[]): ComparisonFinding[][];
|
|
9
|
+
export declare function findingCatalogue(findings: readonly ComparisonFinding[], knownFindingGroups?: readonly (readonly string[])[]): Map<string, CatalogueEntry>;
|
|
10
|
+
export declare function compactFinding(finding: ComparisonFinding): ComparisonFinding;
|
|
11
|
+
//# sourceMappingURL=finding-catalogue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding-catalogue.d.ts","sourceRoot":"","sources":["../src/finding-catalogue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAC/D,MAAM,EACN,OAAO,CACR,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC3C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,kBAAkB,GAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAO,EACvD,gBAAgB,GAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAO,GACpD,iBAAiB,EAAE,EAAE,CAiDvB;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,kBAAkB,GAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAO,GACtD,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAqC7B;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAoD5E"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export function groupFindings(findings, knownFindingGroups = [], occurrenceGroups = []) {
|
|
2
|
+
const parents = new Map();
|
|
3
|
+
const root = (value) => {
|
|
4
|
+
const path = [];
|
|
5
|
+
let current = value;
|
|
6
|
+
while (parents.has(current)) {
|
|
7
|
+
path.push(current);
|
|
8
|
+
current = parents.get(current);
|
|
9
|
+
}
|
|
10
|
+
for (const item of path)
|
|
11
|
+
parents.set(item, current);
|
|
12
|
+
return current;
|
|
13
|
+
};
|
|
14
|
+
const link = (first, second) => {
|
|
15
|
+
const previous = root(first);
|
|
16
|
+
const current = root(second);
|
|
17
|
+
if (previous !== current)
|
|
18
|
+
parents.set(current, previous);
|
|
19
|
+
};
|
|
20
|
+
for (const [prefix, groups] of [
|
|
21
|
+
["finding", knownFindingGroups],
|
|
22
|
+
["occurrence", occurrenceGroups],
|
|
23
|
+
]) {
|
|
24
|
+
for (const group of groups) {
|
|
25
|
+
const identities = prefix === "finding"
|
|
26
|
+
? group.filter((identity) => identity.trim().length > 0)
|
|
27
|
+
: group;
|
|
28
|
+
const first = identities[0];
|
|
29
|
+
if (first === undefined)
|
|
30
|
+
continue;
|
|
31
|
+
for (const value of identities.slice(1)) {
|
|
32
|
+
link(`${prefix}:${first}`, `${prefix}:${value}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const finding of findings) {
|
|
37
|
+
const findingId = finding["findingId"];
|
|
38
|
+
if (typeof findingId === "string" && findingId.trim().length > 0) {
|
|
39
|
+
link(`finding:${findingId}`, `occurrence:${finding.occurrenceId}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const groups = new Map();
|
|
43
|
+
for (const finding of findings) {
|
|
44
|
+
const key = root(`occurrence:${finding.occurrenceId}`);
|
|
45
|
+
const group = groups.get(key);
|
|
46
|
+
if (group === undefined)
|
|
47
|
+
groups.set(key, [finding]);
|
|
48
|
+
else
|
|
49
|
+
group.push(finding);
|
|
50
|
+
}
|
|
51
|
+
return [...groups.values()];
|
|
52
|
+
}
|
|
53
|
+
export function findingCatalogue(findings, knownFindingGroups = []) {
|
|
54
|
+
return new Map(groupFindings(findings, knownFindingGroups).map((occurrences) => {
|
|
55
|
+
const latest = occurrences.at(-1);
|
|
56
|
+
const card = compactFinding(latest);
|
|
57
|
+
if (occurrences.length > 1) {
|
|
58
|
+
const description = (finding) => {
|
|
59
|
+
const value = { ...compactFinding(finding) };
|
|
60
|
+
delete value["occurrenceId"];
|
|
61
|
+
delete value["findingId"];
|
|
62
|
+
return value;
|
|
63
|
+
};
|
|
64
|
+
const current = description(latest);
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
const aliases = occurrences.slice(0, -1).flatMap((finding) => {
|
|
67
|
+
const value = Object.fromEntries(Object.entries(description(finding)).filter(([field, value]) => JSON.stringify(value) !== JSON.stringify(current[field])));
|
|
68
|
+
if (Object.keys(value).length === 0)
|
|
69
|
+
return [];
|
|
70
|
+
const key = JSON.stringify(value);
|
|
71
|
+
if (seen.has(key))
|
|
72
|
+
return [];
|
|
73
|
+
seen.add(key);
|
|
74
|
+
return [value];
|
|
75
|
+
});
|
|
76
|
+
card["occurrenceCount"] = occurrences.length;
|
|
77
|
+
if (aliases.length > 0)
|
|
78
|
+
card["earlierDescriptions"] = aliases;
|
|
79
|
+
}
|
|
80
|
+
const findingId = occurrences[0]["findingId"];
|
|
81
|
+
if (typeof findingId === "string" && findingId.trim().length > 0) {
|
|
82
|
+
card["issueId"] = findingId;
|
|
83
|
+
}
|
|
84
|
+
return [latest.occurrenceId, { card, occurrences }];
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
export function compactFinding(finding) {
|
|
88
|
+
const rootCause = finding["rootCause"] ?? finding["root_cause"];
|
|
89
|
+
const attackPath = record(finding["attackPath"]);
|
|
90
|
+
const dataFlow = attackPath?.["dataFlow"] ??
|
|
91
|
+
attackPath?.["data_flow"] ??
|
|
92
|
+
attackPath?.["dataflow"];
|
|
93
|
+
const locations = Array.isArray(finding["locations"])
|
|
94
|
+
? finding["locations"].flatMap((value) => {
|
|
95
|
+
const location = record(value);
|
|
96
|
+
return location === undefined ? [] : [location];
|
|
97
|
+
})
|
|
98
|
+
: [];
|
|
99
|
+
let controls = locations.filter((location) => location["role"] === "root_control");
|
|
100
|
+
if (controls.length === 0) {
|
|
101
|
+
controls = locations.filter((location) => ["expected_control", "concrete_implementation"].includes(String(location["role"])));
|
|
102
|
+
}
|
|
103
|
+
if (controls.length === 0)
|
|
104
|
+
controls = locations.slice(0, 1);
|
|
105
|
+
return {
|
|
106
|
+
occurrenceId: finding.occurrenceId,
|
|
107
|
+
...present({
|
|
108
|
+
findingId: finding["findingId"],
|
|
109
|
+
title: finding["title"],
|
|
110
|
+
identity: pick(finding["identity"], ["anchor", "instance"]),
|
|
111
|
+
ruleId: finding["ruleId"],
|
|
112
|
+
taxonomy: pick(finding["taxonomy"], ["category", "cwe"]),
|
|
113
|
+
rootCause: (typeof rootCause === "string"
|
|
114
|
+
? rootCause
|
|
115
|
+
: record(rootCause)?.["summary"]) ?? finding["summary"],
|
|
116
|
+
remediation: finding["remediation"],
|
|
117
|
+
locations: controls.map((location) => pick(location, ["path", "startLine", "endLine", "role"])),
|
|
118
|
+
attackPath: present({
|
|
119
|
+
dataFlow: pick(dataFlow, ["source", "sink"]),
|
|
120
|
+
reachability: pick(attackPath?.["reachability"], [
|
|
121
|
+
"attacker",
|
|
122
|
+
"entrypoint",
|
|
123
|
+
]),
|
|
124
|
+
}),
|
|
125
|
+
affectedComponent: finding["affectedComponent"],
|
|
126
|
+
boundaryCrossed: finding["boundaryCrossed"],
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function record(value) {
|
|
131
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
132
|
+
? value
|
|
133
|
+
: undefined;
|
|
134
|
+
}
|
|
135
|
+
function pick(value, fields) {
|
|
136
|
+
if (typeof value === "string")
|
|
137
|
+
return value;
|
|
138
|
+
const object = record(value);
|
|
139
|
+
return object === undefined
|
|
140
|
+
? undefined
|
|
141
|
+
: present(Object.fromEntries(fields.map((field) => [field, object[field]])));
|
|
142
|
+
}
|
|
143
|
+
function present(value) {
|
|
144
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined &&
|
|
145
|
+
item !== null &&
|
|
146
|
+
item !== "" &&
|
|
147
|
+
(!Array.isArray(item) || item.length > 0) &&
|
|
148
|
+
(record(item) === undefined || Object.keys(item).length > 0)));
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=finding-catalogue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding-catalogue.js","sourceRoot":"","sources":["../src/finding-catalogue.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,aAAa,CAC3B,QAAsC,EACtC,qBAAqD,EAAE,EACvD,mBAAmD,EAAE;IAErD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,MAAM,IAAI,GAAG,CAAC,KAAa,EAAU,EAAE;QACrC,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC;QAClC,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IACF,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAc,EAAQ,E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QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,IAAI,CAAC,KAAc,EAAE,MAAyB;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,OAAO,CACL,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAClE,CAAC;AACR,CAAC;AAED,SAAS,OAAO,CAAC,KAA8B;IAC7C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAC1B,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CACX,IAAI,KAAK,SAAS;QAClB,IAAI,KAAK,IAAI;QACb,IAAI,KAAK,EAAE;QACX,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACzC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACzE,CACF,CAAC;AACJ,CAAC","sourcesContent":["export type ComparisonFinding = { occurrenceId: string } & Record<\n string,\n unknown\n>;\n\nexport interface CatalogueEntry {\n card: ComparisonFinding;\n occurrences: readonly ComparisonFinding[];\n}\n\nexport function groupFindings(\n findings: readonly ComparisonFinding[],\n knownFindingGroups: readonly (readonly string[])[] = [],\n occurrenceGroups: readonly (readonly string[])[] = [],\n): ComparisonFinding[][] {\n const parents = new Map<string, string>();\n const root = (value: string): string => {\n const path: string[] = [];\n let current = value;\n while (parents.has(current)) {\n path.push(current);\n current = parents.get(current)!;\n }\n for (const item of path) parents.set(item, current);\n return current;\n };\n const link = (first: string, second: string): void => {\n const previous = root(first);\n const current = root(second);\n if (previous !== current) parents.set(current, previous);\n };\n for (const [prefix, groups] of [\n [\"finding\", knownFindingGroups],\n [\"occurrence\", occurrenceGroups],\n ] as const) {\n for (const group of groups) {\n const identities =\n prefix === \"finding\"\n ? group.filter((identity) => identity.trim().length > 0)\n : group;\n const first = identities[0];\n if (first === undefined) continue;\n for (const value of identities.slice(1)) {\n link(`${prefix}:${first}`, `${prefix}:${value}`);\n }\n }\n }\n for (const finding of findings) {\n const findingId = finding[\"findingId\"];\n if (typeof findingId === \"string\" && findingId.trim().length > 0) {\n link(`finding:${findingId}`, `occurrence:${finding.occurrenceId}`);\n }\n }\n\n const groups = new Map<string, ComparisonFinding[]>();\n for (const finding of findings) {\n const key = root(`occurrence:${finding.occurrenceId}`);\n const group = groups.get(key);\n if (group === undefined) groups.set(key, [finding]);\n else group.push(finding);\n }\n\n return [...groups.values()];\n}\n\nexport function findingCatalogue(\n findings: readonly ComparisonFinding[],\n knownFindingGroups: readonly (readonly string[])[] = [],\n): Map<string, CatalogueEntry> {\n return new Map(\n groupFindings(findings, knownFindingGroups).map((occurrences) => {\n const latest = occurrences.at(-1)!;\n const card = compactFinding(latest);\n if (occurrences.length > 1) {\n const description = (finding: ComparisonFinding) => {\n const value: Record<string, unknown> = { ...compactFinding(finding) };\n delete value[\"occurrenceId\"];\n delete value[\"findingId\"];\n return value;\n };\n const current = description(latest);\n const seen = new Set<string>();\n const aliases = occurrences.slice(0, -1).flatMap((finding) => {\n const value = Object.fromEntries(\n Object.entries(description(finding)).filter(\n ([field, value]) =>\n JSON.stringify(value) !== JSON.stringify(current[field]),\n ),\n );\n if (Object.keys(value).length === 0) return [];\n const key = JSON.stringify(value);\n if (seen.has(key)) return [];\n seen.add(key);\n return [value];\n });\n card[\"occurrenceCount\"] = occurrences.length;\n if (aliases.length > 0) card[\"earlierDescriptions\"] = aliases;\n }\n const findingId = occurrences[0]![\"findingId\"];\n if (typeof findingId === \"string\" && findingId.trim().length > 0) {\n card[\"issueId\"] = findingId;\n }\n return [latest.occurrenceId, { card, occurrences }];\n }),\n );\n}\n\nexport function compactFinding(finding: ComparisonFinding): ComparisonFinding {\n const rootCause = finding[\"rootCause\"] ?? finding[\"root_cause\"];\n const attackPath = record(finding[\"attackPath\"]);\n const dataFlow =\n attackPath?.[\"dataFlow\"] ??\n attackPath?.[\"data_flow\"] ??\n attackPath?.[\"dataflow\"];\n const locations = Array.isArray(finding[\"locations\"])\n ? finding[\"locations\"].flatMap((value) => {\n const location = record(value);\n return location === undefined ? [] : [location];\n })\n : [];\n let controls = locations.filter(\n (location) => location[\"role\"] === \"root_control\",\n );\n if (controls.length === 0) {\n controls = locations.filter((location) =>\n [\"expected_control\", \"concrete_implementation\"].includes(\n String(location[\"role\"]),\n ),\n );\n }\n if (controls.length === 0) controls = locations.slice(0, 1);\n\n return {\n occurrenceId: finding.occurrenceId,\n ...present({\n findingId: finding[\"findingId\"],\n title: finding[\"title\"],\n identity: pick(finding[\"identity\"], [\"anchor\", \"instance\"]),\n ruleId: finding[\"ruleId\"],\n taxonomy: pick(finding[\"taxonomy\"], [\"category\", \"cwe\"]),\n rootCause:\n (typeof rootCause === \"string\"\n ? rootCause\n : record(rootCause)?.[\"summary\"]) ?? finding[\"summary\"],\n remediation: finding[\"remediation\"],\n locations: controls.map((location) =>\n pick(location, [\"path\", \"startLine\", \"endLine\", \"role\"]),\n ),\n attackPath: present({\n dataFlow: pick(dataFlow, [\"source\", \"sink\"]),\n reachability: pick(attackPath?.[\"reachability\"], [\n \"attacker\",\n \"entrypoint\",\n ]),\n }),\n affectedComponent: finding[\"affectedComponent\"],\n boundaryCrossed: finding[\"boundaryCrossed\"],\n }),\n };\n}\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction pick(value: unknown, fields: readonly string[]): unknown {\n if (typeof value === \"string\") return value;\n const object = record(value);\n return object === undefined\n ? undefined\n : present(\n Object.fromEntries(fields.map((field) => [field, object[field]])),\n );\n}\n\nfunction present(value: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(value).filter(\n ([, item]) =>\n item !== undefined &&\n item !== null &&\n item !== \"\" &&\n (!Array.isArray(item) || item.length > 0) &&\n (record(item) === undefined || Object.keys(item as object).length > 0),\n ),\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { CodexSecurity, createSecurity } from "./api.js";
|
|
2
|
+
export { classifySeverity } from "./classify-severity.js";
|
|
3
|
+
export type { ClassifySeverityOptions, SeverityClassificationFinding, SeverityClassification, SeverityAssessment, } from "./classify-severity.js";
|
|
4
|
+
export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
|
|
5
|
+
export type { ClassifyScanSeverityOptions, ScanSeverityClassification, } from "./classify-scan-severity.js";
|
|
2
6
|
export { runComponentScans } from "./component-scan.js";
|
|
3
7
|
export type { ComponentDeduplicationSummary, ComponentReceipt, ComponentScanOptions, ComponentScanEvent, ComponentScanResult, } from "./component-scan.js";
|
|
4
8
|
export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
@@ -8,12 +12,14 @@ export type { ScanCost, ScanSessionEvent } from "./cost.js";
|
|
|
8
12
|
export type { DeepScanProgress } from "./deep-progress.js";
|
|
9
13
|
export type { CustomValidationResult } from "./custom-validation.js";
|
|
10
14
|
export type { ScanActivity, ScanActivityStatus } from "./scan-activity.js";
|
|
11
|
-
export
|
|
15
|
+
export { matchScanFindings } from "./scan-comparison.js";
|
|
16
|
+
export type { ScanComparisonInput, ScanComparisonOptions, ScanComparisonProgress, ScanComparisonResult, } from "./scan-comparison.js";
|
|
17
|
+
export type { CodexSecurityMetadata, DeepScanOptions, ScanAuthMode, ScanAuthentication, ScanBudget, ScanOptions, ScanPreflight, ScanReconnectDetails, ScanTrustedAccessStatus, ScanWarningDetails, ValidationOptions, ValidationResult, } from "./api.js";
|
|
12
18
|
export type { ScanPhase, ScanProgress, ScanWorkerPhase, ScanWorkerStatus, } from "./worker-progress.js";
|
|
13
19
|
export { CodexLoginHandle } from "./auth.js";
|
|
14
20
|
export type { AccountStatus, LoginResult } from "./auth.js";
|
|
15
|
-
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, IncompleteScanError, InvalidTargetError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
16
|
-
export type { ProtectedScanPathKind } from "./errors.js";
|
|
21
|
+
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, DeduplicationReviewError, IncompleteScanError, InvalidTargetError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
22
|
+
export type { DeduplicationReviewFailureCategory, DeduplicationReviewFailureMetadata, DeduplicationReviewStage, ProtectedScanPathKind, } from "./errors.js";
|
|
17
23
|
export { DEFAULT_CODEX_CONFIG, mergedCodexConfig, writeCodexConfig, } from "./config.js";
|
|
18
24
|
export type { CodexSecurityConfig, JsonObject, JsonValue } from "./config.js";
|
|
19
25
|
export { loadContract, requireScanFile } from "./contract.js";
|
|
@@ -22,8 +28,8 @@ export type * from "./models.js";
|
|
|
22
28
|
export { checkScanPublication, publishScan } from "./publish.js";
|
|
23
29
|
export { publishScanToCustom } from "./custom-publish.js";
|
|
24
30
|
export type { PublishScanToCustomOptions, CustomPublicationResult, } from "./custom-publish.js";
|
|
25
|
-
export { deduplicateScan } from "./deduplication/scan.js";
|
|
26
|
-
export type { DeduplicateScanOptions, DeduplicateScanResult, } from "./deduplication/scan.js";
|
|
31
|
+
export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
|
|
32
|
+
export type { DeduplicateScanDirectoryOptions, DeduplicateScanOptions, DeduplicateScanResult, } from "./deduplication/scan.js";
|
|
27
33
|
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
28
34
|
export type { GitHubCodeScanningImportOptions, ImportedGitHubCodeScanningAlert, } from "./github.js";
|
|
29
35
|
export type { CheckScanPublicationOptions, CheckScanPublicationResult, PublishScanOptions, PublishScanProgress, PublishScanResult, } from "./publish.js";
|
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,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC7E,YAAY,EACV,aAAa,EACb,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,YAAY,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tB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export { CodexSecurity, createSecurity } from "./api.js";
|
|
2
|
+
export { classifySeverity } from "./classify-severity.js";
|
|
3
|
+
export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
|
|
2
4
|
export { runComponentScans } from "./component-scan.js";
|
|
3
5
|
export { normalizeComponentPlan, planComponents } from "./component-plan.js";
|
|
4
6
|
export { estimateScanCost } from "./cost.js";
|
|
7
|
+
export { matchScanFindings } from "./scan-comparison.js";
|
|
5
8
|
export { CodexLoginHandle } from "./auth.js";
|
|
6
|
-
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, IncompleteScanError, InvalidTargetError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
9
|
+
export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, ContractValidationError, DeduplicationReviewError, IncompleteScanError, InvalidTargetError, OutputDirectoryError, OutputDirectoryNotEmptyError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
7
10
|
export { DEFAULT_CODEX_CONFIG, mergedCodexConfig, writeCodexConfig, } from "./config.js";
|
|
8
11
|
export { loadContract, requireScanFile } from "./contract.js";
|
|
9
12
|
export { checkScanPublication, publishScan } from "./publish.js";
|
|
10
13
|
export { publishScanToCustom } from "./custom-publish.js";
|
|
11
|
-
export { deduplicateScan } from "./deduplication/scan.js";
|
|
14
|
+
export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
|
|
12
15
|
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
13
16
|
export { ScanResult } from "./result.js";
|
|
14
17
|
export { bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, createIsolatedHome, createMarketplace, extractPluginZip, importAmbientAuth, MARKETPLACE_NAME, pluginExecutionEnvironment, pluginMetadata, PLUGIN_NAME, prepareOutputDir, resolveCodexCommand, resolvePluginPath, resolvePluginPython, validateOutputDir, } from "./runtime.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO1D,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;AAK7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2BzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,EACL,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAMjC,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;AAEtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { CodexSecurity, createSecurity } from \"./api.js\";\nexport { classifySeverity } from \"./classify-severity.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 } from \"./cost.js\";\nexport type { DeepScanProgress } from \"./deep-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 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 OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\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 { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.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 { 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 { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JsonObject } from "./config.js";
|
|
2
|
+
import type { NormalizedTarget } from "./targets.js";
|
|
3
|
+
export declare function writeMockScanDraft(scanDir: string, scanId: string, target: NormalizedTarget, registration: JsonObject, signal: AbortSignal): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=mock-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-scan.d.ts","sourceRoot":"","sources":["../src/mock-scan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAuMrD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,UAAU,EACxB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA0Df"}
|