@openai/codex-security 0.5.0 → 0.6.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 +93 -2
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +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/permission-profile-preflight.mjs +60 -9
- 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/schemas/definitions/artifact-common.schema.json +1 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +12 -1
- package/_bundled_plugin/scripts/generate_in_scope_files.py +6 -6
- package/_bundled_plugin/scripts/generate_rank_input.py +12 -6
- package/_bundled_plugin/scripts/report_projection.py +2 -1
- package/_bundled_plugin/scripts/threat_model_projection.py +1 -3
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +234 -0
- package/_bundled_plugin/scripts/workbench_cli.py +5 -7
- package/_bundled_plugin/scripts/workbench_db.py +12 -6
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +2 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +10 -7
- package/_bundled_plugin/scripts/workbench_publication.py +4 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +5 -1
- package/_bundled_plugin/scripts/workbench_saved_results.py +542 -148
- package/_bundled_plugin/scripts/workbench_scan_history.py +79 -78
- package/_bundled_plugin/scripts/workbench_scan_usage.py +61 -13
- package/_bundled_plugin/scripts/workbench_target.py +21 -7
- package/_bundled_plugin/scripts/workbench_validation.py +21 -18
- package/_bundled_plugin/shared/workbench-migrations.json +26 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +16 -8
- package/_bundled_plugin/skills/publish-findings/SKILL.md +130 -0
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +6 -0
- package/_bundled_plugin/skills/verify-fix/SKILL.md +4 -2
- package/dist/api.d.ts +4 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +233 -91
- package/dist/api.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +16 -18
- package/dist/classify-scan-severity.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-daybreak.d.ts +5 -0
- package/dist/cli-daybreak.d.ts.map +1 -0
- package/dist/cli-daybreak.js +89 -0
- package/dist/cli-daybreak.js.map +1 -0
- 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 +12 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1224 -596
- 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/codeowners.js +2 -2
- package/dist/codeowners.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -2
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.js +2 -2
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts +2 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +17 -8
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +2 -5
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +8 -6
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +5 -2
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/retry.d.ts.map +1 -1
- package/dist/deduplication/retry.js +5 -0
- package/dist/deduplication/retry.js.map +1 -1
- package/dist/deduplication/scan.js +5 -1
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-scan.d.ts +6 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +8 -6
- package/dist/deep-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 +7 -0
- package/dist/endor-findings.d.ts.map +1 -0
- package/dist/endor-findings.js +233 -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 +38 -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 +337 -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 +713 -0
- package/dist/external-findings-publish.js.map +1 -0
- package/dist/external-findings-read.d.ts +6 -0
- package/dist/external-findings-read.d.ts.map +1 -0
- package/dist/external-findings-read.js +88 -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 +13 -0
- package/dist/external-import-contract.d.ts.map +1 -0
- package/dist/external-import-contract.js +254 -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/finding-workflow.d.ts +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -1
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +23 -3
- package/dist/findings-import.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 +131 -0
- package/dist/github-advisories.js.map +1 -0
- package/dist/github-findings.d.ts +10 -0
- package/dist/github-findings.d.ts.map +1 -0
- package/dist/github-findings.js +256 -0
- package/dist/github-findings.js.map +1 -0
- package/dist/host-protocol.d.ts +1 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/hosted-remediation-protocol.d.ts +6 -0
- package/dist/hosted-remediation-protocol.d.ts.map +1 -0
- package/dist/hosted-remediation-protocol.js +32 -0
- package/dist/hosted-remediation-protocol.js.map +1 -0
- package/dist/hosted-remediation.d.ts +93 -0
- package/dist/hosted-remediation.d.ts.map +1 -0
- package/dist/hosted-remediation.js +124 -0
- package/dist/hosted-remediation.js.map +1 -0
- package/dist/hosted-scan.d.ts +16 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +14 -2
- package/dist/hosted-scan.js.map +1 -1
- package/dist/import-scan.d.ts +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +5 -1
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +3 -1
- package/dist/multiscan.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 +15 -9
- 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 +9 -0
- package/dist/publish.js.map +1 -1
- package/dist/remediation.d.ts +69 -0
- package/dist/remediation.d.ts.map +1 -0
- package/dist/remediation.js +121 -0
- package/dist/remediation.js.map +1 -0
- package/dist/request-metadata.d.ts +17 -7
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +43 -8
- package/dist/request-metadata.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 +24 -15
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +16 -4
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.js +8 -8
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +15 -9
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +12 -6
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +5 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +9 -8
- package/dist/scan-executor.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/{deep-progress.d.ts → scan-progress.d.ts} +15 -7
- package/dist/scan-progress.d.ts.map +1 -0
- package/dist/scan-progress.js +138 -0
- package/dist/scan-progress.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/scanner-import.d.ts +20 -0
- package/dist/scanner-import.d.ts.map +1 -0
- package/dist/scanner-import.js +204 -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 -57
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +9 -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/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +4 -0
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +14 -2
- package/dist/server/sqlite-store.js.map +1 -1
- 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 +11 -3
- package/dist/severity-store.js.map +1 -1
- package/dist/snyk-findings.d.ts +9 -0
- package/dist/snyk-findings.d.ts.map +1 -0
- package/dist/snyk-findings.js +349 -0
- package/dist/snyk-findings.js.map +1 -0
- package/dist/targets.d.ts +2 -2
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +12 -2
- package/dist/targets.js.map +1 -1
- package/dist/timestamps.d.ts +3 -0
- package/dist/timestamps.d.ts.map +1 -0
- package/dist/timestamps.js +14 -0
- package/dist/timestamps.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +13 -2
- package/dist/version.js.map +1 -1
- package/dist/wiz-csv.d.ts +8 -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 +4 -0
- package/dist/wiz-findings.d.ts.map +1 -0
- package/dist/wiz-findings.js +460 -0
- package/dist/wiz-findings.js.map +1 -0
- package/dist/workbench-arguments.d.ts.map +1 -1
- package/dist/workbench-arguments.js +9 -3
- package/dist/workbench-arguments.js.map +1 -1
- package/dist/worker-progress.d.ts +11 -1
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +11 -1
- package/dist/worker-progress.js.map +1 -1
- package/docs/classify-severity-records.md +28 -10
- package/docs/cli.md +788 -46
- package/docs/findings-service.md +7 -2
- package/docs/hosted-remediation.md +134 -0
- package/docs/hosted-scans.md +20 -3
- package/package.json +9 -6
- package/schemas/external-findings.schema.json +1421 -0
- package/schemas/project-config.schema.json +4 -0
- package/dist/deep-progress.d.ts.map +0 -1
- package/dist/deep-progress.js +0 -92
- package/dist/deep-progress.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-import-contract.js","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,MAAM,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAUpF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC;IACtB,MAAM,EAAE,KAAK;IACb,eAAe,EAAE,KAAK;IACtB,WAAW,EAAE,IAAI;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EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;QAChE,MAAM,CAAC,KAAK,CAAC,MAAM;QAEnB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;QAAE,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI;QAC7D,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { isIP } from \"node:net\";\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport schema from \"../schemas/external-findings.schema.json\" with { type: \"json\" };\nimport type {\n ExternalFindingEvidence,\n FindingImportRequest,\n FindingImportReceipt,\n ImportRepositoryPage,\n SourceReportPage,\n SourceReport,\n} from \"./external-import-models.js\";\n\nconst ajv = new Ajv2020({\n strict: false,\n validateFormats: false,\n useDefaults: true,\n});\nconst STRING_BYTE_LIMITS: Readonly<Record<string, number>> = {\n description: 65536,\n snippet: 65536,\n remediation_instructions: 65536,\n expected: 65536,\n actual: 65536,\n file_url: 2048,\n path: 2048,\n url: 2048,\n manifest_path: 2048,\n client_id: 128,\n next: 4096,\n};\n\n/** Compare repository URLs without changing the retained vendor evidence.\n * GitHub repository paths are case-insensitive; unknown VCS hosts stay strict.\n * Keep protocols and explicit ports distinct, matching the Cloud URL contract. */\nexport function repositoryUrlKey(value: string): string {\n const normalized = value.replace(/\\/$/u, \"\").replace(/\\.git$/u, \"\");\n const parts = /^(https?):\\/\\/([^/?#]+)((?:\\/[^?#]*)?)((?:[?#].*)?)$/iu.exec(\n normalized,\n );\n if (!parts) return normalized;\n const authority = parts[2]!.toLowerCase();\n const hostname = authority.replace(/:\\d+$/u, \"\");\n const path =\n hostname === \"github.com\" || hostname.endsWith(\".ghe.com\")\n ? parts[3]!.toLowerCase()\n : parts[3]!;\n return `${parts[1]!.toLowerCase()}://${authority}${path}${parts[4]!}`;\n}\n\n// Cloud's import catalog contains GitHub repositories, including custom Enterprise\n// hosts. Match its case-insensitive URL identity without merging schemes or ports.\nexport function cloudRepositoryUrlKey(value: string): string {\n return repositoryUrlKey(value).toLowerCase();\n}\n\n// Cloud ImportModel applies these constraints to both requests and responses.\n// Its UTF-8 limits are not exported as JSON Schema character limits: even a\n// plain string field such as a receipt error message inherits the 512-byte bound.\nfunction validateModelStrings(input: unknown): void {\n if (input === null || typeof input !== \"object\") return;\n if (Array.isArray(input)) {\n for (const item of input) validateModelStrings(item);\n return;\n }\n for (const [field, value] of Object.entries(input)) {\n if (field === \"source_data\") continue;\n if (typeof value === \"string\") {\n if (\n (!value.trim() && ![\"snippet\", \"expected\", \"actual\"].includes(field)) ||\n value.includes(\"\\0\")\n )\n throw new Error(\n `${field} must be nonempty and contain no NUL characters.`,\n );\n const limit = STRING_BYTE_LIMITS[field] ?? 512;\n if (Buffer.byteLength(value) > limit)\n throw new Error(\n `${field} exceeds its Cloud limit of ${limit} UTF-8 bytes.`,\n );\n } else if (\n Array.isArray(value) &&\n value.every((item) => typeof item === \"string\")\n ) {\n if (value.some((item) => Buffer.byteLength(item) > 512))\n throw new Error(\n `${field} entries exceed the Cloud limit of 512 UTF-8 bytes.`,\n );\n } else validateModelStrings(value);\n }\n}\n\ntype ModelSchema = {\n $ref?: string;\n anyOf?: ModelSchema[];\n properties?: Record<string, ModelSchema>;\n [key: string]: unknown;\n};\nconst modelSchemas: Record<string, ModelSchema> = schema.$defs;\nconst detailValidators = new Map<string, ReturnType<typeof ajv.compile>>();\n\n/** AJV does not apply defaults through nullable anyOf references. Validate the\n * present detail objects directly against their generated model definitions so\n * sparse normalized inputs match the backend's serialized evidence. */\nfunction materializeDetailDefaults(\n value: unknown,\n fieldSchema: ModelSchema,\n): void {\n if (value === null || typeof value !== \"object\" || Array.isArray(value))\n return;\n const reference =\n fieldSchema.$ref ?? fieldSchema.anyOf?.find((branch) => branch.$ref)?.$ref;\n if (!reference) return;\n const name = reference.split(\"/\").at(-1)!;\n const definition = modelSchemas[name]!;\n let check = detailValidators.get(reference);\n if (!check) {\n check = ajv.compile({ $defs: schema.$defs, $ref: reference });\n detailValidators.set(reference, check);\n }\n if (!check(value))\n throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);\n for (const [field, childSchema] of Object.entries(\n definition.properties ?? {},\n ))\n materializeDetailDefaults(\n (value as Record<string, unknown>)[field],\n childSchema,\n );\n}\n\nfunction normalizeEvidenceDetails(value: unknown): void {\n if (value !== null && typeof value === \"object\") {\n const fields = value as Record<string, unknown>;\n // Cloud omits these new optional fields when null. Preserve every legacy\n // default so saved Wiz requests still replay the same evidence bytes.\n if (Array.isArray(fields[\"packages\"]))\n for (const value of fields[\"packages\"]) {\n if (\n value &&\n typeof value === \"object\" &&\n value[\"vulnerable_version_range\"] === null\n )\n delete value[\"vulnerable_version_range\"];\n }\n if (fields[\"details\"] === null) delete fields[\"details\"];\n else {\n const details = fields[\"details\"];\n if (details && typeof details === \"object\" && !Array.isArray(details))\n for (const field of [\"repository\", \"advisory\"])\n if ((details as Record<string, unknown>)[field] === null)\n delete (details as Record<string, unknown>)[field];\n materializeDetailDefaults(\n fields[\"details\"],\n modelSchemas[\"ImportedFindingEvidence\"]!.properties![\"details\"]!,\n );\n }\n }\n}\n\nfunction validator<T>(name: keyof typeof schema.$defs) {\n const check = ajv.compile<T>({\n $defs: schema.$defs,\n $ref: `#/$defs/${name}`,\n });\n return (input: unknown): T => {\n if (name === \"ImportedFindingEvidence\") normalizeEvidenceDetails(input);\n else if (input && typeof input === \"object\") {\n if (name === \"SourceReport\" && \"evidence\" in input)\n normalizeEvidenceDetails(input.evidence);\n if (\n name === \"FindingImportRequest\" &&\n \"items\" in input &&\n Array.isArray(input.items)\n )\n for (const item of input.items)\n normalizeEvidenceDetails(item?.evidence);\n }\n if (!check(input))\n throw new Error(`${name}: ${ajv.errorsText(check.errors)}`);\n validateModelStrings(input);\n return input;\n };\n}\n\nconst evidence = validator<ExternalFindingEvidence>(\"ImportedFindingEvidence\");\nconst request = validator<FindingImportRequest>(\"FindingImportRequest\");\nexport const validateImportReceipt = validator<FindingImportReceipt>(\n \"FindingImportReceipt\",\n);\nexport const validateRepositories = validator<ImportRepositoryPage>(\n \"ImportRepositoryPage\",\n);\nexport const validateSourceReports =\n validator<SourceReportPage>(\"SourceReportPage\");\nexport const validateSourceReport = validator<SourceReport>(\"SourceReport\");\n\nexport function validateExternalEvidence(\n input: unknown,\n): ExternalFindingEvidence {\n const result = evidence(input);\n for (const location of result.locations ?? []) {\n const path = location.path.replaceAll(\"\\\\\", \"/\");\n if (\n path.startsWith(\"/\") ||\n /^[A-Za-z]:/.test(path) ||\n path.split(\"/\").includes(\"..\")\n )\n throw new Error(\"Locations must use repository-relative paths.\");\n }\n const details = result.details;\n if (details) {\n if (details.kind === \"advisory\") {\n if (!details.advisory)\n throw new Error(\"Advisory evidence requires its source context.\");\n if (details.advisory.source === \"global\" && details.repository)\n throw new Error(\n \"Global advisory evidence cannot claim a source repository.\",\n );\n if (details.advisory.source === \"repository\" && !details.repository)\n throw new Error(\n \"Repository advisory evidence requires its source repository.\",\n );\n } else {\n if (!details.repository)\n throw new Error(\n \"Repository finding evidence requires its source repository.\",\n );\n if (details.advisory)\n throw new Error(\"Advisory source context requires advisory evidence.\");\n }\n }\n const endLine = result.details?.code?.end_line;\n if (endLine !== null && endLine !== undefined) {\n const firstLine = result.locations?.[0]?.line;\n if (firstLine === null || firstLine === undefined || endLine < firstLine)\n throw new Error(\n \"The code end line requires a first source location line and cannot precede it.\",\n );\n }\n const urls = [\n result.url,\n result.details?.repository?.url,\n result.details?.file_url,\n ];\n for (const value of urls) {\n if (value === null || value === undefined) continue;\n const url = value\n .replace(/[\\t\\r\\n]/gu, \"\")\n .replace(/^[\\u0000-\\u0020]+/u, \"\");\n const authority = /^https?:\\/\\/([^/?#]+)/iu.exec(url)?.[1];\n const normalizedAuthority = (authority ?? \"\")\n .replace(/[@:#?]/gu, \"\")\n .normalize(\"NFKC\");\n let validHost = true;\n if (authority?.includes(\"[\") || authority?.includes(\"]\")) {\n const hostname = /^\\[([^\\]]+)\\](?::[\\s\\S]*)?$/u.exec(authority)?.[1];\n const [address, scope, extraScope] = (hostname ?? \"\").split(\"%\");\n // Cloud accepts scoped IPv6 and IPvFuture hosts in brackets.\n validHost =\n hostname !== undefined &&\n (/^v[a-fA-F0-9]+\\.[\\s\\S]+$/u.test(hostname) ||\n (isIP(address!) === 6 && scope !== \"\" && extraScope === undefined));\n }\n if (\n !authority ||\n authority.includes(\"@\") ||\n /[/?#@:]/u.test(normalizedAuthority) ||\n !validHost\n )\n throw new Error(\n \"Evidence URLs must be HTTP(S) links without credentials.\",\n );\n }\n let numericByteAdjustment = 0;\n const pending: [unknown, number][] = [[result, 0]];\n while (pending.length > 0) {\n const [value, depth] = pending.pop()!;\n if (depth > 20)\n throw new Error(\"Evidence exceeds the Cloud JSON depth limit of 20.\");\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value))\n pending.push([child, depth + 1]);\n } else if (typeof value === \"number\") {\n if (!Number.isFinite(value))\n throw new Error(\"Evidence must contain finite JSON numbers.\");\n if (Number.isInteger(value) && !Number.isSafeInteger(value))\n throw new Error(\n \"Evidence integers must be within JavaScript's safe integer range; export larger values as strings to preserve them exactly.\",\n );\n const wire = JSON.stringify(value);\n // Cloud pads short exponents and formats small fractions scientifically.\n const cloud = (\n wire.includes(\".\") && Math.abs(value) < 1e-4\n ? value.toExponential()\n : wire\n ).replace(/e-(\\d)$/u, \"e-0$1\");\n numericByteAdjustment += cloud.length - wire.length;\n }\n }\n if (\n Buffer.byteLength(JSON.stringify(result)) + numericByteAdjustment >\n 256 * 1024\n )\n throw new Error(\"Evidence exceeds the Cloud limit of 256 KiB.\");\n return result;\n}\n\nexport function validateImportRequest(input: unknown): FindingImportRequest {\n const result = request(input);\n if (\n new Set(result.items.map((item) => item.client_id)).size !==\n result.items.length\n )\n throw new Error(\"Import contains duplicate client IDs.\");\n if (\n new Set(result.items.map((item) => item.source_finding_id)).size !==\n result.items.length\n )\n throw new Error(\"Import contains duplicate source finding identities.\");\n for (const item of result.items) validateExternalEvidence(item.evidence);\n if (Buffer.byteLength(JSON.stringify(result)) > 5 * 1024 * 1024)\n throw new Error(\"Import exceeds the Cloud limit of 5 MiB.\");\n return result;\n}\n"]}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
export type RequestId = string;
|
|
2
|
+
export type Id = string;
|
|
3
|
+
export type RepoConnectorId = string;
|
|
4
|
+
export type EnvironmentId = string;
|
|
5
|
+
export type ResetMarker = string;
|
|
6
|
+
export type Provider = "wiz" | "endor" | "snyk" | "github" | "semgrep";
|
|
7
|
+
export type SourceKey = string;
|
|
8
|
+
export type ClientId = string;
|
|
9
|
+
export type SourceFindingId = string;
|
|
10
|
+
export type ExpectedVersion = number;
|
|
11
|
+
export type Title = string;
|
|
12
|
+
export type Severity = "critical" | "high" | "medium" | "low" | "informational" | "unknown";
|
|
13
|
+
export type Description = string | null;
|
|
14
|
+
export type Url = string | null;
|
|
15
|
+
/**
|
|
16
|
+
* @maxItems 100
|
|
17
|
+
*/
|
|
18
|
+
export type AdvisoryIds = string[];
|
|
19
|
+
export type Name = string;
|
|
20
|
+
export type Ecosystem = string | null;
|
|
21
|
+
export type InstalledVersion = string | null;
|
|
22
|
+
export type VulnerableVersionRange = string | null;
|
|
23
|
+
export type ManifestPath = string | null;
|
|
24
|
+
/**
|
|
25
|
+
* @maxItems 100
|
|
26
|
+
*/
|
|
27
|
+
export type FixedVersions = string[];
|
|
28
|
+
/**
|
|
29
|
+
* @maxItems 100
|
|
30
|
+
*/
|
|
31
|
+
export type Packages = ImportedPackage[];
|
|
32
|
+
export type Path = string;
|
|
33
|
+
export type Line = number | null;
|
|
34
|
+
/**
|
|
35
|
+
* @maxItems 100
|
|
36
|
+
*/
|
|
37
|
+
export type Locations = ImportedLocation[];
|
|
38
|
+
export type Branch = string | null;
|
|
39
|
+
export type CodeRevision = string | null;
|
|
40
|
+
export type SourceScanId = string | null;
|
|
41
|
+
/**
|
|
42
|
+
* @maxItems 100
|
|
43
|
+
*/
|
|
44
|
+
export type ImageDigests = string[];
|
|
45
|
+
export type SourceUpdatedAt = number | null;
|
|
46
|
+
export type Kind = "sast" | "secret" | "iac" | "advisory";
|
|
47
|
+
export type Url1 = string;
|
|
48
|
+
export type Id1 = string | null;
|
|
49
|
+
export type Name1 = string | null;
|
|
50
|
+
export type Source = "repository" | "global";
|
|
51
|
+
export type SourceStatus = string | null;
|
|
52
|
+
export type ScannerOrigin = string | null;
|
|
53
|
+
export type ScannerVerdict = string | null;
|
|
54
|
+
export type Id2 = string | null;
|
|
55
|
+
export type ShortId = string | null;
|
|
56
|
+
export type Name2 = string | null;
|
|
57
|
+
/**
|
|
58
|
+
* @maxItems 100
|
|
59
|
+
*/
|
|
60
|
+
export type WeaknessIds = string[];
|
|
61
|
+
export type RemediationInstructions = string | null;
|
|
62
|
+
export type EndLine = number | null;
|
|
63
|
+
export type Snippet = string | null;
|
|
64
|
+
export type Type = string | null;
|
|
65
|
+
export type ImportedSecretConfidence = string;
|
|
66
|
+
export type ValidationStatus = string | null;
|
|
67
|
+
export type IsEncrypted = boolean | null;
|
|
68
|
+
export type IsManaged = boolean | null;
|
|
69
|
+
export type IntroducedCommit = string | null;
|
|
70
|
+
export type Platform = string | null;
|
|
71
|
+
export type CloudPlatform = string | null;
|
|
72
|
+
export type Expected = string | null;
|
|
73
|
+
export type Actual = string | null;
|
|
74
|
+
export type FileUrl = string | null;
|
|
75
|
+
/**
|
|
76
|
+
* @minItems 1
|
|
77
|
+
* @maxItems 100
|
|
78
|
+
*/
|
|
79
|
+
export type Items = FindingImportItem[];
|
|
80
|
+
export type Id3 = string;
|
|
81
|
+
export type Object = "security.finding_import";
|
|
82
|
+
export type Actor = string;
|
|
83
|
+
export type CreatedAt = number;
|
|
84
|
+
export type ItemCount = number;
|
|
85
|
+
export type Created = number;
|
|
86
|
+
export type Updated = number;
|
|
87
|
+
export type Unchanged = number;
|
|
88
|
+
export type Error = number;
|
|
89
|
+
export type ClientId1 = string;
|
|
90
|
+
export type Outcome = "created" | "updated" | "unchanged" | "error";
|
|
91
|
+
export type SourceReportId = string | null;
|
|
92
|
+
export type ObservationId = string | null;
|
|
93
|
+
export type CanonicalFindingId = string | null;
|
|
94
|
+
export type Version = number | null;
|
|
95
|
+
export type Code = "version_conflict" | "scope_conflict" | "stale_source_snapshot";
|
|
96
|
+
export type Message = string;
|
|
97
|
+
export type Results = FindingImportResult[];
|
|
98
|
+
export type Object1 = "page";
|
|
99
|
+
export type Id4 = string;
|
|
100
|
+
export type Object2 = "security.repository";
|
|
101
|
+
export type RepoConnectorId1 = string;
|
|
102
|
+
export type Url2 = string;
|
|
103
|
+
export type DefaultBranch = string | null;
|
|
104
|
+
export type ResetMarker1 = string;
|
|
105
|
+
export type ImportEnvironmentId = string | null;
|
|
106
|
+
export type Data = ImportRepository[];
|
|
107
|
+
export type HasMore = boolean;
|
|
108
|
+
export type Next = string | null;
|
|
109
|
+
export type Id5 = string;
|
|
110
|
+
export type Object3 = "security.source_report";
|
|
111
|
+
export type Origin = "imported";
|
|
112
|
+
export type RepoId = string;
|
|
113
|
+
export type RepoConnectorId2 = string;
|
|
114
|
+
export type EnvironmentId1 = string;
|
|
115
|
+
export type CanonicalFindingId1 = string;
|
|
116
|
+
export type SourceFindingId1 = string;
|
|
117
|
+
export type ObservationId1 = string;
|
|
118
|
+
export type Version1 = number;
|
|
119
|
+
export type State = "not_assessed";
|
|
120
|
+
export type Id6 = string;
|
|
121
|
+
export type Actor1 = string;
|
|
122
|
+
export type CreatedAt1 = number;
|
|
123
|
+
export type CreatedAt2 = number;
|
|
124
|
+
export type UpdatedAt = number;
|
|
125
|
+
export type Object4 = "page";
|
|
126
|
+
export type Id7 = string;
|
|
127
|
+
export type Object5 = "security.source_report_summary";
|
|
128
|
+
export type Origin1 = "imported";
|
|
129
|
+
export type RepoId1 = string;
|
|
130
|
+
export type RepoConnectorId3 = string;
|
|
131
|
+
export type EnvironmentId2 = string;
|
|
132
|
+
export type CanonicalFindingId2 = string;
|
|
133
|
+
export type SourceFindingId2 = string;
|
|
134
|
+
export type ObservationId2 = string;
|
|
135
|
+
export type Version2 = number;
|
|
136
|
+
export type Title1 = string;
|
|
137
|
+
export type Severity1 = "critical" | "high" | "medium" | "low" | "informational" | "unknown";
|
|
138
|
+
export type SourceUpdatedAt1 = number | null;
|
|
139
|
+
export type CreatedAt3 = number;
|
|
140
|
+
export type UpdatedAt1 = number;
|
|
141
|
+
export type Data1 = SourceReportSummary[];
|
|
142
|
+
export type HasMore1 = boolean;
|
|
143
|
+
export type Next1 = string | null;
|
|
144
|
+
/**
|
|
145
|
+
* Schema export root; transport endpoints return the individual models.
|
|
146
|
+
*/
|
|
147
|
+
export interface ExternalFindingContracts {
|
|
148
|
+
request: FindingImportRequest;
|
|
149
|
+
receipt: FindingImportReceipt;
|
|
150
|
+
repositories: ImportRepositoryPage;
|
|
151
|
+
source_report: SourceReport;
|
|
152
|
+
source_reports: SourceReportPage;
|
|
153
|
+
}
|
|
154
|
+
export interface FindingImportRequest {
|
|
155
|
+
request_id: RequestId;
|
|
156
|
+
repository: ImportDestination;
|
|
157
|
+
source: ImportSource;
|
|
158
|
+
items: Items;
|
|
159
|
+
}
|
|
160
|
+
export interface ImportDestination {
|
|
161
|
+
id: Id;
|
|
162
|
+
repo_connector_id: RepoConnectorId;
|
|
163
|
+
environment_id: EnvironmentId;
|
|
164
|
+
reset_marker: ResetMarker;
|
|
165
|
+
}
|
|
166
|
+
export interface ImportSource {
|
|
167
|
+
provider: Provider;
|
|
168
|
+
source_key: SourceKey;
|
|
169
|
+
}
|
|
170
|
+
export interface FindingImportItem {
|
|
171
|
+
client_id: ClientId;
|
|
172
|
+
source_finding_id: SourceFindingId;
|
|
173
|
+
expected_version: ExpectedVersion;
|
|
174
|
+
evidence: ImportedFindingEvidence;
|
|
175
|
+
}
|
|
176
|
+
export interface ImportedFindingEvidence {
|
|
177
|
+
title: Title;
|
|
178
|
+
severity: Severity;
|
|
179
|
+
description?: Description;
|
|
180
|
+
url?: Url;
|
|
181
|
+
advisory_ids?: AdvisoryIds;
|
|
182
|
+
packages?: Packages;
|
|
183
|
+
locations?: Locations;
|
|
184
|
+
branch?: Branch;
|
|
185
|
+
code_revision?: CodeRevision;
|
|
186
|
+
source_scan_id?: SourceScanId;
|
|
187
|
+
image_digests?: ImageDigests;
|
|
188
|
+
source_updated_at?: SourceUpdatedAt;
|
|
189
|
+
source_data?: SourceData;
|
|
190
|
+
details?: ImportedFindingDetails | null;
|
|
191
|
+
}
|
|
192
|
+
export interface ImportedPackage {
|
|
193
|
+
name: Name;
|
|
194
|
+
ecosystem?: Ecosystem;
|
|
195
|
+
installed_version?: InstalledVersion;
|
|
196
|
+
vulnerable_version_range?: VulnerableVersionRange;
|
|
197
|
+
manifest_path?: ManifestPath;
|
|
198
|
+
fixed_versions?: FixedVersions;
|
|
199
|
+
}
|
|
200
|
+
export interface ImportedLocation {
|
|
201
|
+
path: Path;
|
|
202
|
+
line?: Line;
|
|
203
|
+
}
|
|
204
|
+
export interface SourceData {
|
|
205
|
+
[k: string]: unknown;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Typed repository evidence; vendor state is not a Codex assessment.
|
|
209
|
+
*/
|
|
210
|
+
export interface ImportedFindingDetails {
|
|
211
|
+
kind: Kind;
|
|
212
|
+
repository?: ImportedRepositoryReference | null;
|
|
213
|
+
advisory?: ImportedAdvisoryContext | null;
|
|
214
|
+
source_status?: SourceStatus;
|
|
215
|
+
scanner_origin?: ScannerOrigin;
|
|
216
|
+
scanner_verdict?: ScannerVerdict;
|
|
217
|
+
rule?: ImportedFindingRule | null;
|
|
218
|
+
weakness_ids?: WeaknessIds;
|
|
219
|
+
remediation_instructions?: RemediationInstructions;
|
|
220
|
+
code?: ImportedCodeContext | null;
|
|
221
|
+
secret?: ImportedSecretDetails | null;
|
|
222
|
+
configuration?: ImportedConfigurationDetails | null;
|
|
223
|
+
file_url?: FileUrl;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Vendor repository identity, resolved to the full source-control URL.
|
|
227
|
+
*/
|
|
228
|
+
export interface ImportedRepositoryReference {
|
|
229
|
+
url: Url1;
|
|
230
|
+
id?: Id1;
|
|
231
|
+
name?: Name1;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Where the advisory was read; applicability is assessed separately.
|
|
235
|
+
*/
|
|
236
|
+
export interface ImportedAdvisoryContext {
|
|
237
|
+
source: Source;
|
|
238
|
+
}
|
|
239
|
+
export interface ImportedFindingRule {
|
|
240
|
+
id?: Id2;
|
|
241
|
+
short_id?: ShortId;
|
|
242
|
+
name?: Name2;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Optional range and snippet for the evidence's first source location.
|
|
246
|
+
*/
|
|
247
|
+
export interface ImportedCodeContext {
|
|
248
|
+
end_line?: EndLine;
|
|
249
|
+
snippet?: Snippet;
|
|
250
|
+
}
|
|
251
|
+
export interface ImportedSecretDetails {
|
|
252
|
+
type?: Type;
|
|
253
|
+
confidence?: ImportedSecretConfidence | null;
|
|
254
|
+
validation_status?: ValidationStatus;
|
|
255
|
+
is_encrypted?: IsEncrypted;
|
|
256
|
+
is_managed?: IsManaged;
|
|
257
|
+
introduced_commit?: IntroducedCommit;
|
|
258
|
+
}
|
|
259
|
+
export interface ImportedConfigurationDetails {
|
|
260
|
+
platform?: Platform;
|
|
261
|
+
cloud_platform?: CloudPlatform;
|
|
262
|
+
expected?: Expected;
|
|
263
|
+
actual?: Actual;
|
|
264
|
+
}
|
|
265
|
+
export interface FindingImportReceipt {
|
|
266
|
+
id: Id3;
|
|
267
|
+
object?: Object;
|
|
268
|
+
repository: ImportDestination;
|
|
269
|
+
source: ImportSource;
|
|
270
|
+
actor: Actor;
|
|
271
|
+
created_at: CreatedAt;
|
|
272
|
+
item_count: ItemCount;
|
|
273
|
+
counts: ImportCounts;
|
|
274
|
+
results: Results;
|
|
275
|
+
}
|
|
276
|
+
export interface ImportCounts {
|
|
277
|
+
created?: Created;
|
|
278
|
+
updated?: Updated;
|
|
279
|
+
unchanged?: Unchanged;
|
|
280
|
+
error?: Error;
|
|
281
|
+
}
|
|
282
|
+
export interface FindingImportResult {
|
|
283
|
+
client_id: ClientId1;
|
|
284
|
+
outcome: Outcome;
|
|
285
|
+
source_report_id?: SourceReportId;
|
|
286
|
+
observation_id?: ObservationId;
|
|
287
|
+
canonical_finding_id?: CanonicalFindingId;
|
|
288
|
+
version?: Version;
|
|
289
|
+
error?: ImportItemError | null;
|
|
290
|
+
}
|
|
291
|
+
export interface ImportItemError {
|
|
292
|
+
code: Code;
|
|
293
|
+
message: Message;
|
|
294
|
+
}
|
|
295
|
+
export interface ImportRepositoryPage {
|
|
296
|
+
object?: Object1;
|
|
297
|
+
data: Data;
|
|
298
|
+
has_more: HasMore;
|
|
299
|
+
next: Next;
|
|
300
|
+
}
|
|
301
|
+
export interface ImportRepository {
|
|
302
|
+
id: Id4;
|
|
303
|
+
object?: Object2;
|
|
304
|
+
repo_connector_id: RepoConnectorId1;
|
|
305
|
+
url: Url2;
|
|
306
|
+
default_branch?: DefaultBranch;
|
|
307
|
+
reset_marker: ResetMarker1;
|
|
308
|
+
import_environment_id?: ImportEnvironmentId;
|
|
309
|
+
}
|
|
310
|
+
export interface SourceReport {
|
|
311
|
+
id: Id5;
|
|
312
|
+
object?: Object3;
|
|
313
|
+
origin?: Origin;
|
|
314
|
+
repo_id: RepoId;
|
|
315
|
+
repo_connector_id: RepoConnectorId2;
|
|
316
|
+
environment_id: EnvironmentId1;
|
|
317
|
+
canonical_finding_id: CanonicalFindingId1;
|
|
318
|
+
source: ImportSource;
|
|
319
|
+
source_finding_id: SourceFindingId1;
|
|
320
|
+
observation_id: ObservationId1;
|
|
321
|
+
version: Version1;
|
|
322
|
+
evidence: ImportedFindingEvidence;
|
|
323
|
+
assessment?: ImportedAssessment;
|
|
324
|
+
last_import?: LastImport | null;
|
|
325
|
+
created_at: CreatedAt2;
|
|
326
|
+
updated_at: UpdatedAt;
|
|
327
|
+
}
|
|
328
|
+
export interface ImportedAssessment {
|
|
329
|
+
state?: State;
|
|
330
|
+
}
|
|
331
|
+
export interface LastImport {
|
|
332
|
+
id: Id6;
|
|
333
|
+
actor: Actor1;
|
|
334
|
+
created_at: CreatedAt1;
|
|
335
|
+
}
|
|
336
|
+
export interface SourceReportPage {
|
|
337
|
+
object?: Object4;
|
|
338
|
+
data: Data1;
|
|
339
|
+
has_more: HasMore1;
|
|
340
|
+
next: Next1;
|
|
341
|
+
}
|
|
342
|
+
export interface SourceReportSummary {
|
|
343
|
+
id: Id7;
|
|
344
|
+
object?: Object5;
|
|
345
|
+
origin?: Origin1;
|
|
346
|
+
repo_id: RepoId1;
|
|
347
|
+
repo_connector_id: RepoConnectorId3;
|
|
348
|
+
environment_id: EnvironmentId2;
|
|
349
|
+
canonical_finding_id: CanonicalFindingId2;
|
|
350
|
+
source: ImportSource;
|
|
351
|
+
source_finding_id: SourceFindingId2;
|
|
352
|
+
observation_id: ObservationId2;
|
|
353
|
+
version: Version2;
|
|
354
|
+
title: Title1;
|
|
355
|
+
severity: Severity1;
|
|
356
|
+
source_updated_at: SourceUpdatedAt1;
|
|
357
|
+
assessment?: ImportedAssessment;
|
|
358
|
+
created_at: CreatedAt3;
|
|
359
|
+
updated_at: UpdatedAt1;
|
|
360
|
+
}
|
|
361
|
+
export type ExternalFindingEvidence = ImportedFindingEvidence;
|
|
362
|
+
//# sourceMappingURL=external-import-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-import-models.d.ts","sourceRoot":"","sources":["../src/external-import-models.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,MAAM,CA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ts"],"names":[],"mappings":"AAAA,qGAAqG","sourcesContent":["/* Generated from schemas/external-findings.schema.json. Run pnpm generate:external-import-models. */\n\nexport type RequestId = string;\nexport type Id = string;\nexport type RepoConnectorId = string;\nexport type EnvironmentId = string;\nexport type ResetMarker = string;\nexport type Provider = \"wiz\" | \"endor\" | \"snyk\" | \"github\" | \"semgrep\";\nexport type SourceKey = string;\nexport type ClientId = string;\nexport type SourceFindingId = string;\nexport type ExpectedVersion = number;\nexport type Title = string;\nexport type Severity =\n \"critical\" | \"high\" | \"medium\" | \"low\" | \"informational\" | \"unknown\";\nexport type Description = string | null;\nexport type Url = string | null;\n/**\n * @maxItems 100\n */\nexport type AdvisoryIds = string[];\nexport type Name = string;\nexport type Ecosystem = string | null;\nexport type InstalledVersion = string | null;\nexport type VulnerableVersionRange = string | null;\nexport type ManifestPath = string | null;\n/**\n * @maxItems 100\n */\nexport type FixedVersions = string[];\n/**\n * @maxItems 100\n */\nexport type Packages = ImportedPackage[];\nexport type Path = string;\nexport type Line = number | null;\n/**\n * @maxItems 100\n */\nexport type Locations = ImportedLocation[];\nexport type Branch = string | null;\nexport type CodeRevision = string | null;\nexport type SourceScanId = string | null;\n/**\n * @maxItems 100\n */\nexport type ImageDigests = string[];\nexport type SourceUpdatedAt = number | null;\nexport type Kind = \"sast\" | \"secret\" | \"iac\" | \"advisory\";\nexport type Url1 = string;\nexport type Id1 = string | null;\nexport type Name1 = string | null;\nexport type Source = \"repository\" | \"global\";\nexport type SourceStatus = string | null;\nexport type ScannerOrigin = string | null;\nexport type ScannerVerdict = string | null;\nexport type Id2 = string | null;\nexport type ShortId = string | null;\nexport type Name2 = string | null;\n/**\n * @maxItems 100\n */\nexport type WeaknessIds = string[];\nexport type RemediationInstructions = string | null;\nexport type EndLine = number | null;\nexport type Snippet = string | null;\nexport type Type = string | null;\nexport type ImportedSecretConfidence = string;\nexport type ValidationStatus = string | null;\nexport type IsEncrypted = boolean | null;\nexport type IsManaged = boolean | null;\nexport type IntroducedCommit = string | null;\nexport type Platform = string | null;\nexport type CloudPlatform = string | null;\nexport type Expected = string | null;\nexport type Actual = string | null;\nexport type FileUrl = string | null;\n/**\n * @minItems 1\n * @maxItems 100\n */\nexport type Items = FindingImportItem[];\nexport type Id3 = string;\nexport type Object = \"security.finding_import\";\nexport type Actor = string;\nexport type CreatedAt = number;\nexport type ItemCount = number;\nexport type Created = number;\nexport type Updated = number;\nexport type Unchanged = number;\nexport type Error = number;\nexport type ClientId1 = string;\nexport type Outcome = \"created\" | \"updated\" | \"unchanged\" | \"error\";\nexport type SourceReportId = string | null;\nexport type ObservationId = string | null;\nexport type CanonicalFindingId = string | null;\nexport type Version = number | null;\nexport type Code =\n \"version_conflict\" | \"scope_conflict\" | \"stale_source_snapshot\";\nexport type Message = string;\nexport type Results = FindingImportResult[];\nexport type Object1 = \"page\";\nexport type Id4 = string;\nexport type Object2 = \"security.repository\";\nexport type RepoConnectorId1 = string;\nexport type Url2 = string;\nexport type DefaultBranch = string | null;\nexport type ResetMarker1 = string;\nexport type ImportEnvironmentId = string | null;\nexport type Data = ImportRepository[];\nexport type HasMore = boolean;\nexport type Next = string | null;\nexport type Id5 = string;\nexport type Object3 = \"security.source_report\";\nexport type Origin = \"imported\";\nexport type RepoId = string;\nexport type RepoConnectorId2 = string;\nexport type EnvironmentId1 = string;\nexport type CanonicalFindingId1 = string;\nexport type SourceFindingId1 = string;\nexport type ObservationId1 = string;\nexport type Version1 = number;\nexport type State = \"not_assessed\";\nexport type Id6 = string;\nexport type Actor1 = string;\nexport type CreatedAt1 = number;\nexport type CreatedAt2 = number;\nexport type UpdatedAt = number;\nexport type Object4 = \"page\";\nexport type Id7 = string;\nexport type Object5 = \"security.source_report_summary\";\nexport type Origin1 = \"imported\";\nexport type RepoId1 = string;\nexport type RepoConnectorId3 = string;\nexport type EnvironmentId2 = string;\nexport type CanonicalFindingId2 = string;\nexport type SourceFindingId2 = string;\nexport type ObservationId2 = string;\nexport type Version2 = number;\nexport type Title1 = string;\nexport type Severity1 =\n \"critical\" | \"high\" | \"medium\" | \"low\" | \"informational\" | \"unknown\";\nexport type SourceUpdatedAt1 = number | null;\nexport type CreatedAt3 = number;\nexport type UpdatedAt1 = number;\nexport type Data1 = SourceReportSummary[];\nexport type HasMore1 = boolean;\nexport type Next1 = string | null;\n\n/**\n * Schema export root; transport endpoints return the individual models.\n */\nexport interface ExternalFindingContracts {\n request: FindingImportRequest;\n receipt: FindingImportReceipt;\n repositories: ImportRepositoryPage;\n source_report: SourceReport;\n source_reports: SourceReportPage;\n}\nexport interface FindingImportRequest {\n request_id: RequestId;\n repository: ImportDestination;\n source: ImportSource;\n items: Items;\n}\nexport interface ImportDestination {\n id: Id;\n repo_connector_id: RepoConnectorId;\n environment_id: EnvironmentId;\n reset_marker: ResetMarker;\n}\nexport interface ImportSource {\n provider: Provider;\n source_key: SourceKey;\n}\nexport interface FindingImportItem {\n client_id: ClientId;\n source_finding_id: SourceFindingId;\n expected_version: ExpectedVersion;\n evidence: ImportedFindingEvidence;\n}\nexport interface ImportedFindingEvidence {\n title: Title;\n severity: Severity;\n description?: Description;\n url?: Url;\n advisory_ids?: AdvisoryIds;\n packages?: Packages;\n locations?: Locations;\n branch?: Branch;\n code_revision?: CodeRevision;\n source_scan_id?: SourceScanId;\n image_digests?: ImageDigests;\n source_updated_at?: SourceUpdatedAt;\n source_data?: SourceData;\n details?: ImportedFindingDetails | null;\n}\nexport interface ImportedPackage {\n name: Name;\n ecosystem?: Ecosystem;\n installed_version?: InstalledVersion;\n vulnerable_version_range?: VulnerableVersionRange;\n manifest_path?: ManifestPath;\n fixed_versions?: FixedVersions;\n}\nexport interface ImportedLocation {\n path: Path;\n line?: Line;\n}\nexport interface SourceData {\n [k: string]: unknown;\n}\n/**\n * Typed repository evidence; vendor state is not a Codex assessment.\n */\nexport interface ImportedFindingDetails {\n kind: Kind;\n repository?: ImportedRepositoryReference | null;\n advisory?: ImportedAdvisoryContext | null;\n source_status?: SourceStatus;\n scanner_origin?: ScannerOrigin;\n scanner_verdict?: ScannerVerdict;\n rule?: ImportedFindingRule | null;\n weakness_ids?: WeaknessIds;\n remediation_instructions?: RemediationInstructions;\n code?: ImportedCodeContext | null;\n secret?: ImportedSecretDetails | null;\n configuration?: ImportedConfigurationDetails | null;\n file_url?: FileUrl;\n}\n/**\n * Vendor repository identity, resolved to the full source-control URL.\n */\nexport interface ImportedRepositoryReference {\n url: Url1;\n id?: Id1;\n name?: Name1;\n}\n/**\n * Where the advisory was read; applicability is assessed separately.\n */\nexport interface ImportedAdvisoryContext {\n source: Source;\n}\nexport interface ImportedFindingRule {\n id?: Id2;\n short_id?: ShortId;\n name?: Name2;\n}\n/**\n * Optional range and snippet for the evidence's first source location.\n */\nexport interface ImportedCodeContext {\n end_line?: EndLine;\n snippet?: Snippet;\n}\nexport interface ImportedSecretDetails {\n type?: Type;\n confidence?: ImportedSecretConfidence | null;\n validation_status?: ValidationStatus;\n is_encrypted?: IsEncrypted;\n is_managed?: IsManaged;\n introduced_commit?: IntroducedCommit;\n}\nexport interface ImportedConfigurationDetails {\n platform?: Platform;\n cloud_platform?: CloudPlatform;\n expected?: Expected;\n actual?: Actual;\n}\nexport interface FindingImportReceipt {\n id: Id3;\n object?: Object;\n repository: ImportDestination;\n source: ImportSource;\n actor: Actor;\n created_at: CreatedAt;\n item_count: ItemCount;\n counts: ImportCounts;\n results: Results;\n}\nexport interface ImportCounts {\n created?: Created;\n updated?: Updated;\n unchanged?: Unchanged;\n error?: Error;\n}\nexport interface FindingImportResult {\n client_id: ClientId1;\n outcome: Outcome;\n source_report_id?: SourceReportId;\n observation_id?: ObservationId;\n canonical_finding_id?: CanonicalFindingId;\n version?: Version;\n error?: ImportItemError | null;\n}\nexport interface ImportItemError {\n code: Code;\n message: Message;\n}\nexport interface ImportRepositoryPage {\n object?: Object1;\n data: Data;\n has_more: HasMore;\n next: Next;\n}\nexport interface ImportRepository {\n id: Id4;\n object?: Object2;\n repo_connector_id: RepoConnectorId1;\n url: Url2;\n default_branch?: DefaultBranch;\n reset_marker: ResetMarker1;\n import_environment_id?: ImportEnvironmentId;\n}\nexport interface SourceReport {\n id: Id5;\n object?: Object3;\n origin?: Origin;\n repo_id: RepoId;\n repo_connector_id: RepoConnectorId2;\n environment_id: EnvironmentId1;\n canonical_finding_id: CanonicalFindingId1;\n source: ImportSource;\n source_finding_id: SourceFindingId1;\n observation_id: ObservationId1;\n version: Version1;\n evidence: ImportedFindingEvidence;\n assessment?: ImportedAssessment;\n last_import?: LastImport | null;\n created_at: CreatedAt2;\n updated_at: UpdatedAt;\n}\nexport interface ImportedAssessment {\n state?: State;\n}\nexport interface LastImport {\n id: Id6;\n actor: Actor1;\n created_at: CreatedAt1;\n}\nexport interface SourceReportPage {\n object?: Object4;\n data: Data1;\n has_more: HasMore1;\n next: Next1;\n}\nexport interface SourceReportSummary {\n id: Id7;\n object?: Object5;\n origin?: Origin1;\n repo_id: RepoId1;\n repo_connector_id: RepoConnectorId3;\n environment_id: EnvironmentId2;\n canonical_finding_id: CanonicalFindingId2;\n source: ImportSource;\n source_finding_id: SourceFindingId2;\n observation_id: ObservationId2;\n version: Version2;\n title: Title1;\n severity: Severity1;\n source_updated_at: SourceUpdatedAt1;\n assessment?: ImportedAssessment;\n created_at: CreatedAt3;\n updated_at: UpdatedAt1;\n}\n\nexport type ExternalFindingEvidence = ImportedFindingEvidence;\n"]}
|
|
@@ -44,7 +44,7 @@ export declare class FindingWorkflow {
|
|
|
44
44
|
bind(binding: WorkflowBinding): Promise<WorkflowState>;
|
|
45
45
|
begin(stage: WorkflowStage): Promise<WorkflowState>;
|
|
46
46
|
complete(stage: WorkflowStage, result: unknown): Promise<WorkflowState>;
|
|
47
|
-
fail(stage: WorkflowStage, error: unknown): Promise<void>;
|
|
47
|
+
fail(stage: WorkflowStage, error: unknown, result?: unknown): Promise<void>;
|
|
48
48
|
run<T>(stage: WorkflowStage, operation: () => Promise<T>): Promise<T>;
|
|
49
49
|
registeredScan(scanId: string): Promise<JsonObject>;
|
|
50
50
|
sourceSnapshot(repository: string, gitDisabled?: boolean, privateStatePaths?: readonly string[]): Promise<JsonObject>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finding-workflow.d.ts","sourceRoot":"","sources":["../src/finding-workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAML,YAAY,EAEb,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC1D,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AACD,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CACZ,aAAa,EACb;QACE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;QACvD,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,kBAAkB,CAAC;KACnC,CACF,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC5E;AAED,wBAAgB,cAAc,C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AM,EAAE,OAAO,EACf,YAAY,EAAE,kBAAkB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAOf;YAEa,OAAO;YAKP,OAAO;YAOP,IAAI;CAgBnB"}
|
package/dist/finding-workflow.js
CHANGED
|
@@ -51,11 +51,12 @@ export class FindingWorkflow {
|
|
|
51
51
|
async complete(stage, result) {
|
|
52
52
|
return (await this.command({ action: "complete", stage, result }));
|
|
53
53
|
}
|
|
54
|
-
async fail(stage, error) {
|
|
54
|
+
async fail(stage, error, result) {
|
|
55
55
|
await this.command({
|
|
56
56
|
action: "fail",
|
|
57
57
|
stage,
|
|
58
58
|
error: errorMessage(error),
|
|
59
|
+
...(result === undefined ? {} : { result }),
|
|
59
60
|
}).catch(() => undefined);
|
|
60
61
|
}
|
|
61
62
|
async run(stage, operation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finding-workflow.js","sourceRoot":"","sources":["../src/finding-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,GAEb,MAAM,cAAc,CAAC;AA8BtB,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAa,EAAE,EAAE,CACzD,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAC/D,CAAC,CAAC,MAAM,CAAC,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;QACN,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isAbsolute, relative, sep } from \"node:path\";\nimport type { JsonObject } from \"./config.js\";\nimport { CodexSecurityError, errorMessage } from \"./errors.js\";\nimport { findingsBaseUrl } from \"./findings-client.js\";\nimport type { FindingSearchScope } from \"./finding-retrieval.js\";\nimport {\n bundledPluginRoot,\n canonicalizeModelSafePath,\n codexSecurityStateDirectory,\n workbenchEnvironment,\n resolvePluginPython,\n runWorkbench,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport type WorkflowStage = \"scan\" | \"publish\" | \"dedupe\";\nexport interface WorkflowBinding {\n repositoryPath?: string;\n scanRequestDigest?: string;\n scanId?: string;\n scanDir?: string;\n artifactDigest?: string;\n destination?: string;\n scope?: FindingSearchScope;\n}\nexport interface WorkflowState extends WorkflowBinding {\n id: string;\n stages: Record<\n WorkflowStage,\n {\n status: \"pending\" | \"running\" | \"failed\" | \"completed\";\n result?: unknown;\n error?: string;\n pendingWrite?: DedupePendingWrite;\n }\n >;\n}\n\nexport interface DedupePendingWrite {\n groups: string[][];\n local?: { inputDigest: string; source: JsonObject; gitDisabled?: boolean };\n}\n\nexport function workflowDigest(value: unknown): string {\n const json = JSON.stringify(value, (_key, item: unknown) =>\n item !== null && typeof item === \"object\" && !Array.isArray(item)\n ? Object.fromEntries(\n Object.entries(item).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),\n )\n : item,\n );\n return createHash(\"sha256\").update(json).digest(\"hex\");\n}\n\nexport function workflowDestination(url: string): string {\n const destination = findingsBaseUrl(url);\n destination.username = \"\";\n destination.password = \"\";\n return destination.href;\n}\n\n/** State lives in the workbench database, never in sealed scan artifacts. */\nexport class FindingWorkflow {\n private options?: Promise<WorkbenchCommandOptions>;\n\n constructor(\n readonly id: string,\n private readonly environment: NodeJS.ProcessEnv = process.env,\n private readonly workbench: typeof runWorkbench = runWorkbench,\n private readonly pythonPath?: string,\n private readonly protectedRoot?: string,\n ) {\n if (!id.trim())\n throw new CodexSecurityError(\"workflowId must be a nonempty string.\");\n }\n\n async protectArtifacts(scanDir: string): Promise<void> {\n const path = relative(\n await canonicalizeModelSafePath(scanDir),\n await canonicalizeModelSafePath(\n codexSecurityStateDirectory(this.environment),\n ),\n );\n if (\n path === \"\" ||\n (!isAbsolute(path) && path !== \"..\" && !path.startsWith(`..${sep}`))\n ) {\n throw new CodexSecurityError(\n \"Workflow state must be outside the sealed scan artifacts.\",\n );\n }\n }\n\n async get(): Promise<WorkflowState | null> {\n return (await this.command({ action: \"get\" })) as WorkflowState | null;\n }\n\n async bind(binding: WorkflowBinding): Promise<WorkflowState> {\n return (await this.command({ action: \"bind\", binding }))!;\n }\n\n async begin(stage: WorkflowStage): Promise<WorkflowState> {\n return (await this.command({ action: \"begin\", stage }))!;\n }\n\n async complete(\n stage: WorkflowStage,\n result: unknown,\n ): Promise<WorkflowState> {\n return (await this.command({ action: \"complete\", stage, result }))!;\n }\n\n async fail(stage: WorkflowStage, error: unknown): Promise<void> {\n await this.command({\n action: \"fail\",\n stage,\n error: errorMessage(error),\n }).catch(() => undefined);\n }\n\n async run<T>(stage: WorkflowStage, operation: () => Promise<T>): Promise<T> {\n const state = await this.begin(stage);\n if (state.stages[stage].status === \"completed\")\n return state.stages[stage].result as T;\n try {\n const result = await operation();\n await this.complete(stage, result);\n return result;\n } catch (error) {\n await this.fail(stage, error);\n throw error;\n }\n }\n\n async registeredScan(scanId: string): Promise<JsonObject> {\n const context = await this.call([\"get-scan\", \"--scan-id\", scanId]);\n return context[\"scan\"] as JsonObject;\n }\n\n async sourceSnapshot(\n repository: string,\n gitDisabled = false,\n privateStatePaths: readonly string[] = [],\n ): Promise<JsonObject> {\n return (\n await this.request({\n action: \"source\",\n repository,\n ...(gitDisabled ? { gitDisabled } : {}),\n ...(privateStatePaths.length ? { privateStatePaths } : {}),\n })\n )[\"source\"] as JsonObject;\n }\n\n async getReview(key: string): Promise<unknown> {\n return (await this.request({ action: \"get-review\", key }))[\"review\"];\n }\n\n async saveReview(\n key: string,\n binding: object,\n result: unknown,\n ): Promise<void> {\n await this.request({ action: \"save-review\", key, binding, result });\n }\n\n async prepareDedupe(\n result: unknown,\n pendingWrite: DedupePendingWrite,\n ): Promise<void> {\n await this.command({\n action: \"prepare-dedupe\",\n stage: \"dedupe\",\n result,\n pendingWrite,\n });\n }\n\n private async command(payload: object): Promise<WorkflowState | null> {\n const result = await this.request(payload);\n return result[\"workflow\"] as unknown as WorkflowState | null;\n }\n\n private async request(payload: object): Promise<JsonObject> {\n return await this.call(\n [\"finding-workflow\"],\n JSON.stringify({ id: this.id, ...payload }),\n );\n }\n\n private async call(\n args: readonly string[],\n input?: string,\n ): Promise<JsonObject> {\n this.options ??= (async () => ({\n pluginRoot: await bundledPluginRoot(),\n python: await resolvePluginPython({\n environment: this.environment,\n configuredPath: this.pythonPath,\n protectedRoot: this.protectedRoot,\n }),\n environment: workbenchEnvironment(this.environment),\n failureMessage: \"Could not save or resume the findings workflow\",\n }))();\n return await this.workbench(await this.options, args, input);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"finding-workflow.js","sourceRoot":"","sources":["../src/finding-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,GAEb,MAAM,cAAc,CAAC;AA8BtB,MAAM,UAAU,cAAc,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,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,iBAAiB,EAAE;YACrC,MAAM,EAAE,MAAM,mBAAmB,CAAC;gBAChC,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,cAAc,EAAE,IAAI,CAAC,UAAU;gBAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;aAClC,CAAC;YACF,WAAW,EAAE,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC;YACnD,cAAc,EAAE,gDAAgD;SACjE,CAAC,CAAC,EAAE,CAAC;QACN,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isAbsolute, relative, sep } from \"node:path\";\nimport type { JsonObject } from \"./config.js\";\nimport { CodexSecurityError, errorMessage } from \"./errors.js\";\nimport { findingsBaseUrl } from \"./findings-client.js\";\nimport type { FindingSearchScope } from \"./finding-retrieval.js\";\nimport {\n bundledPluginRoot,\n canonicalizeModelSafePath,\n codexSecurityStateDirectory,\n workbenchEnvironment,\n resolvePluginPython,\n runWorkbench,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\n\nexport type WorkflowStage = \"scan\" | \"publish\" | \"dedupe\";\nexport interface WorkflowBinding {\n repositoryPath?: string;\n scanRequestDigest?: string;\n scanId?: string;\n scanDir?: string;\n artifactDigest?: string;\n destination?: string;\n scope?: FindingSearchScope;\n}\nexport interface WorkflowState extends WorkflowBinding {\n id: string;\n stages: Record<\n WorkflowStage,\n {\n status: \"pending\" | \"running\" | \"failed\" | \"completed\";\n result?: unknown;\n error?: string;\n pendingWrite?: DedupePendingWrite;\n }\n >;\n}\n\nexport interface DedupePendingWrite {\n groups: string[][];\n local?: { inputDigest: string; source: JsonObject; gitDisabled?: boolean };\n}\n\nexport function workflowDigest(value: unknown): string {\n const json = JSON.stringify(value, (_key, item: unknown) =>\n item !== null && typeof item === \"object\" && !Array.isArray(item)\n ? Object.fromEntries(\n Object.entries(item).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),\n )\n : item,\n );\n return createHash(\"sha256\").update(json).digest(\"hex\");\n}\n\nexport function workflowDestination(url: string): string {\n const destination = findingsBaseUrl(url);\n destination.username = \"\";\n destination.password = \"\";\n return destination.href;\n}\n\n/** State lives in the workbench database, never in sealed scan artifacts. */\nexport class FindingWorkflow {\n private options?: Promise<WorkbenchCommandOptions>;\n\n constructor(\n readonly id: string,\n private readonly environment: NodeJS.ProcessEnv = process.env,\n private readonly workbench: typeof runWorkbench = runWorkbench,\n private readonly pythonPath?: string,\n private readonly protectedRoot?: string,\n ) {\n if (!id.trim())\n throw new CodexSecurityError(\"workflowId must be a nonempty string.\");\n }\n\n async protectArtifacts(scanDir: string): Promise<void> {\n const path = relative(\n await canonicalizeModelSafePath(scanDir),\n await canonicalizeModelSafePath(\n codexSecurityStateDirectory(this.environment),\n ),\n );\n if (\n path === \"\" ||\n (!isAbsolute(path) && path !== \"..\" && !path.startsWith(`..${sep}`))\n ) {\n throw new CodexSecurityError(\n \"Workflow state must be outside the sealed scan artifacts.\",\n );\n }\n }\n\n async get(): Promise<WorkflowState | null> {\n return (await this.command({ action: \"get\" })) as WorkflowState | null;\n }\n\n async bind(binding: WorkflowBinding): Promise<WorkflowState> {\n return (await this.command({ action: \"bind\", binding }))!;\n }\n\n async begin(stage: WorkflowStage): Promise<WorkflowState> {\n return (await this.command({ action: \"begin\", stage }))!;\n }\n\n async complete(\n stage: WorkflowStage,\n result: unknown,\n ): Promise<WorkflowState> {\n return (await this.command({ action: \"complete\", stage, result }))!;\n }\n\n async fail(\n stage: WorkflowStage,\n error: unknown,\n result?: unknown,\n ): Promise<void> {\n await this.command({\n action: \"fail\",\n stage,\n error: errorMessage(error),\n ...(result === undefined ? {} : { result }),\n }).catch(() => undefined);\n }\n\n async run<T>(stage: WorkflowStage, operation: () => Promise<T>): Promise<T> {\n const state = await this.begin(stage);\n if (state.stages[stage].status === \"completed\")\n return state.stages[stage].result as T;\n try {\n const result = await operation();\n await this.complete(stage, result);\n return result;\n } catch (error) {\n await this.fail(stage, error);\n throw error;\n }\n }\n\n async registeredScan(scanId: string): Promise<JsonObject> {\n const context = await this.call([\"get-scan\", \"--scan-id\", scanId]);\n return context[\"scan\"] as JsonObject;\n }\n\n async sourceSnapshot(\n repository: string,\n gitDisabled = false,\n privateStatePaths: readonly string[] = [],\n ): Promise<JsonObject> {\n return (\n await this.request({\n action: \"source\",\n repository,\n ...(gitDisabled ? { gitDisabled } : {}),\n ...(privateStatePaths.length ? { privateStatePaths } : {}),\n })\n )[\"source\"] as JsonObject;\n }\n\n async getReview(key: string): Promise<unknown> {\n return (await this.request({ action: \"get-review\", key }))[\"review\"];\n }\n\n async saveReview(\n key: string,\n binding: object,\n result: unknown,\n ): Promise<void> {\n await this.request({ action: \"save-review\", key, binding, result });\n }\n\n async prepareDedupe(\n result: unknown,\n pendingWrite: DedupePendingWrite,\n ): Promise<void> {\n await this.command({\n action: \"prepare-dedupe\",\n stage: \"dedupe\",\n result,\n pendingWrite,\n });\n }\n\n private async command(payload: object): Promise<WorkflowState | null> {\n const result = await this.request(payload);\n return result[\"workflow\"] as unknown as WorkflowState | null;\n }\n\n private async request(payload: object): Promise<JsonObject> {\n return await this.call(\n [\"finding-workflow\"],\n JSON.stringify({ id: this.id, ...payload }),\n );\n }\n\n private async call(\n args: readonly string[],\n input?: string,\n ): Promise<JsonObject> {\n this.options ??= (async () => ({\n pluginRoot: await bundledPluginRoot(),\n python: await resolvePluginPython({\n environment: this.environment,\n configuredPath: this.pythonPath,\n protectedRoot: this.protectedRoot,\n }),\n environment: workbenchEnvironment(this.environment),\n failureMessage: \"Could not save or resume the findings workflow\",\n }))();\n return await this.workbench(await this.options, args, input);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findings-import.d.ts","sourceRoot":"","sources":["../src/findings-import.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AAE7D,eAAO,MAAM,aAAa,8BAA8B,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,CAAC;AAKlD,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"findings-import.d.ts","sourceRoot":"","sources":["../src/findings-import.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AAE7D,eAAO,MAAM,aAAa,8BAA8B,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,CAAC;AAKlD,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuFrB,CAAC;AACL,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAOzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,EAAE,CAAC,CAsDpB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,OAAO,EAAE,EACnB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,EAAE,CA6BX;AAiBD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE,CAkDhE;AAMD,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAmDzD"}
|
package/dist/findings-import.js
CHANGED
|
@@ -20,7 +20,10 @@ const csvFindingRowSchema = z
|
|
|
20
20
|
candidate_id: z
|
|
21
21
|
.string()
|
|
22
22
|
.optional()
|
|
23
|
-
.transform((value) => value === undefined ||
|
|
23
|
+
.transform((value) => value === undefined ||
|
|
24
|
+
(value.trim() === "" && !value.includes("\uFEFF"))
|
|
25
|
+
? undefined
|
|
26
|
+
: value),
|
|
24
27
|
title: requiredCsvText("title"),
|
|
25
28
|
summary: requiredCsvText("summary"),
|
|
26
29
|
severity: z.enum(["critical", "high", "medium", "low", "informational"], {
|
|
@@ -40,7 +43,7 @@ const csvFindingRowSchema = z
|
|
|
40
43
|
.transform((value) => (value === "" ? undefined : value)),
|
|
41
44
|
note: z
|
|
42
45
|
.string()
|
|
43
|
-
.transform((value) =>
|
|
46
|
+
.transform((value) => value.trim() === "" && !value.includes("\uFEFF") ? undefined : value),
|
|
44
47
|
remediation: requiredCsvText("remediation"),
|
|
45
48
|
path: z.string().refine(safeFindingPath, {
|
|
46
49
|
error: "has an invalid path",
|
|
@@ -155,10 +158,27 @@ export function bindImportedFindings(findings, format, scanId, targetId) {
|
|
|
155
158
|
};
|
|
156
159
|
});
|
|
157
160
|
}
|
|
161
|
+
function exportedCsvNewline(source) {
|
|
162
|
+
const start = source.startsWith("\uFEFF") ? 1 : 0;
|
|
163
|
+
for (const columns of [CSV_COLUMNS, REQUIRED_CSV_COLUMNS]) {
|
|
164
|
+
const header = columns.join(",");
|
|
165
|
+
if (!source.startsWith(header, start))
|
|
166
|
+
continue;
|
|
167
|
+
const end = start + header.length;
|
|
168
|
+
for (const newline of ["\r\n", "\r", "\n"]) {
|
|
169
|
+
// Require the exporter's first cell: skipped empty records can make
|
|
170
|
+
// other mixed-ending CSV valid under Papa's existing auto-detection.
|
|
171
|
+
if (source.startsWith(`${newline}occ_`, end))
|
|
172
|
+
return newline;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
158
177
|
export function parseFindingsCsv(source) {
|
|
159
178
|
const { data: rows, errors, meta, } = Papa.parse(source, {
|
|
160
179
|
header: true,
|
|
161
180
|
delimiter: ",",
|
|
181
|
+
newline: exportedCsvNewline(source),
|
|
162
182
|
skipEmptyLines: "greedy",
|
|
163
183
|
transform: decodeExportedCsvCell,
|
|
164
184
|
});
|
|
@@ -256,7 +276,7 @@ function validCsvLine(value) {
|
|
|
256
276
|
return Number.isSafeInteger(Number(value));
|
|
257
277
|
}
|
|
258
278
|
function safeFindingPath(value) {
|
|
259
|
-
if (value.
|
|
279
|
+
if (value.length === 0 ||
|
|
260
280
|
value === "." ||
|
|
261
281
|
isAbsolute(value) ||
|
|
262
282
|
/^[A-Za-z]:/u.test(value) ||
|