@openai/codex-security 0.10.0 → 0.10.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.
Files changed (130) hide show
  1. package/_bundled_plugin/.mcp.json +1 -0
  2. package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
  3. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  4. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  5. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  6. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  7. package/_bundled_plugin/mcp/server.mjs.br +0 -0
  8. package/_bundled_plugin/references/access-advisory.md +1 -1
  9. package/_bundled_plugin/references/threat-model.md +1 -0
  10. package/_bundled_plugin/scripts/deep_scan_workbench.py +1 -0
  11. package/_bundled_plugin/scripts/finalize_scan_contract.py +18 -6
  12. package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +2 -0
  13. package/_bundled_plugin/scripts/workbench_db.py +16 -54
  14. package/_bundled_plugin/scripts/workbench_scan_history.py +23 -28
  15. package/_bundled_plugin/scripts/workbench_scan_start.py +65 -2
  16. package/_bundled_plugin/scripts/workbench_source_scopes.py +8 -0
  17. package/_bundled_plugin/scripts/workbench_target.py +17 -3
  18. package/_bundled_plugin/shared/workbench-history-repairs.json +5 -1
  19. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +4 -2
  20. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +2 -2
  21. package/_bundled_plugin/skills/publish-findings/SKILL.md +3 -1
  22. package/dist/api.d.ts +1 -0
  23. package/dist/api.d.ts.map +1 -1
  24. package/dist/api.js +23 -4
  25. package/dist/api.js.map +1 -1
  26. package/dist/classify-severity-diagnostics.d.ts +10 -0
  27. package/dist/classify-severity-diagnostics.d.ts.map +1 -0
  28. package/dist/classify-severity-diagnostics.js +57 -0
  29. package/dist/classify-severity-diagnostics.js.map +1 -0
  30. package/dist/classify-severity-records.d.ts +4 -0
  31. package/dist/classify-severity-records.d.ts.map +1 -1
  32. package/dist/classify-severity-records.js +35 -8
  33. package/dist/classify-severity-records.js.map +1 -1
  34. package/dist/cli.d.ts +3 -0
  35. package/dist/cli.d.ts.map +1 -1
  36. package/dist/cli.js +99 -11
  37. package/dist/cli.js.map +1 -1
  38. package/dist/component-plan.d.ts.map +1 -1
  39. package/dist/component-plan.js +3 -3
  40. package/dist/component-plan.js.map +1 -1
  41. package/dist/continuum-aws.d.ts +6 -0
  42. package/dist/continuum-aws.d.ts.map +1 -0
  43. package/dist/continuum-aws.js +202 -0
  44. package/dist/continuum-aws.js.map +1 -0
  45. package/dist/continuum-collector.d.ts +44 -0
  46. package/dist/continuum-collector.d.ts.map +1 -0
  47. package/dist/continuum-collector.js +266 -0
  48. package/dist/continuum-collector.js.map +1 -0
  49. package/dist/continuum-findings.d.ts +31 -2
  50. package/dist/continuum-findings.d.ts.map +1 -1
  51. package/dist/continuum-findings.js +440 -64
  52. package/dist/continuum-findings.js.map +1 -1
  53. package/dist/contract.d.ts +1 -0
  54. package/dist/contract.d.ts.map +1 -1
  55. package/dist/contract.js +3 -0
  56. package/dist/contract.js.map +1 -1
  57. package/dist/crowdstrike-findings.d.ts +7 -0
  58. package/dist/crowdstrike-findings.d.ts.map +1 -0
  59. package/dist/crowdstrike-findings.js +210 -0
  60. package/dist/crowdstrike-findings.js.map +1 -0
  61. package/dist/external-findings-local.d.ts.map +1 -1
  62. package/dist/external-findings-local.js +26 -8
  63. package/dist/external-findings-local.js.map +1 -1
  64. package/dist/external-findings-publish.d.ts.map +1 -1
  65. package/dist/external-findings-publish.js +5 -1
  66. package/dist/external-findings-publish.js.map +1 -1
  67. package/dist/external-findings-read.d.ts +10 -2
  68. package/dist/external-findings-read.d.ts.map +1 -1
  69. package/dist/external-findings-read.js +26 -3
  70. package/dist/external-findings-read.js.map +1 -1
  71. package/dist/external-import-contract.d.ts +3 -0
  72. package/dist/external-import-contract.d.ts.map +1 -1
  73. package/dist/external-import-contract.js +6 -1
  74. package/dist/external-import-contract.js.map +1 -1
  75. package/dist/host-protocol.d.ts +6 -0
  76. package/dist/host-protocol.d.ts.map +1 -1
  77. package/dist/host-protocol.js +11 -1
  78. package/dist/host-protocol.js.map +1 -1
  79. package/dist/host-records-protocol.d.ts +2 -0
  80. package/dist/host-records-protocol.d.ts.map +1 -1
  81. package/dist/host-records-protocol.js +4 -0
  82. package/dist/host-records-protocol.js.map +1 -1
  83. package/dist/index.d.ts +2 -1
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +1 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/multiscan.d.ts.map +1 -1
  88. package/dist/multiscan.js +4 -2
  89. package/dist/multiscan.js.map +1 -1
  90. package/dist/project-config-schema.d.ts +2 -0
  91. package/dist/project-config-schema.d.ts.map +1 -1
  92. package/dist/project-config-schema.js +1 -0
  93. package/dist/project-config-schema.js.map +1 -1
  94. package/dist/project-config.d.ts +1 -0
  95. package/dist/project-config.d.ts.map +1 -1
  96. package/dist/project-config.js +3 -0
  97. package/dist/project-config.js.map +1 -1
  98. package/dist/runtime.d.ts.map +1 -1
  99. package/dist/runtime.js +4 -0
  100. package/dist/runtime.js.map +1 -1
  101. package/dist/scan-comparison.d.ts +20 -2
  102. package/dist/scan-comparison.d.ts.map +1 -1
  103. package/dist/scan-comparison.js +20 -3
  104. package/dist/scan-comparison.js.map +1 -1
  105. package/dist/scan-settings.d.ts +1 -0
  106. package/dist/scan-settings.d.ts.map +1 -1
  107. package/dist/scan-settings.js +1 -0
  108. package/dist/scan-settings.js.map +1 -1
  109. package/dist/severity-review.d.ts.map +1 -1
  110. package/dist/severity-review.js +1 -0
  111. package/dist/severity-review.js.map +1 -1
  112. package/dist/stored-finding-projection.d.ts.map +1 -1
  113. package/dist/stored-finding-projection.js +30 -5
  114. package/dist/stored-finding-projection.js.map +1 -1
  115. package/dist/targets.d.ts +2 -0
  116. package/dist/targets.d.ts.map +1 -1
  117. package/dist/targets.js +27 -0
  118. package/dist/targets.js.map +1 -1
  119. package/dist/trusted-executable.d.ts +1 -0
  120. package/dist/trusted-executable.d.ts.map +1 -1
  121. package/dist/trusted-executable.js +11 -3
  122. package/dist/trusted-executable.js.map +1 -1
  123. package/dist/value.js +3 -1
  124. package/dist/value.js.map +1 -1
  125. package/docs/classify-severity-records.md +30 -0
  126. package/docs/cli.md +164 -18
  127. package/docs/sdk.md +23 -8
  128. package/package.json +7 -2
  129. package/schemas/project-config.schema.json +5 -0
  130. package/_bundled_plugin/skills/publish-findings/scripts/collect_continuum.py +0 -224
