@openai/codex-security 0.8.1 → 0.8.2
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 -2
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +0 -17
- package/_bundled_plugin/scripts/workbench_db.py +1 -3
- package/_bundled_plugin/scripts/workbench_saved_results.py +0 -66
- package/_bundled_plugin/scripts/workbench_target.py +0 -108
- package/_bundled_plugin/skills/publish-findings/SKILL.md +4 -0
- package/_bundled_plugin/skills/resolve-dependency-alert/SKILL.md +18 -0
- package/_bundled_plugin/skills/resolve-dependency-alert/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model-visualize/SKILL.md +83 -0
- package/_bundled_plugin/skills/threat-model-visualize/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-overview.svg +366 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-path.svg +558 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/control-effects.js +85 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.css +17 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.html +38 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.js +372 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/route-paths.js +71 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/source-roles.js +47 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/svg-layout.js +149 -0
- package/_bundled_plugin/skills/threat-model-visualize/references/context-explorer.md +21 -0
- package/_bundled_plugin/skills/threat-model-visualize/references/view-model.md +49 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +563 -0
- package/dist/api.js +3 -3
- package/dist/api.js.map +1 -1
- package/dist/auth.js +1 -1
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -8
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -4
- package/dist/contract.js.map +1 -1
- package/dist/custom-validation.js +2 -2
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +1 -1
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +36 -22
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +3 -1
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +12 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +46 -61
- package/dist/endor-findings.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +8 -6
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +3 -1
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +117 -36
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +3 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +51 -27
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +2 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +9 -0
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +11 -0
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +13 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/host-protocol.d.ts +5 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +27 -3
- package/dist/host-protocol.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/inspector-findings.d.ts +9 -0
- package/dist/inspector-findings.d.ts.map +1 -0
- package/dist/inspector-findings.js +517 -0
- package/dist/inspector-findings.js.map +1 -0
- package/dist/patch-tui.d.ts +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +4 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +15 -5
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +25 -15
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scanner-import.d.ts +6 -1
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +14 -5
- package/dist/scanner-import.js.map +1 -1
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +39 -49
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +78 -88
- package/dist/snyk-findings.js.map +1 -1
- package/docs/cli.md +14 -8
- package/docs/dedupe-records.md +17 -4
- package/package.json +3 -3
- package/schemas/external-findings.schema.json +1 -1
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { cloudRepositoryUrlKey, repositoryUrlKey, } from "./external-import-contract.js";
|
|
2
2
|
import { EXTERNAL_FINDINGS_PROVIDERS, readExternalFindings, } from "./external-findings-read.js";
|
|
3
|
-
import {
|
|
3
|
+
import { prepareLocalImport, } from "./external-findings-local.js";
|
|
4
|
+
import { snapshotImportOptions } from "./external-findings.js";
|
|
4
5
|
import { abortable } from "./targets.js";
|
|
5
6
|
import { requireExternalImports } from "./external-imports-feature.js";
|
|
6
7
|
/** Read an installed vendor format and prepare it for the local workbench. */
|
|
7
8
|
export async function prepareLocalExternalImport(path, options, dependencies = {}) {
|
|
8
9
|
dependencies.signal?.throwIfAborted();
|
|
9
10
|
requireExternalImports(dependencies.environment);
|
|
10
|
-
const
|
|
11
|
+
const settings = snapshotImportOptions(options);
|
|
12
|
+
const parsed = await abortable(() => readExternalFindings(path, settings, "local"), dependencies.signal);
|
|
11
13
|
const normalizedOptions = {
|
|
12
|
-
...
|
|
13
|
-
provider: EXTERNAL_FINDINGS_PROVIDERS[
|
|
14
|
+
...settings,
|
|
15
|
+
provider: EXTERNAL_FINDINGS_PROVIDERS[settings.provider],
|
|
14
16
|
};
|
|
15
17
|
let sourceRepositories = parsed.sourceRepositories ?? [];
|
|
16
18
|
if (normalizedOptions.provider === "semgrep") {
|
|
17
19
|
// The Cloud reader allows custom GitHub casing. Local provenance must also
|
|
18
20
|
// agree with the caller's source URL when the checkout has no remote.
|
|
19
|
-
const source =
|
|
21
|
+
const source = settings.sourceRepositoryUrl;
|
|
20
22
|
const knownGitHub = dependencies.sourceRepositories?.some(({ url, platform }) => platform === "github" &&
|
|
21
23
|
cloudRepositoryUrlKey(url) === cloudRepositoryUrlKey(source));
|
|
22
24
|
const key = knownGitHub ? cloudRepositoryUrlKey : repositoryUrlKey;
|
|
@@ -34,7 +36,7 @@ export async function prepareLocalExternalImport(path, options, dependencies = {
|
|
|
34
36
|
];
|
|
35
37
|
}
|
|
36
38
|
const { environment, ...workbench } = dependencies;
|
|
37
|
-
return
|
|
39
|
+
return prepareLocalImport(parsed.findings, normalizedOptions, {
|
|
38
40
|
...workbench,
|
|
39
41
|
environment,
|
|
40
42
|
sourceRepositories: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-import.js","sourceRoot":"","sources":["../src/external-findings-import.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"external-findings-import.js","sourceRoot":"","sources":["../src/external-findings-import.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,IAAY,EACZ,OAAmC,EACnC,YAAY,GAAoC,EAAE;IAElD,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACtC,sBAAsB,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,SAAS,CAC5B,GAAG,EAAE,CAAC,oBAAoB,CAAC,IAAI,EA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B,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE;QAC5D,GAAG,SAAS;QACZ,WAAW;QACX,kBAAkB,EAAE;YAClB,GAAG,CAAC,YAAY,CAAC,kBAAkB,IAAI,EAAE,CAAC;YAC1C,GAAG,kBAAkB;SACtB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ExternalPublicationOptions } from \"./external-findings-publish.js\";\nimport {\n cloudRepositoryUrlKey,\n repositoryUrlKey,\n} from \"./external-import-contract.js\";\nimport {\n EXTERNAL_FINDINGS_PROVIDERS,\n readExternalFindings,\n} from \"./external-findings-read.js\";\nimport {\n prepareLocalImport,\n type LocalExternalImportDependencies,\n} from \"./external-findings-local.js\";\nimport { snapshotImportOptions } from \"./external-findings.js\";\nimport { abortable } from \"./targets.js\";\nimport { requireExternalImports } from \"./external-imports-feature.js\";\n\n/** Read an installed vendor format and prepare it for the local workbench. */\nexport async function prepareLocalExternalImport(\n path: string,\n options: ExternalPublicationOptions,\n dependencies: LocalExternalImportDependencies = {},\n) {\n dependencies.signal?.throwIfAborted();\n requireExternalImports(dependencies.environment);\n const settings = snapshotImportOptions(options);\n const parsed = await abortable(\n () => readExternalFindings(path, settings, \"local\"),\n dependencies.signal,\n );\n const normalizedOptions = {\n ...settings,\n provider: EXTERNAL_FINDINGS_PROVIDERS[settings.provider],\n };\n let sourceRepositories = parsed.sourceRepositories ?? [];\n if (normalizedOptions.provider === \"semgrep\") {\n // The Cloud reader allows custom GitHub casing. Local provenance must also\n // agree with the caller's source URL when the checkout has no remote.\n const source = settings.sourceRepositoryUrl!;\n const knownGitHub = dependencies.sourceRepositories?.some(\n ({ url, platform }) =>\n platform === \"github\" &&\n cloudRepositoryUrlKey(url) === cloudRepositoryUrlKey(source),\n );\n const key = knownGitHub ? cloudRepositoryUrlKey : repositoryUrlKey;\n for (const reference of sourceRepositories) {\n if (key(reference.url) !== key(source))\n throw new Error(\n \"SARIF source repository does not match the declared source repository URL.\",\n );\n }\n if (knownGitHub)\n sourceRepositories = [\n { url: source, platform: \"github\" },\n ...sourceRepositories.map((reference) => ({\n ...reference,\n platform: \"github\" as const,\n })),\n ];\n }\n const { environment, ...workbench } = dependencies;\n return prepareLocalImport(parsed.findings, normalizedOptions, {\n ...workbench,\n environment,\n sourceRepositories: [\n ...(dependencies.sourceRepositories ?? []),\n ...sourceRepositories,\n ],\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExternalFindings, type ExternalSourceRepository } from "./external-findings.js";
|
|
2
2
|
import type { ExternalFindingEvidence, Provider } from "./external-import-models.js";
|
|
3
3
|
import { runWorkbench } from "./runtime.js";
|
|
4
4
|
/** A scanner source record, independent of a Codex assessment or completed scan. */
|
|
@@ -22,6 +22,8 @@ export interface NormalizedLocalImportOptions {
|
|
|
22
22
|
provider: Provider;
|
|
23
23
|
/** Stable scanner organization/project/branch namespace across imports. */
|
|
24
24
|
sourceKey: string;
|
|
25
|
+
/** Full Inspector project ARNs mapped to independently verified repository URLs. */
|
|
26
|
+
inspectorProjectMap?: ReadonlyMap<string, string>;
|
|
25
27
|
}
|
|
26
28
|
export interface LocalExternalImportDependencies {
|
|
27
29
|
environment?: NodeJS.ProcessEnv;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-findings-local.d.ts","sourceRoot":"","sources":["../src/external-findings-local.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"external-findings-local.d.ts","sourceRoot":"","sources":["../src/external-findings-local.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAMhC,OAAO,KAAK,EACV,uBAAuB,EACvB,QAAQ,EACT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAML,YAAY,EAGb,MAAM,cAAc,CAAC;AAUtB,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,EA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IAClC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,0BAA0B,CAAC;IACpC,MAAM,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAC9C;AAwdD,0FAA0F;AAC1F,wBAAsB,4BAA4B,CAChD,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,4BAA4B,EACrC,YAAY,GAAE,+BAAoC,GACjD,OAAO,CAAC,2BAA2B,CAAC,CAQtC;AAkKD,4FAA4F;AAC5F,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9C,YAAY,GAAE,+BAAoC,GACjD,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAkBlC"}
|
|
@@ -4,8 +4,10 @@ import { isNumberObject } from "node:util/types";
|
|
|
4
4
|
import { environmentEntry } from "./auth.js";
|
|
5
5
|
import { CodexSecurityError } from "./errors.js";
|
|
6
6
|
import { forwardExternalImportSetting, requireExternalImports, } from "./external-imports-feature.js";
|
|
7
|
+
import { snapshotImportOptions, } from "./external-findings.js";
|
|
7
8
|
import { cloudRepositoryUrlKey, repositoryUrlKey, validateExternalReport, } from "./external-import-contract.js";
|
|
8
|
-
import { parseGitRemote } from "./git-remote.js";
|
|
9
|
+
import { isGitHubCloudHost, parseGitRemote } from "./git-remote.js";
|
|
10
|
+
import { inspectorReportRepository } from "./inspector-findings.js";
|
|
9
11
|
import { isRecord } from "./record.js";
|
|
10
12
|
import { dependabotRepository } from "./github-dependabot-findings.js";
|
|
11
13
|
import { bundledPluginRoot, canonicalConfigPath, canonicalizeModelSafePath, expandHome, requireOutputOutsideRepositories, runWorkbench, workbenchEnvironment, } from "./runtime.js";
|
|
@@ -14,47 +16,104 @@ function requireIdentity(value, field) {
|
|
|
14
16
|
if (typeof value !== "string" || !value.trim() || value.includes("\0"))
|
|
15
17
|
throw new CodexSecurityError(`${field} must be nonempty and contain no NUL characters.`);
|
|
16
18
|
}
|
|
19
|
+
const gitTransportPorts = {
|
|
20
|
+
"http:": "80",
|
|
21
|
+
"https:": "443",
|
|
22
|
+
"ssh:": "22",
|
|
23
|
+
"git+ssh:": "22",
|
|
24
|
+
"ssh+git:": "22",
|
|
25
|
+
"git:": "9418",
|
|
26
|
+
"ftp:": "21",
|
|
27
|
+
"ftps:": "990",
|
|
28
|
+
};
|
|
17
29
|
/** Compare transport forms without changing retained scanner evidence. */
|
|
18
|
-
function
|
|
30
|
+
function remoteRepository(value, provider, bound) {
|
|
19
31
|
if (/^[A-Za-z]:[\\/]/u.test(value))
|
|
20
32
|
return undefined;
|
|
33
|
+
const transport = bound
|
|
34
|
+
? /^(?:ssh|git\+ssh|ssh\+git|git):\/\/([^/]*)(.*)$/isu.exec(value)
|
|
35
|
+
: null;
|
|
36
|
+
const authority = transport?.[1];
|
|
37
|
+
const http = bound && /^https?:\/\//iu.test(value.trimStart());
|
|
38
|
+
// Git decodes the authority before locating its path. An encoded delimiter
|
|
39
|
+
// cannot prove a match to another spelling through WHATWG URL's hostname.
|
|
40
|
+
if (authority &&
|
|
41
|
+
(/%2f|[?#]/iu.test(authority) ||
|
|
42
|
+
authority.slice(authority.lastIndexOf("@") + 1).includes("%")))
|
|
43
|
+
return { key: value };
|
|
21
44
|
let remote;
|
|
22
45
|
try {
|
|
23
46
|
remote = parseGitRemote(value);
|
|
24
47
|
}
|
|
25
48
|
catch {
|
|
26
|
-
return undefined;
|
|
49
|
+
return transport || http ? { key: "\0" + value } : undefined;
|
|
27
50
|
}
|
|
28
|
-
if (!remote ||
|
|
29
|
-
![
|
|
30
|
-
"http:",
|
|
31
|
-
"https:",
|
|
32
|
-
"ssh:",
|
|
33
|
-
"git:",
|
|
34
|
-
"ftp:",
|
|
35
|
-
"ftps:",
|
|
36
|
-
"git+ssh:",
|
|
37
|
-
"ssh+git:",
|
|
38
|
-
].includes(remote.url.protocol))
|
|
51
|
+
if (!remote || !Object.hasOwn(gitTransportPorts, remote.url.protocol))
|
|
39
52
|
return undefined;
|
|
40
|
-
const url = remote
|
|
41
|
-
const ssh =
|
|
53
|
+
const { url, path, scpStyle } = remote;
|
|
54
|
+
const ssh = url.protocol.includes("ssh");
|
|
42
55
|
const protocol = url.protocol === "http:" ? "http:" : "https:";
|
|
43
56
|
const githubSshOverHttps = ssh &&
|
|
44
57
|
url.hostname.toLowerCase() === "ssh.github.com" &&
|
|
45
58
|
url.port === "443";
|
|
46
59
|
const hostname = githubSshOverHttps ? "github.com" : url.hostname;
|
|
47
|
-
const port = githubSshOverHttps ||
|
|
48
|
-
(ssh && url.port === "22") ||
|
|
49
|
-
(url.protocol === "git:" && url.port === "9418") ||
|
|
50
|
-
(url.protocol === "ftp:" && url.port === "21") ||
|
|
51
|
-
(url.protocol === "ftps:" && url.port === "990")
|
|
60
|
+
const port = githubSshOverHttps || url.port === gitTransportPorts[url.protocol]
|
|
52
61
|
? ""
|
|
53
62
|
: url.port;
|
|
54
63
|
// A GitHub source identifies a case-insensitive repository on custom Enterprise
|
|
55
64
|
// hosts too; other providers can refer to VCS hosts with case-sensitive paths.
|
|
56
65
|
const key = provider === "github" ? cloudRepositoryUrlKey : repositoryUrlKey;
|
|
57
|
-
|
|
66
|
+
const origin = `${protocol}//${hostname}${port ? `:${port}` : ""}/`;
|
|
67
|
+
if (!bound)
|
|
68
|
+
return { key: key(origin + path) };
|
|
69
|
+
if (!ssh && url.protocol !== "git:") {
|
|
70
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
71
|
+
// libcurl and WHATWG differ on backslashes and encoded dot segments.
|
|
72
|
+
const raw = /^https?:\/\/[^/\\?#\s]+(\/[^\\?#]*)?(?:[?#].*)?$/iu.exec(value);
|
|
73
|
+
if (!raw || /\/(?:%2e|\.%2e|%2e\.|%2e%2e)(?:\/|$)/iu.test(raw[1] ?? ""))
|
|
74
|
+
return { key: "\0" + value };
|
|
75
|
+
}
|
|
76
|
+
const suffix = /[?#].*$/su.exec(value)?.[0] ?? "";
|
|
77
|
+
// HTTP sends the query and omits fragment text from repository requests.
|
|
78
|
+
if (suffix && !["http:", "https:"].includes(url.protocol))
|
|
79
|
+
return { key: key(origin + path) + "\0" };
|
|
80
|
+
return {
|
|
81
|
+
key: key(origin + path) + suffix.replace(/#.*$/su, "#").replace(/\/$/u, ""),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Git passes the original path (including dot segments, '?' and '#') to upload-pack.
|
|
85
|
+
const literal = (raw) => {
|
|
86
|
+
const bytes = Buffer.from(raw).toString("latin1");
|
|
87
|
+
return scpStyle
|
|
88
|
+
? bytes
|
|
89
|
+
: bytes.replace(/%(?!00)([\da-f]{2})/giu, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
90
|
+
};
|
|
91
|
+
if (!scpStyle && !transport)
|
|
92
|
+
return { key: value };
|
|
93
|
+
const gitPath = literal(transport?.[2] ?? path);
|
|
94
|
+
const login = scpStyle
|
|
95
|
+
? /^([^@/:\s?#]+)@/u.exec(value)?.[1]
|
|
96
|
+
: /^(.*)@/u.exec(authority ?? "")?.[1];
|
|
97
|
+
const homeRelative = /^\/?~(?:\/|$)/u.test(gitPath) || (scpStyle && !/^[~/]/u.test(gitPath));
|
|
98
|
+
const suffix = /[?#].*$/su.exec(gitPath);
|
|
99
|
+
// Express upload-pack bytes as a URL path for comparison with the HTTP source.
|
|
100
|
+
const name = gitPath
|
|
101
|
+
.slice(0, suffix?.index)
|
|
102
|
+
.replace(/^\//u, "")
|
|
103
|
+
.replace(/[%\x00-\x20\x7f-\xff]/gu, (byte) => "%" + byte.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0"));
|
|
104
|
+
const repository = suffix
|
|
105
|
+
? key(origin + name + "?") +
|
|
106
|
+
"\0" +
|
|
107
|
+
suffix[0].replace(/\/$/u, "").replace(/\.git$/u, "")
|
|
108
|
+
: key(origin + name);
|
|
109
|
+
return {
|
|
110
|
+
key: repository,
|
|
111
|
+
account: ssh && login ? literal(login) : undefined,
|
|
112
|
+
// GitHub serves the same repository path through its SCP and SSH URLs.
|
|
113
|
+
homeRelative: ssh && provider !== "github" && !isGitHubCloudHost(hostname.toLowerCase())
|
|
114
|
+
? homeRelative
|
|
115
|
+
: undefined,
|
|
116
|
+
};
|
|
58
117
|
}
|
|
59
118
|
async function bareMetadataRoots(repository, signal) {
|
|
60
119
|
const roots = [];
|
|
@@ -205,26 +264,32 @@ async function requireMatchingRepository(repository, provider, sources, protecte
|
|
|
205
264
|
const urls = await readGit(["remote", "get-url", "--all", "--", name]);
|
|
206
265
|
remotes.push(...urls.split(/\r?\n/u));
|
|
207
266
|
}
|
|
267
|
+
const identity = (value, platform) => remoteRepository(value, platform, provider === "inspector");
|
|
208
268
|
const githubRepositories = new Set(sources.flatMap((source) => {
|
|
209
269
|
if (source.platform !== "github")
|
|
210
270
|
return [];
|
|
211
|
-
const key =
|
|
271
|
+
const key = identity(source.url, "github")?.key;
|
|
212
272
|
return key === undefined ? [] : [key];
|
|
213
273
|
}));
|
|
214
274
|
for (const source of sources) {
|
|
215
|
-
const githubKey =
|
|
275
|
+
const githubKey = identity(source.url, "github")?.key;
|
|
216
276
|
const sourceProvider = source.platform === "github" ||
|
|
217
277
|
(githubKey !== undefined && githubRepositories.has(githubKey))
|
|
218
278
|
? "github"
|
|
219
279
|
: provider;
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
return key === undefined ? [] : [key];
|
|
223
|
-
}));
|
|
224
|
-
if (remoteKeys.size === 0)
|
|
280
|
+
const targets = remotes.flatMap((remote) => identity(remote, sourceProvider) ?? []);
|
|
281
|
+
if (!targets.length)
|
|
225
282
|
continue;
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
283
|
+
const target = identity(source.url, sourceProvider);
|
|
284
|
+
if (!target ||
|
|
285
|
+
!targets.some(({ key, account, homeRelative }) => key === target.key &&
|
|
286
|
+
(homeRelative === undefined ||
|
|
287
|
+
target.homeRelative === undefined ||
|
|
288
|
+
homeRelative === target.homeRelative) &&
|
|
289
|
+
((homeRelative === false && target.homeRelative === false) ||
|
|
290
|
+
account === undefined ||
|
|
291
|
+
target.account === undefined ||
|
|
292
|
+
account === target.account)))
|
|
228
293
|
throw new CodexSecurityError(`Imported repository ${JSON.stringify(source.url)} does not match a configured remote of ${repository}. Select the matching local repository.`);
|
|
229
294
|
}
|
|
230
295
|
}
|
|
@@ -261,6 +326,10 @@ async function localContext(selectedRepository, dependencies, mode = "import") {
|
|
|
261
326
|
export async function prepareNormalizedLocalImport(input, options, dependencies = {}) {
|
|
262
327
|
dependencies.signal?.throwIfAborted();
|
|
263
328
|
requireExternalImports(dependencies.environment);
|
|
329
|
+
return prepareLocalImport(input, snapshotImportOptions(options), dependencies);
|
|
330
|
+
}
|
|
331
|
+
/** @internal Prepare evidence using settings captured by either local import entrypoint. */
|
|
332
|
+
export async function prepareLocalImport(input, options, dependencies) {
|
|
264
333
|
requireIdentity(options.sourceKey, "Source key");
|
|
265
334
|
const current = structuredClone(input);
|
|
266
335
|
validateExternalReport(current.report);
|
|
@@ -288,15 +357,27 @@ export async function prepareNormalizedLocalImport(input, options, dependencies
|
|
|
288
357
|
}
|
|
289
358
|
const { repository, options: workbenchOptions } = await localContext(options.repository, dependencies);
|
|
290
359
|
const sources = new Map();
|
|
291
|
-
for (const
|
|
292
|
-
const url = evidence.details?.repository?.url;
|
|
360
|
+
for (const finding of current.findings) {
|
|
361
|
+
const url = finding.evidence.details?.repository?.url;
|
|
293
362
|
if (url)
|
|
294
363
|
sources.set(url, { url });
|
|
295
364
|
}
|
|
296
|
-
|
|
297
|
-
|
|
365
|
+
const inspector = inspectorReportRepository(options.provider, current.findings, "local", options.inspectorProjectMap);
|
|
366
|
+
if (inspector) {
|
|
367
|
+
const platform = inspector.platform ?? options.provider;
|
|
368
|
+
const native = remoteRepository(inspector.url, platform, true);
|
|
369
|
+
for (const url of sources.keys()) {
|
|
370
|
+
if (!native || remoteRepository(url, platform, true)?.key !== native.key)
|
|
371
|
+
throw new CodexSecurityError(`Imported repository ${JSON.stringify(url)} does not match the retained Inspector repository ${JSON.stringify(inspector.url)}.`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
for (const source of [
|
|
375
|
+
...(inspector ? [inspector] : []),
|
|
376
|
+
...(dependencies.sourceRepositories ?? []),
|
|
377
|
+
]) {
|
|
378
|
+
// A reader's platform must not loosen an operator-supplied Inspector map.
|
|
298
379
|
if (sources.get(source.url)?.platform !== "github")
|
|
299
|
-
sources.set(source.url, source);
|
|
380
|
+
sources.set(source.url, options.inspectorProjectMap ? { url: source.url } : source);
|
|
300
381
|
}
|
|
301
382
|
if (dependabotSource)
|
|
302
383
|
sources.set(dependabotSource, {
|
|
@@ -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;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,CAA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AAe,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IAC5E,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,YAAY,CAChD,SAAS,CAAC,UAAU,EACpB,YAAY,EACZ,MAAM,CACP,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE;QAClC,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACtC,OAAO,CAAC,YAAY,CAAC,YAAY,IAAI,YAAY,CAAC,CAChD,OAAO,EACP,CAAC,wBAAwB,CAAC,EAC1B,IAAI,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 { 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
|
+
{"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,W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AAE,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAC9B,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC3C,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAuC;gBAClE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAwC;aAChE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,SAA8C,EAC9C,YAAY,GAAoC,EAAE;IAElD,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACtC,sBAAsB,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS;QAAE,eAAe,CAAC,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IAC5E,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,YAAY,CAChD,SAAS,CAAC,UAAU,EACpB,YAAY,EACZ,MAAM,CACP,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE;QAClC,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACtC,OAAO,CAAC,YAAY,CAAC,YAAY,IAAI,YAAY,CAAC,CAChD,OAAO,EACP,CAAC,wBAAwB,CAAC,EAC1B,IAAI,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 {\n snapshotImportOptions,\n type ExternalFindings,\n type 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 { isGitHubCloudHost, parseGitRemote } from \"./git-remote.js\";\nimport { inspectorReportRepository } from \"./inspector-findings.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 /** Full Inspector project ARNs mapped to independently verified repository URLs. */\n inspectorProjectMap?: ReadonlyMap<string, 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\nconst gitTransportPorts: Readonly<Record<string, string>> = {\n \"http:\": \"80\",\n \"https:\": \"443\",\n \"ssh:\": \"22\",\n \"git+ssh:\": \"22\",\n \"ssh+git:\": \"22\",\n \"git:\": \"9418\",\n \"ftp:\": \"21\",\n \"ftps:\": \"990\",\n};\n\n/** Compare transport forms without changing retained scanner evidence. */\nfunction remoteRepository(\n value: string,\n provider: Provider,\n bound: boolean,\n): { key: string; account?: string; homeRelative?: boolean } | undefined {\n if (/^[A-Za-z]:[\\\\/]/u.test(value)) return undefined;\n const transport = bound\n ? /^(?:ssh|git\\+ssh|ssh\\+git|git):\\/\\/([^/]*)(.*)$/isu.exec(value)\n : null;\n const authority = transport?.[1];\n const http = bound && /^https?:\\/\\//iu.test(value.trimStart());\n // Git decodes the authority before locating its path. An encoded delimiter\n // cannot prove a match to another spelling through WHATWG URL's hostname.\n if (\n authority &&\n (/%2f|[?#]/iu.test(authority) ||\n authority.slice(authority.lastIndexOf(\"@\") + 1).includes(\"%\"))\n )\n return { key: value };\n let remote;\n try {\n remote = parseGitRemote(value);\n } catch {\n return transport || http ? { key: \"\\0\" + value } : undefined;\n }\n if (!remote || !Object.hasOwn(gitTransportPorts, remote.url.protocol))\n return undefined;\n const { url, path, scpStyle } = remote;\n const ssh = url.protocol.includes(\"ssh\");\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 || url.port === gitTransportPorts[url.protocol]\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 const origin = `${protocol}//${hostname}${port ? `:${port}` : \"\"}/`;\n if (!bound) return { key: key(origin + path) };\n\n if (!ssh && url.protocol !== \"git:\") {\n if (url.protocol === \"http:\" || url.protocol === \"https:\") {\n // libcurl and WHATWG differ on backslashes and encoded dot segments.\n const raw = /^https?:\\/\\/[^/\\\\?#\\s]+(\\/[^\\\\?#]*)?(?:[?#].*)?$/iu.exec(\n value,\n );\n if (!raw || /\\/(?:%2e|\\.%2e|%2e\\.|%2e%2e)(?:\\/|$)/iu.test(raw[1] ?? \"\"))\n return { key: \"\\0\" + value };\n }\n const suffix = /[?#].*$/su.exec(value)?.[0] ?? \"\";\n // HTTP sends the query and omits fragment text from repository requests.\n if (suffix && ![\"http:\", \"https:\"].includes(url.protocol))\n return { key: key(origin + path) + \"\\0\" };\n return {\n key:\n key(origin + path) + suffix.replace(/#.*$/su, \"#\").replace(/\\/$/u, \"\"),\n };\n }\n\n // Git passes the original path (including dot segments, '?' and '#') to upload-pack.\n const literal = (raw: string) => {\n const bytes = Buffer.from(raw).toString(\"latin1\");\n return scpStyle\n ? bytes\n : bytes.replace(/%(?!00)([\\da-f]{2})/giu, (_, hex: string) =>\n String.fromCharCode(parseInt(hex, 16)),\n );\n };\n if (!scpStyle && !transport) return { key: value };\n const gitPath = literal(transport?.[2] ?? path);\n const login = scpStyle\n ? /^([^@/:\\s?#]+)@/u.exec(value)?.[1]\n : /^(.*)@/u.exec(authority ?? \"\")?.[1];\n const homeRelative =\n /^\\/?~(?:\\/|$)/u.test(gitPath) || (scpStyle && !/^[~/]/u.test(gitPath));\n const suffix = /[?#].*$/su.exec(gitPath);\n // Express upload-pack bytes as a URL path for comparison with the HTTP source.\n const name = gitPath\n .slice(0, suffix?.index)\n .replace(/^\\//u, \"\")\n .replace(\n /[%\\x00-\\x20\\x7f-\\xff]/gu,\n (byte) =>\n \"%\" + byte.charCodeAt(0).toString(16).toUpperCase().padStart(2, \"0\"),\n );\n const repository = suffix\n ? key(origin + name + \"?\") +\n \"\\0\" +\n suffix[0].replace(/\\/$/u, \"\").replace(/\\.git$/u, \"\")\n : key(origin + name);\n return {\n key: repository,\n account: ssh && login ? literal(login) : undefined,\n // GitHub serves the same repository path through its SCP and SSH URLs.\n homeRelative:\n ssh && provider !== \"github\" && !isGitHubCloudHost(hostname.toLowerCase())\n ? homeRelative\n : undefined,\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 identity = (value: string, platform: Provider) =>\n remoteRepository(value, platform, provider === \"inspector\");\n const githubRepositories = new Set(\n sources.flatMap((source) => {\n if (source.platform !== \"github\") return [];\n const key = identity(source.url, \"github\")?.key;\n return key === undefined ? [] : [key];\n }),\n );\n for (const source of sources) {\n const githubKey = identity(source.url, \"github\")?.key;\n const sourceProvider =\n source.platform === \"github\" ||\n (githubKey !== undefined && githubRepositories.has(githubKey))\n ? \"github\"\n : provider;\n const targets = remotes.flatMap(\n (remote) => identity(remote, sourceProvider) ?? [],\n );\n if (!targets.length) continue;\n const target = identity(source.url, sourceProvider);\n if (\n !target ||\n !targets.some(\n ({ key, account, homeRelative }) =>\n key === target.key &&\n (homeRelative === undefined ||\n target.homeRelative === undefined ||\n homeRelative === target.homeRelative) &&\n ((homeRelative === false && target.homeRelative === false) ||\n account === undefined ||\n target.account === undefined ||\n account === target.account),\n )\n )\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 return prepareLocalImport(\n input,\n snapshotImportOptions(options),\n dependencies,\n );\n}\n\n/** @internal Prepare evidence using settings captured by either local import entrypoint. */\nexport async function prepareLocalImport(\n input: ExternalFindings,\n options: NormalizedLocalImportOptions,\n dependencies: LocalExternalImportDependencies,\n): Promise<PreparedLocalExternalImport> {\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 finding of current.findings) {\n const url = finding.evidence.details?.repository?.url;\n if (url) sources.set(url, { url });\n }\n const inspector = inspectorReportRepository(\n options.provider,\n current.findings,\n \"local\",\n options.inspectorProjectMap,\n );\n if (inspector) {\n const platform = inspector.platform ?? options.provider;\n const native = remoteRepository(inspector.url, platform, true);\n for (const url of sources.keys()) {\n if (!native || remoteRepository(url, platform, true)?.key !== native.key)\n throw new CodexSecurityError(\n `Imported repository ${JSON.stringify(url)} does not match the retained Inspector repository ${JSON.stringify(inspector.url)}.`,\n );\n }\n }\n for (const source of [\n ...(inspector ? [inspector] : []),\n ...(dependencies.sourceRepositories ?? []),\n ]) {\n // A reader's platform must not loosen an operator-supplied Inspector map.\n if (sources.get(source.url)?.platform !== \"github\")\n sources.set(\n source.url,\n options.inspectorProjectMap ? { url: source.url } : source,\n );\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,12 +1,14 @@
|
|
|
1
1
|
import { CodexSecurityError } from "./errors.js";
|
|
2
2
|
import { type ExternalFindingsReaderOptions } from "./external-findings-read.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type ExternalFindings } from "./external-findings.js";
|
|
4
4
|
import type { FindingImportRequest, FindingImportReceipt, ImportRepository } from "./external-import-models.js";
|
|
5
5
|
/** Source and destination for evidence already normalized to the Cloud contract. */
|
|
6
6
|
export interface NormalizedExternalPublicationOptions {
|
|
7
7
|
repository: string;
|
|
8
8
|
provider: FindingImportRequest["source"]["provider"];
|
|
9
9
|
sourceKey: string;
|
|
10
|
+
/** Full Inspector project ARNs mapped to independently verified repository URLs. */
|
|
11
|
+
inspectorProjectMap?: ReadonlyMap<string, string>;
|
|
10
12
|
}
|
|
11
13
|
/** File readers accept the vendor formats installed in this SDK. */
|
|
12
14
|
export interface ExternalPublicationOptions extends Omit<NormalizedExternalPublicationOptions, "provider"> {
|
|
@@ -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;AAOrC,OAAO,EAEL,KAAK,gBAAgB,EA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