@openai/codex-security 0.3.0 → 0.5.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 +45 -9
- package/_bundled_plugin/.codex-plugin/plugin.json +5 -5
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +13 -20
- 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/core-scan.md +2 -0
- package/_bundled_plugin/references/final-report.md +5 -1
- package/_bundled_plugin/references/investigation-time-budget.md +11 -0
- package/_bundled_plugin/references/sarif-adapter.md +1 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -6
- package/_bundled_plugin/references/scan-runtime.md +15 -0
- package/_bundled_plugin/references/threat-model.md +2 -0
- package/_bundled_plugin/schemas/coverage.schema.json +45 -126
- package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +5 -1
- package/_bundled_plugin/schemas/findings.schema.json +140 -427
- package/_bundled_plugin/schemas/patch-risk-assessment.schema.json +106 -119
- package/_bundled_plugin/schemas/scan-manifest.schema.json +73 -188
- package/_bundled_plugin/scripts/deep_scan_workbench.py +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +87 -49
- package/_bundled_plugin/scripts/finding_preview.py +5 -3
- package/_bundled_plugin/scripts/generate_rank_input.py +26 -106
- package/_bundled_plugin/scripts/launch_codex_security_mcp +39 -4
- package/_bundled_plugin/scripts/report_projection.py +35 -13
- package/_bundled_plugin/scripts/snapshot_sqlite.py +7 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -1
- package/_bundled_plugin/scripts/workbench_cli.py +9 -9
- package/_bundled_plugin/scripts/workbench_constants.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +103 -45
- package/_bundled_plugin/scripts/workbench_progress.py +0 -50
- package/_bundled_plugin/scripts/workbench_publication.py +216 -247
- package/_bundled_plugin/scripts/workbench_scan_history.py +3 -2
- package/_bundled_plugin/scripts/workbench_scan_start.py +12 -4
- package/_bundled_plugin/scripts/workbench_scan_usage.py +360 -37
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +74 -51
- package/_bundled_plugin/scripts/workbench_source_scopes.py +388 -0
- package/_bundled_plugin/scripts/workbench_target.py +7 -5
- package/_bundled_plugin/scripts/workbench_validation.py +52 -2
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -0
- package/_bundled_plugin/shared/workbench-migrations.json +22 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +4 -2
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +4 -2
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -3
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +2 -0
- package/_bundled_plugin/skills/track-findings/SKILL.md +8 -4
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +1 -1
- package/dist/api.d.ts +6 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +266 -39
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +2 -1
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +38 -23
- package/dist/artifact-export.js.map +1 -1
- package/dist/classify-severity-records.d.ts +76 -0
- package/dist/classify-severity-records.d.ts.map +1 -0
- package/dist/classify-severity-records.js +141 -0
- package/dist/classify-severity-records.js.map +1 -0
- package/dist/classify-severity.d.ts +1 -23
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -24
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +2 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +148 -149
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +1 -1
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.js +1 -1
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/component-plan.js +1 -1
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +5 -4
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -4
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +6 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +69 -20
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +7 -2
- package/dist/cost-model.js.map +1 -1
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +1 -5
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +2 -2
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +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 +3 -8
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +11 -171
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.js +1 -1
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +10 -9
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +4 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +21 -1
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +15 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +15 -16
- package/dist/deep-progress.js.map +1 -1
- package/dist/executable-path.d.ts +2 -0
- package/dist/executable-path.d.ts.map +1 -0
- package/dist/executable-path.js +12 -0
- package/dist/executable-path.js.map +1 -0
- package/dist/feedback.d.ts +1 -4
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +1 -1
- package/dist/feedback.js.map +1 -1
- package/dist/findings-import.d.ts +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +3 -3
- package/dist/findings-import.js.map +1 -1
- package/dist/git-remote.d.ts +10 -0
- package/dist/git-remote.d.ts.map +1 -0
- package/dist/git-remote.js +24 -0
- package/dist/git-remote.js.map +1 -0
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +5 -7
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +19 -0
- package/dist/host-protocol.d.ts.map +1 -0
- package/dist/host-protocol.js +270 -0
- package/dist/host-protocol.js.map +1 -0
- package/dist/host-records-protocol.d.ts +15 -0
- package/dist/host-records-protocol.d.ts.map +1 -0
- package/dist/host-records-protocol.js +15 -0
- package/dist/host-records-protocol.js.map +1 -0
- package/dist/hosted-scan-protocol.d.ts +4 -0
- package/dist/hosted-scan-protocol.d.ts.map +1 -0
- package/dist/hosted-scan-protocol.js +25 -0
- package/dist/hosted-scan-protocol.js.map +1 -0
- package/dist/hosted-scan.d.ts +112 -0
- package/dist/hosted-scan.d.ts.map +1 -0
- package/dist/hosted-scan.js +260 -0
- package/dist/hosted-scan.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +87 -7
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +108 -36
- package/dist/multiscan.js.map +1 -1
- package/dist/patch-publication.d.ts +26 -0
- package/dist/patch-publication.d.ts.map +1 -0
- package/dist/patch-publication.js +105 -0
- package/dist/patch-publication.js.map +1 -0
- 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/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +16 -6
- package/dist/project-config.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +73 -63
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +0 -2
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +135 -24
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +39 -25
- package/dist/publish.js.map +1 -1
- package/dist/runtime.d.ts +5 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +86 -58
- package/dist/runtime.js.map +1 -1
- package/dist/scan-executor.d.ts +104 -0
- package/dist/scan-executor.d.ts.map +1 -0
- package/dist/scan-executor.js +62 -0
- package/dist/scan-executor.js.map +1 -0
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +7 -1
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-time-budget.d.ts +9 -0
- package/dist/scan-time-budget.d.ts.map +1 -0
- package/dist/scan-time-budget.js +16 -0
- package/dist/scan-time-budget.js.map +1 -0
- package/dist/severity-review.d.ts +29 -0
- package/dist/severity-review.d.ts.map +1 -0
- package/dist/severity-review.js +47 -0
- package/dist/severity-review.js.map +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +17 -25
- package/dist/targets.js.map +1 -1
- package/dist/validation-records.d.ts +38 -0
- package/dist/validation-records.d.ts.map +1 -0
- package/dist/validation-records.js +76 -0
- package/dist/validation-records.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +4 -2
- package/dist/version.js.map +1 -1
- package/dist/worker-progress.d.ts +43 -15
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +22 -80
- package/dist/worker-progress.js.map +1 -1
- package/docs/classify-severity-records.md +89 -0
- package/docs/cli.md +281 -35
- package/docs/hosted-scans.md +242 -0
- package/docs/validate-records.md +69 -0
- package/package.json +18 -14
- package/schemas/hosted-scan-v2.fixture.json +145 -0
- package/schemas/project-config.schema.json +7 -1
- package/_bundled_plugin/preflight/capability-profiles.toml +0 -76
- package/_bundled_plugin/references/config-preflight.md +0 -93
- package/_bundled_plugin/references/desktop-config-preflight.md +0 -11
- package/_bundled_plugin/scripts/config_preflight.py +0 -911
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { readScanFile, safeScopePath } from "./contract.js";
|
|
4
|
+
import { isRecord } from "./record.js";
|
|
5
|
+
import { VERSION } from "./version.js";
|
|
6
|
+
import { ScanExecutionError, } from "./scan-executor.js";
|
|
7
|
+
import { realpath } from "node:fs/promises";
|
|
8
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { CodexSecurity } from "./api.js";
|
|
11
|
+
import { ScanInterruptedError, errorMessage } from "./errors.js";
|
|
12
|
+
import { normalizeRepository, repositoryRevision } from "./targets.js";
|
|
13
|
+
import { isWithin } from "./trusted-executable.js";
|
|
14
|
+
/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */
|
|
15
|
+
export const HostedScanInputSchema = z.strictObject({
|
|
16
|
+
version: z.literal(2),
|
|
17
|
+
repository: z.string().min(1),
|
|
18
|
+
revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),
|
|
19
|
+
scope: z
|
|
20
|
+
.strictObject({ paths: z.array(z.string().min(1)).min(1) })
|
|
21
|
+
.optional(),
|
|
22
|
+
outputDirectory: z.string().min(1),
|
|
23
|
+
stateDirectory: z.string().min(1),
|
|
24
|
+
model: z.string().min(1),
|
|
25
|
+
reasoningEffort: z.string(),
|
|
26
|
+
identity: z.strictObject({
|
|
27
|
+
runId: z.string().min(1),
|
|
28
|
+
attemptId: z.string().min(1),
|
|
29
|
+
buildId: z.string().min(1),
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
export class HostedScanPreparationError extends Error {
|
|
33
|
+
reason;
|
|
34
|
+
constructor(reason, message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.reason = reason;
|
|
37
|
+
this.name = "HostedScanPreparationError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function normalizeHostedScope(path) {
|
|
41
|
+
const parts = path.split(process.platform === "win32" ? /[/\\]/ : "/");
|
|
42
|
+
if (path.length === 0 ||
|
|
43
|
+
path.includes("\0") ||
|
|
44
|
+
isAbsolute(path) ||
|
|
45
|
+
(process.platform === "win32" && /^[a-z]:/i.test(path)) ||
|
|
46
|
+
parts.includes("..")) {
|
|
47
|
+
throw new HostedScanPreparationError("scope_syntax", "Use non-empty repository-relative folders or files without parent traversal or NUL characters.");
|
|
48
|
+
}
|
|
49
|
+
const normalized = parts
|
|
50
|
+
.filter((part) => part !== "" && part !== ".")
|
|
51
|
+
.join("/");
|
|
52
|
+
try {
|
|
53
|
+
return safeScopePath(normalized || ".");
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new HostedScanPreparationError("scope_syntax", `${JSON.stringify(path)} cannot be used as scan scope: the output contract requires UTF-8 repository-relative paths without drive prefixes, backslashes, or control characters.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function comparePaths(left, right) {
|
|
60
|
+
return Buffer.compare(Buffer.from(left), Buffer.from(right));
|
|
61
|
+
}
|
|
62
|
+
export function normalizeHostedPaths(paths = ["."]) {
|
|
63
|
+
if (paths.length === 0)
|
|
64
|
+
throw new HostedScanPreparationError("scope_syntax", "An explicit path scope must not be empty. Omit scope to scan the repository.");
|
|
65
|
+
const normalized = [...new Set(paths.map(normalizeHostedScope))].sort(comparePaths);
|
|
66
|
+
if (normalized.length > 1 && normalized.includes("."))
|
|
67
|
+
throw new HostedScanPreparationError("scope_syntax", "Repository scope cannot be mixed with narrower paths.");
|
|
68
|
+
return normalized;
|
|
69
|
+
}
|
|
70
|
+
/** Validate every path at the frozen commit before registering a scan/executing. */
|
|
71
|
+
async function prepareHostedScan(input, signal) {
|
|
72
|
+
const scope = { paths: normalizeHostedPaths(input.scope?.paths) };
|
|
73
|
+
const repository = await normalizeRepository(input.repository, signal);
|
|
74
|
+
if ((await repositoryRevision(repository, signal)) !== input.revision)
|
|
75
|
+
throw new HostedScanPreparationError("revision_mismatch", "Checkout does not match the frozen revision.");
|
|
76
|
+
for (const path of scope.paths) {
|
|
77
|
+
const selected = resolve(repository, path);
|
|
78
|
+
let target;
|
|
79
|
+
try {
|
|
80
|
+
target = await realpath(selected);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (!(error instanceof Error) ||
|
|
84
|
+
!("code" in error) ||
|
|
85
|
+
error.code !== "ENOENT")
|
|
86
|
+
throw error;
|
|
87
|
+
throw new HostedScanPreparationError("scope_missing", `${path} does not exist at the selected revision. Update the paths and start a new scan.`);
|
|
88
|
+
}
|
|
89
|
+
if (!isWithin(repository, target))
|
|
90
|
+
throw new HostedScanPreparationError("scope_outside_repository", `${path} resolves outside the repository.`);
|
|
91
|
+
if (target !== selected) {
|
|
92
|
+
const canonical = relative(repository, target).split(sep).join("/") || ".";
|
|
93
|
+
throw new HostedScanPreparationError("scope_alias", `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
repository,
|
|
98
|
+
revision: input.revision,
|
|
99
|
+
scope,
|
|
100
|
+
identity: input.identity,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function hostedScanEnvironment(stateDirectory) {
|
|
104
|
+
const environment = {
|
|
105
|
+
PATH: process.env["PATH"] ?? "",
|
|
106
|
+
CODEX_SECURITY_STATE_DIR: resolve(stateDirectory),
|
|
107
|
+
};
|
|
108
|
+
for (const key of [
|
|
109
|
+
"SYSTEMROOT",
|
|
110
|
+
"WINDIR",
|
|
111
|
+
"PATHEXT",
|
|
112
|
+
"TMPDIR",
|
|
113
|
+
"TEMP",
|
|
114
|
+
"TMP",
|
|
115
|
+
])
|
|
116
|
+
if (process.env[key] !== undefined)
|
|
117
|
+
environment[key] = process.env[key];
|
|
118
|
+
return environment;
|
|
119
|
+
}
|
|
120
|
+
/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */
|
|
121
|
+
export async function runHostedScan(value, options) {
|
|
122
|
+
const input = HostedScanInputSchema.parse(value);
|
|
123
|
+
const context = await prepareHostedScan(input, options.signal);
|
|
124
|
+
let execution;
|
|
125
|
+
let request;
|
|
126
|
+
let scanId;
|
|
127
|
+
const onEvent = (event) => {
|
|
128
|
+
void Promise.resolve()
|
|
129
|
+
.then(() => options.onEvent?.(event))
|
|
130
|
+
.catch(() => { });
|
|
131
|
+
};
|
|
132
|
+
const client = new CodexSecurity({
|
|
133
|
+
codexOverrides: {
|
|
134
|
+
model: input.model,
|
|
135
|
+
model_reasoning_effort: input.reasoningEffort,
|
|
136
|
+
},
|
|
137
|
+
}, {
|
|
138
|
+
environment: hostedScanEnvironment(input.stateDirectory),
|
|
139
|
+
hostedScan: {
|
|
140
|
+
context,
|
|
141
|
+
executor: {
|
|
142
|
+
async run(value, runOptions) {
|
|
143
|
+
request = value;
|
|
144
|
+
execution = await options.executor.run(value, runOptions);
|
|
145
|
+
return execution;
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
onEvent,
|
|
149
|
+
},
|
|
150
|
+
createCodex() {
|
|
151
|
+
throw new Error("Local inference is unavailable in hosted mode.");
|
|
152
|
+
},
|
|
153
|
+
}, { surface: "sdk" });
|
|
154
|
+
let outputDirectory = resolve(input.outputDirectory);
|
|
155
|
+
const base = () => ({
|
|
156
|
+
version: 2,
|
|
157
|
+
...context,
|
|
158
|
+
outputDirectory,
|
|
159
|
+
...(scanId === undefined ? {} : { scanId }),
|
|
160
|
+
...(request === undefined
|
|
161
|
+
? {}
|
|
162
|
+
: {
|
|
163
|
+
pluginVersion: request.runtime.pluginVersion,
|
|
164
|
+
}),
|
|
165
|
+
provenance: {
|
|
166
|
+
cliVersion: VERSION,
|
|
167
|
+
buildId: input.identity.buildId,
|
|
168
|
+
...(request === undefined
|
|
169
|
+
? {}
|
|
170
|
+
: { pluginVersion: request.runtime.pluginVersion }),
|
|
171
|
+
},
|
|
172
|
+
...(execution === undefined ? {} : { execution }),
|
|
173
|
+
});
|
|
174
|
+
try {
|
|
175
|
+
const result = await client.run(context.repository, {
|
|
176
|
+
target: context.scope.paths[0] === "."
|
|
177
|
+
? "repository"
|
|
178
|
+
: context.scope.paths.map((path) => `./${path}`),
|
|
179
|
+
mode: "standard",
|
|
180
|
+
outputDir: outputDirectory,
|
|
181
|
+
signal: options.signal,
|
|
182
|
+
onOutputDirReady(path) {
|
|
183
|
+
outputDirectory = path;
|
|
184
|
+
},
|
|
185
|
+
onScanRegistered(scan) {
|
|
186
|
+
scanId = scan.scanId;
|
|
187
|
+
outputDirectory = scan.scanDir;
|
|
188
|
+
},
|
|
189
|
+
onProgress(progress) {
|
|
190
|
+
onEvent({ type: "progress", progress });
|
|
191
|
+
},
|
|
192
|
+
onActivity(activity) {
|
|
193
|
+
onEvent({ type: "activity", activity });
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
if (result.manifest.scan.target.revision !== context.revision ||
|
|
197
|
+
(await repositoryRevision(context.repository, options.signal)) !==
|
|
198
|
+
context.revision)
|
|
199
|
+
throw new Error("Checkout changed from the frozen revision during execution.");
|
|
200
|
+
if (!isDeepStrictEqual([...result.manifest.scan.scope.includePaths].sort(comparePaths), context.scope.paths) ||
|
|
201
|
+
result.manifest.scan.scope.excludePaths.length !== 0)
|
|
202
|
+
throw new Error("Completed artifacts do not match the requested scope.");
|
|
203
|
+
const sources = result.manifest.scan["preservedSources"];
|
|
204
|
+
const names = new Set([
|
|
205
|
+
"scan-manifest.json",
|
|
206
|
+
"findings.json",
|
|
207
|
+
"coverage.json",
|
|
208
|
+
"report.md",
|
|
209
|
+
...result.manifest.scan.artifacts.map((artifact) => artifact.path),
|
|
210
|
+
...(isRecord(sources) ? Object.keys(sources) : []),
|
|
211
|
+
]);
|
|
212
|
+
const artifacts = await Promise.all([...names].sort().map(async (path) => {
|
|
213
|
+
const contents = await readScanFile(outputDirectory, path, path);
|
|
214
|
+
return {
|
|
215
|
+
path,
|
|
216
|
+
sha256: createHash("sha256").update(contents).digest("hex"),
|
|
217
|
+
bytes: Buffer.byteLength(contents),
|
|
218
|
+
};
|
|
219
|
+
}));
|
|
220
|
+
return {
|
|
221
|
+
...base(),
|
|
222
|
+
status: "completed",
|
|
223
|
+
artifacts,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
if (error instanceof ScanExecutionError)
|
|
228
|
+
execution = error.result;
|
|
229
|
+
return {
|
|
230
|
+
...base(),
|
|
231
|
+
status: execution?.status === "acceptance_unknown"
|
|
232
|
+
? "acceptance_unknown"
|
|
233
|
+
: options.signal?.aborted ||
|
|
234
|
+
execution?.status === "canceled" ||
|
|
235
|
+
error instanceof ScanInterruptedError
|
|
236
|
+
? "canceled"
|
|
237
|
+
: "failed",
|
|
238
|
+
error: errorMessage(error),
|
|
239
|
+
artifacts: [],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
try {
|
|
244
|
+
await client.close();
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
onEvent({
|
|
248
|
+
type: "activity",
|
|
249
|
+
activity: {
|
|
250
|
+
id: "runtime.cleanup",
|
|
251
|
+
kind: "message",
|
|
252
|
+
status: "failed",
|
|
253
|
+
description: `Hosted scan cleanup failed: ${errorMessage(error)}`,
|
|
254
|
+
paths: [],
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=hosted-scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scan.js","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,GAKnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE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,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC;gBACN,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE;oBACR,EAAE,EAAE,iBAAiB;oBACrB,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,QAAQ;oBAChB,WAAW,EAAE,+BAA+B,YAAY,CAAC,KAAK,CAAC,EAAE;oBACjE,KAAK,EAAE,EAAE;iBACV;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { readScanFile, safeScopePath } from \"./contract.js\";\nimport { isRecord } from \"./record.js\";\nimport { VERSION } from \"./version.js\";\nimport {\n ScanExecutionError,\n type ScanExecutor,\n type ScanExecutionResult,\n type ScanExecutionEvent,\n type ScanExecutionRequest,\n} from \"./scan-executor.js\";\nexport type { ScanExecutor, ScanExecutionRequest } from \"./scan-executor.js\";\nimport { realpath } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { CodexSecurity } from \"./api.js\";\nimport { ScanInterruptedError, errorMessage } from \"./errors.js\";\nimport { normalizeRepository, repositoryRevision } from \"./targets.js\";\nimport { isWithin } from \"./trusted-executable.js\";\n\n/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */\nexport const HostedScanInputSchema = z.strictObject({\n version: z.literal(2),\n repository: z.string().min(1),\n revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),\n scope: z\n .strictObject({ paths: z.array(z.string().min(1)).min(1) })\n .optional(),\n outputDirectory: z.string().min(1),\n stateDirectory: z.string().min(1),\n model: z.string().min(1),\n reasoningEffort: z.string(),\n identity: z.strictObject({\n runId: z.string().min(1),\n attemptId: z.string().min(1),\n buildId: z.string().min(1),\n }),\n});\n\nexport type HostedScanInput = z.infer<typeof HostedScanInputSchema>;\nexport class HostedScanPreparationError extends Error {\n constructor(\n readonly reason:\n | \"scope_syntax\"\n | \"scope_missing\"\n | \"scope_outside_repository\"\n | \"scope_alias\"\n | \"revision_mismatch\",\n message: string,\n ) {\n super(message);\n this.name = \"HostedScanPreparationError\";\n }\n}\n\nexport function normalizeHostedScope(path: string): string {\n const parts = path.split(process.platform === \"win32\" ? /[/\\\\]/ : \"/\");\n if (\n path.length === 0 ||\n path.includes(\"\\0\") ||\n isAbsolute(path) ||\n (process.platform === \"win32\" && /^[a-z]:/i.test(path)) ||\n parts.includes(\"..\")\n ) {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Use non-empty repository-relative folders or files without parent traversal or NUL characters.\",\n );\n }\n const normalized = parts\n .filter((part) => part !== \"\" && part !== \".\")\n .join(\"/\");\n try {\n return safeScopePath(normalized || \".\");\n } catch {\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n `${JSON.stringify(path)} cannot be used as scan scope: the output contract requires UTF-8 repository-relative paths without drive prefixes, backslashes, or control characters.`,\n );\n }\n}\n\nfunction comparePaths(left: string, right: string): number {\n return Buffer.compare(Buffer.from(left), Buffer.from(right));\n}\n\nexport function normalizeHostedPaths(\n paths: readonly string[] = [\".\"],\n): string[] {\n if (paths.length === 0)\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"An explicit path scope must not be empty. Omit scope to scan the repository.\",\n );\n const normalized = [...new Set(paths.map(normalizeHostedScope))].sort(\n comparePaths,\n );\n if (normalized.length > 1 && normalized.includes(\".\"))\n throw new HostedScanPreparationError(\n \"scope_syntax\",\n \"Repository scope cannot be mixed with narrower paths.\",\n );\n return normalized;\n}\n\n/** Validate every path at the frozen commit before registering a scan/executing. */\nasync function prepareHostedScan(input: HostedScanInput, signal?: AbortSignal) {\n const scope = { paths: normalizeHostedPaths(input.scope?.paths) };\n const repository = await normalizeRepository(input.repository, signal);\n if ((await repositoryRevision(repository, signal)) !== input.revision)\n throw new HostedScanPreparationError(\n \"revision_mismatch\",\n \"Checkout does not match the frozen revision.\",\n );\n for (const path of scope.paths) {\n const selected = resolve(repository, path);\n let target: string;\n try {\n target = await realpath(selected);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n !(\"code\" in error) ||\n error.code !== \"ENOENT\"\n )\n throw error;\n throw new HostedScanPreparationError(\n \"scope_missing\",\n `${path} does not exist at the selected revision. Update the paths and start a new scan.`,\n );\n }\n if (!isWithin(repository, target))\n throw new HostedScanPreparationError(\n \"scope_outside_repository\",\n `${path} resolves outside the repository.`,\n );\n if (target !== selected) {\n const canonical =\n relative(repository, target).split(sep).join(\"/\") || \".\";\n throw new HostedScanPreparationError(\n \"scope_alias\",\n `${path} resolves to ${canonical}. Use the canonical repository path and start a new scan.`,\n );\n }\n }\n return {\n repository,\n revision: input.revision,\n scope,\n identity: input.identity,\n };\n}\n\nfunction hostedScanEnvironment(stateDirectory: string): Record<string, string> {\n const environment: Record<string, string> = {\n PATH: process.env[\"PATH\"] ?? \"\",\n CODEX_SECURITY_STATE_DIR: resolve(stateDirectory),\n };\n for (const key of [\n \"SYSTEMROOT\",\n \"WINDIR\",\n \"PATHEXT\",\n \"TMPDIR\",\n \"TEMP\",\n \"TMP\",\n ])\n if (process.env[key] !== undefined) environment[key] = process.env[key]!;\n return environment;\n}\n\nexport interface HostedScanOptions {\n executor: ScanExecutor;\n signal?: AbortSignal;\n onEvent?: (event: ScanExecutionEvent) => void;\n}\n\n/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */\nexport async function runHostedScan(\n value: HostedScanInput,\n options: HostedScanOptions,\n) {\n const input = HostedScanInputSchema.parse(value);\n const context = await prepareHostedScan(input, options.signal);\n let execution: ScanExecutionResult | undefined;\n let request: ScanExecutionRequest | undefined;\n let scanId: string | undefined;\n const onEvent = (event: ScanExecutionEvent): void => {\n void Promise.resolve()\n .then(() => options.onEvent?.(event))\n .catch(() => {});\n };\n const client = new CodexSecurity(\n {\n codexOverrides: {\n model: input.model,\n model_reasoning_effort: input.reasoningEffort,\n },\n },\n {\n environment: hostedScanEnvironment(input.stateDirectory),\n hostedScan: {\n context,\n executor: {\n async run(value, runOptions) {\n request = value;\n execution = await options.executor.run(value, runOptions);\n return execution;\n },\n },\n onEvent,\n },\n createCodex() {\n throw new Error(\"Local inference is unavailable in hosted mode.\");\n },\n },\n { surface: \"sdk\" },\n );\n let outputDirectory = resolve(input.outputDirectory);\n const base = () => ({\n version: 2 as const,\n ...context,\n outputDirectory,\n ...(scanId === undefined ? {} : { scanId }),\n ...(request === undefined\n ? {}\n : {\n pluginVersion: request.runtime.pluginVersion,\n }),\n provenance: {\n cliVersion: VERSION,\n buildId: input.identity.buildId,\n ...(request === undefined\n ? {}\n : { pluginVersion: request.runtime.pluginVersion }),\n },\n ...(execution === undefined ? {} : { execution }),\n });\n try {\n const result = await client.run(context.repository, {\n target:\n context.scope.paths[0] === \".\"\n ? \"repository\"\n : context.scope.paths.map((path) => `./${path}`),\n mode: \"standard\",\n outputDir: outputDirectory,\n signal: options.signal,\n onOutputDirReady(path) {\n outputDirectory = path;\n },\n onScanRegistered(scan) {\n scanId = scan.scanId;\n outputDirectory = scan.scanDir;\n },\n onProgress(progress) {\n onEvent({ type: \"progress\", progress });\n },\n onActivity(activity) {\n onEvent({ type: \"activity\", activity });\n },\n });\n if (\n result.manifest.scan.target.revision !== context.revision ||\n (await repositoryRevision(context.repository, options.signal)) !==\n context.revision\n )\n throw new Error(\n \"Checkout changed from the frozen revision during execution.\",\n );\n if (\n !isDeepStrictEqual(\n [...result.manifest.scan.scope.includePaths].sort(comparePaths),\n context.scope.paths,\n ) ||\n result.manifest.scan.scope.excludePaths.length !== 0\n )\n throw new Error(\"Completed artifacts do not match the requested scope.\");\n const sources = result.manifest.scan[\"preservedSources\"];\n const names = new Set([\n \"scan-manifest.json\",\n \"findings.json\",\n \"coverage.json\",\n \"report.md\",\n ...result.manifest.scan.artifacts.map((artifact) => artifact.path),\n ...(isRecord(sources) ? Object.keys(sources) : []),\n ]);\n const artifacts = await Promise.all(\n [...names].sort().map(async (path) => {\n const contents = await readScanFile(outputDirectory, path, path);\n return {\n path,\n sha256: createHash(\"sha256\").update(contents).digest(\"hex\"),\n bytes: Buffer.byteLength(contents),\n };\n }),\n );\n return {\n ...base(),\n status: \"completed\" as const,\n artifacts,\n };\n } catch (error) {\n if (error instanceof ScanExecutionError) execution = error.result;\n return {\n ...base(),\n status:\n execution?.status === \"acceptance_unknown\"\n ? (\"acceptance_unknown\" as const)\n : options.signal?.aborted ||\n execution?.status === \"canceled\" ||\n error instanceof ScanInterruptedError\n ? (\"canceled\" as const)\n : (\"failed\" as const),\n error: errorMessage(error),\n artifacts: [],\n };\n } finally {\n try {\n await client.close();\n } catch (error) {\n onEvent({\n type: \"activity\",\n activity: {\n id: \"runtime.cleanup\",\n kind: \"message\",\n status: \"failed\",\n description: `Hosted scan cleanup failed: ${errorMessage(error)}`,\n paths: [],\n },\n });\n }\n }\n}\n\nexport type HostedScanResult = Awaited<ReturnType<typeof runHostedScan>>;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { exportArtifact } from "./artifact-export.js";
|
|
2
2
|
export type { ExportArtifactOptions, ArtifactExportResult, } from "./artifact-export.js";
|
|
3
3
|
export { CodexSecurity, createSecurity } from "./api.js";
|
|
4
|
+
export { runHostedScan, HostedScanInputSchema, HostedScanPreparationError, } from "./hosted-scan.js";
|
|
5
|
+
export type { HostedScanInput, HostedScanOptions, HostedScanResult, } from "./hosted-scan.js";
|
|
6
|
+
export type { ScanExecutor, ScanExecutionRequest, ScanExecutionResult, ScanExecutionEvent, } from "./scan-executor.js";
|
|
4
7
|
export { loadProjectConfig, resolveProjectConfig } from "./project-config.js";
|
|
5
8
|
export type { ResolvedProjectConfig, ProjectConfigProvenance, } from "./project-config.js";
|
|
6
9
|
export type { ProjectConfigInput, ProjectScope, } from "./project-config-schema.js";
|
|
@@ -59,4 +62,8 @@ export { DiffTarget, normalizeRepository, normalizeTarget, repositoryRevision, v
|
|
|
59
62
|
export type { NormalizedTarget, ScanMode, ScanTarget } from "./targets.js";
|
|
60
63
|
export type { AbsolutePath } from "./config-path.js";
|
|
61
64
|
export { BUNDLED_PLUGIN_VERSION, VERSION } from "./version.js";
|
|
65
|
+
export { classifySeverityRecords, classifySeverityRecordsInputSchema, } from "./classify-severity-records.js";
|
|
66
|
+
export type { ClassifySeverityRecordsInput, ClassifySeverityRecordsOptions, ClassifySeverityRecordsResult, CanonicalSeverityAssessment, SeverityClassificationReviewRequest, } from "./classify-severity-records.js";
|
|
67
|
+
export { validateRecords } from "./validation-records.js";
|
|
68
|
+
export type { ValidateRecordsInput, ValidateRecordsOptions, ValidationReviewRequest, } from "./validation-records.js";
|
|
62
69
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,gBAAgB,EACh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AAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,4BAA4B,EAC5B,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,EAC3B,mCAAmC,GACpC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { exportArtifact } from "./artifact-export.js";
|
|
2
2
|
export { CodexSecurity, createSecurity } from "./api.js";
|
|
3
|
+
export { runHostedScan, HostedScanInputSchema, HostedScanPreparationError, } from "./hosted-scan.js";
|
|
3
4
|
export { loadProjectConfig, resolveProjectConfig } from "./project-config.js";
|
|
4
5
|
export { classifySeverity } from "./classify-severity.js";
|
|
5
6
|
export { suggestOwners } from "./suggest-owners.js";
|
|
@@ -22,4 +23,6 @@ export { ScanResult } from "./result.js";
|
|
|
22
23
|
export { bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, createIsolatedHome, createMarketplace, extractPluginZip, importAmbientAuth, MARKETPLACE_NAME, pluginExecutionEnvironment, pluginMetadata, PLUGIN_NAME, prepareOutputDir, resolveCodexCommand, resolvePluginPath, resolvePluginPython, validateOutputDir, } from "./runtime.js";
|
|
23
24
|
export { DiffTarget, normalizeRepository, normalizeTarget, repositoryRevision, validateMode, } from "./targets.js";
|
|
24
25
|
export { BUNDLED_PLUGIN_VERSION, VERSION } from "./version.js";
|
|
26
|
+
export { classifySeverityRecords, classifySeverityRecordsInputSchema, } from "./classify-severity-records.js";
|
|
27
|
+
export { validateRecords } from "./validation-records.js";
|
|
25
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAU9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAepD,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAM7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA6BzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAWhE,OAAO,EACL,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAajC,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAY7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { exportArtifact } from \"./artifact-export.js\";\nexport type {\n ExportArtifactOptions,\n ArtifactExportResult,\n} from \"./artifact-export.js\";\nexport { CodexSecurity, createSecurity } from \"./api.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport { suggestOwners } from \"./suggest-owners.js\";\nexport type {\n OwnerFinding,\n CodeownerIdentity,\n OwnerIdentity,\n OwnerSuggestion,\n OwnerSuggestions,\n SuggestOwnersOptions,\n} from \"./suggest-owners.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent, ScanWorkerEvent } from \"./cost.js\";\nexport type { ScanTokenUsage } from \"./cost-model.js\";\nexport type { DeepScanProgress } from \"./deep-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n PatchOptions,\n PatchResult,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n LocalPluginBootstrapError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n SandboxUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport { deduplicateRecords } from \"./deduplication/records.js\";\nexport type {\n DeduplicateRecordsInput,\n DeduplicateRecordsOptions,\n DeduplicateRecordsResult,\n} from \"./deduplication/records.js\";\nexport type {\n DeduplicationReviewRequest,\n DeduplicationReviewAttribution,\n DeduplicationReviewRunner,\n} from \"./deduplication/review.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport type { FindingEmbeddingBinding } from \"./deduplication/local.js\";\nexport type {\n DeduplicationDiagnostic,\n DeduplicationDiagnosticObserver,\n} from \"./deduplication/diagnostics.js\";\nexport type { FindingEmbedder } from \"./server/embeddings.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLU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D,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAWhE,OAAO,EACL,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAajC,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAY7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { exportArtifact } from \"./artifact-export.js\";\nexport type {\n ExportArtifactOptions,\n ArtifactExportResult,\n} from \"./artifact-export.js\";\nexport { CodexSecurity, createSecurity } from \"./api.js\";\nexport {\n runHostedScan,\n HostedScanInputSchema,\n HostedScanPreparationError,\n} from \"./hosted-scan.js\";\nexport type {\n HostedScanInput,\n HostedScanOptions,\n HostedScanResult,\n} from \"./hosted-scan.js\";\nexport type {\n ScanExecutor,\n ScanExecutionRequest,\n ScanExecutionResult,\n ScanExecutionEvent,\n} from \"./scan-executor.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport { suggestOwners } from \"./suggest-owners.js\";\nexport type {\n OwnerFinding,\n CodeownerIdentity,\n OwnerIdentity,\n OwnerSuggestion,\n OwnerSuggestions,\n SuggestOwnersOptions,\n} from \"./suggest-owners.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent, ScanWorkerEvent } from \"./cost.js\";\nexport type { ScanTokenUsage } from \"./cost-model.js\";\nexport type { DeepScanProgress } from \"./deep-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n PatchOptions,\n PatchResult,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n LocalPluginBootstrapError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n SandboxUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport { deduplicateRecords } from \"./deduplication/records.js\";\nexport type {\n DeduplicateRecordsInput,\n DeduplicateRecordsOptions,\n DeduplicateRecordsResult,\n} from \"./deduplication/records.js\";\nexport type {\n DeduplicationReviewRequest,\n DeduplicationReviewAttribution,\n DeduplicationReviewRunner,\n} from \"./deduplication/review.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport type { FindingEmbeddingBinding } from \"./deduplication/local.js\";\nexport type {\n DeduplicationDiagnostic,\n DeduplicationDiagnosticObserver,\n} from \"./deduplication/diagnostics.js\";\nexport type { FindingEmbedder } from \"./server/embeddings.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n\nexport {\n classifySeverityRecords,\n classifySeverityRecordsInputSchema,\n} from \"./classify-severity-records.js\";\nexport type {\n ClassifySeverityRecordsInput,\n ClassifySeverityRecordsOptions,\n ClassifySeverityRecordsResult,\n CanonicalSeverityAssessment,\n SeverityClassificationReviewRequest,\n} from \"./classify-severity-records.js\";\nexport { validateRecords } from \"./validation-records.js\";\nexport type {\n ValidateRecordsInput,\n ValidateRecordsOptions,\n ValidationReviewRequest,\n} from \"./validation-records.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;AAyFD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,qBAAqB,EAChD,MAAM,CAAC,EAAE,WAAW,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC,CAyChC"}
|
package/dist/knowledge-base.js
CHANGED
|
@@ -3,6 +3,7 @@ import { lstat, mkdtemp, readFile, readdir, realpath, rm, stat, writeFile, } fro
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { basename, extname, join, resolve } from "node:path";
|
|
5
5
|
import { unzipSync } from "fflate";
|
|
6
|
+
import { SaxesParser } from "saxes";
|
|
6
7
|
import { ConfigurationError, errorMessage } from "./errors.js";
|
|
7
8
|
import { expandHome } from "./runtime.js";
|
|
8
9
|
import { gitMarkerRoot, isGitMetadataDirectory, nullIfMissingFile, } from "./targets.js";
|
|
@@ -234,14 +235,93 @@ function extractDocx(path, bytes) {
|
|
|
234
235
|
if (document === undefined)
|
|
235
236
|
throw new Error("Missing word/document.xml.");
|
|
236
237
|
const xml = decodeText(path, document);
|
|
237
|
-
|
|
238
|
+
let text = [];
|
|
239
|
+
let fields = [];
|
|
240
|
+
const stories = [];
|
|
241
|
+
const parser = new SaxesParser();
|
|
242
|
+
let documentElement = false;
|
|
243
|
+
let deletedDepth = 0;
|
|
244
|
+
let instructionText = false;
|
|
245
|
+
const append = (value) => {
|
|
246
|
+
if (deletedDepth > 0)
|
|
247
|
+
return;
|
|
248
|
+
const field = fields.at(-1);
|
|
249
|
+
if (field === undefined)
|
|
250
|
+
text.push(value);
|
|
251
|
+
else if (!field.instructions)
|
|
252
|
+
field.result.push(value);
|
|
253
|
+
else if (!instructionText)
|
|
254
|
+
field.literal.push(value);
|
|
255
|
+
};
|
|
256
|
+
const finishField = (closed) => {
|
|
257
|
+
const field = fields.pop();
|
|
258
|
+
if (field !== undefined) {
|
|
259
|
+
// Unclosed fields retain ordinary runs; completed fields show only results.
|
|
260
|
+
append((closed ? "" : field.literal.join("")) + field.result.join(""));
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
parser.on("opentag", ({ name, attributes }) => {
|
|
264
|
+
const localName = name.split(":").at(-1);
|
|
265
|
+
if (localName === "del" ||
|
|
266
|
+
localName === "delText" ||
|
|
267
|
+
localName === "delInstrText") {
|
|
268
|
+
deletedDepth++;
|
|
269
|
+
}
|
|
270
|
+
if (deletedDepth > 0)
|
|
271
|
+
return;
|
|
272
|
+
if (localName === "txbxContent") {
|
|
273
|
+
// Text boxes have their own field boundaries.
|
|
274
|
+
stories.push({ text, fields });
|
|
275
|
+
text = [];
|
|
276
|
+
fields = [];
|
|
277
|
+
}
|
|
278
|
+
else if (localName === "document")
|
|
279
|
+
documentElement = true;
|
|
280
|
+
else if (localName === "instrText")
|
|
281
|
+
instructionText = true;
|
|
282
|
+
else if (localName === "fldChar") {
|
|
283
|
+
const type = decodeXml(Object.entries(attributes).find(([name]) => name.split(":").at(-1) === "fldCharType")?.[1] ?? "");
|
|
284
|
+
if (type === "begin")
|
|
285
|
+
fields.push({ instructions: true, literal: [], result: [] });
|
|
286
|
+
else if (type === "separate" && fields.length > 0)
|
|
287
|
+
fields.at(-1).instructions = false;
|
|
288
|
+
else if (type === "end")
|
|
289
|
+
finishField(true);
|
|
290
|
+
}
|
|
291
|
+
else if (localName === "br" || localName === "cr")
|
|
292
|
+
append("\n");
|
|
293
|
+
else if (localName === "tab")
|
|
294
|
+
append("\t");
|
|
295
|
+
});
|
|
296
|
+
parser.on("closetag", ({ name, isSelfClosing }) => {
|
|
297
|
+
const localName = name.split(":").at(-1);
|
|
298
|
+
if (deletedDepth === 0 && localName === "txbxContent") {
|
|
299
|
+
while (fields.length > 0)
|
|
300
|
+
finishField(false);
|
|
301
|
+
const content = text.join("");
|
|
302
|
+
({ text, fields } = stories.pop());
|
|
303
|
+
append(content);
|
|
304
|
+
}
|
|
305
|
+
if (localName === "instrText")
|
|
306
|
+
instructionText = false;
|
|
307
|
+
if (!isSelfClosing && localName === "p")
|
|
308
|
+
append("\n");
|
|
309
|
+
if (localName === "del" ||
|
|
310
|
+
localName === "delText" ||
|
|
311
|
+
localName === "delInstrText") {
|
|
312
|
+
deletedDepth--;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
parser.on("text", (value) => append(decodeXml(value)));
|
|
316
|
+
parser.on("cdata", (value) => append(value.replaceAll("&", "&")));
|
|
317
|
+
// Keep the existing entity decoder's handling of unusable references.
|
|
318
|
+
// CDATA is literal text, so only undo this escaping in its handler.
|
|
319
|
+
parser.write(xml.replaceAll("&", "&")).close();
|
|
320
|
+
if (!documentElement)
|
|
238
321
|
throw new Error("Malformed word/document.xml.");
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
.replace(/<(?:\w+:)?(?:br|cr)\b[^>]*>/gu, "\n")
|
|
243
|
-
.replace(/<(?:\w+:)?tab\b[^>]*>/gu, "\t")
|
|
244
|
-
.replace(/<[^>]+>/gu, ""));
|
|
322
|
+
while (fields.length > 0)
|
|
323
|
+
finishField(false);
|
|
324
|
+
return text.join("");
|
|
245
325
|
}
|
|
246
326
|
catch (error) {
|
|
247
327
|
throw new Error(`Cannot extract text from knowledge base DOCX: ${path}`, {
|