@@ -0,0 +1,266 @@
1
+ import { execFile as execFileCallback } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { z } from "zod";
4
+ import { prepareContinuumAws } from "./continuum-aws.js";
5
+ import { continuumIssueFormat, findingIdentity, issueIdentity, readPatch, selectFindingValidationArtifact, singleFindingValidationIssue, } from "./continuum-findings.js";
6
+ import { CodexSecurityError } from "./errors.js";
7
+ import { array, record } from "./scanner-import.js";
8
+ import { declaredScannerRepositoryUrl } from "./scanner-repository-url.js";
9
+ const execFile = promisify(execFileCallback);
10
+ const continuumId = z
11
+ .string()
12
+ .regex(/^[a-z0-9]{1,64}$/u, "Use a short Continuum ID with lowercase letters and digits.");
13
+ export const continuumEnvironmentId = continuumId.describe("Short Continuum environment ID.");
14
+ export const continuumFindingId = continuumId.describe("Short Continuum finding ID.");
15
+ const nativeRecord = z.record(z.string(), z.unknown());
16
+ const continuumIssueExport = z.object({
17
+ format: z.literal(continuumIssueFormat),
18
+ environmentId: continuumEnvironmentId,
19
+ sourceRepositoryUrl: z.string(),
20
+ issues: z.array(z.object({
21
+ issue: z.looseObject({ artifacts: z.array(nativeRecord) }),
22
+ findings: z.array(nativeRecord),
23
+ })),
24
+ });
25
+ export const continuumImportOutput = z.union([
26
+ continuumIssueExport,
27
+ nativeRecord,
28
+ ]);
29
+ const environmentSources = z.object({
30
+ configuration: z
31
+ .object({
32
+ codeConfiguration: z
33
+ .object({
34
+ sourceConfiguration: z
35
+ .object({
36
+ repositorySources: z.array(z.unknown()).optional(),
37
+ s3Sources: z.array(z.unknown()).optional(),
38
+ })
39
+ .optional(),
40
+ })
41
+ .optional(),
42
+ })
43
+ .optional(),
44
+ });
45
+ const repositorySource = z.object({
46
+ integrationId: continuumId,
47
+ repository: z.string().regex(/^[a-z0-9_.-]+(?:\/[a-z0-9_.-]+)+$/iu),
48
+ });
49
+ const gitLabIntegration = z.object({
50
+ providerDetails: z.object({
51
+ gitlab: z.object({ instanceUrl: z.string().startsWith("https://") }),
52
+ }),
53
+ });
54
+ function configuredSources(environment) {
55
+ const { configuration } = environmentSources.parse(environment);
56
+ const sources = configuration?.codeConfiguration?.sourceConfiguration;
57
+ return {
58
+ repositories: sources?.repositorySources ?? [],
59
+ s3Sources: sources?.s3Sources ?? [],
60
+ };
61
+ }
62
+ async function singleRepositorySource(environment, getIntegration) {
63
+ const { repositories, s3Sources } = configuredSources(environment);
64
+ if (repositories.length !== 1)
65
+ throw new CodexSecurityError(`Continuum collection requires exactly one configured Git repository. This environment has ${repositories.length}.`);
66
+ const { integrationId, repository } = repositorySource.parse(repositories[0]);
67
+ const integration = await getIntegration(integrationId);
68
+ const type = integration["integrationType"];
69
+ if (type !== "GITHUB" && type !== "GITLAB")
70
+ throw new CodexSecurityError("Expected a GitHub or GitLab integration for the Continuum repository.");
71
+ const base = type === "GITHUB"
72
+ ? "https://github.com"
73
+ : gitLabIntegration.parse(integration).providerDetails.gitlab.instanceUrl;
74
+ return {
75
+ url: declaredScannerRepositoryUrl(`${base.replace(/\/$/u, "")}/${repository}`, "Continuum"),
76
+ // Mixed environments do not identify the Git source by the patch's AWS source name.
77
+ includePatches: s3Sources.length === 0,
78
+ };
79
+ }
80
+ async function awsCommand({ cwd, environment, signal, sourceRoot, }) {
81
+ const aws = await prepareContinuumAws(cwd, environment, signal, sourceRoot);
82
+ return async (args) => {
83
+ const command = execFile(aws.executable, args, {
84
+ cwd: aws.cwd,
85
+ env: aws.environment,
86
+ signal,
87
+ maxBuffer: Infinity,
88
+ windowsHide: true,
89
+ });
90
+ command.child.stdin?.end();
91
+ const { stdout } = await command;
92
+ return record(JSON.parse(stdout), `AWS Continuum ${args[1]} response`);
93
+ };
94
+ }
95
+ async function continuumRequests(options, runAws) {
96
+ const { profile, region, signal } = options;
97
+ signal?.throwIfAborted();
98
+ const run = runAws ?? (await awsCommand(options));
99
+ const awsArgs = [
100
+ "--output",
101
+ "json",
102
+ "--no-cli-pager",
103
+ ...(profile === undefined ? [] : ["--profile", profile]),
104
+ ...(region === undefined ? [] : ["--region", region]),
105
+ ];
106
+ return (operation, scope, ...args) => {
107
+ signal?.throwIfAborted();
108
+ return run(["continuum", operation, ...scope, ...awsArgs, ...args]);
109
+ };
110
+ }
111
+ async function getIssueArtifact(request, scope, issueId, artifactId, artifactType) {
112
+ const artifact = await request("get-code-issue-artifact", scope, "--issue-id", issueId, "--artifact-id", artifactId);
113
+ if (artifact["artifactId"] !== artifactId ||
114
+ artifact["artifactType"] !== artifactType)
115
+ throw new CodexSecurityError(`Unexpected Continuum artifact ${artifactId} for issue ${issueId}.`);
116
+ return artifact;
117
+ }
118
+ function requireCompleteList(response, name) {
119
+ if (Object.hasOwn(response, "nextToken") ||
120
+ Object.hasOwn(response, "NextToken"))
121
+ throw new CodexSecurityError(`Expected a complete Continuum ${name} list.`);
122
+ }
123
+ async function getFindingValidationIssue(request, scope, issueId, identity) {
124
+ const issue = await request("get-code-issue", scope, "--issue-id", issueId);
125
+ const selected = issueIdentity(issue);
126
+ if (selected.scope !== identity.scope || selected.id !== issueId)
127
+ throw new CodexSecurityError(`Unexpected detail for Continuum issue ${issueId}.`);
128
+ return singleFindingValidationIssue(issue, issueId, identity);
129
+ }
130
+ export async function collectContinuumFinding(options, runAws) {
131
+ const { environmentId, findingId, repositoryName, warn, signal } = options;
132
+ const request = await continuumRequests(options, runAws);
133
+ const scope = ["--environment-id", environmentId];
134
+ if (repositoryName === undefined) {
135
+ const { repositories, s3Sources } = configuredSources(await request("get-environment", scope));
136
+ if (repositories.length !== 1 ||
137
+ s3Sources.length !== 0 ||
138
+ !repositorySource.safeParse(repositories[0]).success)
139
+ throw new CodexSecurityError("Pass --repository-name with the exact AWS source name. Omitting it requires exactly one configured Git repository and no S3 sources.");
140
+ }
141
+ const finding = await request("get-code-finding", scope, "--finding-id", findingId);
142
+ const identity = findingIdentity(finding);
143
+ if (finding["environmentId"] !== environmentId || identity.id !== findingId)
144
+ throw new CodexSecurityError(`Unexpected detail for Continuum finding ${findingId}.`);
145
+ const linkedIssue = finding["createdIssueId"] || finding["duplicateOfIssueId"];
146
+ if (!linkedIssue)
147
+ return finding;
148
+ const issueId = continuumId.parse(linkedIssue);
149
+ const list = await request("list-code-issue-artifacts", scope, "--issue-id", issueId);
150
+ requireCompleteList(list, "issue artifact");
151
+ const artifacts = array(list["items"], "Continuum issue artifacts")
152
+ .flatMap((item) => {
153
+ const summary = record(item, "Continuum issue artifact summary");
154
+ const type = summary["artifactType"];
155
+ if (type !== "PATCH" && type !== "VALIDATION_EVIDENCE")
156
+ return [];
157
+ return [{ id: continuumId.parse(summary["artifactId"]), type }];
158
+ })
159
+ .sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0);
160
+ const patches = [];
161
+ const evidenceArtifacts = [];
162
+ let validationIssue;
163
+ for (const { id: artifactId, type } of artifacts) {
164
+ const artifact = await getIssueArtifact(request, scope, issueId, artifactId, type);
165
+ if (type === "VALIDATION_EVIDENCE") {
166
+ const selected = selectFindingValidationArtifact(artifact, findingId);
167
+ if (!selected)
168
+ continue;
169
+ if (selected.scope === "issue") {
170
+ if (validationIssue === undefined)
171
+ validationIssue = await getFindingValidationIssue(request, scope, issueId, identity);
172
+ if (!validationIssue)
173
+ continue;
174
+ }
175
+ evidenceArtifacts.push(selected.artifact);
176
+ continue;
177
+ }
178
+ const body = record(artifact["body"], "Continuum artifact body");
179
+ const patch = record(body["patch"], `Continuum artifact ${artifactId} patch body`);
180
+ if (repositoryName !== undefined &&
181
+ patch["repositoryName"] !== repositoryName) {
182
+ if (!patch["repositoryName"])
183
+ warn?.(`Skipped Continuum patch ${artifactId}: AWS did not identify its repository.`);
184
+ continue;
185
+ }
186
+ patches.push(readPatch({ ...patch, artifactId }));
187
+ }
188
+ signal?.throwIfAborted();
189
+ if (!patches.length && !evidenceArtifacts.length)
190
+ return finding;
191
+ return {
192
+ finding,
193
+ ...(patches.length && { patches }),
194
+ ...(validationIssue && { validationIssue }),
195
+ ...(evidenceArtifacts.length && { evidenceArtifacts }),
196
+ };
197
+ }
198
+ export async function collectContinuumIssues(options, runAws) {
199
+ const { environmentId, signal } = options;
200
+ const request = await continuumRequests(options, runAws);
201
+ const environmentArgs = ["--environment-id", environmentId];
202
+ const { url: sourceRepositoryUrl, includePatches } = await singleRepositorySource(await request("get-environment", environmentArgs), (id) => request("get-integration", ["--integration-id", id]));
203
+ // Let the AWS CLI assemble every page. A continuation token means the
204
+ // capture is incomplete and cannot be published as the environment's report.
205
+ const list = await request("list-code-issues", environmentArgs);
206
+ requireCompleteList(list, "issue");
207
+ const issues = [];
208
+ const seenIssues = new Set();
209
+ const fetchedFindings = new Map();
210
+ let environmentScope;
211
+ for (const summary of array(list["items"], "Continuum issue list")) {
212
+ const selected = issueIdentity(summary);
213
+ if (selected.environmentId !== environmentId ||
214
+ (environmentScope !== undefined && environmentScope !== selected.scope) ||
215
+ seenIssues.has(selected.id))
216
+ throw new CodexSecurityError("The Continuum issue list contains a duplicate issue or an issue from another environment.");
217
+ environmentScope = selected.scope;
218
+ seenIssues.add(selected.id);
219
+ const issue = await request("get-code-issue", environmentArgs, "--issue-id", selected.id);
220
+ if (issueIdentity(issue).arn !== selected.arn)
221
+ throw new CodexSecurityError(`Unexpected detail for Continuum issue ${selected.id}.`);
222
+ const ids = z.array(continuumId).nonempty().parse(issue["findingIds"]);
223
+ if (new Set(ids).size !== ids.length)
224
+ throw new CodexSecurityError(`Duplicate finding IDs on Continuum issue ${selected.id}.`);
225
+ const findings = [];
226
+ for (const id of ids) {
227
+ let finding = fetchedFindings.get(id);
228
+ if (!finding) {
229
+ finding = await request("get-code-finding", environmentArgs, "--finding-id", id);
230
+ const identity = findingIdentity(finding);
231
+ if (identity.id !== id || identity.scope !== selected.scope)
232
+ throw new CodexSecurityError(`Unexpected detail for Continuum finding ${id}.`);
233
+ fetchedFindings.set(id, finding);
234
+ }
235
+ findings.push(finding);
236
+ }
237
+ const issueArtifacts = [];
238
+ if (issue["evidenceAvailability"] !== "NONE") {
239
+ const issueArgs = ["--issue-id", selected.id];
240
+ const artifacts = await request("list-code-issue-artifacts", environmentArgs, ...issueArgs);
241
+ requireCompleteList(artifacts, "issue artifact");
242
+ for (const item of array(artifacts["items"], "Continuum issue artifacts")) {
243
+ const summary = record(item, "Continuum issue artifact summary");
244
+ const type = summary["artifactType"];
245
+ if (type !== "EVIDENCE" &&
246
+ type !== "VALIDATION_EVIDENCE" &&
247
+ !(includePatches && type === "PATCH"))
248
+ continue;
249
+ const artifactId = continuumId.parse(summary["artifactId"]);
250
+ issueArtifacts.push(await getIssueArtifact(request, environmentArgs, selected.id, artifactId, type));
251
+ }
252
+ }
253
+ issues.push({
254
+ issue: { ...issue, artifacts: issueArtifacts },
255
+ findings,
256
+ });
257
+ }
258
+ signal?.throwIfAborted();
259
+ return {
260
+ format: continuumIssueFormat,
261
+ environmentId,
262
+ sourceRepositoryUrl,
263
+ issues,
264
+ };
265
+ }
266
+ //# sourceMappingURL=continuum-collector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continuum-collector.js","sourceRoot":"","sources":["../src/continuum-collector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,o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MAAM,cAAc,GAA8B,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,sBAAsB,CAAC,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,MAAM,OAAO,CAC7B,2BAA2B,EAC3B,eAAe,EACf,GAAG,SAAS,CACb,CAAC;YACF,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;YACjD,KAAK,MAAM,IAAI,IAAI,KAAK,CACtB,SAAS,CAAC,OAAO,CAAC,EAClB,2BAA2B,CAC5B,EAAE,CAAC;gBACF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,kCAAkC,CAAC,CAAC;gBACjE,MAAM,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;gBACrC,IACE,IAAI,KAAK,UAAU;oBACnB,IAAI,KAAK,qBAAqB;oBAC9B,CAAC,CAAC,cAAc,IAAI,IAAI,KAAK,OAAO,CAAC;oBAErC,SAAS;gBACX,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC5D,cAAc,CAAC,IAAI,CACjB,MAAM,gBAAgB,CACpB,OAAO,EACP,eAAe,EACf,QAAQ,CAAC,EAAE,EACX,UAAU,EACV,IAAI,CACL,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE;YAC9C,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IACD,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,OAAO;QACL,MAAM,EAAE,oBAAoB;QAC5B,aAAa;QACb,mBAAmB;QACnB,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { execFile as execFileCallback } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { z } from \"zod\";\nimport { prepareContinuumAws } from \"./continuum-aws.js\";\nimport {\n continuumIssueFormat,\n findingIdentity,\n issueIdentity,\n readPatch,\n selectFindingValidationArtifact,\n singleFindingValidationIssue,\n} from \"./continuum-findings.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { array, record } from \"./scanner-import.js\";\nimport { declaredScannerRepositoryUrl } from \"./scanner-repository-url.js\";\n\nconst execFile = promisify(execFileCallback);\nconst continuumId = z\n .string()\n .regex(\n /^[a-z0-9]{1,64}$/u,\n \"Use a short Continuum ID with lowercase letters and digits.\",\n );\nexport const continuumEnvironmentId = continuumId.describe(\n \"Short Continuum environment ID.\",\n);\nexport const continuumFindingId = continuumId.describe(\n \"Short Continuum finding ID.\",\n);\nconst nativeRecord = z.record(z.string(), z.unknown());\nconst continuumIssueExport = z.object({\n format: z.literal(continuumIssueFormat),\n environmentId: continuumEnvironmentId,\n sourceRepositoryUrl: z.string(),\n issues: z.array(\n z.object({\n issue: z.looseObject({ artifacts: z.array(nativeRecord) }),\n findings: z.array(nativeRecord),\n }),\n ),\n});\n\nexport const continuumImportOutput = z.union([\n continuumIssueExport,\n nativeRecord,\n]);\n\ninterface ContinuumCollectionOptions {\n environmentId: string;\n profile?: string;\n region?: string;\n cwd: string;\n sourceRoot?: string;\n environment: NodeJS.ProcessEnv;\n signal?: AbortSignal;\n}\n\ntype AwsCommand = (args: string[]) => Promise<Record<string, unknown>>;\n\nconst environmentSources = z.object({\n configuration: z\n .object({\n codeConfiguration: z\n .object({\n sourceConfiguration: z\n .object({\n repositorySources: z.array(z.unknown()).optional(),\n s3Sources: z.array(z.unknown()).optional(),\n })\n .optional(),\n })\n .optional(),\n })\n .optional(),\n});\nconst repositorySource = z.object({\n integrationId: continuumId,\n repository: z.string().regex(/^[a-z0-9_.-]+(?:\\/[a-z0-9_.-]+)+$/iu),\n});\nconst gitLabIntegration = z.object({\n providerDetails: z.object({\n gitlab: z.object({ instanceUrl: z.string().startsWith(\"https://\") }),\n }),\n});\n\nfunction configuredSources(environment: Record<string, unknown>) {\n const { configuration } = environmentSources.parse(environment);\n const sources = configuration?.codeConfiguration?.sourceConfiguration;\n return {\n repositories: sources?.repositorySources ?? [],\n s3Sources: sources?.s3Sources ?? [],\n };\n}\n\nasync function singleRepositorySource(\n environment: Record<string, unknown>,\n getIntegration: (id: string) => Promise<Record<string, unknown>>,\n) {\n const { repositories, s3Sources } = configuredSources(environment);\n if (repositories.length !== 1)\n throw new CodexSecurityError(\n `Continuum collection requires exactly one configured Git repository. This environment has ${repositories.length}.`,\n );\n const { integrationId, repository } = repositorySource.parse(repositories[0]);\n const integration = await getIntegration(integrationId);\n const type = integration[\"integrationType\"];\n if (type !== \"GITHUB\" && type !== \"GITLAB\")\n throw new CodexSecurityError(\n \"Expected a GitHub or GitLab integration for the Continuum repository.\",\n );\n const base =\n type === \"GITHUB\"\n ? \"https://github.com\"\n : gitLabIntegration.parse(integration).providerDetails.gitlab.instanceUrl;\n return {\n url: declaredScannerRepositoryUrl(\n `${base.replace(/\\/$/u, \"\")}/${repository}`,\n \"Continuum\",\n ),\n // Mixed environments do not identify the Git source by the patch's AWS source name.\n includePatches: s3Sources.length === 0,\n };\n}\n\nasync function awsCommand({\n cwd,\n environment,\n signal,\n sourceRoot,\n}: ContinuumCollectionOptions): Promise<AwsCommand> {\n const aws = await prepareContinuumAws(cwd, environment, signal, sourceRoot);\n return async (args) => {\n const command = execFile(aws.executable, args, {\n cwd: aws.cwd,\n env: aws.environment,\n signal,\n maxBuffer: Infinity,\n windowsHide: true,\n });\n command.child.stdin?.end();\n const { stdout } = await command;\n return record(JSON.parse(stdout), `AWS Continuum ${args[1]} response`);\n };\n}\n\nasync function continuumRequests(\n options: ContinuumCollectionOptions,\n runAws?: AwsCommand,\n) {\n const { profile, region, signal } = options;\n signal?.throwIfAborted();\n const run = runAws ?? (await awsCommand(options));\n const awsArgs = [\n \"--output\",\n \"json\",\n \"--no-cli-pager\",\n ...(profile === undefined ? [] : [\"--profile\", profile]),\n ...(region === undefined ? [] : [\"--region\", region]),\n ];\n return (operation: string, scope: string[], ...args: string[]) => {\n signal?.throwIfAborted();\n return run([\"continuum\", operation, ...scope, ...awsArgs, ...args]);\n };\n}\n\ntype ContinuumRequest = Awaited<ReturnType<typeof continuumRequests>>;\n\nasync function getIssueArtifact(\n request: ContinuumRequest,\n scope: string[],\n issueId: string,\n artifactId: string,\n artifactType: string,\n) {\n const artifact = await request(\n \"get-code-issue-artifact\",\n scope,\n \"--issue-id\",\n issueId,\n \"--artifact-id\",\n artifactId,\n );\n if (\n artifact[\"artifactId\"] !== artifactId ||\n artifact[\"artifactType\"] !== artifactType\n )\n throw new CodexSecurityError(\n `Unexpected Continuum artifact ${artifactId} for issue ${issueId}.`,\n );\n return artifact;\n}\n\nfunction requireCompleteList(response: Record<string, unknown>, name: string) {\n if (\n Object.hasOwn(response, \"nextToken\") ||\n Object.hasOwn(response, \"NextToken\")\n )\n throw new CodexSecurityError(`Expected a complete Continuum ${name} list.`);\n}\n\nasync function getFindingValidationIssue(\n request: ContinuumRequest,\n scope: string[],\n issueId: string,\n identity: ReturnType<typeof findingIdentity>,\n) {\n const issue = await request(\"get-code-issue\", scope, \"--issue-id\", issueId);\n const selected = issueIdentity(issue);\n if (selected.scope !== identity.scope || selected.id !== issueId)\n throw new CodexSecurityError(\n `Unexpected detail for Continuum issue ${issueId}.`,\n );\n return singleFindingValidationIssue(issue, issueId, identity);\n}\n\nexport async function collectContinuumFinding(\n options: ContinuumCollectionOptions & {\n findingId: string;\n sourceRoot: string;\n repositoryName?: string;\n warn?: (message: string) => void;\n },\n runAws?: AwsCommand,\n): Promise<Record<string, unknown>> {\n const { environmentId, findingId, repositoryName, warn, signal } = options;\n const request = await continuumRequests(options, runAws);\n const scope = [\"--environment-id\", environmentId];\n if (repositoryName === undefined) {\n const { repositories, s3Sources } = configuredSources(\n await request(\"get-environment\", scope),\n );\n if (\n repositories.length !== 1 ||\n s3Sources.length !== 0 ||\n !repositorySource.safeParse(repositories[0]).success\n )\n throw new CodexSecurityError(\n \"Pass --repository-name with the exact AWS source name. Omitting it requires exactly one configured Git repository and no S3 sources.\",\n );\n }\n\n const finding = await request(\n \"get-code-finding\",\n scope,\n \"--finding-id\",\n findingId,\n );\n const identity = findingIdentity(finding);\n if (finding[\"environmentId\"] !== environmentId || identity.id !== findingId)\n throw new CodexSecurityError(\n `Unexpected detail for Continuum finding ${findingId}.`,\n );\n\n const linkedIssue =\n finding[\"createdIssueId\"] || finding[\"duplicateOfIssueId\"];\n if (!linkedIssue) return finding;\n const issueId = continuumId.parse(linkedIssue);\n const list = await request(\n \"list-code-issue-artifacts\",\n scope,\n \"--issue-id\",\n issueId,\n );\n requireCompleteList(list, \"issue artifact\");\n const artifacts = array(list[\"items\"], \"Continuum issue artifacts\")\n .flatMap((item) => {\n const summary = record(item, \"Continuum issue artifact summary\");\n const type = summary[\"artifactType\"];\n if (type !== \"PATCH\" && type !== \"VALIDATION_EVIDENCE\") return [];\n return [{ id: continuumId.parse(summary[\"artifactId\"]), type }];\n })\n .sort((left, right) =>\n left.id < right.id ? -1 : left.id > right.id ? 1 : 0,\n );\n const patches = [];\n const evidenceArtifacts = [];\n let validationIssue:\n ReturnType<typeof singleFindingValidationIssue> | undefined;\n for (const { id: artifactId, type } of artifacts) {\n const artifact = await getIssueArtifact(\n request,\n scope,\n issueId,\n artifactId,\n type,\n );\n if (type === \"VALIDATION_EVIDENCE\") {\n const selected = selectFindingValidationArtifact(artifact, findingId);\n if (!selected) continue;\n if (selected.scope === \"issue\") {\n if (validationIssue === undefined)\n validationIssue = await getFindingValidationIssue(\n request,\n scope,\n issueId,\n identity,\n );\n if (!validationIssue) continue;\n }\n evidenceArtifacts.push(selected.artifact);\n continue;\n }\n const body = record(artifact[\"body\"], \"Continuum artifact body\");\n const patch = record(\n body[\"patch\"],\n `Continuum artifact ${artifactId} patch body`,\n );\n if (\n repositoryName !== undefined &&\n patch[\"repositoryName\"] !== repositoryName\n ) {\n if (!patch[\"repositoryName\"])\n warn?.(\n `Skipped Continuum patch ${artifactId}: AWS did not identify its repository.`,\n );\n continue;\n }\n patches.push(readPatch({ ...patch, artifactId }));\n }\n signal?.throwIfAborted();\n if (!patches.length && !evidenceArtifacts.length) return finding;\n return {\n finding,\n ...(patches.length && { patches }),\n ...(validationIssue && { validationIssue }),\n ...(evidenceArtifacts.length && { evidenceArtifacts }),\n };\n}\n\nexport async function collectContinuumIssues(\n options: ContinuumCollectionOptions,\n runAws?: AwsCommand,\n): Promise<z.infer<typeof continuumIssueExport>> {\n const { environmentId, signal } = options;\n const request = await continuumRequests(options, runAws);\n const environmentArgs = [\"--environment-id\", environmentId];\n const { url: sourceRepositoryUrl, includePatches } =\n await singleRepositorySource(\n await request(\"get-environment\", environmentArgs),\n (id) => request(\"get-integration\", [\"--integration-id\", id]),\n );\n\n // Let the AWS CLI assemble every page. A continuation token means the\n // capture is incomplete and cannot be published as the environment's report.\n const list = await request(\"list-code-issues\", environmentArgs);\n requireCompleteList(list, \"issue\");\n\n const issues: z.infer<typeof continuumIssueExport>[\"issues\"] = [];\n const seenIssues = new Set<string>();\n const fetchedFindings = new Map<string, Record<string, unknown>>();\n let environmentScope: string | undefined;\n for (const summary of array(list[\"items\"], \"Continuum issue list\")) {\n const selected = issueIdentity(summary);\n if (\n selected.environmentId !== environmentId ||\n (environmentScope !== undefined && environmentScope !== selected.scope) ||\n seenIssues.has(selected.id)\n )\n throw new CodexSecurityError(\n \"The Continuum issue list contains a duplicate issue or an issue from another environment.\",\n );\n environmentScope = selected.scope;\n seenIssues.add(selected.id);\n const issue = await request(\n \"get-code-issue\",\n environmentArgs,\n \"--issue-id\",\n selected.id,\n );\n if (issueIdentity(issue).arn !== selected.arn)\n throw new CodexSecurityError(\n `Unexpected detail for Continuum issue ${selected.id}.`,\n );\n\n const ids = z.array(continuumId).nonempty().parse(issue[\"findingIds\"]);\n if (new Set(ids).size !== ids.length)\n throw new CodexSecurityError(\n `Duplicate finding IDs on Continuum issue ${selected.id}.`,\n );\n const findings: Record<string, unknown>[] = [];\n for (const id of ids) {\n let finding = fetchedFindings.get(id);\n if (!finding) {\n finding = await request(\n \"get-code-finding\",\n environmentArgs,\n \"--finding-id\",\n id,\n );\n const identity = findingIdentity(finding);\n if (identity.id !== id || identity.scope !== selected.scope)\n throw new CodexSecurityError(\n `Unexpected detail for Continuum finding ${id}.`,\n );\n fetchedFindings.set(id, finding);\n }\n findings.push(finding);\n }\n const issueArtifacts: Record<string, unknown>[] = [];\n if (issue[\"evidenceAvailability\"] !== \"NONE\") {\n const issueArgs = [\"--issue-id\", selected.id];\n const artifacts = await request(\n \"list-code-issue-artifacts\",\n environmentArgs,\n ...issueArgs,\n );\n requireCompleteList(artifacts, \"issue artifact\");\n for (const item of array(\n artifacts[\"items\"],\n \"Continuum issue artifacts\",\n )) {\n const summary = record(item, \"Continuum issue artifact summary\");\n const type = summary[\"artifactType\"];\n if (\n type !== \"EVIDENCE\" &&\n type !== \"VALIDATION_EVIDENCE\" &&\n !(includePatches && type === \"PATCH\")\n )\n continue;\n const artifactId = continuumId.parse(summary[\"artifactId\"]);\n issueArtifacts.push(\n await getIssueArtifact(\n request,\n environmentArgs,\n selected.id,\n artifactId,\n type,\n ),\n );\n }\n }\n issues.push({\n issue: { ...issue, artifacts: issueArtifacts },\n findings,\n });\n }\n signal?.throwIfAborted();\n return {\n format: continuumIssueFormat,\n environmentId,\n sourceRepositoryUrl,\n issues,\n };\n}\n"]}
@@ -1,7 +1,36 @@
1
1
  import type { ExternalFinding, ExternalFindings } from "./external-findings.js";
