@openai/codex-security 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/scan-artifacts.md +1 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +37 -1
- package/_bundled_plugin/scripts/servicenow_avit.py +107 -0
- package/_bundled_plugin/scripts/workbench_scan_start.py +4 -1
- package/_bundled_plugin/skills/publish-findings/SKILL.md +5 -3
- package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +33 -12
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +12 -3
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +30 -10
- package/dist/artifact-export.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +1 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +45 -42
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +12 -8
- package/dist/contract.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +12 -4
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +19 -0
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +5 -4
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +5 -5
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts +6 -0
- package/dist/github-dependabot-findings.d.ts.map +1 -0
- package/dist/github-dependabot-findings.js +247 -0
- package/dist/github-dependabot-findings.js.map +1 -0
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +11 -4
- package/dist/github-findings.js.map +1 -1
- package/dist/github-identifiers.d.ts +4 -0
- package/dist/github-identifiers.d.ts.map +1 -0
- package/dist/github-identifiers.js +9 -0
- package/dist/github-identifiers.js.map +1 -0
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +4 -6
- package/dist/github.js.map +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +13 -5
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/scanner-import.d.ts +0 -1
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +9 -9
- package/dist/scanner-import.js.map +1 -1
- package/docs/cli.md +39 -7
- package/docs/hosted-scans.md +14 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-local.js","sourceRoot":"","sources":["../src/external-findings-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;A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I,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CACjD,CAAC;IACJ,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,UAAU,CAAuC,CAAC;AAClE,CAAC","sourcesContent":["import { lstat, readFile, realpath, stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve, sep } from \"node:path\";\nimport { isNumberObject } from \"node:util/types\";\nimport { environmentEntry } from \"./auth.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n forwardExternalImportSetting,\n requireExternalImports,\n} from \"./external-imports-feature.js\";\nimport type {\n ExternalFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport {\n cloudRepositoryUrlKey,\n repositoryUrlKey,\n validateExternalReport,\n} from \"./external-import-contract.js\";\nimport type {\n ExternalFindingEvidence,\n Provider,\n} from \"./external-import-models.js\";\nimport { parseGitRemote } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n bundledPluginRoot,\n canonicalConfigPath,\n canonicalizeModelSafePath,\n expandHome,\n requireOutputOutsideRepositories,\n runWorkbench,\n workbenchEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\nimport {\n abortable,\n gitMarkerRoot,\n gitOutput,\n gitProtectionRoots,\n normalizeRepository,\n nullIfMissingPath,\n} from \"./targets.js\";\n\n/** A scanner source record, independent of a Codex assessment or completed scan. */\nexport interface StoredExternalFinding {\n id: string;\n repository: string;\n provider: Provider;\n sourceKey: string;\n sourceFindingId: string;\n evidence: ExternalFindingEvidence;\n assessment: { state: \"not_assessed\" };\n version: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NormalizedLocalImportOptions {\n /** Local checkout or source directory to associate with these records. */\n repository: string;\n provider: Provider;\n /** Stable scanner organization/project/branch namespace across imports. */\n sourceKey: string;\n}\n\nexport interface LocalExternalImportDependencies {\n environment?: NodeJS.ProcessEnv;\n signal?: AbortSignal;\n runWorkbench?: typeof runWorkbench;\n /** Repository references supplied by a reader outside its projected evidence. */\n sourceRepositories?: readonly ExternalSourceRepository[];\n}\n\nexport interface LocalExternalImportPreview extends ExternalFindings {\n repository: string;\n source: { provider: Provider; source_key: string };\n}\n\nexport interface LocalExternalImportResult {\n repository: string;\n read: number;\n report?: ExternalFindings[\"report\"];\n ready: number;\n excluded: ExternalFindings[\"excluded\"];\n findings: StoredExternalFinding[];\n counts: { created: number; updated: number; unchanged: number };\n}\n\nexport interface PreparedLocalExternalImport {\n preview: LocalExternalImportPreview;\n import(): Promise<LocalExternalImportResult>;\n}\n\nfunction requireIdentity(\n value: unknown,\n field: string,\n): asserts value is string {\n if (typeof value !== \"string\" || !value.trim() || value.includes(\"\\0\"))\n throw new CodexSecurityError(\n `${field} must be nonempty and contain no NUL characters.`,\n );\n}\n\n/** Compare transport forms without changing retained scanner evidence. */\nfunction remoteRepositoryKey(\n value: string,\n provider: Provider,\n): string | undefined {\n if (/^[A-Za-z]:[\\\\/]/u.test(value)) return undefined;\n let remote;\n try {\n remote = parseGitRemote(value);\n } catch {\n return undefined;\n }\n if (\n !remote ||\n ![\n \"http:\",\n \"https:\",\n \"ssh:\",\n \"git:\",\n \"ftp:\",\n \"ftps:\",\n \"git+ssh:\",\n \"ssh+git:\",\n ].includes(remote.url.protocol)\n )\n return undefined;\n const url = remote.url;\n const ssh = [\"ssh:\", \"git+ssh:\", \"ssh+git:\"].includes(url.protocol);\n const protocol = url.protocol === \"http:\" ? \"http:\" : \"https:\";\n const githubSshOverHttps =\n ssh &&\n url.hostname.toLowerCase() === \"ssh.github.com\" &&\n url.port === \"443\";\n const hostname = githubSshOverHttps ? \"github.com\" : url.hostname;\n const port =\n githubSshOverHttps ||\n (ssh && url.port === \"22\") ||\n (url.protocol === \"git:\" && url.port === \"9418\") ||\n (url.protocol === \"ftp:\" && url.port === \"21\") ||\n (url.protocol === \"ftps:\" && url.port === \"990\")\n ? \"\"\n : url.port;\n // A GitHub source identifies a case-insensitive repository on custom Enterprise\n // hosts too; other providers can refer to VCS hosts with case-sensitive paths.\n const key = provider === \"github\" ? cloudRepositoryUrlKey : repositoryUrlKey;\n return key(\n `${protocol}//${hostname}${port ? `:${port}` : \"\"}/${remote.path}`,\n );\n}\n\nasync function bareMetadataRoots(\n repository: string,\n signal?: AbortSignal,\n): Promise<string[]> {\n const roots: string[] = [];\n let directory = repository;\n for (;;) {\n signal?.throwIfAborted();\n const present = async (name: string) =>\n (await abortable(\n () => lstat(join(directory, name)).catch(nullIfMissingPath),\n signal,\n )) !== null;\n // Git also discovers bare repositories and linked metadata without .git.\n const head = await abortable(\n () => lstat(join(directory, \"HEAD\")).catch(nullIfMissingPath),\n signal,\n );\n if (\n (head?.isFile() || head?.isSymbolicLink()) &&\n ((await present(\"commondir\")) ||\n ((await present(\"objects\")) && (await present(\"refs\"))))\n )\n roots.push(directory);\n const parent = dirname(directory);\n if (parent === directory) return roots;\n directory = parent;\n }\n}\n\nasync function metadataPointer(\n path: string,\n prefix: string,\n context: { directory: string; environment: NodeJS.ProcessEnv },\n signal?: AbortSignal,\n): Promise<string | undefined> {\n const metadata = await abortable(\n () => stat(path).catch(nullIfMissingPath),\n signal,\n );\n if (!metadata?.isFile()) return undefined;\n const text = await abortable(() => readFile(path, \"utf8\"), signal);\n if (!text.startsWith(prefix) || (prefix === \"\" && text.length === 0))\n return undefined;\n const payload = text.slice(prefix.length).replace(/[\\r\\n]+$/u, \"\");\n if (prefix !== \"\" && payload.length === 0) return undefined;\n // Git checks emptiness before consuming the path as a NUL-terminated string.\n const value = payload.split(\"\\0\", 1)[0]!;\n // Preserve filesystem traversal through links before '..'.\n let target = isAbsolute(value) ? value : `${dirname(path)}${sep}${value}`;\n if (process.platform === \"win32\") {\n const drive = /^[A-Za-z]:(?![\\\\/])/u.exec(value)?.[0].toUpperCase();\n if (drive !== undefined) {\n const directory =\n context.directory.slice(0, 2).toUpperCase() === drive\n ? context.directory\n : environmentEntry(context.environment, `=${drive}`) || `${drive}\\\\`;\n target = resolve(directory, value.slice(2));\n } else if (isAbsolute(value)) target = resolve(context.directory, value);\n }\n return (\n (await abortable(\n () => realpath(target).catch(nullIfMissingPath),\n signal,\n )) ?? undefined\n );\n}\n\nasync function associatedMetadataRoots(\n directory: string,\n context: { directory: string; environment: NodeJS.ProcessEnv },\n signal?: AbortSignal,\n configurationDirectory?: string,\n): Promise<string[]> {\n const head = await abortable(\n () => lstat(join(directory, \"HEAD\")).catch(nullIfMissingPath),\n signal,\n );\n if (!head || (!head.isFile() && !head.isSymbolicLink())) return [];\n const commonMarker = join(directory, \"commondir\");\n const hasCommon = await abortable(\n () => lstat(commonMarker).catch(nullIfMissingPath),\n signal,\n );\n const common = hasCommon\n ? await metadataPointer(commonMarker, \"\", context, signal)\n : undefined;\n if (hasCommon && common === undefined) return [];\n const storage = common ?? directory;\n for (const name of [\"objects\", \"refs\"]) {\n const metadata = await abortable(\n () => stat(join(storage, name)).catch(nullIfMissingPath),\n signal,\n );\n if (!metadata?.isDirectory()) return [];\n }\n const roots = common === undefined ? [directory] : [directory, common];\n if (\n process.platform === \"win32\" &&\n configurationDirectory !== undefined &&\n configurationDirectory !== context.directory\n ) {\n // Git rereads commondir after changing to the discovered repository root.\n roots.push(\n ...(await associatedMetadataRoots(\n directory,\n {\n ...context,\n directory: await abortable(\n () => canonicalConfigPath(configurationDirectory),\n signal,\n ),\n },\n signal,\n )),\n );\n }\n return roots;\n}\n\nasync function localGitProtectionRoots(\n repository: string,\n environment: NodeJS.ProcessEnv,\n signal?: AbortSignal,\n): Promise<string[]> {\n const roots = new Set(\n await abortable(() => gitProtectionRoots(repository, signal), signal),\n );\n const context = {\n directory: await abortable(() => canonicalConfigPath(repository), signal),\n environment,\n };\n const paths = new Set([resolve(repository), context.directory]);\n for (const path of paths) {\n for (const root of await bareMetadataRoots(path, signal)) {\n roots.add(root);\n for (const associated of await associatedMetadataRoots(\n root,\n context,\n signal,\n root,\n ))\n roots.add(associated);\n }\n let directory = path;\n for (;;) {\n signal?.throwIfAborted();\n const marker = join(directory, \".git\");\n const metadata = await abortable(\n () => stat(marker).catch(nullIfMissingPath),\n signal,\n );\n if (metadata !== null) {\n roots.add(directory);\n const gitDirectory = metadata.isDirectory()\n ? await abortable(() => realpath(marker), signal)\n : await metadataPointer(marker, \"gitdir: \", context, signal);\n if (gitDirectory !== undefined)\n for (const associated of await associatedMetadataRoots(\n gitDirectory,\n context,\n signal,\n directory,\n ))\n roots.add(associated);\n }\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n }\n for (const root of [...roots])\n roots.add(await abortable(() => canonicalConfigPath(root), signal));\n return [...roots];\n}\n\nasync function hasGitMetadata(\n repository: string,\n signal?: AbortSignal,\n): Promise<boolean> {\n return (\n (await abortable(\n () => gitMarkerRoot(repository, signal, \"nearest\"),\n signal,\n )) !== null || (await bareMetadataRoots(repository, signal)).length !== 0\n );\n}\n\nasync function requireMatchingRepository(\n repository: string,\n provider: Provider,\n sources: readonly ExternalSourceRepository[],\n protectedRoots: WorkbenchCommandOptions[\"protectedRoot\"],\n environment: WorkbenchCommandOptions[\"environment\"],\n signal?: AbortSignal,\n): Promise<void> {\n if (sources.length === 0) return;\n if (!(await hasGitMetadata(repository, signal))) return;\n const gitProtectedRoots = [\n ...(typeof protectedRoots === \"string\"\n ? [protectedRoots]\n : (protectedRoots ?? [])),\n await abortable(() => canonicalConfigPath(process.cwd()), signal),\n ];\n const readGit = (args: readonly string[]) =>\n abortable(\n () =>\n gitOutput(\n repository,\n args,\n signal,\n { LC_ALL: \"C\" },\n undefined,\n \"utf8\",\n gitProtectedRoots,\n environment,\n ),\n signal,\n );\n let remoteNames: string;\n try {\n remoteNames = await readGit([\"remote\"]);\n } catch (error) {\n signal?.throwIfAborted();\n // A local source directory need not be a Git checkout.\n if (\n error instanceof Error &&\n \"code\" in error &&\n error.code === 128 &&\n \"stderr\" in error &&\n typeof error.stderr === \"string\" &&\n (error.stderr.trimEnd() ===\n \"fatal: not a git repository (or any of the parent directories): .git\" ||\n /^fatal: not a git repository \\(or any parent up to mount point [^\\r\\n]+\\)\\r?\\nStopping at filesystem boundary \\(GIT_DISCOVERY_ACROSS_FILESYSTEM not set\\)\\.$/u.test(\n error.stderr.trimEnd(),\n ))\n )\n return;\n throw error;\n }\n const remotes: string[] = [];\n for (const name of remoteNames.split(/\\r?\\n/u).filter(Boolean)) {\n const urls = await readGit([\"remote\", \"get-url\", \"--all\", \"--\", name]);\n remotes.push(...urls.split(/\\r?\\n/u));\n }\n const githubRepositories = new Set(\n sources.flatMap((source) => {\n if (source.platform !== \"github\") return [];\n const key = remoteRepositoryKey(source.url, \"github\");\n return key === undefined ? [] : [key];\n }),\n );\n for (const source of sources) {\n const githubKey = remoteRepositoryKey(source.url, \"github\");\n const sourceProvider =\n source.platform === \"github\" ||\n (githubKey !== undefined && githubRepositories.has(githubKey))\n ? \"github\"\n : provider;\n const remoteKeys = new Set(\n remotes.flatMap((remote) => {\n const key = remoteRepositoryKey(remote, sourceProvider);\n return key === undefined ? [] : [key];\n }),\n );\n if (remoteKeys.size === 0) continue;\n const key = remoteRepositoryKey(source.url, sourceProvider);\n if (key === undefined || !remoteKeys.has(key))\n throw new CodexSecurityError(\n `Imported repository ${JSON.stringify(source.url)} does not match a configured remote of ${repository}. Select the matching local repository.`,\n );\n }\n}\n\nasync function localContext(\n selectedRepository: string,\n dependencies: LocalExternalImportDependencies,\n mode: \"import\" | \"read\" = \"import\",\n) {\n dependencies.signal?.throwIfAborted();\n const selected = dependencies.environment ?? process.env;\n const environment = workbenchEnvironment(selected);\n forwardExternalImportSetting(selected, environment);\n requireExternalImports(environment);\n const path = expandHome(selectedRepository, environment);\n const repository =\n mode === \"read\"\n ? await abortable(() => canonicalConfigPath(path), dependencies.signal)\n : await normalizeRepository(path, dependencies.signal);\n const protectedRoot = [\n ...new Set([\n repository,\n ...(await abortable(\n () => localGitProtectionRoots(path, environment, dependencies.signal),\n dependencies.signal,\n )),\n ...(await abortable(\n () =>\n localGitProtectionRoots(\n process.cwd(),\n environment,\n dependencies.signal,\n ),\n dependencies.signal,\n )),\n ]),\n ];\n requireOutputOutsideRepositories(\n protectedRoot,\n await abortable(\n () => canonicalizeModelSafePath(environment.CODEX_SECURITY_STATE_DIR),\n dependencies.signal,\n ),\n \"runtime\",\n );\n return {\n repository,\n options: {\n pluginRoot: await abortable(\n () => bundledPluginRoot(),\n dependencies.signal,\n ),\n environment,\n protectedRoot,\n signal: dependencies.signal,\n failureMessage: \"Could not access imported local findings\",\n },\n };\n}\n\n/** Prepare scanner evidence without writing state or performing a security assessment. */\nexport async function prepareNormalizedLocalImport(\n input: ExternalFindings,\n options: NormalizedLocalImportOptions,\n dependencies: LocalExternalImportDependencies = {},\n): Promise<PreparedLocalExternalImport> {\n dependencies.signal?.throwIfAborted();\n requireExternalImports(dependencies.environment);\n requireIdentity(options.sourceKey, \"Source key\");\n const current = structuredClone(input);\n validateExternalReport(current.report);\n const identities = new Set<string>();\n for (const finding of current.findings) {\n requireIdentity(finding.source_finding_id, \"Source finding id\");\n if (identities.has(finding.source_finding_id))\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}.`,\n );\n identities.add(finding.source_finding_id);\n if (!isRecord(finding.evidence))\n throw new CodexSecurityError(\"Imported evidence must be an object.\");\n }\n const { repository, options: workbenchOptions } = await localContext(\n options.repository,\n dependencies,\n );\n const sources = new Map<string, ExternalSourceRepository>();\n for (const { evidence } of current.findings) {\n const url = evidence.details?.repository?.url;\n if (url) sources.set(url, { url });\n }\n for (const source of dependencies.sourceRepositories ?? []) {\n // A reader's explicit platform also applies to the same URL in typed evidence.\n if (sources.get(source.url)?.platform !== \"github\")\n sources.set(source.url, source);\n }\n await requireMatchingRepository(\n repository,\n options.provider,\n [...sources.values()],\n workbenchOptions.protectedRoot,\n workbenchOptions.environment,\n dependencies.signal,\n );\n dependencies.signal?.throwIfAborted();\n const preview = {\n ...structuredClone(current),\n repository,\n source: { provider: options.provider, source_key: options.sourceKey },\n };\n const payload = JSON.stringify(\n {\n repository,\n provider: options.provider,\n sourceKey: options.sourceKey,\n findings: current.findings,\n },\n (_key, value: unknown) => {\n if (isNumberObject(value)) value = +value;\n if (typeof value === \"number\" && !Number.isFinite(value))\n throw new TypeError(\n \"Stored finding JSON cannot contain non-finite numbers.\",\n );\n return value;\n },\n );\n return {\n preview,\n async import() {\n dependencies.signal?.throwIfAborted();\n const protectedRoot = [\n ...new Set([\n ...workbenchOptions.protectedRoot,\n ...(await abortable(\n () =>\n localGitProtectionRoots(\n process.cwd(),\n workbenchOptions.environment,\n dependencies.signal,\n ),\n dependencies.signal,\n )),\n ]),\n ];\n requireOutputOutsideRepositories(\n protectedRoot,\n await abortable(\n () =>\n canonicalizeModelSafePath(\n workbenchOptions.environment.CODEX_SECURITY_STATE_DIR,\n ),\n dependencies.signal,\n ),\n \"runtime\",\n );\n const result = await abortable(() => {\n dependencies.signal?.throwIfAborted();\n return (dependencies.runWorkbench ?? runWorkbench)(\n { ...workbenchOptions, protectedRoot },\n [\"store-external-findings\"],\n payload,\n );\n }, dependencies.signal);\n return {\n repository,\n read: current.read,\n ...(current.report === undefined\n ? {}\n : { report: structuredClone(current.report) }),\n ready: current.findings.length,\n excluded: structuredClone(current.excluded),\n findings: result[\"findings\"] as unknown as StoredExternalFinding[],\n counts: result[\"counts\"] as LocalExternalImportResult[\"counts\"],\n };\n },\n };\n}\n\n/** Read imported source records, including evidence that has not been assessed by Codex. */\nexport async function listLocalExternalFindings(\n selection: { repository: string; id?: string },\n dependencies: LocalExternalImportDependencies = {},\n): Promise<StoredExternalFinding[]> {\n dependencies.signal?.throwIfAborted();\n requireExternalImports(dependencies.environment);\n if (selection.id !== undefined) requireIdentity(selection.id, \"Finding id\");\n const { repository, options } = await localContext(\n selection.repository,\n dependencies,\n \"read\",\n );\n const result = await abortable(() => {\n dependencies.signal?.throwIfAborted();\n return (dependencies.runWorkbench ?? runWorkbench)(\n options,\n [\"list-external-findings\"],\n JSON.stringify({ repository, id: selection.id }),\n );\n }, dependencies.signal);\n return result[\"findings\"] as unknown as StoredExternalFinding[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"external-findings-local.js","sourceRoot":"","sources":["../src/external-findings-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,UAAU,EACV,gCAAgC,EAChC,YAAY,EACZ,oBAAoB,GAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAoDtB,SAAS,eAAe,CACtB,KAAc,EACd,KAAa;IAEb,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACpE,MAAM,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;IACJ,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,UAAU,CAAuC,CAAC;AAClE,CAAC","sourcesContent":["import { lstat, readFile, realpath, stat } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve, sep } from \"node:path\";\nimport { isNumberObject } from \"node:util/types\";\nimport { environmentEntry } from \"./auth.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n forwardExternalImportSetting,\n requireExternalImports,\n} from \"./external-imports-feature.js\";\nimport type {\n ExternalFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport {\n cloudRepositoryUrlKey,\n repositoryUrlKey,\n validateExternalReport,\n} from \"./external-import-contract.js\";\nimport type {\n ExternalFindingEvidence,\n Provider,\n} from \"./external-import-models.js\";\nimport { parseGitRemote } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport { dependabotRepository } from \"./github-dependabot-findings.js\";\nimport {\n bundledPluginRoot,\n canonicalConfigPath,\n canonicalizeModelSafePath,\n expandHome,\n requireOutputOutsideRepositories,\n runWorkbench,\n workbenchEnvironment,\n type WorkbenchCommandOptions,\n} from \"./runtime.js\";\nimport {\n abortable,\n gitMarkerRoot,\n gitOutput,\n gitProtectionRoots,\n normalizeRepository,\n nullIfMissingPath,\n} from \"./targets.js\";\n\n/** A scanner source record, independent of a Codex assessment or completed scan. */\nexport interface StoredExternalFinding {\n id: string;\n repository: string;\n provider: Provider;\n sourceKey: string;\n sourceFindingId: string;\n evidence: ExternalFindingEvidence;\n assessment: { state: \"not_assessed\" };\n version: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NormalizedLocalImportOptions {\n /** Local checkout or source directory to associate with these records. */\n repository: string;\n provider: Provider;\n /** Stable scanner organization/project/branch namespace across imports. */\n sourceKey: string;\n}\n\nexport interface LocalExternalImportDependencies {\n environment?: NodeJS.ProcessEnv;\n signal?: AbortSignal;\n runWorkbench?: typeof runWorkbench;\n /** Repository references supplied by a reader outside its projected evidence. */\n sourceRepositories?: readonly ExternalSourceRepository[];\n}\n\nexport interface LocalExternalImportPreview extends ExternalFindings {\n repository: string;\n source: { provider: Provider; source_key: string };\n}\n\nexport interface LocalExternalImportResult {\n repository: string;\n read: number;\n report?: ExternalFindings[\"report\"];\n ready: number;\n excluded: ExternalFindings[\"excluded\"];\n findings: StoredExternalFinding[];\n counts: { created: number; updated: number; unchanged: number };\n}\n\nexport interface PreparedLocalExternalImport {\n preview: LocalExternalImportPreview;\n import(): Promise<LocalExternalImportResult>;\n}\n\nfunction requireIdentity(\n value: unknown,\n field: string,\n): asserts value is string {\n if (typeof value !== \"string\" || !value.trim() || value.includes(\"\\0\"))\n throw new CodexSecurityError(\n `${field} must be nonempty and contain no NUL characters.`,\n );\n}\n\n/** Compare transport forms without changing retained scanner evidence. */\nfunction remoteRepositoryKey(\n value: string,\n provider: Provider,\n): string | undefined {\n if (/^[A-Za-z]:[\\\\/]/u.test(value)) return undefined;\n let remote;\n try {\n remote = parseGitRemote(value);\n } catch {\n return undefined;\n }\n if (\n !remote ||\n ![\n \"http:\",\n \"https:\",\n \"ssh:\",\n \"git:\",\n \"ftp:\",\n \"ftps:\",\n \"git+ssh:\",\n \"ssh+git:\",\n ].includes(remote.url.protocol)\n )\n return undefined;\n const url = remote.url;\n const ssh = [\"ssh:\", \"git+ssh:\", \"ssh+git:\"].includes(url.protocol);\n const protocol = url.protocol === \"http:\" ? \"http:\" : \"https:\";\n const githubSshOverHttps =\n ssh &&\n url.hostname.toLowerCase() === \"ssh.github.com\" &&\n url.port === \"443\";\n const hostname = githubSshOverHttps ? \"github.com\" : url.hostname;\n const port =\n githubSshOverHttps ||\n (ssh && url.port === \"22\") ||\n (url.protocol === \"git:\" && url.port === \"9418\") ||\n (url.protocol === \"ftp:\" && url.port === \"21\") ||\n (url.protocol === \"ftps:\" && url.port === \"990\")\n ? \"\"\n : url.port;\n // A GitHub source identifies a case-insensitive repository on custom Enterprise\n // hosts too; other providers can refer to VCS hosts with case-sensitive paths.\n const key = provider === \"github\" ? cloudRepositoryUrlKey : repositoryUrlKey;\n return key(\n `${protocol}//${hostname}${port ? `:${port}` : \"\"}/${remote.path}`,\n );\n}\n\nasync function bareMetadataRoots(\n repository: string,\n signal?: AbortSignal,\n): Promise<string[]> {\n const roots: string[] = [];\n let directory = repository;\n for (;;) {\n signal?.throwIfAborted();\n const present = async (name: string) =>\n (await abortable(\n () => lstat(join(directory, name)).catch(nullIfMissingPath),\n signal,\n )) !== null;\n // Git also discovers bare repositories and linked metadata without .git.\n const head = await abortable(\n () => lstat(join(directory, \"HEAD\")).catch(nullIfMissingPath),\n signal,\n );\n if (\n (head?.isFile() || head?.isSymbolicLink()) &&\n ((await present(\"commondir\")) ||\n ((await present(\"objects\")) && (await present(\"refs\"))))\n )\n roots.push(directory);\n const parent = dirname(directory);\n if (parent === directory) return roots;\n directory = parent;\n }\n}\n\nasync function metadataPointer(\n path: string,\n prefix: string,\n context: { directory: string; environment: NodeJS.ProcessEnv },\n signal?: AbortSignal,\n): Promise<string | undefined> {\n const metadata = await abortable(\n () => stat(path).catch(nullIfMissingPath),\n signal,\n );\n if (!metadata?.isFile()) return undefined;\n const text = await abortable(() => readFile(path, \"utf8\"), signal);\n if (!text.startsWith(prefix) || (prefix === \"\" && text.length === 0))\n return undefined;\n const payload = text.slice(prefix.length).replace(/[\\r\\n]+$/u, \"\");\n if (prefix !== \"\" && payload.length === 0) return undefined;\n // Git checks emptiness before consuming the path as a NUL-terminated string.\n const value = payload.split(\"\\0\", 1)[0]!;\n // Preserve filesystem traversal through links before '..'.\n let target = isAbsolute(value) ? value : `${dirname(path)}${sep}${value}`;\n if (process.platform === \"win32\") {\n const drive = /^[A-Za-z]:(?![\\\\/])/u.exec(value)?.[0].toUpperCase();\n if (drive !== undefined) {\n const directory =\n context.directory.slice(0, 2).toUpperCase() === drive\n ? context.directory\n : environmentEntry(context.environment, `=${drive}`) || `${drive}\\\\`;\n target = resolve(directory, value.slice(2));\n } else if (isAbsolute(value)) target = resolve(context.directory, value);\n }\n return (\n (await abortable(\n () => realpath(target).catch(nullIfMissingPath),\n signal,\n )) ?? undefined\n );\n}\n\nasync function associatedMetadataRoots(\n directory: string,\n context: { directory: string; environment: NodeJS.ProcessEnv },\n signal?: AbortSignal,\n configurationDirectory?: string,\n): Promise<string[]> {\n const head = await abortable(\n () => lstat(join(directory, \"HEAD\")).catch(nullIfMissingPath),\n signal,\n );\n if (!head || (!head.isFile() && !head.isSymbolicLink())) return [];\n const commonMarker = join(directory, \"commondir\");\n const hasCommon = await abortable(\n () => lstat(commonMarker).catch(nullIfMissingPath),\n signal,\n );\n const common = hasCommon\n ? await metadataPointer(commonMarker, \"\", context, signal)\n : undefined;\n if (hasCommon && common === undefined) return [];\n const storage = common ?? directory;\n for (const name of [\"objects\", \"refs\"]) {\n const metadata = await abortable(\n () => stat(join(storage, name)).catch(nullIfMissingPath),\n signal,\n );\n if (!metadata?.isDirectory()) return [];\n }\n const roots = common === undefined ? [directory] : [directory, common];\n if (\n process.platform === \"win32\" &&\n configurationDirectory !== undefined &&\n configurationDirectory !== context.directory\n ) {\n // Git rereads commondir after changing to the discovered repository root.\n roots.push(\n ...(await associatedMetadataRoots(\n directory,\n {\n ...context,\n directory: await abortable(\n () => canonicalConfigPath(configurationDirectory),\n signal,\n ),\n },\n signal,\n )),\n );\n }\n return roots;\n}\n\nasync function localGitProtectionRoots(\n repository: string,\n environment: NodeJS.ProcessEnv,\n signal?: AbortSignal,\n): Promise<string[]> {\n const roots = new Set(\n await abortable(() => gitProtectionRoots(repository, signal), signal),\n );\n const context = {\n directory: await abortable(() => canonicalConfigPath(repository), signal),\n environment,\n };\n const paths = new Set([resolve(repository), context.directory]);\n for (const path of paths) {\n for (const root of await bareMetadataRoots(path, signal)) {\n roots.add(root);\n for (const associated of await associatedMetadataRoots(\n root,\n context,\n signal,\n root,\n ))\n roots.add(associated);\n }\n let directory = path;\n for (;;) {\n signal?.throwIfAborted();\n const marker = join(directory, \".git\");\n const metadata = await abortable(\n () => stat(marker).catch(nullIfMissingPath),\n signal,\n );\n if (metadata !== null) {\n roots.add(directory);\n const gitDirectory = metadata.isDirectory()\n ? await abortable(() => realpath(marker), signal)\n : await metadataPointer(marker, \"gitdir: \", context, signal);\n if (gitDirectory !== undefined)\n for (const associated of await associatedMetadataRoots(\n gitDirectory,\n context,\n signal,\n directory,\n ))\n roots.add(associated);\n }\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n }\n for (const root of [...roots])\n roots.add(await abortable(() => canonicalConfigPath(root), signal));\n return [...roots];\n}\n\nasync function hasGitMetadata(\n repository: string,\n signal?: AbortSignal,\n): Promise<boolean> {\n return (\n (await abortable(\n () => gitMarkerRoot(repository, signal, \"nearest\"),\n signal,\n )) !== null || (await bareMetadataRoots(repository, signal)).length !== 0\n );\n}\n\nasync function requireMatchingRepository(\n repository: string,\n provider: Provider,\n sources: readonly ExternalSourceRepository[],\n protectedRoots: WorkbenchCommandOptions[\"protectedRoot\"],\n environment: WorkbenchCommandOptions[\"environment\"],\n signal?: AbortSignal,\n): Promise<void> {\n if (sources.length === 0) return;\n if (!(await hasGitMetadata(repository, signal))) return;\n const gitProtectedRoots = [\n ...(typeof protectedRoots === \"string\"\n ? [protectedRoots]\n : (protectedRoots ?? [])),\n await abortable(() => canonicalConfigPath(process.cwd()), signal),\n ];\n const readGit = (args: readonly string[]) =>\n abortable(\n () =>\n gitOutput(\n repository,\n args,\n signal,\n { LC_ALL: \"C\" },\n undefined,\n \"utf8\",\n gitProtectedRoots,\n environment,\n ),\n signal,\n );\n let remoteNames: string;\n try {\n remoteNames = await readGit([\"remote\"]);\n } catch (error) {\n signal?.throwIfAborted();\n // A local source directory need not be a Git checkout.\n if (\n error instanceof Error &&\n \"code\" in error &&\n error.code === 128 &&\n \"stderr\" in error &&\n typeof error.stderr === \"string\" &&\n (error.stderr.trimEnd() ===\n \"fatal: not a git repository (or any of the parent directories): .git\" ||\n /^fatal: not a git repository \\(or any parent up to mount point [^\\r\\n]+\\)\\r?\\nStopping at filesystem boundary \\(GIT_DISCOVERY_ACROSS_FILESYSTEM not set\\)\\.$/u.test(\n error.stderr.trimEnd(),\n ))\n )\n return;\n throw error;\n }\n const remotes: string[] = [];\n for (const name of remoteNames.split(/\\r?\\n/u).filter(Boolean)) {\n const urls = await readGit([\"remote\", \"get-url\", \"--all\", \"--\", name]);\n remotes.push(...urls.split(/\\r?\\n/u));\n }\n const githubRepositories = new Set(\n sources.flatMap((source) => {\n if (source.platform !== \"github\") return [];\n const key = remoteRepositoryKey(source.url, \"github\");\n return key === undefined ? [] : [key];\n }),\n );\n for (const source of sources) {\n const githubKey = remoteRepositoryKey(source.url, \"github\");\n const sourceProvider =\n source.platform === \"github\" ||\n (githubKey !== undefined && githubRepositories.has(githubKey))\n ? \"github\"\n : provider;\n const remoteKeys = new Set(\n remotes.flatMap((remote) => {\n const key = remoteRepositoryKey(remote, sourceProvider);\n return key === undefined ? [] : [key];\n }),\n );\n if (remoteKeys.size === 0) continue;\n const key = remoteRepositoryKey(source.url, sourceProvider);\n if (key === undefined || !remoteKeys.has(key))\n throw new CodexSecurityError(\n `Imported repository ${JSON.stringify(source.url)} does not match a configured remote of ${repository}. Select the matching local repository.`,\n );\n }\n}\n\nasync function localContext(\n selectedRepository: string,\n dependencies: LocalExternalImportDependencies,\n mode: \"import\" | \"read\" = \"import\",\n) {\n dependencies.signal?.throwIfAborted();\n const selected = dependencies.environment ?? process.env;\n const environment = workbenchEnvironment(selected);\n forwardExternalImportSetting(selected, environment);\n requireExternalImports(environment);\n const path = expandHome(selectedRepository, environment);\n const repository =\n mode === \"read\"\n ? await abortable(() => canonicalConfigPath(path), dependencies.signal)\n : await normalizeRepository(path, dependencies.signal);\n const protectedRoot = [\n ...new Set([\n repository,\n ...(await abortable(\n () => localGitProtectionRoots(path, environment, dependencies.signal),\n dependencies.signal,\n )),\n ...(await abortable(\n () =>\n localGitProtectionRoots(\n process.cwd(),\n environment,\n dependencies.signal,\n ),\n dependencies.signal,\n )),\n ]),\n ];\n requireOutputOutsideRepositories(\n protectedRoot,\n await abortable(\n () => canonicalizeModelSafePath(environment.CODEX_SECURITY_STATE_DIR),\n dependencies.signal,\n ),\n \"runtime\",\n );\n return {\n repository,\n options: {\n pluginRoot: await abortable(\n () => bundledPluginRoot(),\n dependencies.signal,\n ),\n environment,\n protectedRoot,\n signal: dependencies.signal,\n failureMessage: \"Could not access imported local findings\",\n },\n };\n}\n\n/** Prepare scanner evidence without writing state or performing a security assessment. */\nexport async function prepareNormalizedLocalImport(\n input: ExternalFindings,\n options: NormalizedLocalImportOptions,\n dependencies: LocalExternalImportDependencies = {},\n): Promise<PreparedLocalExternalImport> {\n dependencies.signal?.throwIfAborted();\n requireExternalImports(dependencies.environment);\n requireIdentity(options.sourceKey, \"Source key\");\n const current = structuredClone(input);\n validateExternalReport(current.report);\n let dependabotSource: string | undefined;\n const identities = new Set<string>();\n for (const finding of current.findings) {\n requireIdentity(finding.source_finding_id, \"Source finding id\");\n if (identities.has(finding.source_finding_id))\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}.`,\n );\n identities.add(finding.source_finding_id);\n if (!isRecord(finding.evidence))\n throw new CodexSecurityError(\"Imported evidence must be an object.\");\n if (options.provider !== \"github\") continue;\n const native = dependabotRepository(finding);\n if (!native) continue;\n const claimed = finding.evidence.details?.repository?.url;\n if (\n claimed &&\n cloudRepositoryUrlKey(claimed) !== cloudRepositoryUrlKey(native)\n )\n throw new CodexSecurityError(\n \"The normalized repository does not match the original Dependabot alert.\",\n );\n if (dependabotSource && dependabotSource !== native)\n throw new CodexSecurityError(\n \"Select Dependabot alerts from only one GitHub host and repository.\",\n );\n dependabotSource = native;\n }\n const { repository, options: workbenchOptions } = await localContext(\n options.repository,\n dependencies,\n );\n const sources = new Map<string, ExternalSourceRepository>();\n for (const { evidence } of current.findings) {\n const url = evidence.details?.repository?.url;\n if (url) sources.set(url, { url });\n }\n for (const source of dependencies.sourceRepositories ?? []) {\n // A reader's explicit platform also applies to the same URL in typed evidence.\n if (sources.get(source.url)?.platform !== \"github\")\n sources.set(source.url, source);\n }\n if (dependabotSource)\n sources.set(dependabotSource, {\n url: dependabotSource,\n platform: \"github\",\n });\n await requireMatchingRepository(\n repository,\n options.provider,\n [...sources.values()],\n workbenchOptions.protectedRoot,\n workbenchOptions.environment,\n dependencies.signal,\n );\n dependencies.signal?.throwIfAborted();\n const preview = {\n ...structuredClone(current),\n repository,\n source: { provider: options.provider, source_key: options.sourceKey },\n };\n const payload = JSON.stringify(\n {\n repository,\n provider: options.provider,\n sourceKey: options.sourceKey,\n findings: current.findings,\n },\n (_key, value: unknown) => {\n if (isNumberObject(value)) value = +value;\n if (typeof value === \"number\" && !Number.isFinite(value))\n throw new TypeError(\n \"Stored finding JSON cannot contain non-finite numbers.\",\n );\n return value;\n },\n );\n return {\n preview,\n async import() {\n dependencies.signal?.throwIfAborted();\n const protectedRoot = [\n ...new Set([\n ...workbenchOptions.protectedRoot,\n ...(await abortable(\n () =>\n localGitProtectionRoots(\n process.cwd(),\n workbenchOptions.environment,\n dependencies.signal,\n ),\n dependencies.signal,\n )),\n ]),\n ];\n requireOutputOutsideRepositories(\n protectedRoot,\n await abortable(\n () =>\n canonicalizeModelSafePath(\n workbenchOptions.environment.CODEX_SECURITY_STATE_DIR,\n ),\n dependencies.signal,\n ),\n \"runtime\",\n );\n const result = await abortable(() => {\n dependencies.signal?.throwIfAborted();\n return (dependencies.runWorkbench ?? runWorkbench)(\n { ...workbenchOptions, protectedRoot },\n [\"store-external-findings\"],\n payload,\n );\n }, dependencies.signal);\n return {\n repository,\n read: current.read,\n ...(current.report === undefined\n ? {}\n : { report: structuredClone(current.report) }),\n ready: current.findings.length,\n excluded: structuredClone(current.excluded),\n findings: result[\"findings\"] as unknown as StoredExternalFinding[],\n counts: result[\"counts\"] as LocalExternalImportResult[\"counts\"],\n };\n },\n };\n}\n\n/** Read imported source records, including evidence that has not been assessed by Codex. */\nexport async function listLocalExternalFindings(\n selection: { repository: string; id?: string },\n dependencies: LocalExternalImportDependencies = {},\n): Promise<StoredExternalFinding[]> {\n dependencies.signal?.throwIfAborted();\n requireExternalImports(dependencies.environment);\n if (selection.id !== undefined) requireIdentity(selection.id, \"Finding id\");\n const { repository, options } = await localContext(\n selection.repository,\n dependencies,\n \"read\",\n );\n const result = await abortable(() => {\n dependencies.signal?.throwIfAborted();\n return (dependencies.runWorkbench ?? runWorkbench)(\n options,\n [\"list-external-findings\"],\n JSON.stringify({ repository, id: selection.id }),\n );\n }, dependencies.signal);\n return result[\"findings\"] as unknown as StoredExternalFinding[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-publish.d.ts","sourceRoot":"","sources":["../src/external-findings-publish.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAOjD,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"external-findings-publish.d.ts","sourceRoot":"","sources":["../src/external-findings-publish.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAOjD,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,6BAA6B,CAAC;AAIrC,oFAAoF;AACpF,MAAM,WAAW,oCAAoC;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC;IACrD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,oEAAoE;AACpE,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CACtD,oCAAoC,EACpC,UA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AM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gFAAgF;AAChF,qBAAa,wBAAyB,SAAQ,kBAAkB;aAG5C,MAAM,EAAE,yBAAyB;IAFnD,YACE,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,yBAAyB,EACjD,KAAK,EAAE,OAAO,EAGf;CACF;AASD,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,oBAAoB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,0BAA0B,CAAC;IACpC,OAAO,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAC/C;AAsMD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,0BAA0B,EACnC,YAAY,GAAE,+BAAoC,GACjD,OAAO,CAAC,2BAA2B,CAAC,CAkBtC;AAED,4EAA4E;AAC5E,wBAAsB,oCAAoC,CACxD,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,oCAAoC,EAC7C,YAAY,GAAE,+BAAoC,GACjD,OAAO,CAAC,2BAA2B,CAAC,CA4CtC"}
|
|
@@ -12,6 +12,7 @@ import { codexSecurityStateDirectory, createWindowsOutputDirectory, validatePrep
|
|
|
12
12
|
import { EXTERNAL_FINDINGS_PROVIDERS, readExternalFindings, } from "./external-findings-read.js";
|
|
13
13
|
import { canonicalJson } from "./record.js";
|
|
14
14
|
import { wizCsvRepositoryUrl } from "./wiz-csv.js";
|
|
15
|
+
import { dependabotRepository } from "./github-dependabot-findings.js";
|
|
15
16
|
import { snykRepositoryUrls } from "./snyk-findings.js";
|
|
16
17
|
import { endorRepositoryUrls } from "./endor-findings.js";
|
|
17
18
|
import { cloudRepositoryUrlKey, validateImportRequest, validateExternalEvidence, validateExternalReport, validateImportReceipt, validateRepositories, validateSourceReports, validateSourceReport, } from "./external-import-contract.js";
|
|
@@ -470,6 +471,9 @@ async function preparePublicationInput(input, options, dependencies) {
|
|
|
470
471
|
...(options.provider === "endor"
|
|
471
472
|
? endorRepositoryUrls(finding.evidence.source_data)
|
|
472
473
|
: []),
|
|
474
|
+
options.provider === "github"
|
|
475
|
+
? dependabotRepository(finding)
|
|
476
|
+
: undefined,
|
|
473
477
|
];
|
|
474
478
|
for (const sourceRepository of sourceRepositories)
|
|
475
479
|
if (sourceRepository &&
|
|
@@ -564,9 +568,6 @@ async function preparePublicationInput(input, options, dependencies) {
|
|
|
564
568
|
};
|
|
565
569
|
const preview = {
|
|
566
570
|
...parsed,
|
|
567
|
-
...(parsed.report === undefined
|
|
568
|
-
? {}
|
|
569
|
-
: { report: structuredClone(parsed.report) }),
|
|
570
571
|
findings: submissionFindings(requests),
|
|
571
572
|
cloudApiUrl,
|
|
572
573
|
cloudUrl: cloudFindingsUrl(environment, destination.id),
|
|
@@ -577,7 +578,7 @@ async function preparePublicationInput(input, options, dependencies) {
|
|
|
577
578
|
requests,
|
|
578
579
|
};
|
|
579
580
|
return {
|
|
580
|
-
preview,
|
|
581
|
+
preview: structuredClone(preview),
|
|
581
582
|
async publish() {
|
|
582
583
|
progress({ phase: "waiting", completed: 0 });
|
|
583
584
|
const result = (acknowledged, verified) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-publish.js","sourceRoot":"","sources":["../src/external-findings-publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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AAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM;oBAChC,MAAM,IAAI,kBAAkB,CAC1B,oDAAoD,CACrD,CAAC;gBACJ,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAChD,0BAA0B,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAE,CAAC,CACtD,CAAC;gBACF,MAAM,OAAO,GAAG,KAAK;oBACnB,CAAC,CAAC,8GAA8G,WAAW,EAAE;oBAC7H,CAAC,CAAC,wFAAwF,CAAC;gBAC7F,MAAM,IAAI,wBAAwB,CAChC,OAAO,EACP;oBACE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;oBAC1B,MAAM,EAAE,aAAa;oBACrB,KAAK,EAAE,OAAO;oBACd,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACnD,EACD,KAAK,CACN,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { hash, randomUUID } from \"node:crypto\";\nimport { chmodSync } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n open,\n readFile,\n readdir,\n rename,\n rm,\n} from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { readCloudCredentials } from \"./cloud-publish.js\";\nimport {\n cloudBaseUrl,\n cloudFindingsUrl,\n DEFAULT_CLOUD_BASE_URL,\n} from \"./cloud-endpoint.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { requireExternalImports } from \"./external-imports-feature.js\";\nimport {\n codexSecurityStateDirectory,\n createWindowsOutputDirectory,\n validatePreparedOutputDir,\n} from \"./runtime.js\";\nimport {\n EXTERNAL_FINDINGS_PROVIDERS,\n readExternalFindings,\n type ExternalFindingsReaderOptions,\n} from \"./external-findings-read.js\";\nimport { canonicalJson } from \"./record.js\";\nimport { wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport { snykRepositoryUrls } from \"./snyk-findings.js\";\nimport { endorRepositoryUrls } from \"./endor-findings.js\";\nimport type {\n ExternalFindings,\n ExternalPublicationInput,\n} from \"./external-findings.js\";\nimport {\n cloudRepositoryUrlKey,\n validateImportRequest,\n validateExternalEvidence,\n validateExternalReport,\n validateImportReceipt,\n validateRepositories,\n validateSourceReports,\n validateSourceReport,\n} from \"./external-import-contract.js\";\nimport type {\n FindingImportRequest,\n FindingImportReceipt,\n ImportRepository,\n SourceReportSummary,\n} from \"./external-import-models.js\";\n\nconst MAX_REQUEST_BYTES = 5 * 1024 * 1024;\n\n/** Source and destination for evidence already normalized to the Cloud contract. */\nexport interface NormalizedExternalPublicationOptions {\n repository: string;\n provider: FindingImportRequest[\"source\"][\"provider\"];\n sourceKey: string;\n}\n\n/** File readers accept the vendor formats installed in this SDK. */\nexport interface ExternalPublicationOptions extends Omit<\n NormalizedExternalPublicationOptions,\n \"provider\"\n> {\n provider: ExternalFindingsReaderOptions[\"provider\"];\n sourceRepositoryUrl?: string;\n}\n\n/** Optional transport, account, cancellation, and progress hooks. */\nexport interface ExternalPublicationDependencies {\n environment?: NodeJS.ProcessEnv;\n fetch?: (url: string, options: RequestInit) => Promise<Response>;\n credentials?: () => Promise<{ access_token: string; account_id: string }>;\n signal?: AbortSignal;\n onProgress?: (event: ExternalPublicationProgress) => void;\n}\n\nexport interface ExternalPublicationProgress {\n phase:\n | \"reading\"\n | \"discovering\"\n | \"preparing\"\n | \"waiting\"\n | \"uploading\"\n | \"verifying\";\n completed: number;\n total?: number;\n}\n\n/** Counts describe acknowledged receipts, even when later transport or readback fails. */\nexport interface ExternalPublicationResult {\n cloudApiUrl: string;\n cloudUrl?: string;\n status: \"complete\" | \"partial\" | \"interrupted\";\n read: number;\n report?: ExternalFindings[\"report\"];\n ready: number;\n excluded: ExternalFindings[\"excluded\"];\n receipts: FindingImportReceipt[];\n counts: Required<FindingImportReceipt[\"counts\"]>;\n failures: { source_finding_id: string; code: string; message: string }[];\n unacknowledged: number;\n verified: number;\n error?: string;\n savedSubmission?: string;\n}\n\n/** Preserve accepted work in CLI JSON output when publication cannot finish. */\nexport class ExternalPublicationError extends CodexSecurityError {\n constructor(\n message: string,\n public readonly result: ExternalPublicationResult,\n cause: unknown,\n ) {\n super(message, { cause });\n }\n}\n\ninterface SavedSubmission {\n accountId: string;\n requests: FindingImportRequest[];\n receipts?: FindingImportReceipt[];\n inputProjection?: { inputDigest: string; savedEvidenceDigest: string };\n}\n\nexport interface ExternalPublicationPreview extends ExternalFindings {\n cloudApiUrl: string;\n cloudUrl?: string;\n accountId: string;\n destination: ImportRepository;\n source: FindingImportRequest[\"source\"];\n resumed: boolean;\n requests: FindingImportRequest[];\n}\n\nexport interface PreparedExternalPublication {\n preview: ExternalPublicationPreview;\n publish(): Promise<ExternalPublicationResult>;\n}\n\n// Limit read concurrency to avoid one network round trip per finding in series.\n// Wait for the entire batch on failure so callers never outlive their read tasks.\nasync function readInBatches<T, U>(\n items: T[],\n read: (item: T) => Promise<U>,\n): Promise<U[]> {\n const output: U[] = [];\n for (let start = 0; start < items.length; start += 4) {\n const batch = await Promise.allSettled(\n items.slice(start, start + 4).map(read),\n );\n for (const result of batch) {\n if (result.status === \"rejected\") throw result.reason;\n output.push(result.value);\n }\n }\n return output;\n}\n\nfunction sameSubmission(\n left: SavedSubmission,\n right: SavedSubmission,\n): boolean {\n return (\n left.accountId === right.accountId &&\n canonicalJson(left.requests) === canonicalJson(right.requests)\n );\n}\n\nfunction submissionFindings(\n requests: readonly FindingImportRequest[],\n): ExternalFindings[\"findings\"] {\n return requests.flatMap((batch) =>\n batch.items.map(({ source_finding_id, evidence }) => ({\n source_finding_id,\n evidence,\n })),\n );\n}\n\nfunction sameFindingSelection(\n left: ExternalFindings[\"findings\"],\n right: ExternalFindings[\"findings\"],\n): boolean {\n return (\n left.length === right.length &&\n left.every(\n (finding, index) =>\n finding.source_finding_id === right[index]!.source_finding_id,\n )\n );\n}\n\nasync function readOptionalFile(path: string): Promise<string | undefined> {\n return readFile(path, \"utf8\").catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return undefined;\n throw error;\n });\n}\n\nfunction reportForJson(report: ExternalFindings[\"report\"]) {\n const errors = report?.[\"errors\"];\n if (!Array.isArray(errors)) return report;\n const json = JSON.stringify(errors, (_key, entry: unknown) =>\n entry instanceof Error ? { message: entry.message } : entry,\n );\n return { ...report, errors: JSON.parse(json) as unknown[] };\n}\n\nasync function writeAtomicJson(path: string, value: unknown): Promise<void> {\n const temporary = `${path}.${randomUUID()}.tmp`;\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(JSON.stringify(value));\n await file.sync();\n } finally {\n await file.close();\n }\n await rename(temporary, path);\n } finally {\n await rm(temporary, { force: true });\n }\n}\n\nfunction sourcePath(repository: ImportRepository): string {\n return `/repository_connectors/${encodeURIComponent(repository.repo_connector_id)}/repositories/${encodeURIComponent(repository.id)}/source_reports`;\n}\n\nclass CloudImportError extends CodexSecurityError {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n }\n}\n\nfunction validatePublicationReceipt(\n value: unknown,\n batch: FindingImportRequest,\n): FindingImportReceipt {\n const receipt = validateImportReceipt(value);\n const batchItems = new Map(batch.items.map((item) => [item.client_id, item]));\n if (\n receipt.id !== batch.request_id ||\n canonicalJson(receipt.repository) !== canonicalJson(batch.repository) ||\n canonicalJson(receipt.source) !== canonicalJson(batch.source) ||\n receipt.item_count !== batch.items.length ||\n receipt.results.length !== batch.items.length ||\n new Set(receipt.results.map((item) => item.client_id)).size !==\n batch.items.length ||\n receipt.results.some((item) => !batchItems.has(item.client_id))\n )\n throw new CodexSecurityError(\n \"Cloud returned a receipt for a different publication.\",\n );\n const actual = { created: 0, updated: 0, unchanged: 0, error: 0 };\n for (const result of receipt.results) {\n actual[result.outcome]++;\n if (result.outcome === \"error\") {\n if (\n !result.error ||\n result.source_report_id !== null ||\n result.observation_id !== null ||\n result.canonical_finding_id !== null ||\n result.version !== null\n )\n throw new CodexSecurityError(\n \"Cloud returned inconsistent item error fields.\",\n );\n } else if (\n result.error !== null ||\n !result.source_report_id ||\n !result.observation_id ||\n !result.canonical_finding_id ||\n result.version === null\n )\n throw new CodexSecurityError(\n \"Cloud returned an incomplete saved finding.\",\n );\n }\n if (canonicalJson(receipt.counts) !== canonicalJson(actual))\n throw new CodexSecurityError(\n \"Cloud returned inconsistent publication counts.\",\n );\n return receipt;\n}\n\nasync function withImportLock<T>(\n state: string,\n key: string,\n signal: AbortSignal | undefined,\n operation: () => Promise<T>,\n): Promise<T> {\n if (process.platform === \"win32\")\n await createWindowsOutputDirectory(state, true);\n else await mkdir(state, { recursive: true, mode: 0o700 });\n await validatePreparedOutputDir(state, undefined, true);\n const path = join(state, `${key}.lock.sqlite`);\n const metadata = await lstat(path).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return undefined;\n throw error;\n });\n if (metadata && !metadata.isFile())\n throw new CodexSecurityError(\"The publication lock is not a regular file.\");\n const require = createRequire(import.meta.url);\n const Database = (\n process.versions[\"bun\"]\n ? require(\"bun:sqlite\").Database\n : require(\"node:sqlite\").DatabaseSync\n ) as new (path: string) => { exec(sql: string): void; close(): void };\n const guard = new Database(path);\n try {\n if (process.platform !== \"win32\") chmodSync(path, 0o600);\n guard.exec(\"PRAGMA busy_timeout = 0\");\n for (;;) {\n signal?.throwIfAborted();\n try {\n // Keep this inode across invocations. SQLite releases the transaction\n // on process exit, so a paused publisher cannot lose its lock to a lease.\n guard.exec(\"BEGIN EXCLUSIVE\");\n break;\n } catch (error) {\n const sqliteError = error as { code?: string; errcode?: number };\n if (sqliteError.errcode !== 5 && sqliteError.code !== \"SQLITE_BUSY\")\n throw error;\n await delay(50, undefined, { signal });\n }\n }\n return await operation();\n } finally {\n guard.close();\n }\n}\n\nexport async function prepareExternalPublication(\n path: string,\n options: ExternalPublicationOptions,\n dependencies: ExternalPublicationDependencies = {},\n): Promise<PreparedExternalPublication> {\n requireExternalImports(dependencies.environment);\n const parsed = await readExternalFindings(path, options);\n const normalizedOptions = {\n ...options,\n provider: EXTERNAL_FINDINGS_PROVIDERS[options.provider],\n };\n return parsed.publication\n ? preparePublicationInput(\n parsed.publication,\n normalizedOptions,\n dependencies,\n )\n : prepareNormalizedExternalPublication(\n parsed.findings,\n normalizedOptions,\n dependencies,\n );\n}\n\n/** Prepare normalized provider evidence without reading a vendor export. */\nexport async function prepareNormalizedExternalPublication(\n input: ExternalFindings,\n options: NormalizedExternalPublicationOptions,\n dependencies: ExternalPublicationDependencies = {},\n): Promise<PreparedExternalPublication> {\n requireExternalImports(dependencies.environment);\n // Validation adds Cloud defaults; leave the caller's objects unchanged.\n const { report, ...parsed } = input;\n const current: ExternalFindings = structuredClone(parsed);\n if (report !== undefined) {\n current.report = structuredClone(report);\n validateExternalReport(current.report);\n }\n // structuredClone preserves aliases. Detach every raw record before adding\n // typed defaults, including aliases shared with another finding's evidence.\n for (const finding of current.findings)\n if (finding.evidence.source_data !== undefined)\n finding.evidence.source_data = structuredClone(\n finding.evidence.source_data,\n );\n const identities = new Set<string>();\n for (const finding of current.findings) {\n const id = finding.source_finding_id;\n if (!id.trim() || id.includes(\"\\0\") || Buffer.byteLength(id) > 512)\n throw new CodexSecurityError(\n \"Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.\",\n );\n if (identities.has(id))\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(id)}.`,\n );\n identities.add(id);\n finding.evidence = validateExternalEvidence(finding.evidence);\n }\n const identity =\n current.report === undefined\n ? current.findings\n : { findings: current.findings, report: reportForJson(current.report) };\n return preparePublicationInput(\n {\n current,\n legacy: current,\n currentIdentity: identity,\n legacyIdentity: identity,\n },\n options,\n dependencies,\n );\n}\n\nasync function preparePublicationInput(\n input: ExternalPublicationInput,\n options: NormalizedExternalPublicationOptions,\n dependencies: ExternalPublicationDependencies,\n): Promise<PreparedExternalPublication> {\n const progress = (event: ExternalPublicationProgress): void => {\n try {\n dependencies.onProgress?.(event);\n } catch {\n // Optional progress must not interrupt preparation or publication.\n }\n };\n if (\n !options.sourceKey.trim() ||\n options.sourceKey.includes(\"\\0\") ||\n Buffer.byteLength(options.sourceKey) > 512\n ) {\n throw new CodexSecurityError(\n \"The source key must contain 1–512 UTF-8 bytes and no NUL characters. Use a stable scanner organization/project/branch namespace across imports.\",\n );\n }\n progress({ phase: \"reading\", completed: 0 });\n const {\n current: parsed,\n legacy: legacyParsed,\n currentIdentity,\n legacyIdentity,\n } = input;\n if (parsed.findings.length === 0) {\n const diagnostics = reportForJson(parsed.report)?.[\"errors\"];\n throw new CodexSecurityError(\n `No supported findings are ready to publish. ${parsed.excluded.map((item) => `Item ${item.position}: ${item.reason}`).join(\" \")}${Array.isArray(diagnostics) && diagnostics.length ? ` Scanner diagnostics: ${JSON.stringify(diagnostics)}` : \"\"}`,\n );\n }\n progress({ phase: \"discovering\", completed: 0 });\n const environment = dependencies.environment ?? process.env;\n requireExternalImports(environment);\n const apiBaseUrl = cloudBaseUrl(environment);\n const cloudApiUrl = `${apiBaseUrl}/external`;\n // Validate the configured return destination before authentication or uploads.\n cloudFindingsUrl(environment, options.repository);\n const credentials = await (\n dependencies.credentials ?? (() => readCloudCredentials(environment))\n )();\n async function request(\n endpoint: string,\n body?: FindingImportRequest,\n ): Promise<unknown> {\n dependencies.signal?.throwIfAborted();\n // Allow upload and response transport around the server's publication budget.\n const timeout = AbortSignal.timeout(body ? 60_000 : 30_000);\n const response = await (dependencies.fetch ?? globalThis.fetch)(\n `${cloudApiUrl}${endpoint}`,\n {\n method: body ? \"POST\" : \"GET\",\n headers: {\n Authorization: `Bearer ${credentials.access_token}`,\n \"ChatGPT-Account-ID\": credentials.account_id,\n Accept: \"application/json\",\n ...(body ? { \"Content-Type\": \"application/json\" } : {}),\n },\n ...(body ? { body: JSON.stringify(body) } : {}),\n redirect: \"error\",\n signal: dependencies.signal\n ? AbortSignal.any([dependencies.signal, timeout])\n : timeout,\n },\n );\n if (!response.ok) {\n const payload = (await response.json().catch(() => null)) as {\n error?: { message?: string };\n } | null;\n const retryAfter = response.headers.get(\"Retry-After\");\n throw new CloudImportError(\n response.status,\n `Cloud import failed (HTTP ${response.status}). ${payload?.error?.message ?? response.statusText}${retryAfter ? ` Retry-After: ${retryAfter}.` : \"\"}`,\n );\n }\n return response.json();\n }\n const destinations: ImportRepository[] = [];\n let page: string | null = null;\n const seenPages = new Set<string>();\n do {\n const result = validateRepositories(\n await request(\n `/repositories?limit=20&repository=${encodeURIComponent(options.repository)}${page ? `&page=${encodeURIComponent(page)}` : \"\"}`,\n ),\n );\n destinations.push(\n ...result.data.filter(\n (item) =>\n item.id === options.repository ||\n cloudRepositoryUrlKey(item.url) ===\n cloudRepositoryUrlKey(options.repository),\n ),\n );\n page = result.next;\n if (\n result.has_more !== (page !== null) ||\n (page !== null && seenPages.has(page))\n )\n throw new CodexSecurityError(\n \"Cloud returned invalid repository pagination.\",\n );\n if (page !== null) seenPages.add(page);\n } while (page !== null);\n if (destinations.length !== 1)\n throw new CodexSecurityError(\n destinations.length\n ? \"The repository matches multiple connectors. Select an unambiguous Cloud repository.\"\n : \"The destination repository is not available to this Cloud account. Copy its repository URL or ID from Codex Security Cloud and check that you are signed into the intended account.\",\n );\n const destination = destinations[0]!;\n const source = { provider: options.provider, source_key: options.sourceKey };\n const state = join(\n codexSecurityStateDirectory(environment),\n \"external-finding-publications\",\n );\n const checkpointIdentity = [\n // Keep existing production checkpoints readable; other deployments must\n // never share a saved request or receipt with the production default.\n ...(apiBaseUrl === DEFAULT_CLOUD_BASE_URL ? [] : [apiBaseUrl]),\n credentials.account_id,\n destination.id,\n destination.repo_connector_id,\n source,\n ];\n const inputDigest = hash(\"sha256\", canonicalJson(currentIdentity));\n const legacyInputDigest = hash(\"sha256\", canonicalJson(legacyIdentity));\n function validateSaved(serialized: string, legacy = false): SavedSubmission {\n const content = JSON.parse(serialized) as SavedSubmission;\n if (\n content.accountId !== credentials.account_id ||\n !Array.isArray(content.requests) ||\n content.requests.length === 0\n )\n throw new Error(\"Saved import account or requests do not match.\");\n content.requests = content.requests.map(validateImportRequest);\n const savedFindings = submissionFindings(content.requests);\n const savedEvidence = canonicalJson(savedFindings);\n const expected = legacy ? legacyParsed.findings : parsed.findings;\n const matches =\n content.inputProjection !== undefined\n ? sameFindingSelection(savedFindings, expected) &&\n content.inputProjection?.inputDigest ===\n (legacy ? legacyInputDigest : inputDigest) &&\n content.inputProjection?.savedEvidenceDigest ===\n hash(\"sha256\", savedEvidence)\n : savedEvidence === canonicalJson(expected);\n if (!matches)\n throw new Error(\n \"Saved import evidence does not match the selected input.\",\n );\n for (const submission of content.requests) {\n if (\n submission.repository.id !== destination.id ||\n submission.repository.repo_connector_id !==\n destination.repo_connector_id ||\n canonicalJson(submission.source) !== canonicalJson(source)\n )\n throw new Error(\"Saved import destination does not match.\");\n }\n return content;\n }\n const key = hash(\n \"sha256\",\n canonicalJson([...checkpointIdentity, currentIdentity]),\n );\n const pendingPath = join(state, `${key}.pending.json`);\n const historicalKey = hash(\n \"sha256\",\n canonicalJson(\n [...checkpointIdentity, legacyParsed.findings],\n (left, right) => left.localeCompare(right),\n ),\n );\n const legacyKeys = new Set([\n hash(\"sha256\", canonicalJson([...checkpointIdentity, legacyIdentity])),\n historicalKey,\n ]);\n async function rejectUnidentifiedLegacyCheckpoint(): Promise<void> {\n const entries = await readdir(state, { withFileTypes: true }).catch(\n (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return [];\n throw error;\n },\n );\n if (entries.length) await validatePreparedOutputDir(state, undefined, true);\n for (const entry of entries) {\n if (!entry.isFile() || !/^[a-f0-9]{64}\\.pending\\.json$/u.test(entry.name))\n continue;\n const candidateKey = entry.name.slice(0, -\".pending.json\".length);\n if (candidateKey === key || legacyKeys.has(candidateKey)) continue;\n const serialized = await readOptionalFile(join(state, entry.name));\n if (serialized === undefined) continue;\n try {\n // Locale-dependent filenames predate input projections. Later formats\n // must remain isolated by their deployment-bound checkpoint keys.\n const content = JSON.parse(serialized) as SavedSubmission | null;\n if (!content || content.inputProjection !== undefined) continue;\n validateSaved(serialized, true);\n } catch {\n continue;\n }\n // These older bodies contain no deployment identity. Do not guess a\n // destination or replace their immutable request with a fresh publication.\n throw new CodexSecurityError(\n \"An older pending import matches this input, but its checkpoint identity could not be established. Resume it using the original deployment and locale before publishing this selection. The saved request was preserved without uploading.\",\n );\n }\n }\n let recovered: SavedSubmission | undefined;\n for (const legacyKey of legacyKeys) {\n if (legacyKey === key) continue;\n const legacyPath = join(state, `${legacyKey}.pending.json`);\n const captured = await readOptionalFile(legacyPath);\n if (captured !== undefined) {\n // Preserve requests staged by the earlier locale-based filename format.\n // Hold both publication locks while moving the original checkpoint.\n await withImportLock(state, key, dependencies.signal, async () =>\n withImportLock(state, legacyKey, dependencies.signal, async () => {\n const current = await readOptionalFile(pendingPath);\n const serialized = await readOptionalFile(legacyPath);\n if (current !== undefined) {\n recovered = validateSaved(current);\n if (serialized !== undefined) {\n // A crash may leave both copies after installing the canonical file.\n // Retire only an identical immutable submission, never another request.\n let duplicate: SavedSubmission | null = null;\n try {\n duplicate = JSON.parse(serialized) as SavedSubmission | null;\n } catch (error) {\n if (!(error instanceof SyntaxError)) throw error;\n }\n if (\n duplicate !== null &&\n typeof duplicate === \"object\" &&\n sameSubmission(duplicate, recovered)\n )\n await rm(legacyPath);\n }\n return;\n }\n // A competing resumer may have completed and removed both paths while\n // this caller waited. Retain its observed immutable request and receipts.\n const content = validateSaved(serialized ?? captured, true);\n if (!sameFindingSelection(legacyParsed.findings, parsed.findings))\n throw new CodexSecurityError(\n \"The saved import selects different findings from this input. Resume the original selection before publishing this selection.\",\n );\n if (\n content.requests.some(\n (submission) =>\n submission.repository.reset_marker !== destination.reset_marker,\n )\n ) {\n if (serialized !== undefined) await rm(legacyPath);\n throw new CloudImportError(\n 409,\n \"The repository was reset after this submission. The saved request was retired without uploading. Review the destination and run the command again to approve a fresh publication.\",\n );\n }\n const savedEvidenceDigest =\n content.inputProjection?.savedEvidenceDigest ??\n hash(\"sha256\", canonicalJson(legacyParsed.findings));\n const rebindProjection =\n content.inputProjection !== undefined ||\n savedEvidenceDigest !== inputDigest;\n if (rebindProjection)\n content.inputProjection = { inputDigest, savedEvidenceDigest };\n recovered = content;\n if (serialized === undefined) return;\n if (!rebindProjection) {\n await rename(legacyPath, pendingPath);\n } else {\n // Bind the new input projection to the original immutable evidence,\n // so later inventory reordering still resumes these exact requests.\n await writeAtomicJson(pendingPath, content);\n await rm(legacyPath);\n }\n }),\n );\n }\n }\n const serialized = await readOptionalFile(pendingPath);\n const saved =\n serialized === undefined ? recovered : validateSaved(serialized);\n if (!saved) await rejectUnidentifiedLegacyCheckpoint();\n if (saved) {\n const content = saved;\n for (const submission of content.requests) {\n if (submission.repository.reset_marker !== destination.reset_marker) {\n // The old request is never sent after reset. A subsequent explicit\n // invocation prepares a fresh submission and asks for approval again.\n await withImportLock(state, key, dependencies.signal, async () => {\n const current = await readOptionalFile(pendingPath);\n if (\n current !== undefined &&\n sameSubmission(JSON.parse(current) as SavedSubmission, content)\n )\n await rm(pendingPath);\n });\n throw new CloudImportError(\n 409,\n \"The repository was reset after this submission. The saved request was retired without uploading. Review the destination and run the command again to approve a fresh publication.\",\n );\n }\n }\n }\n let requests = saved?.requests;\n if (!requests) {\n for (const finding of parsed.findings) {\n const sourceRepositories = [\n finding.evidence.details?.repository?.url,\n ...(options.provider === \"wiz\"\n ? [wizCsvRepositoryUrl(finding.evidence)]\n : []),\n ...(options.provider === \"snyk\"\n ? snykRepositoryUrls(finding.evidence.source_data, {\n cloudRepositoryUrl: destination.url,\n })\n : []),\n ...(options.provider === \"endor\"\n ? endorRepositoryUrls(finding.evidence.source_data)\n : []),\n ];\n for (const sourceRepository of sourceRepositories)\n if (\n sourceRepository &&\n cloudRepositoryUrlKey(sourceRepository) !==\n cloudRepositoryUrlKey(destination.url)\n )\n throw new CodexSecurityError(\n `Finding ${JSON.stringify(finding.source_finding_id)} belongs to ${JSON.stringify(sourceRepository)}, which does not match the selected Cloud repository ${JSON.stringify(destination.url)}. Verify the source repository mapping before publishing.`,\n );\n }\n let preparedCount = 0;\n progress({\n phase: \"preparing\",\n completed: 0,\n total: parsed.findings.length,\n });\n const previousReports = await readInBatches(\n parsed.findings,\n async (finding): Promise<SourceReportSummary | undefined> => {\n const query = new URLSearchParams({\n provider: source.provider,\n source_key: source.source_key,\n source_finding_id: finding.source_finding_id,\n limit: \"2\",\n });\n const summaries = validateSourceReports(\n await request(`${sourcePath(destination)}?${query}`),\n );\n if (summaries.has_more || summaries.data.length > 1)\n throw new CodexSecurityError(\n \"Cloud returned more than one report for a source identity.\",\n );\n const previous = summaries.data[0];\n if (\n previous &&\n (previous.source_finding_id !== finding.source_finding_id ||\n previous.source.provider !== source.provider ||\n previous.source.source_key !== source.source_key ||\n previous.repo_id !== destination.id ||\n previous.repo_connector_id !== destination.repo_connector_id)\n )\n throw new CodexSecurityError(\n \"Cloud returned a different source identity.\",\n );\n progress({\n phase: \"preparing\",\n completed: ++preparedCount,\n total: parsed.findings.length,\n });\n return previous;\n },\n );\n requests = [];\n let current: FindingImportRequest | undefined;\n let currentBytes = 0;\n for (const [index, finding] of parsed.findings.entries()) {\n const previous = previousReports[index];\n const environmentId =\n previous?.environment_id ?? destination.import_environment_id;\n if (environmentId == null)\n throw new CodexSecurityError(\n \"Configure an authorized Cloud environment for this repository before importing findings.\",\n );\n const item = {\n client_id: `item-${index + 1}`,\n source_finding_id: finding.source_finding_id,\n expected_version: previous?.version ?? 0,\n evidence: finding.evidence,\n };\n const itemBytes = Buffer.byteLength(JSON.stringify(item));\n if (\n current &&\n (current.repository.environment_id !== environmentId ||\n current.items.length === 100 ||\n currentBytes + 1 + itemBytes > MAX_REQUEST_BYTES)\n ) {\n requests.push(validateImportRequest(current));\n current = undefined;\n }\n if (!current) {\n current = {\n request_id: randomUUID(),\n repository: {\n id: destination.id,\n repo_connector_id: destination.repo_connector_id,\n environment_id: environmentId,\n reset_marker: destination.reset_marker,\n },\n source,\n items: [],\n };\n currentBytes = Buffer.byteLength(JSON.stringify(current));\n } else {\n currentBytes++;\n }\n current.items.push(item);\n currentBytes += itemBytes;\n }\n if (current) requests.push(validateImportRequest(current));\n }\n const submission: SavedSubmission = {\n accountId: credentials.account_id,\n requests,\n receipts: saved?.receipts,\n inputProjection: saved?.inputProjection ?? {\n inputDigest,\n savedEvidenceDigest: hash(\n \"sha256\",\n canonicalJson(submissionFindings(requests)),\n ),\n },\n };\n const preview: ExternalPublicationPreview = {\n ...parsed,\n ...(parsed.report === undefined\n ? {}\n : { report: structuredClone(parsed.report) }),\n findings: submissionFindings(requests),\n cloudApiUrl,\n cloudUrl: cloudFindingsUrl(environment, destination.id),\n accountId: credentials.account_id,\n destination,\n source,\n resumed: saved !== undefined,\n requests,\n };\n return {\n preview,\n async publish() {\n progress({ phase: \"waiting\", completed: 0 });\n const result = (\n acknowledged: FindingImportReceipt[],\n verified: number,\n ): ExternalPublicationResult => {\n const counts = { created: 0, updated: 0, unchanged: 0, error: 0 };\n const failures: ExternalPublicationResult[\"failures\"] = [];\n for (const [index, receipt] of acknowledged.entries()) {\n for (const outcome of Object.keys(counts) as (keyof typeof counts)[])\n counts[outcome] += receipt.counts[outcome] ?? 0;\n const ids = new Map(\n requests[index]!.items.map((item) => [\n item.client_id,\n item.source_finding_id,\n ]),\n );\n for (const item of receipt.results)\n if (item.error)\n failures.push({\n source_finding_id: ids.get(item.client_id)!,\n ...item.error,\n });\n }\n return {\n cloudApiUrl,\n cloudUrl: preview.cloudUrl,\n status:\n parsed.excluded.length || counts.error ? \"partial\" : \"complete\",\n read: parsed.read,\n ...(parsed.report === undefined\n ? {}\n : { report: structuredClone(parsed.report) }),\n ready: parsed.findings.length,\n excluded: parsed.excluded,\n receipts: acknowledged,\n counts,\n failures,\n unacknowledged:\n parsed.findings.length -\n Object.values(counts).reduce((sum, count) => sum + count, 0),\n verified,\n };\n };\n let acquired = false;\n return await withImportLock(state, key, dependencies.signal, async () => {\n acquired = true;\n // Re-read under the lock to keep checkpoints from another publisher.\n const pending = await readOptionalFile(pendingPath);\n if (pending === undefined && !saved)\n await rejectUnidentifiedLegacyCheckpoint();\n const current =\n pending === undefined\n ? submission\n : (JSON.parse(pending) as SavedSubmission);\n if (!sameSubmission(current, submission))\n throw new CodexSecurityError(\n \"Another publication prepared this input. Run the command again to review and resume that saved request.\",\n );\n const receipts = (current.receipts ?? []).map(validateImportReceipt);\n if (receipts.length > requests.length)\n throw new CodexSecurityError(\n \"Saved publication has more receipts than requests.\",\n );\n const acknowledged: FindingImportReceipt[] = [];\n let verified = 0;\n let persisted = pending !== undefined;\n try {\n if (pending === undefined) {\n await writeAtomicJson(pendingPath, submission);\n persisted = true;\n }\n progress({\n phase: \"uploading\",\n completed: 0,\n total: parsed.findings.length,\n });\n let acknowledgedCount = 0;\n for (const [batchIndex, batch] of requests.entries()) {\n const receipt = validatePublicationReceipt(\n receipts[batchIndex] ??\n (await request(\"/finding_imports\", batch)),\n batch,\n );\n acknowledged.push(receipt);\n acknowledgedCount += receipt.item_count;\n progress({\n phase: \"uploading\",\n completed: acknowledgedCount,\n total: parsed.findings.length,\n });\n if (batchIndex === receipts.length) {\n receipts.push(receipt);\n // Acknowledged batches must not consume another POST quota on retry.\n // Readback can still resume after this checkpoint without replaying writes.\n await writeAtomicJson(pendingPath, {\n ...submission,\n receipts,\n });\n }\n }\n // Verify readable source records without mistaking a newer concurrent\n // observation for failure of the original, immutable import receipt.\n const readbacks = receipts.flatMap((receipt, batchIndex) => {\n const batch = requests[batchIndex]!;\n const batchItems = new Map(\n batch.items.map((item) => [item.client_id, item]),\n );\n return receipt.results\n .filter((item) => item.outcome !== \"error\")\n .map((item) => ({\n item,\n expected: batchItems.get(item.client_id)!,\n batch,\n }));\n });\n progress({\n phase: \"verifying\",\n completed: 0,\n total: readbacks.length,\n });\n await readInBatches(readbacks, async ({ item, expected, batch }) => {\n const report = validateSourceReport(\n await request(\n `${sourcePath(destination)}/${encodeURIComponent(item.source_report_id!)}`,\n ),\n );\n if (\n report.id !== item.source_report_id ||\n report.canonical_finding_id !== item.canonical_finding_id ||\n report.version < item.version! ||\n (report.version === item.version &&\n (report.observation_id !== item.observation_id ||\n canonicalJson(report.evidence) !==\n canonicalJson(expected.evidence))) ||\n report.source_finding_id !== expected.source_finding_id ||\n report.repo_id !== destination.id ||\n report.repo_connector_id !== destination.repo_connector_id ||\n report.environment_id !== batch.repository.environment_id ||\n canonicalJson(report.source) !== canonicalJson(source)\n )\n throw new CodexSecurityError(\n \"Cloud readback did not match the saved finding identity.\",\n );\n progress({\n phase: \"verifying\",\n completed: ++verified,\n total: readbacks.length,\n });\n });\n const completed = result(acknowledged, verified);\n await writeAtomicJson(join(state, `${key}.result.json`), {\n ...completed,\n report: reportForJson(completed.report),\n });\n await rm(pendingPath, { force: true });\n return completed;\n } catch (error) {\n if (error instanceof CloudImportError && error.status === 409) {\n await rm(pendingPath, { force: true });\n persisted = false;\n }\n const message = `${error instanceof Error ? error.message : String(error)} ${error instanceof CloudImportError && error.status === 409 ? \"The old submission was retired. Rediscover and approve a fresh publication.\" : persisted ? `Repeat the same command to resume the saved request. Saved submission: ${pendingPath}` : \"No resumable request was saved. Correct the error and review the input before retrying.\"}`;\n throw new ExternalPublicationError(\n message,\n {\n ...result(acknowledged, verified),\n status: \"interrupted\",\n error: message,\n ...(persisted ? { savedSubmission: pendingPath } : {}),\n },\n error,\n );\n }\n }).catch((error: unknown) => {\n if (acquired || !dependencies.signal?.aborted) throw error;\n // The active publisher owns the checkpoint. Report only acknowledgements\n // already observed during preparation, without rewriting its files.\n const known = submission.receipts ?? [];\n if (known.length > requests.length)\n throw new CodexSecurityError(\n \"Saved publication has more receipts than requests.\",\n );\n const acknowledged = known.map((receipt, index) =>\n validatePublicationReceipt(receipt, requests[index]!),\n );\n const message = saved\n ? `Publication canceled while waiting. Repeat the same command to resume the saved request. Saved submission: ${pendingPath}`\n : \"Publication canceled while waiting. No resumable request was saved by this invocation.\";\n throw new ExternalPublicationError(\n message,\n {\n ...result(acknowledged, 0),\n status: \"interrupted\",\n error: message,\n ...(saved ? { savedSubmission: pendingPath } : {}),\n },\n error,\n );\n });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"external-findings-publish.js","sourceRoot":"","sources":["../src/external-findings-publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,EAAE,GACH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAA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E,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBACvD,EACD,KAAK,CACN,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBAC1B,IAAI,QAAQ,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO;oBAAE,MAAM,KAAK,CAAC;gBAC3D,yEAAyE;gBACzE,oEAAoE;gBACpE,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACxC,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM;oBAChC,MAAM,IAAI,kBAAkB,CAC1B,oDAAoD,CACrD,CAAC;gBACJ,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAChD,0BAA0B,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAE,CAAC,CACtD,CAAC;gBACF,MAAM,OAAO,GAAG,KAAK;oBACnB,CAAC,CAAC,8GAA8G,WAAW,EAAE;oBAC7H,CAAC,CAAC,wFAAwF,CAAC;gBAC7F,MAAM,IAAI,wBAAwB,CAChC,OAAO,EACP;oBACE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;oBAC1B,MAAM,EAAE,aAAa;oBACrB,KAAK,EAAE,OAAO;oBACd,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACnD,EACD,KAAK,CACN,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { hash, randomUUID } from \"node:crypto\";\nimport { chmodSync } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n open,\n readFile,\n readdir,\n rename,\n rm,\n} from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { readCloudCredentials } from \"./cloud-publish.js\";\nimport {\n cloudBaseUrl,\n cloudFindingsUrl,\n DEFAULT_CLOUD_BASE_URL,\n} from \"./cloud-endpoint.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { requireExternalImports } from \"./external-imports-feature.js\";\nimport {\n codexSecurityStateDirectory,\n createWindowsOutputDirectory,\n validatePreparedOutputDir,\n} from \"./runtime.js\";\nimport {\n EXTERNAL_FINDINGS_PROVIDERS,\n readExternalFindings,\n type ExternalFindingsReaderOptions,\n} from \"./external-findings-read.js\";\nimport { canonicalJson } from \"./record.js\";\nimport { wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport { dependabotRepository } from \"./github-dependabot-findings.js\";\nimport { snykRepositoryUrls } from \"./snyk-findings.js\";\nimport { endorRepositoryUrls } from \"./endor-findings.js\";\nimport type {\n ExternalFindings,\n ExternalPublicationInput,\n} from \"./external-findings.js\";\nimport {\n cloudRepositoryUrlKey,\n validateImportRequest,\n validateExternalEvidence,\n validateExternalReport,\n validateImportReceipt,\n validateRepositories,\n validateSourceReports,\n validateSourceReport,\n} from \"./external-import-contract.js\";\nimport type {\n FindingImportRequest,\n FindingImportReceipt,\n ImportRepository,\n SourceReportSummary,\n} from \"./external-import-models.js\";\n\nconst MAX_REQUEST_BYTES = 5 * 1024 * 1024;\n\n/** Source and destination for evidence already normalized to the Cloud contract. */\nexport interface NormalizedExternalPublicationOptions {\n repository: string;\n provider: FindingImportRequest[\"source\"][\"provider\"];\n sourceKey: string;\n}\n\n/** File readers accept the vendor formats installed in this SDK. */\nexport interface ExternalPublicationOptions extends Omit<\n NormalizedExternalPublicationOptions,\n \"provider\"\n> {\n provider: ExternalFindingsReaderOptions[\"provider\"];\n sourceRepositoryUrl?: string;\n}\n\n/** Optional transport, account, cancellation, and progress hooks. */\nexport interface ExternalPublicationDependencies {\n environment?: NodeJS.ProcessEnv;\n fetch?: (url: string, options: RequestInit) => Promise<Response>;\n credentials?: () => Promise<{ access_token: string; account_id: string }>;\n signal?: AbortSignal;\n onProgress?: (event: ExternalPublicationProgress) => void;\n}\n\nexport interface ExternalPublicationProgress {\n phase:\n | \"reading\"\n | \"discovering\"\n | \"preparing\"\n | \"waiting\"\n | \"uploading\"\n | \"verifying\";\n completed: number;\n total?: number;\n}\n\n/** Counts describe acknowledged receipts, even when later transport or readback fails. */\nexport interface ExternalPublicationResult {\n cloudApiUrl: string;\n cloudUrl?: string;\n status: \"complete\" | \"partial\" | \"interrupted\";\n read: number;\n report?: ExternalFindings[\"report\"];\n ready: number;\n excluded: ExternalFindings[\"excluded\"];\n receipts: FindingImportReceipt[];\n counts: Required<FindingImportReceipt[\"counts\"]>;\n failures: { source_finding_id: string; code: string; message: string }[];\n unacknowledged: number;\n verified: number;\n error?: string;\n savedSubmission?: string;\n}\n\n/** Preserve accepted work in CLI JSON output when publication cannot finish. */\nexport class ExternalPublicationError extends CodexSecurityError {\n constructor(\n message: string,\n public readonly result: ExternalPublicationResult,\n cause: unknown,\n ) {\n super(message, { cause });\n }\n}\n\ninterface SavedSubmission {\n accountId: string;\n requests: FindingImportRequest[];\n receipts?: FindingImportReceipt[];\n inputProjection?: { inputDigest: string; savedEvidenceDigest: string };\n}\n\nexport interface ExternalPublicationPreview extends ExternalFindings {\n cloudApiUrl: string;\n cloudUrl?: string;\n accountId: string;\n destination: ImportRepository;\n source: FindingImportRequest[\"source\"];\n resumed: boolean;\n requests: FindingImportRequest[];\n}\n\nexport interface PreparedExternalPublication {\n preview: ExternalPublicationPreview;\n publish(): Promise<ExternalPublicationResult>;\n}\n\n// Limit read concurrency to avoid one network round trip per finding in series.\n// Wait for the entire batch on failure so callers never outlive their read tasks.\nasync function readInBatches<T, U>(\n items: T[],\n read: (item: T) => Promise<U>,\n): Promise<U[]> {\n const output: U[] = [];\n for (let start = 0; start < items.length; start += 4) {\n const batch = await Promise.allSettled(\n items.slice(start, start + 4).map(read),\n );\n for (const result of batch) {\n if (result.status === \"rejected\") throw result.reason;\n output.push(result.value);\n }\n }\n return output;\n}\n\nfunction sameSubmission(\n left: SavedSubmission,\n right: SavedSubmission,\n): boolean {\n return (\n left.accountId === right.accountId &&\n canonicalJson(left.requests) === canonicalJson(right.requests)\n );\n}\n\nfunction submissionFindings(\n requests: readonly FindingImportRequest[],\n): ExternalFindings[\"findings\"] {\n return requests.flatMap((batch) =>\n batch.items.map(({ source_finding_id, evidence }) => ({\n source_finding_id,\n evidence,\n })),\n );\n}\n\nfunction sameFindingSelection(\n left: ExternalFindings[\"findings\"],\n right: ExternalFindings[\"findings\"],\n): boolean {\n return (\n left.length === right.length &&\n left.every(\n (finding, index) =>\n finding.source_finding_id === right[index]!.source_finding_id,\n )\n );\n}\n\nasync function readOptionalFile(path: string): Promise<string | undefined> {\n return readFile(path, \"utf8\").catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return undefined;\n throw error;\n });\n}\n\nfunction reportForJson(report: ExternalFindings[\"report\"]) {\n const errors = report?.[\"errors\"];\n if (!Array.isArray(errors)) return report;\n const json = JSON.stringify(errors, (_key, entry: unknown) =>\n entry instanceof Error ? { message: entry.message } : entry,\n );\n return { ...report, errors: JSON.parse(json) as unknown[] };\n}\n\nasync function writeAtomicJson(path: string, value: unknown): Promise<void> {\n const temporary = `${path}.${randomUUID()}.tmp`;\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(JSON.stringify(value));\n await file.sync();\n } finally {\n await file.close();\n }\n await rename(temporary, path);\n } finally {\n await rm(temporary, { force: true });\n }\n}\n\nfunction sourcePath(repository: ImportRepository): string {\n return `/repository_connectors/${encodeURIComponent(repository.repo_connector_id)}/repositories/${encodeURIComponent(repository.id)}/source_reports`;\n}\n\nclass CloudImportError extends CodexSecurityError {\n constructor(\n public readonly status: number,\n message: string,\n ) {\n super(message);\n }\n}\n\nfunction validatePublicationReceipt(\n value: unknown,\n batch: FindingImportRequest,\n): FindingImportReceipt {\n const receipt = validateImportReceipt(value);\n const batchItems = new Map(batch.items.map((item) => [item.client_id, item]));\n if (\n receipt.id !== batch.request_id ||\n canonicalJson(receipt.repository) !== canonicalJson(batch.repository) ||\n canonicalJson(receipt.source) !== canonicalJson(batch.source) ||\n receipt.item_count !== batch.items.length ||\n receipt.results.length !== batch.items.length ||\n new Set(receipt.results.map((item) => item.client_id)).size !==\n batch.items.length ||\n receipt.results.some((item) => !batchItems.has(item.client_id))\n )\n throw new CodexSecurityError(\n \"Cloud returned a receipt for a different publication.\",\n );\n const actual = { created: 0, updated: 0, unchanged: 0, error: 0 };\n for (const result of receipt.results) {\n actual[result.outcome]++;\n if (result.outcome === \"error\") {\n if (\n !result.error ||\n result.source_report_id !== null ||\n result.observation_id !== null ||\n result.canonical_finding_id !== null ||\n result.version !== null\n )\n throw new CodexSecurityError(\n \"Cloud returned inconsistent item error fields.\",\n );\n } else if (\n result.error !== null ||\n !result.source_report_id ||\n !result.observation_id ||\n !result.canonical_finding_id ||\n result.version === null\n )\n throw new CodexSecurityError(\n \"Cloud returned an incomplete saved finding.\",\n );\n }\n if (canonicalJson(receipt.counts) !== canonicalJson(actual))\n throw new CodexSecurityError(\n \"Cloud returned inconsistent publication counts.\",\n );\n return receipt;\n}\n\nasync function withImportLock<T>(\n state: string,\n key: string,\n signal: AbortSignal | undefined,\n operation: () => Promise<T>,\n): Promise<T> {\n if (process.platform === \"win32\")\n await createWindowsOutputDirectory(state, true);\n else await mkdir(state, { recursive: true, mode: 0o700 });\n await validatePreparedOutputDir(state, undefined, true);\n const path = join(state, `${key}.lock.sqlite`);\n const metadata = await lstat(path).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return undefined;\n throw error;\n });\n if (metadata && !metadata.isFile())\n throw new CodexSecurityError(\"The publication lock is not a regular file.\");\n const require = createRequire(import.meta.url);\n const Database = (\n process.versions[\"bun\"]\n ? require(\"bun:sqlite\").Database\n : require(\"node:sqlite\").DatabaseSync\n ) as new (path: string) => { exec(sql: string): void; close(): void };\n const guard = new Database(path);\n try {\n if (process.platform !== \"win32\") chmodSync(path, 0o600);\n guard.exec(\"PRAGMA busy_timeout = 0\");\n for (;;) {\n signal?.throwIfAborted();\n try {\n // Keep this inode across invocations. SQLite releases the transaction\n // on process exit, so a paused publisher cannot lose its lock to a lease.\n guard.exec(\"BEGIN EXCLUSIVE\");\n break;\n } catch (error) {\n const sqliteError = error as { code?: string; errcode?: number };\n if (sqliteError.errcode !== 5 && sqliteError.code !== \"SQLITE_BUSY\")\n throw error;\n await delay(50, undefined, { signal });\n }\n }\n return await operation();\n } finally {\n guard.close();\n }\n}\n\nexport async function prepareExternalPublication(\n path: string,\n options: ExternalPublicationOptions,\n dependencies: ExternalPublicationDependencies = {},\n): Promise<PreparedExternalPublication> {\n requireExternalImports(dependencies.environment);\n const parsed = await readExternalFindings(path, options);\n const normalizedOptions = {\n ...options,\n provider: EXTERNAL_FINDINGS_PROVIDERS[options.provider],\n };\n return parsed.publication\n ? preparePublicationInput(\n parsed.publication,\n normalizedOptions,\n dependencies,\n )\n : prepareNormalizedExternalPublication(\n parsed.findings,\n normalizedOptions,\n dependencies,\n );\n}\n\n/** Prepare normalized provider evidence without reading a vendor export. */\nexport async function prepareNormalizedExternalPublication(\n input: ExternalFindings,\n options: NormalizedExternalPublicationOptions,\n dependencies: ExternalPublicationDependencies = {},\n): Promise<PreparedExternalPublication> {\n requireExternalImports(dependencies.environment);\n // Validation adds Cloud defaults; leave the caller's objects unchanged.\n const { report, ...parsed } = input;\n const current: ExternalFindings = structuredClone(parsed);\n if (report !== undefined) {\n current.report = structuredClone(report);\n validateExternalReport(current.report);\n }\n // structuredClone preserves aliases. Detach every raw record before adding\n // typed defaults, including aliases shared with another finding's evidence.\n for (const finding of current.findings)\n if (finding.evidence.source_data !== undefined)\n finding.evidence.source_data = structuredClone(\n finding.evidence.source_data,\n );\n const identities = new Set<string>();\n for (const finding of current.findings) {\n const id = finding.source_finding_id;\n if (!id.trim() || id.includes(\"\\0\") || Buffer.byteLength(id) > 512)\n throw new CodexSecurityError(\n \"Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.\",\n );\n if (identities.has(id))\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(id)}.`,\n );\n identities.add(id);\n finding.evidence = validateExternalEvidence(finding.evidence);\n }\n const identity =\n current.report === undefined\n ? current.findings\n : { findings: current.findings, report: reportForJson(current.report) };\n return preparePublicationInput(\n {\n current,\n legacy: current,\n currentIdentity: identity,\n legacyIdentity: identity,\n },\n options,\n dependencies,\n );\n}\n\nasync function preparePublicationInput(\n input: ExternalPublicationInput,\n options: NormalizedExternalPublicationOptions,\n dependencies: ExternalPublicationDependencies,\n): Promise<PreparedExternalPublication> {\n const progress = (event: ExternalPublicationProgress): void => {\n try {\n dependencies.onProgress?.(event);\n } catch {\n // Optional progress must not interrupt preparation or publication.\n }\n };\n if (\n !options.sourceKey.trim() ||\n options.sourceKey.includes(\"\\0\") ||\n Buffer.byteLength(options.sourceKey) > 512\n ) {\n throw new CodexSecurityError(\n \"The source key must contain 1–512 UTF-8 bytes and no NUL characters. Use a stable scanner organization/project/branch namespace across imports.\",\n );\n }\n progress({ phase: \"reading\", completed: 0 });\n const {\n current: parsed,\n legacy: legacyParsed,\n currentIdentity,\n legacyIdentity,\n } = input;\n if (parsed.findings.length === 0) {\n const diagnostics = reportForJson(parsed.report)?.[\"errors\"];\n throw new CodexSecurityError(\n `No supported findings are ready to publish. ${parsed.excluded.map((item) => `Item ${item.position}: ${item.reason}`).join(\" \")}${Array.isArray(diagnostics) && diagnostics.length ? ` Scanner diagnostics: ${JSON.stringify(diagnostics)}` : \"\"}`,\n );\n }\n progress({ phase: \"discovering\", completed: 0 });\n const environment = dependencies.environment ?? process.env;\n requireExternalImports(environment);\n const apiBaseUrl = cloudBaseUrl(environment);\n const cloudApiUrl = `${apiBaseUrl}/external`;\n // Validate the configured return destination before authentication or uploads.\n cloudFindingsUrl(environment, options.repository);\n const credentials = await (\n dependencies.credentials ?? (() => readCloudCredentials(environment))\n )();\n async function request(\n endpoint: string,\n body?: FindingImportRequest,\n ): Promise<unknown> {\n dependencies.signal?.throwIfAborted();\n // Allow upload and response transport around the server's publication budget.\n const timeout = AbortSignal.timeout(body ? 60_000 : 30_000);\n const response = await (dependencies.fetch ?? globalThis.fetch)(\n `${cloudApiUrl}${endpoint}`,\n {\n method: body ? \"POST\" : \"GET\",\n headers: {\n Authorization: `Bearer ${credentials.access_token}`,\n \"ChatGPT-Account-ID\": credentials.account_id,\n Accept: \"application/json\",\n ...(body ? { \"Content-Type\": \"application/json\" } : {}),\n },\n ...(body ? { body: JSON.stringify(body) } : {}),\n redirect: \"error\",\n signal: dependencies.signal\n ? AbortSignal.any([dependencies.signal, timeout])\n : timeout,\n },\n );\n if (!response.ok) {\n const payload = (await response.json().catch(() => null)) as {\n error?: { message?: string };\n } | null;\n const retryAfter = response.headers.get(\"Retry-After\");\n throw new CloudImportError(\n response.status,\n `Cloud import failed (HTTP ${response.status}). ${payload?.error?.message ?? response.statusText}${retryAfter ? ` Retry-After: ${retryAfter}.` : \"\"}`,\n );\n }\n return response.json();\n }\n const destinations: ImportRepository[] = [];\n let page: string | null = null;\n const seenPages = new Set<string>();\n do {\n const result = validateRepositories(\n await request(\n `/repositories?limit=20&repository=${encodeURIComponent(options.repository)}${page ? `&page=${encodeURIComponent(page)}` : \"\"}`,\n ),\n );\n destinations.push(\n ...result.data.filter(\n (item) =>\n item.id === options.repository ||\n cloudRepositoryUrlKey(item.url) ===\n cloudRepositoryUrlKey(options.repository),\n ),\n );\n page = result.next;\n if (\n result.has_more !== (page !== null) ||\n (page !== null && seenPages.has(page))\n )\n throw new CodexSecurityError(\n \"Cloud returned invalid repository pagination.\",\n );\n if (page !== null) seenPages.add(page);\n } while (page !== null);\n if (destinations.length !== 1)\n throw new CodexSecurityError(\n destinations.length\n ? \"The repository matches multiple connectors. Select an unambiguous Cloud repository.\"\n : \"The destination repository is not available to this Cloud account. Copy its repository URL or ID from Codex Security Cloud and check that you are signed into the intended account.\",\n );\n const destination = destinations[0]!;\n const source = { provider: options.provider, source_key: options.sourceKey };\n const state = join(\n codexSecurityStateDirectory(environment),\n \"external-finding-publications\",\n );\n const checkpointIdentity = [\n // Keep existing production checkpoints readable; other deployments must\n // never share a saved request or receipt with the production default.\n ...(apiBaseUrl === DEFAULT_CLOUD_BASE_URL ? [] : [apiBaseUrl]),\n credentials.account_id,\n destination.id,\n destination.repo_connector_id,\n source,\n ];\n const inputDigest = hash(\"sha256\", canonicalJson(currentIdentity));\n const legacyInputDigest = hash(\"sha256\", canonicalJson(legacyIdentity));\n function validateSaved(serialized: string, legacy = false): SavedSubmission {\n const content = JSON.parse(serialized) as SavedSubmission;\n if (\n content.accountId !== credentials.account_id ||\n !Array.isArray(content.requests) ||\n content.requests.length === 0\n )\n throw new Error(\"Saved import account or requests do not match.\");\n content.requests = content.requests.map(validateImportRequest);\n const savedFindings = submissionFindings(content.requests);\n const savedEvidence = canonicalJson(savedFindings);\n const expected = legacy ? legacyParsed.findings : parsed.findings;\n const matches =\n content.inputProjection !== undefined\n ? sameFindingSelection(savedFindings, expected) &&\n content.inputProjection?.inputDigest ===\n (legacy ? legacyInputDigest : inputDigest) &&\n content.inputProjection?.savedEvidenceDigest ===\n hash(\"sha256\", savedEvidence)\n : savedEvidence === canonicalJson(expected);\n if (!matches)\n throw new Error(\n \"Saved import evidence does not match the selected input.\",\n );\n for (const submission of content.requests) {\n if (\n submission.repository.id !== destination.id ||\n submission.repository.repo_connector_id !==\n destination.repo_connector_id ||\n canonicalJson(submission.source) !== canonicalJson(source)\n )\n throw new Error(\"Saved import destination does not match.\");\n }\n return content;\n }\n const key = hash(\n \"sha256\",\n canonicalJson([...checkpointIdentity, currentIdentity]),\n );\n const pendingPath = join(state, `${key}.pending.json`);\n const historicalKey = hash(\n \"sha256\",\n canonicalJson(\n [...checkpointIdentity, legacyParsed.findings],\n (left, right) => left.localeCompare(right),\n ),\n );\n const legacyKeys = new Set([\n hash(\"sha256\", canonicalJson([...checkpointIdentity, legacyIdentity])),\n historicalKey,\n ]);\n async function rejectUnidentifiedLegacyCheckpoint(): Promise<void> {\n const entries = await readdir(state, { withFileTypes: true }).catch(\n (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return [];\n throw error;\n },\n );\n if (entries.length) await validatePreparedOutputDir(state, undefined, true);\n for (const entry of entries) {\n if (!entry.isFile() || !/^[a-f0-9]{64}\\.pending\\.json$/u.test(entry.name))\n continue;\n const candidateKey = entry.name.slice(0, -\".pending.json\".length);\n if (candidateKey === key || legacyKeys.has(candidateKey)) continue;\n const serialized = await readOptionalFile(join(state, entry.name));\n if (serialized === undefined) continue;\n try {\n // Locale-dependent filenames predate input projections. Later formats\n // must remain isolated by their deployment-bound checkpoint keys.\n const content = JSON.parse(serialized) as SavedSubmission | null;\n if (!content || content.inputProjection !== undefined) continue;\n validateSaved(serialized, true);\n } catch {\n continue;\n }\n // These older bodies contain no deployment identity. Do not guess a\n // destination or replace their immutable request with a fresh publication.\n throw new CodexSecurityError(\n \"An older pending import matches this input, but its checkpoint identity could not be established. Resume it using the original deployment and locale before publishing this selection. The saved request was preserved without uploading.\",\n );\n }\n }\n let recovered: SavedSubmission | undefined;\n for (const legacyKey of legacyKeys) {\n if (legacyKey === key) continue;\n const legacyPath = join(state, `${legacyKey}.pending.json`);\n const captured = await readOptionalFile(legacyPath);\n if (captured !== undefined) {\n // Preserve requests staged by the earlier locale-based filename format.\n // Hold both publication locks while moving the original checkpoint.\n await withImportLock(state, key, dependencies.signal, async () =>\n withImportLock(state, legacyKey, dependencies.signal, async () => {\n const current = await readOptionalFile(pendingPath);\n const serialized = await readOptionalFile(legacyPath);\n if (current !== undefined) {\n recovered = validateSaved(current);\n if (serialized !== undefined) {\n // A crash may leave both copies after installing the canonical file.\n // Retire only an identical immutable submission, never another request.\n let duplicate: SavedSubmission | null = null;\n try {\n duplicate = JSON.parse(serialized) as SavedSubmission | null;\n } catch (error) {\n if (!(error instanceof SyntaxError)) throw error;\n }\n if (\n duplicate !== null &&\n typeof duplicate === \"object\" &&\n sameSubmission(duplicate, recovered)\n )\n await rm(legacyPath);\n }\n return;\n }\n // A competing resumer may have completed and removed both paths while\n // this caller waited. Retain its observed immutable request and receipts.\n const content = validateSaved(serialized ?? captured, true);\n if (!sameFindingSelection(legacyParsed.findings, parsed.findings))\n throw new CodexSecurityError(\n \"The saved import selects different findings from this input. Resume the original selection before publishing this selection.\",\n );\n if (\n content.requests.some(\n (submission) =>\n submission.repository.reset_marker !== destination.reset_marker,\n )\n ) {\n if (serialized !== undefined) await rm(legacyPath);\n throw new CloudImportError(\n 409,\n \"The repository was reset after this submission. The saved request was retired without uploading. Review the destination and run the command again to approve a fresh publication.\",\n );\n }\n const savedEvidenceDigest =\n content.inputProjection?.savedEvidenceDigest ??\n hash(\"sha256\", canonicalJson(legacyParsed.findings));\n const rebindProjection =\n content.inputProjection !== undefined ||\n savedEvidenceDigest !== inputDigest;\n if (rebindProjection)\n content.inputProjection = { inputDigest, savedEvidenceDigest };\n recovered = content;\n if (serialized === undefined) return;\n if (!rebindProjection) {\n await rename(legacyPath, pendingPath);\n } else {\n // Bind the new input projection to the original immutable evidence,\n // so later inventory reordering still resumes these exact requests.\n await writeAtomicJson(pendingPath, content);\n await rm(legacyPath);\n }\n }),\n );\n }\n }\n const serialized = await readOptionalFile(pendingPath);\n const saved =\n serialized === undefined ? recovered : validateSaved(serialized);\n if (!saved) await rejectUnidentifiedLegacyCheckpoint();\n if (saved) {\n const content = saved;\n for (const submission of content.requests) {\n if (submission.repository.reset_marker !== destination.reset_marker) {\n // The old request is never sent after reset. A subsequent explicit\n // invocation prepares a fresh submission and asks for approval again.\n await withImportLock(state, key, dependencies.signal, async () => {\n const current = await readOptionalFile(pendingPath);\n if (\n current !== undefined &&\n sameSubmission(JSON.parse(current) as SavedSubmission, content)\n )\n await rm(pendingPath);\n });\n throw new CloudImportError(\n 409,\n \"The repository was reset after this submission. The saved request was retired without uploading. Review the destination and run the command again to approve a fresh publication.\",\n );\n }\n }\n }\n let requests = saved?.requests;\n if (!requests) {\n for (const finding of parsed.findings) {\n const sourceRepositories = [\n finding.evidence.details?.repository?.url,\n ...(options.provider === \"wiz\"\n ? [wizCsvRepositoryUrl(finding.evidence)]\n : []),\n ...(options.provider === \"snyk\"\n ? snykRepositoryUrls(finding.evidence.source_data, {\n cloudRepositoryUrl: destination.url,\n })\n : []),\n ...(options.provider === \"endor\"\n ? endorRepositoryUrls(finding.evidence.source_data)\n : []),\n options.provider === \"github\"\n ? dependabotRepository(finding)\n : undefined,\n ];\n for (const sourceRepository of sourceRepositories)\n if (\n sourceRepository &&\n cloudRepositoryUrlKey(sourceRepository) !==\n cloudRepositoryUrlKey(destination.url)\n )\n throw new CodexSecurityError(\n `Finding ${JSON.stringify(finding.source_finding_id)} belongs to ${JSON.stringify(sourceRepository)}, which does not match the selected Cloud repository ${JSON.stringify(destination.url)}. Verify the source repository mapping before publishing.`,\n );\n }\n let preparedCount = 0;\n progress({\n phase: \"preparing\",\n completed: 0,\n total: parsed.findings.length,\n });\n const previousReports = await readInBatches(\n parsed.findings,\n async (finding): Promise<SourceReportSummary | undefined> => {\n const query = new URLSearchParams({\n provider: source.provider,\n source_key: source.source_key,\n source_finding_id: finding.source_finding_id,\n limit: \"2\",\n });\n const summaries = validateSourceReports(\n await request(`${sourcePath(destination)}?${query}`),\n );\n if (summaries.has_more || summaries.data.length > 1)\n throw new CodexSecurityError(\n \"Cloud returned more than one report for a source identity.\",\n );\n const previous = summaries.data[0];\n if (\n previous &&\n (previous.source_finding_id !== finding.source_finding_id ||\n previous.source.provider !== source.provider ||\n previous.source.source_key !== source.source_key ||\n previous.repo_id !== destination.id ||\n previous.repo_connector_id !== destination.repo_connector_id)\n )\n throw new CodexSecurityError(\n \"Cloud returned a different source identity.\",\n );\n progress({\n phase: \"preparing\",\n completed: ++preparedCount,\n total: parsed.findings.length,\n });\n return previous;\n },\n );\n requests = [];\n let current: FindingImportRequest | undefined;\n let currentBytes = 0;\n for (const [index, finding] of parsed.findings.entries()) {\n const previous = previousReports[index];\n const environmentId =\n previous?.environment_id ?? destination.import_environment_id;\n if (environmentId == null)\n throw new CodexSecurityError(\n \"Configure an authorized Cloud environment for this repository before importing findings.\",\n );\n const item = {\n client_id: `item-${index + 1}`,\n source_finding_id: finding.source_finding_id,\n expected_version: previous?.version ?? 0,\n evidence: finding.evidence,\n };\n const itemBytes = Buffer.byteLength(JSON.stringify(item));\n if (\n current &&\n (current.repository.environment_id !== environmentId ||\n current.items.length === 100 ||\n currentBytes + 1 + itemBytes > MAX_REQUEST_BYTES)\n ) {\n requests.push(validateImportRequest(current));\n current = undefined;\n }\n if (!current) {\n current = {\n request_id: randomUUID(),\n repository: {\n id: destination.id,\n repo_connector_id: destination.repo_connector_id,\n environment_id: environmentId,\n reset_marker: destination.reset_marker,\n },\n source,\n items: [],\n };\n currentBytes = Buffer.byteLength(JSON.stringify(current));\n } else {\n currentBytes++;\n }\n current.items.push(item);\n currentBytes += itemBytes;\n }\n if (current) requests.push(validateImportRequest(current));\n }\n const submission: SavedSubmission = {\n accountId: credentials.account_id,\n requests,\n receipts: saved?.receipts,\n inputProjection: saved?.inputProjection ?? {\n inputDigest,\n savedEvidenceDigest: hash(\n \"sha256\",\n canonicalJson(submissionFindings(requests)),\n ),\n },\n };\n const preview: ExternalPublicationPreview = {\n ...parsed,\n findings: submissionFindings(requests),\n cloudApiUrl,\n cloudUrl: cloudFindingsUrl(environment, destination.id),\n accountId: credentials.account_id,\n destination,\n source,\n resumed: saved !== undefined,\n requests,\n };\n return {\n preview: structuredClone(preview),\n async publish() {\n progress({ phase: \"waiting\", completed: 0 });\n const result = (\n acknowledged: FindingImportReceipt[],\n verified: number,\n ): ExternalPublicationResult => {\n const counts = { created: 0, updated: 0, unchanged: 0, error: 0 };\n const failures: ExternalPublicationResult[\"failures\"] = [];\n for (const [index, receipt] of acknowledged.entries()) {\n for (const outcome of Object.keys(counts) as (keyof typeof counts)[])\n counts[outcome] += receipt.counts[outcome] ?? 0;\n const ids = new Map(\n requests[index]!.items.map((item) => [\n item.client_id,\n item.source_finding_id,\n ]),\n );\n for (const item of receipt.results)\n if (item.error)\n failures.push({\n source_finding_id: ids.get(item.client_id)!,\n ...item.error,\n });\n }\n return {\n cloudApiUrl,\n cloudUrl: preview.cloudUrl,\n status:\n parsed.excluded.length || counts.error ? \"partial\" : \"complete\",\n read: parsed.read,\n ...(parsed.report === undefined\n ? {}\n : { report: structuredClone(parsed.report) }),\n ready: parsed.findings.length,\n excluded: parsed.excluded,\n receipts: acknowledged,\n counts,\n failures,\n unacknowledged:\n parsed.findings.length -\n Object.values(counts).reduce((sum, count) => sum + count, 0),\n verified,\n };\n };\n let acquired = false;\n return await withImportLock(state, key, dependencies.signal, async () => {\n acquired = true;\n // Re-read under the lock to keep checkpoints from another publisher.\n const pending = await readOptionalFile(pendingPath);\n if (pending === undefined && !saved)\n await rejectUnidentifiedLegacyCheckpoint();\n const current =\n pending === undefined\n ? submission\n : (JSON.parse(pending) as SavedSubmission);\n if (!sameSubmission(current, submission))\n throw new CodexSecurityError(\n \"Another publication prepared this input. Run the command again to review and resume that saved request.\",\n );\n const receipts = (current.receipts ?? []).map(validateImportReceipt);\n if (receipts.length > requests.length)\n throw new CodexSecurityError(\n \"Saved publication has more receipts than requests.\",\n );\n const acknowledged: FindingImportReceipt[] = [];\n let verified = 0;\n let persisted = pending !== undefined;\n try {\n if (pending === undefined) {\n await writeAtomicJson(pendingPath, submission);\n persisted = true;\n }\n progress({\n phase: \"uploading\",\n completed: 0,\n total: parsed.findings.length,\n });\n let acknowledgedCount = 0;\n for (const [batchIndex, batch] of requests.entries()) {\n const receipt = validatePublicationReceipt(\n receipts[batchIndex] ??\n (await request(\"/finding_imports\", batch)),\n batch,\n );\n acknowledged.push(receipt);\n acknowledgedCount += receipt.item_count;\n progress({\n phase: \"uploading\",\n completed: acknowledgedCount,\n total: parsed.findings.length,\n });\n if (batchIndex === receipts.length) {\n receipts.push(receipt);\n // Acknowledged batches must not consume another POST quota on retry.\n // Readback can still resume after this checkpoint without replaying writes.\n await writeAtomicJson(pendingPath, {\n ...submission,\n receipts,\n });\n }\n }\n // Verify readable source records without mistaking a newer concurrent\n // observation for failure of the original, immutable import receipt.\n const readbacks = receipts.flatMap((receipt, batchIndex) => {\n const batch = requests[batchIndex]!;\n const batchItems = new Map(\n batch.items.map((item) => [item.client_id, item]),\n );\n return receipt.results\n .filter((item) => item.outcome !== \"error\")\n .map((item) => ({\n item,\n expected: batchItems.get(item.client_id)!,\n batch,\n }));\n });\n progress({\n phase: \"verifying\",\n completed: 0,\n total: readbacks.length,\n });\n await readInBatches(readbacks, async ({ item, expected, batch }) => {\n const report = validateSourceReport(\n await request(\n `${sourcePath(destination)}/${encodeURIComponent(item.source_report_id!)}`,\n ),\n );\n if (\n report.id !== item.source_report_id ||\n report.canonical_finding_id !== item.canonical_finding_id ||\n report.version < item.version! ||\n (report.version === item.version &&\n (report.observation_id !== item.observation_id ||\n canonicalJson(report.evidence) !==\n canonicalJson(expected.evidence))) ||\n report.source_finding_id !== expected.source_finding_id ||\n report.repo_id !== destination.id ||\n report.repo_connector_id !== destination.repo_connector_id ||\n report.environment_id !== batch.repository.environment_id ||\n canonicalJson(report.source) !== canonicalJson(source)\n )\n throw new CodexSecurityError(\n \"Cloud readback did not match the saved finding identity.\",\n );\n progress({\n phase: \"verifying\",\n completed: ++verified,\n total: readbacks.length,\n });\n });\n const completed = result(acknowledged, verified);\n await writeAtomicJson(join(state, `${key}.result.json`), {\n ...completed,\n report: reportForJson(completed.report),\n });\n await rm(pendingPath, { force: true });\n return completed;\n } catch (error) {\n if (error instanceof CloudImportError && error.status === 409) {\n await rm(pendingPath, { force: true });\n persisted = false;\n }\n const message = `${error instanceof Error ? error.message : String(error)} ${error instanceof CloudImportError && error.status === 409 ? \"The old submission was retired. Rediscover and approve a fresh publication.\" : persisted ? `Repeat the same command to resume the saved request. Saved submission: ${pendingPath}` : \"No resumable request was saved. Correct the error and review the input before retrying.\"}`;\n throw new ExternalPublicationError(\n message,\n {\n ...result(acknowledged, verified),\n status: \"interrupted\",\n error: message,\n ...(persisted ? { savedSubmission: pendingPath } : {}),\n },\n error,\n );\n }\n }).catch((error: unknown) => {\n if (acquired || !dependencies.signal?.aborted) throw error;\n // The active publisher owns the checkpoint. Report only acknowledgements\n // already observed during preparation, without rewriting its files.\n const known = submission.receipts ?? [];\n if (known.length > requests.length)\n throw new CodexSecurityError(\n \"Saved publication has more receipts than requests.\",\n );\n const acknowledged = known.map((receipt, index) =>\n validatePublicationReceipt(receipt, requests[index]!),\n );\n const message = saved\n ? `Publication canceled while waiting. Repeat the same command to resume the saved request. Saved submission: ${pendingPath}`\n : \"Publication canceled while waiting. No resumable request was saved by this invocation.\";\n throw new ExternalPublicationError(\n message,\n {\n ...result(acknowledged, 0),\n status: \"interrupted\",\n error: message,\n ...(saved ? { savedSubmission: pendingPath } : {}),\n },\n error,\n );\n });\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-advisories.d.ts","sourceRoot":"","sources":["../src/github-advisories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"github-advisories.d.ts","sourceRoot":"","sources":["../src/github-advisories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAS7C,eAAO,MAAM,sBAAsB,YACjC,WAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAQ,CACA,CAAC;AAEX,MAAM,WAAW,2BAA2B;IAC1C,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,CAAC,OAAO,sBAAsB,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