@openai/codex-security 0.1.31 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +295 -32
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- 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/references/artifact-storage.md +4 -4
- package/_bundled_plugin/references/config-preflight.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -2
- package/_bundled_plugin/references/final-report.md +4 -2
- package/_bundled_plugin/references/scan-artifacts.md +2 -2
- package/_bundled_plugin/references/scan-contract.md +2 -2
- package/_bundled_plugin/references/threat-model.md +2 -2
- package/_bundled_plugin/schemas/coverage.schema.json +22 -0
- package/_bundled_plugin/schemas/scan-manifest.schema.json +100 -85
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +116 -102
- package/_bundled_plugin/scripts/config_preflight.py +4 -8
- package/_bundled_plugin/scripts/deep_scan_workbench.py +83 -217
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
- package/_bundled_plugin/scripts/finalize_scan_contract.py +441 -166
- package/_bundled_plugin/scripts/finding_preview.py +42 -82
- package/_bundled_plugin/scripts/generate_in_scope_files.py +30 -34
- package/_bundled_plugin/scripts/generate_rank_input.py +58 -99
- package/_bundled_plugin/scripts/launch_codex_security_mcp +5 -1
- package/_bundled_plugin/scripts/rank_preview.py +85 -68
- package/_bundled_plugin/scripts/report_projection.py +37 -58
- package/_bundled_plugin/scripts/threat_model_projection.py +164 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +11 -6
- package/_bundled_plugin/scripts/workbench/storage.py +11 -0
- package/_bundled_plugin/scripts/workbench_cli.py +11 -17
- package/_bundled_plugin/scripts/workbench_constants.py +6 -14
- package/_bundled_plugin/scripts/workbench_db.py +116 -228
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -6
- package/_bundled_plugin/scripts/workbench_native_indexes.py +1 -4
- package/_bundled_plugin/scripts/workbench_progress.py +12 -34
- package/_bundled_plugin/scripts/workbench_publication.py +47 -62
- package/_bundled_plugin/scripts/workbench_remediation.py +2 -20
- package/_bundled_plugin/scripts/workbench_saved_results.py +1246 -230
- package/_bundled_plugin/scripts/workbench_scan_start.py +4 -11
- package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -15
- package/_bundled_plugin/scripts/workbench_schema.py +86 -271
- package/_bundled_plugin/scripts/workbench_severity.py +3 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +5 -6
- package/_bundled_plugin/scripts/workbench_target.py +98 -10
- package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
- package/_bundled_plugin/scripts/workbench_validation.py +6 -20
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +3 -3
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +3 -3
- package/_bundled_plugin/skills/security-scan/SKILL.md +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
- package/dist/api.d.ts +3 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +201 -207
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +70 -0
- package/dist/artifact-export.d.ts.map +1 -0
- package/dist/artifact-export.js +277 -0
- package/dist/artifact-export.js.map +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -3
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +8 -9
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +2 -5
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts +2 -8
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -5
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +281 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli.d.ts +19 -22
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +631 -714
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +1 -8
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +1 -2
- package/dist/codex-prompt.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +2 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -0
- package/dist/codex-sdk-environment.js +30 -0
- package/dist/codex-sdk-environment.js.map +1 -0
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +2 -6
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +1 -0
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +31 -9
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -33
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +2 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +63 -122
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +65 -34
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +15 -31
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.js +4 -4
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +17 -16
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +10 -11
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +2 -0
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +3 -3
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +2 -0
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js +40 -62
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +1 -4
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +2 -1
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +24 -6
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/review.d.ts +7 -0
- package/dist/deduplication/review.d.ts.map +1 -1
- package/dist/deduplication/review.js.map +1 -1
- package/dist/deduplication/scan.js +3 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +3 -19
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +0 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +22 -40
- package/dist/deep-progress.js.map +1 -1
- package/dist/errors.d.ts +3 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -7
- package/dist/errors.js.map +1 -1
- package/dist/finding-catalogue.d.ts.map +1 -1
- package/dist/finding-catalogue.js +22 -22
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +4 -7
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +7 -17
- package/dist/findings-import.js.map +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +2 -3
- package/dist/github.js.map +1 -1
- package/dist/import-scan.js +2 -2
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.js +2 -2
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +2 -3
- package/dist/linear.js.map +1 -1
- package/dist/models.d.ts +24 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +36 -31
- package/dist/multiscan.js.map +1 -1
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -6
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +2 -4
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +10 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -0
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +0 -1
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +2 -4
- package/dist/prompt-files.js.map +1 -1
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +15 -29
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +9 -13
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +11 -14
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +31 -41
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +2 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +4 -0
- package/dist/record.js.map +1 -0
- package/dist/result.d.ts +4 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +10 -13
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +203 -131
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan.d.ts.map +1 -1
- package/dist/saved-scan.js +10 -20
- package/dist/saved-scan.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +8 -22
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +3 -3
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +38 -73
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +0 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +10 -19
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +1 -2
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +2 -6
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +1 -3
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +5 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/security-policy-cli.d.ts.map +1 -1
- package/dist/security-policy-cli.js +8 -6
- package/dist/security-policy-cli.js.map +1 -1
- package/dist/security-policy.d.ts +8 -4
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +98 -84
- package/dist/security-policy.js.map +1 -1
- package/dist/server/dashboard/app.js +5 -5
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +1 -0
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/routes.d.ts +3 -2
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +19 -7
- package/dist/server/routes.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +2 -3
- package/dist/server/server.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +4 -14
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-store.js +8 -15
- package/dist/severity-store.js.map +1 -1
- package/dist/suggest-owners.d.ts +2 -3
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +4 -5
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +24 -21
- package/dist/targets.js.map +1 -1
- package/dist/trusted-executable.d.ts +5 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +22 -5
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.d.ts +2 -0
- package/dist/value.d.ts.map +1 -0
- package/dist/value.js +20 -0
- package/dist/value.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -6
- package/dist/version.js.map +1 -1
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -2
- package/dist/windows-path.js.map +1 -1
- package/dist/worker-progress.d.ts +1 -0
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +13 -34
- package/dist/worker-progress.js.map +1 -1
- package/docs/dedupe-records.md +24 -0
- package/package.json +11 -10
- package/schemas/project-config.schema.json +5 -0
- package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
- package/dist/server/findings-service.d.ts +0 -20
- package/dist/server/findings-service.d.ts.map +0 -1
- package/dist/server/findings-service.js +0 -31
- package/dist/server/findings-service.js.map +0 -1
package/dist/contract.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { createHash, hash } from "node:crypto";
|
|
2
|
+
import { isNonEmptyString } from "./value.js";
|
|
2
3
|
import { constants } from "node:fs";
|
|
3
4
|
import { lstat, open, readFile, realpath, } from "node:fs/promises";
|
|
4
|
-
import { isAbsolute, join, posix,
|
|
5
|
+
import { isAbsolute, join, posix, resolve } from "node:path";
|
|
5
6
|
import Ajv2020 from "ajv/dist/2020.js";
|
|
6
|
-
import { ContractValidationError } from "./errors.js";
|
|
7
|
+
import { ContractValidationError, abortReason } from "./errors.js";
|
|
8
|
+
import { isRecord } from "./record.js";
|
|
7
9
|
import { requirePrivateOutputDirectory, requireSecureOutputAncestry, } from "./runtime.js";
|
|
10
|
+
import { isWithin as isContained } from "./trusted-executable.js";
|
|
8
11
|
import { isWindowsUnsafePathComponent } from "./windows-path.js";
|
|
9
12
|
const DOCUMENTS = {
|
|
10
13
|
"scan-manifest.json": "scan-manifest.schema.json",
|
|
@@ -41,29 +44,25 @@ export async function loadContractWithScanDirectory(scanDirectory, options) {
|
|
|
41
44
|
for (const [filename, schemaName] of Object.entries(DOCUMENTS)) {
|
|
42
45
|
const schema = await readJson(join(options.pluginRoot, "schemas", schemaName), options.signal);
|
|
43
46
|
let validate;
|
|
44
|
-
|
|
45
|
-
validate = ajv.compile(schema);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
throw new ContractValidationError(`${schemaName}: invalid JSON Schema.`);
|
|
49
|
-
}
|
|
50
|
-
let payload = filename === "findings.json"
|
|
51
|
-
? findingsPayload
|
|
52
|
-
: payloads[filename];
|
|
47
|
+
let payload;
|
|
53
48
|
let valid;
|
|
54
49
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (typeof compatibleResult !== "boolean") {
|
|
50
|
+
validate = ajv.compile(schema);
|
|
51
|
+
payload =
|
|
52
|
+
filename === "findings.json"
|
|
53
|
+
? findingsPayload
|
|
54
|
+
: payloads[filename];
|
|
55
|
+
const validatePayload = (payload) => {
|
|
56
|
+
const result = validate(payload);
|
|
57
|
+
if (typeof result !== "boolean") {
|
|
64
58
|
throw new Error("asynchronous JSON Schema validation is unsupported");
|
|
65
59
|
}
|
|
66
|
-
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
valid = validatePayload(payload);
|
|
63
|
+
if (!valid && filename === "findings.json") {
|
|
64
|
+
payload = normalizePersistedFindings(payload);
|
|
65
|
+
valid = validatePayload(payload);
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
catch {
|
|
@@ -104,29 +103,24 @@ export async function loadContractWithScanDirectory(scanDirectory, options) {
|
|
|
104
103
|
scanDirectory: scanRoot.path,
|
|
105
104
|
};
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
function legacySealedFindingsForValidation(payload) {
|
|
106
|
+
/** Normalize optional legacy details on a copy, without changing saved artifacts. */
|
|
107
|
+
export function normalizePersistedFindings(payload) {
|
|
111
108
|
const compatible = structuredClone(payload);
|
|
112
|
-
if (!
|
|
109
|
+
if (!isRecord(compatible) || !Array.isArray(compatible["findings"])) {
|
|
113
110
|
return compatible;
|
|
114
111
|
}
|
|
115
112
|
for (const finding of compatible["findings"]) {
|
|
116
|
-
if (!
|
|
113
|
+
if (!isRecord(finding))
|
|
117
114
|
continue;
|
|
118
115
|
const legacyEvidence = finding["code_evidence"];
|
|
119
116
|
if (Array.isArray(legacyEvidence)) {
|
|
120
117
|
const compatibleEvidence = [];
|
|
121
118
|
for (const evidence of legacyEvidence) {
|
|
122
|
-
if (!
|
|
119
|
+
if (!isRecord(evidence))
|
|
123
120
|
continue;
|
|
124
121
|
const id = evidence["id"];
|
|
125
122
|
const code = evidence["code"];
|
|
126
|
-
if (
|
|
127
|
-
id.length === 0 ||
|
|
128
|
-
typeof code !== "string" ||
|
|
129
|
-
code.length === 0) {
|
|
123
|
+
if (!isNonEmptyString(id) || !isNonEmptyString(code)) {
|
|
130
124
|
continue;
|
|
131
125
|
}
|
|
132
126
|
compatibleEvidence.push(evidence);
|
|
@@ -163,12 +157,12 @@ function legacySealedFindingsForValidation(payload) {
|
|
|
163
157
|
],
|
|
164
158
|
]) {
|
|
165
159
|
const section = finding[sectionName];
|
|
166
|
-
if (!
|
|
160
|
+
if (!isRecord(section))
|
|
167
161
|
continue;
|
|
168
162
|
normalizeLegacyStringLists(section, listFields);
|
|
169
163
|
}
|
|
170
164
|
const legacyRootCause = finding["root_cause"];
|
|
171
|
-
if (
|
|
165
|
+
if (isRecord(legacyRootCause)) {
|
|
172
166
|
removeUnsupportedLegacyStrings(legacyRootCause, [
|
|
173
167
|
"summary",
|
|
174
168
|
"code",
|
|
@@ -181,17 +175,16 @@ function legacySealedFindingsForValidation(payload) {
|
|
|
181
175
|
delete finding["root_cause"];
|
|
182
176
|
}
|
|
183
177
|
const validation = finding["validation"];
|
|
184
|
-
if (
|
|
185
|
-
|
|
178
|
+
if (isRecord(validation)) {
|
|
179
|
+
if (typeof validation["evidence"] !== "string" ||
|
|
180
|
+
validation["evidence"].length === 0) {
|
|
181
|
+
normalizeLegacyStringLists(validation, ["evidence"]);
|
|
182
|
+
}
|
|
186
183
|
removeUnsupportedLegacyStrings(validation, ["method", "summary"]);
|
|
187
|
-
|
|
188
|
-
"status",
|
|
189
|
-
"disposition",
|
|
190
|
-
"result",
|
|
191
|
-
]);
|
|
184
|
+
removeUnsupportedLegacyStrings(validation, ["status", "disposition", "result"].filter((field) => validation[field] !== null));
|
|
192
185
|
}
|
|
193
186
|
const attackPath = finding["attackPath"];
|
|
194
|
-
if (!
|
|
187
|
+
if (!isRecord(attackPath))
|
|
195
188
|
continue;
|
|
196
189
|
removeUnsupportedLegacyStrings(attackPath, ["summary"]);
|
|
197
190
|
for (const field of ["dataFlow", "data_flow", "dataflow", "reachability"]) {
|
|
@@ -205,7 +198,7 @@ function legacySealedFindingsForValidation(payload) {
|
|
|
205
198
|
delete attackPath[field];
|
|
206
199
|
continue;
|
|
207
200
|
}
|
|
208
|
-
if (!
|
|
201
|
+
if (!isRecord(detail)) {
|
|
209
202
|
if (field in attackPath)
|
|
210
203
|
delete attackPath[field];
|
|
211
204
|
continue;
|
|
@@ -226,30 +219,27 @@ function legacySealedFindingsForValidation(payload) {
|
|
|
226
219
|
}
|
|
227
220
|
for (const field of ["impact", "likelihood"]) {
|
|
228
221
|
const detail = attackPath[field];
|
|
229
|
-
if (
|
|
222
|
+
if (isRecord(detail)) {
|
|
230
223
|
removeUnsupportedLegacyStrings(detail, ["level", "rationale", "why"]);
|
|
231
224
|
}
|
|
232
225
|
else if (detail !== undefined &&
|
|
233
226
|
detail !== null &&
|
|
234
|
-
(
|
|
227
|
+
!isNonEmptyString(detail)) {
|
|
235
228
|
delete attackPath[field];
|
|
236
229
|
}
|
|
237
230
|
}
|
|
238
231
|
}
|
|
239
232
|
return compatible;
|
|
240
233
|
}
|
|
241
|
-
function isJsonRecord(value) {
|
|
242
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
243
|
-
}
|
|
244
234
|
function normalizeLegacyStringLists(section, fields) {
|
|
245
235
|
for (const field of fields) {
|
|
246
236
|
if (!(field in section))
|
|
247
237
|
continue;
|
|
248
238
|
const value = section[field];
|
|
249
239
|
if (Array.isArray(value)) {
|
|
250
|
-
section[field] = value.filter(
|
|
240
|
+
section[field] = value.filter(isNonEmptyString);
|
|
251
241
|
}
|
|
252
|
-
else if (
|
|
242
|
+
else if (isNonEmptyString(value)) {
|
|
253
243
|
section[field] = [value];
|
|
254
244
|
}
|
|
255
245
|
else {
|
|
@@ -257,22 +247,6 @@ function normalizeLegacyStringLists(section, fields) {
|
|
|
257
247
|
}
|
|
258
248
|
}
|
|
259
249
|
}
|
|
260
|
-
function normalizeLegacyStringOrList(section, field) {
|
|
261
|
-
if (!(field in section))
|
|
262
|
-
return;
|
|
263
|
-
const value = section[field];
|
|
264
|
-
if (typeof value === "string") {
|
|
265
|
-
if (value.length === 0)
|
|
266
|
-
delete section[field];
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (!Array.isArray(value)) {
|
|
270
|
-
delete section[field];
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
const normalized = value.filter((item) => typeof item === "string" && item.length > 0);
|
|
274
|
-
section[field] = normalized;
|
|
275
|
-
}
|
|
276
250
|
function removeUnsupportedLegacyStrings(section, fields) {
|
|
277
251
|
for (const field of fields) {
|
|
278
252
|
if (field in section &&
|
|
@@ -281,15 +255,6 @@ function removeUnsupportedLegacyStrings(section, fields) {
|
|
|
281
255
|
}
|
|
282
256
|
}
|
|
283
257
|
}
|
|
284
|
-
function removeUnsupportedLegacyNullableStrings(section, fields) {
|
|
285
|
-
for (const field of fields) {
|
|
286
|
-
if (field in section &&
|
|
287
|
-
section[field] !== null &&
|
|
288
|
-
(typeof section[field] !== "string" || section[field].length === 0)) {
|
|
289
|
-
delete section[field];
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
258
|
function validateCanonicalContract(manifest, findings) {
|
|
294
259
|
const remote = manifest.scan.target.remote;
|
|
295
260
|
if (remote !== undefined) {
|
|
@@ -338,15 +303,15 @@ function validateCanonicalContract(manifest, findings) {
|
|
|
338
303
|
throw new ContractValidationError(`${locationContext}.path: expected a safe repository-relative POSIX path.`, { cause: error });
|
|
339
304
|
}
|
|
340
305
|
}
|
|
341
|
-
const fingerprint = `codex-security/v1:sha256:${
|
|
306
|
+
const fingerprint = `codex-security/v1:sha256:${hash("sha256", [
|
|
342
307
|
"codex-security/v1",
|
|
343
308
|
manifest.scan.target.targetId,
|
|
344
309
|
finding.ruleId,
|
|
345
310
|
finding.identity.anchor,
|
|
346
311
|
finding.identity.instance ?? "",
|
|
347
312
|
].join("\0"))}`;
|
|
348
|
-
const findingId = `csf_${
|
|
349
|
-
const occurrenceId = `occ_${
|
|
313
|
+
const findingId = `csf_${hash("sha256", fingerprint).slice(0, 24)}`;
|
|
314
|
+
const occurrenceId = `occ_${hash("sha256", [manifest.scan.id, fingerprint].join("\0")).slice(0, 24)}`;
|
|
350
315
|
if (finding.findingId !== findingId) {
|
|
351
316
|
throw new ContractValidationError(`${context}.findingId: does not match derived fingerprint identity.`);
|
|
352
317
|
}
|
|
@@ -358,9 +323,6 @@ function validateCanonicalContract(manifest, findings) {
|
|
|
358
323
|
}
|
|
359
324
|
}
|
|
360
325
|
}
|
|
361
|
-
function sha256Text(value) {
|
|
362
|
-
return createHash("sha256").update(value, "utf8").digest("hex");
|
|
363
|
-
}
|
|
364
326
|
export async function requireScanFile(scanDirectory, relativePath, context, signal) {
|
|
365
327
|
return (await requireCheckedScanFile(scanDirectory, relativePath, context, signal)).path;
|
|
366
328
|
}
|
|
@@ -390,15 +352,11 @@ async function requireCheckedScanFile(scanDirectory, relativePath, context, sign
|
|
|
390
352
|
}
|
|
391
353
|
const parents = [{ path: scanDir, metadata: rootMetadata }];
|
|
392
354
|
throwIfAborted(signal);
|
|
393
|
-
if (!parents[0].metadata.isDirectory() ||
|
|
394
|
-
parents[0].metadata.isSymbolicLink()) {
|
|
395
|
-
throw new Error("unsafe scan directory");
|
|
396
|
-
}
|
|
397
355
|
for (const part of parts.slice(0, -1)) {
|
|
398
356
|
current = join(current, part);
|
|
399
357
|
const metadata = await lstat(current);
|
|
400
358
|
throwIfAborted(signal);
|
|
401
|
-
if (
|
|
359
|
+
if (!metadata.isDirectory()) {
|
|
402
360
|
throw new Error("unsafe parent");
|
|
403
361
|
}
|
|
404
362
|
parents.push({ path: current, metadata });
|
|
@@ -406,7 +364,7 @@ async function requireCheckedScanFile(scanDirectory, relativePath, context, sign
|
|
|
406
364
|
const path = join(scanDir, ...parts);
|
|
407
365
|
const metadata = await lstat(path);
|
|
408
366
|
throwIfAborted(signal);
|
|
409
|
-
if (
|
|
367
|
+
if (!metadata.isFile()) {
|
|
410
368
|
throw new ContractValidationError(`${context}: expected a regular non-symlink file.`);
|
|
411
369
|
}
|
|
412
370
|
const canonical = await realpath(path);
|
|
@@ -510,11 +468,14 @@ function validateExpectation(manifest, coverage, expectation, workbenchValidated
|
|
|
510
468
|
}
|
|
511
469
|
}
|
|
512
470
|
if (requested.kind === "paths") {
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
471
|
+
const actualPaths = scan.scope.includePaths.map(safeScopePath);
|
|
472
|
+
const actual = new Set(actualPaths);
|
|
473
|
+
if (actualPaths.length === actual.size) {
|
|
474
|
+
const expected = new Set(requested.paths);
|
|
475
|
+
if (actual.size === expected.size && actual.isSubsetOf(expected))
|
|
476
|
+
return;
|
|
517
477
|
}
|
|
478
|
+
throw new ContractValidationError("Manifest include paths do not match the requested path target.");
|
|
518
479
|
}
|
|
519
480
|
}
|
|
520
481
|
function expectedCoverageMode(target, mode) {
|
|
@@ -539,13 +500,10 @@ async function requireScanRoot(scanDirectory, signal) {
|
|
|
539
500
|
const returned = await lstat(canonical);
|
|
540
501
|
throwIfAborted(signal);
|
|
541
502
|
if (!metadata.isDirectory() ||
|
|
542
|
-
metadata.isSymbolicLink() ||
|
|
543
503
|
!current.isDirectory() ||
|
|
544
|
-
current.isSymbolicLink() ||
|
|
545
504
|
metadata.dev !== current.dev ||
|
|
546
505
|
metadata.ino !== current.ino ||
|
|
547
506
|
!returned.isDirectory() ||
|
|
548
|
-
returned.isSymbolicLink() ||
|
|
549
507
|
metadata.dev !== returned.dev ||
|
|
550
508
|
metadata.ino !== returned.ino) {
|
|
551
509
|
throw new Error("not a directory");
|
|
@@ -573,7 +531,6 @@ async function verifyScanRoot(root, signal) {
|
|
|
573
531
|
const current = await lstat(root.path);
|
|
574
532
|
throwIfAborted(signal);
|
|
575
533
|
if (!current.isDirectory() ||
|
|
576
|
-
current.isSymbolicLink() ||
|
|
577
534
|
current.dev !== root.metadata.dev ||
|
|
578
535
|
current.ino !== root.metadata.ino) {
|
|
579
536
|
throw new Error("scan directory changed while reading");
|
|
@@ -589,7 +546,7 @@ async function verifyScanRoot(root, signal) {
|
|
|
589
546
|
function safeRelativePath(value, context) {
|
|
590
547
|
const parts = value.split("/");
|
|
591
548
|
if (value.trim().length === 0 ||
|
|
592
|
-
|
|
549
|
+
Buffer.from(value, "utf8").toString("utf8") !== value ||
|
|
593
550
|
value === "." ||
|
|
594
551
|
value.startsWith("/") ||
|
|
595
552
|
/^[A-Za-z]:/.test(value) ||
|
|
@@ -622,7 +579,7 @@ async function readScanJson(scanDir, relativePath, documentDigests, signal, expe
|
|
|
622
579
|
const file = await openCheckedScanFile(scanDir, relativePath, relativePath, signal, expectedRoot);
|
|
623
580
|
try {
|
|
624
581
|
const bytes = await file.readFile({ signal });
|
|
625
|
-
documentDigests.set(relativePath,
|
|
582
|
+
documentDigests.set(relativePath, hash("sha256", bytes));
|
|
626
583
|
return parseJson(join(scanDir, relativePath), bytes);
|
|
627
584
|
}
|
|
628
585
|
catch (error) {
|
|
@@ -685,7 +642,7 @@ function validateParsedJson(value, context) {
|
|
|
685
642
|
return;
|
|
686
643
|
}
|
|
687
644
|
if (typeof value === "string") {
|
|
688
|
-
if (!
|
|
645
|
+
if (!value.isWellFormed()) {
|
|
689
646
|
throw new ContractValidationError(`${context}: expected well-formed Unicode JSON strings.`);
|
|
690
647
|
}
|
|
691
648
|
return;
|
|
@@ -698,16 +655,13 @@ function validateParsedJson(value, context) {
|
|
|
698
655
|
}
|
|
699
656
|
if (isRecord(value)) {
|
|
700
657
|
for (const [key, item] of Object.entries(value)) {
|
|
701
|
-
if (!
|
|
658
|
+
if (!key.isWellFormed()) {
|
|
702
659
|
throw new ContractValidationError(`${context}: expected well-formed Unicode JSON keys.`);
|
|
703
660
|
}
|
|
704
661
|
validateParsedJson(item, `${context}.<property>`);
|
|
705
662
|
}
|
|
706
663
|
}
|
|
707
664
|
}
|
|
708
|
-
function isWellFormedUnicode(value) {
|
|
709
|
-
return Buffer.from(value, "utf8").toString("utf8") === value;
|
|
710
|
-
}
|
|
711
665
|
function createValidator() {
|
|
712
666
|
// The plugin schemas are the immutable v0 contract. They are valid Draft
|
|
713
667
|
// 2020-12 but intentionally omit redundant local `type` keywords that Ajv's
|
|
@@ -755,7 +709,6 @@ async function openCheckedScanFile(scanDir, relativePath, context, signal, expec
|
|
|
755
709
|
const current = await lstat(parent.path);
|
|
756
710
|
throwIfAborted(signal);
|
|
757
711
|
if (!current.isDirectory() ||
|
|
758
|
-
current.isSymbolicLink() ||
|
|
759
712
|
current.dev !== parent.metadata.dev ||
|
|
760
713
|
current.ino !== parent.metadata.ino) {
|
|
761
714
|
throw new ContractValidationError(`${context}: checked parent changed before opening the file.`);
|
|
@@ -764,7 +717,6 @@ async function openCheckedScanFile(scanDir, relativePath, context, signal, expec
|
|
|
764
717
|
const current = await lstat(checked.path);
|
|
765
718
|
throwIfAborted(signal);
|
|
766
719
|
if (!current.isFile() ||
|
|
767
|
-
current.isSymbolicLink() ||
|
|
768
720
|
current.dev !== checked.metadata.dev ||
|
|
769
721
|
current.ino !== checked.metadata.ino) {
|
|
770
722
|
throw new ContractValidationError(`${context}: checked file changed before reading.`);
|
|
@@ -792,7 +744,6 @@ export async function sameCheckedFileDevice(file, checked, opened, platform = pr
|
|
|
792
744
|
]);
|
|
793
745
|
if (!openedIdentity.isFile() ||
|
|
794
746
|
!checkedIdentity.isFile() ||
|
|
795
|
-
checkedIdentity.isSymbolicLink() ||
|
|
796
747
|
openedIdentity.ino !== checkedIdentity.ino) {
|
|
797
748
|
return false;
|
|
798
749
|
}
|
|
@@ -810,8 +761,7 @@ export async function sameCheckedFileDevice(file, checked, opened, platform = pr
|
|
|
810
761
|
function throwIfAborted(signal) {
|
|
811
762
|
if (!signal?.aborted)
|
|
812
763
|
return;
|
|
813
|
-
throw (signal
|
|
814
|
-
new DOMException("The operation was aborted.", "AbortError"));
|
|
764
|
+
throw abortReason(signal);
|
|
815
765
|
}
|
|
816
766
|
function validRfc3339DateTime(value) {
|
|
817
767
|
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i.exec(value);
|
|
@@ -869,28 +819,19 @@ function schemaError(filename, errors) {
|
|
|
869
819
|
.join(".");
|
|
870
820
|
const keyword = first?.keyword ?? "unknown";
|
|
871
821
|
const count = errors.length;
|
|
872
|
-
|
|
873
|
-
const detail = keyword === "format" && format === "date-time" ? "; date-time" : "";
|
|
874
|
-
return new ContractValidationError(`${filename}:${location}: schema validation failed (${keyword}${detail}; ${count} ${count === 1 ? "error" : "errors"}).`);
|
|
822
|
+
return new ContractValidationError(`${filename}:${location}: schema validation failed (${keyword}${keyword === "format" && first?.params["format"] === "date-time" ? "; date-time" : ""}; ${count} ${count === 1 ? "error" : "errors"}).`);
|
|
875
823
|
}
|
|
876
824
|
function sameArray(left, right) {
|
|
877
825
|
return (left.length === right.length &&
|
|
878
826
|
left.every((value, index) => value === right[index]));
|
|
879
827
|
}
|
|
880
|
-
function sameSet(left, right) {
|
|
881
|
-
return (left.size === right.size && [...left].every((value) => right.has(value)));
|
|
882
|
-
}
|
|
883
|
-
function isContained(root, candidate) {
|
|
884
|
-
const child = relative(root, candidate);
|
|
885
|
-
return (child === "" ||
|
|
886
|
-
(child !== ".." && !child.startsWith(`..${sep}`) && !isAbsolute(child)));
|
|
887
|
-
}
|
|
888
|
-
function isRecord(value) {
|
|
889
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
890
|
-
}
|
|
891
828
|
function nodeErrorCode(error) {
|
|
892
829
|
return typeof error === "object" && error !== null && "code" in error
|
|
893
830
|
? String(error.code)
|
|
894
831
|
: undefined;
|
|
895
832
|
}
|
|
833
|
+
/** @internal */
|
|
834
|
+
export function sha256Text(value) {
|
|
835
|
+
return hash("sha256", value);
|
|
836
|
+
}
|
|
896
837
|
//# sourceMappingURL=contract.js.map
|