2
2
  import { type ExternalImportTarget } from "./external-import-contract.js";
3
3
  import type { Provider } from "./external-import-models.js";
4
+ export declare const continuumIssueFormat = "aws-continuum-code-issues/v1";
5
+ export declare function findingIdentity(value: unknown): {
6
+ arn: string;
7
+ scope: string;
8
+ id: string;
9
+ };
10
+ export declare function issueIdentity(value: unknown): {
11
+ arn: string;
12
+ scope: string;
13
+ environmentId: string;
14
+ id: string;
15
+ };
4
16
  export declare const continuumReportRepositories: (provider: Provider, findings: readonly ExternalFinding[], target: ExternalImportTarget, sameRepositories?: (urls: Iterable<string>) => boolean) => Map<string, import("./external-findings.js").ExternalSourceRepository>;
5
- export declare function normalizeContinuumFindings(input: unknown, sourceRepositoryUrl: string, target?: ExternalImportTarget): ExternalFindings;
6
- export declare const readContinuumFindings: (path: string, sourceRepositoryUrl: string, target?: ExternalImportTarget | undefined) => Promise<ExternalFindings>;
17
+ export declare function readPatch(value: unknown): {
18
+ artifactId: string;
19
+ patch: string;
20
+ patchSha256: string;
21
+ sizeBytes: number;
22
+ format?: string | undefined;
23
+ repositoryName?: string | undefined;
24
+ };
25
+ export declare function singleFindingValidationIssue(issue: unknown, issueId: unknown, finding: ReturnType<typeof findingIdentity>): {
26
+ issueArn: string;
27
+ issueId: string;
28
+ findingIds: string[];
29
+ } | null;
30
+ export declare function selectFindingValidationArtifact(artifact: Record<string, unknown>, findingId: unknown): {
31
+ scope: string;
32
+ artifact: Record<string, unknown>;
33
+ } | undefined;
34
+ export declare function normalizeContinuumFindings(input: unknown, sourceRepositoryUrl?: string, target?: ExternalImportTarget): ExternalFindings;
35
+ export declare const readContinuumFindings: (path: string, sourceRepositoryUrl?: string | undefined, target?: ExternalImportTarget | undefined) => Promise<ExternalFindings>;
7
36
  //# sourceMappingURL=continuum-findings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"continuum-findings.d.ts","sourceRoot":"","sources":["../src/continuum-findings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAGL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA+E7E,eAAO,MAAM,2BAA2B,4NAGvC,CAAC;AAiNF,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,mBAAmB,EAAE,MAAM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