@openai/codex-security 0.1.26 → 0.1.28
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 +637 -74
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs +24 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/COPYRIGHT-library.html +5556 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +5989 -0
- 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/licenses/Apache-2.0.txt +73 -0
- package/_bundled_plugin/mcp/native/licenses/BSD-2-Clause.txt +9 -0
- package/_bundled_plugin/mcp/native/licenses/MIT.txt +9 -0
- package/_bundled_plugin/mcp/native/licenses/Unicode-3.0.txt +39 -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 +56 -0
- package/_bundled_plugin/references/config-preflight.md +9 -1
- package/_bundled_plugin/references/core-scan.md +1 -1
- package/_bundled_plugin/references/final-report.md +2 -0
- package/_bundled_plugin/references/scan-artifacts.md +6 -14
- package/_bundled_plugin/references/scan-contract.md +35 -35
- package/_bundled_plugin/references/scan-prologue.md +2 -0
- package/_bundled_plugin/references/security-guidance.md +9 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +10 -8
- package/_bundled_plugin/scripts/deep_scan_defaults.json +8 -0
- package/_bundled_plugin/scripts/generate_in_scope_files.py +2 -2
- package/_bundled_plugin/scripts/generate_rank_input.py +8 -1
- package/_bundled_plugin/scripts/launch_codex_security_mcp +6 -0
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +43 -9
- package/_bundled_plugin/scripts/rank_preview.py +4 -1
- package/_bundled_plugin/scripts/reserved_artifact_paths.json +6 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +1 -3
- package/_bundled_plugin/scripts/workbench/storage.py +18 -0
- package/_bundled_plugin/scripts/workbench_cli.py +17 -0
- package/_bundled_plugin/scripts/workbench_db.py +46 -42
- package/_bundled_plugin/scripts/workbench_saved_results.py +72 -1
- package/_bundled_plugin/scripts/workbench_scan_history.py +117 -2
- package/_bundled_plugin/scripts/workbench_scan_usage.py +23 -10
- package/_bundled_plugin/scripts/workbench_validation.py +4 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +2 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +2 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +5 -1
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +3 -3
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +2 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +3 -1
- package/_bundled_plugin/skills/fix-finding/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +2 -0
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +5 -1
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -0
- package/_bundled_plugin/skills/validation/SKILL.md +2 -0
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +2 -0
- package/dist/api.d.ts +14 -24
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +585 -168
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +10 -0
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +2 -2
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +24 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1577 -610
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +2 -207
- package/dist/cloud-publish.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +116 -32
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +4 -2
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +7 -1
- package/dist/component-scan.js.map +1 -1
- package/dist/config-path.d.ts +6 -0
- package/dist/config-path.d.ts.map +1 -0
- package/dist/config-path.js +6 -0
- package/dist/config-path.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -5
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +5 -10
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +30 -0
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +123 -4
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +18 -3
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.js +1 -1
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +6 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +72 -17
- 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.map +1 -1
- package/dist/deduplication/deduplication.d.ts +2 -0
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +99 -26
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/retry.d.ts +3 -0
- package/dist/deduplication/retry.d.ts.map +1 -0
- package/dist/deduplication/retry.js +15 -0
- package/dist/deduplication/retry.js.map +1 -0
- package/dist/deduplication/scan.d.ts +2 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +4 -2
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +17 -0
- package/dist/deep-config.d.ts.map +1 -0
- package/dist/deep-config.js +145 -0
- package/dist/deep-config.js.map +1 -0
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-scan-defaults.d.ts +9 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -0
- package/dist/deep-scan-defaults.js +10 -0
- package/dist/deep-scan-defaults.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/feedback.d.ts +20 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +135 -0
- package/dist/feedback.js.map +1 -0
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +7 -1
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +55 -10
- package/dist/findings-client.js.map +1 -1
- package/dist/findings-import.d.ts +44 -0
- package/dist/findings-import.d.ts.map +1 -0
- package/dist/findings-import.js +302 -0
- package/dist/findings-import.js.map +1 -0
- package/dist/github.d.ts +625 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js.map +1 -1
- package/dist/import-scan.d.ts +27 -0
- package/dist/import-scan.d.ts.map +1 -0
- package/dist/import-scan.js +236 -0
- package/dist/import-scan.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +19 -8
- package/dist/knowledge-base.js.map +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts +7 -5
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +212 -55
- package/dist/multiscan.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +191 -0
- package/dist/project-config-schema.d.ts.map +1 -0
- package/dist/project-config-schema.js +85 -0
- package/dist/project-config-schema.js.map +1 -0
- package/dist/project-config.d.ts +50 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +220 -0
- package/dist/project-config.js.map +1 -0
- package/dist/prompt-files.d.ts +13 -0
- package/dist/prompt-files.d.ts.map +1 -0
- package/dist/prompt-files.js +74 -0
- package/dist/prompt-files.js.map +1 -0
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +7 -2
- package/dist/publication-events.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/result.d.ts +2 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +5 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +12 -6
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +45 -20
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +39 -3
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +77 -15
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-modes.d.ts +3 -0
- package/dist/scan-modes.d.ts.map +1 -0
- package/dist/scan-modes.js +2 -0
- package/dist/scan-modes.js.map +1 -0
- package/dist/scan-settings.d.ts +81 -0
- package/dist/scan-settings.d.ts.map +1 -0
- package/dist/scan-settings.js +123 -0
- package/dist/scan-settings.js.map +1 -0
- package/dist/security-policy-cli.d.ts +39 -0
- package/dist/security-policy-cli.d.ts.map +1 -0
- package/dist/security-policy-cli.js +193 -0
- package/dist/security-policy-cli.js.map +1 -0
- package/dist/security-policy.d.ts +80 -0
- package/dist/security-policy.d.ts.map +1 -0
- package/dist/security-policy.js +672 -0
- package/dist/security-policy.js.map +1 -0
- package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/server/dashboard/app.js +2 -2
- package/dist/server/dashboard.js.map +1 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js.map +1 -1
- package/dist/server/findings-service.d.ts.map +1 -1
- package/dist/server/findings-service.js.map +1 -1
- package/dist/server/serve.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-store.js.map +1 -1
- package/dist/targets.d.ts +10 -2
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +243 -14
- package/dist/targets.js.map +1 -1
- package/dist/thread-source.d.ts.map +1 -1
- package/dist/version.js.map +1 -1
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js.map +1 -1
- package/package.json +36 -29
- package/schemas/project-config.schema.json +211 -0
- package/_bundled_plugin/scripts/resolve_security_md.py +0 -158
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ProjectScopeSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
3
|
+
paths: z.ZodArray<z.ZodString>;
|
|
4
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
5
|
+
diff: z.ZodObject<{
|
|
6
|
+
base: z.ZodString;
|
|
7
|
+
head: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
10
|
+
working_tree: z.ZodObject<{
|
|
11
|
+
base: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
}, z.core.$strict>]>;
|
|
14
|
+
export declare const ProjectConfigInputSchema: z.ZodObject<{
|
|
15
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
16
|
+
auth: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
"api-key": "api-key";
|
|
18
|
+
auto: "auto";
|
|
19
|
+
chatgpt: "chatgpt";
|
|
20
|
+
}>>;
|
|
21
|
+
scan: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
deep: "deep";
|
|
24
|
+
standard: "standard";
|
|
25
|
+
}>>;
|
|
26
|
+
scope: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
27
|
+
paths: z.ZodArray<z.ZodString>;
|
|
28
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
+
diff: z.ZodObject<{
|
|
30
|
+
base: z.ZodString;
|
|
31
|
+
head: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
34
|
+
working_tree: z.ZodObject<{
|
|
35
|
+
base: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
}, z.core.$strict>]>>;
|
|
38
|
+
knowledge_base: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
instructions_file: z.ZodOptional<z.ZodString>;
|
|
40
|
+
validation_file: z.ZodOptional<z.ZodString>;
|
|
41
|
+
deep: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
workers: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
subagents_per_worker: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
stop_after_no_new: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
stop_after_consecutive_errors: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
max_discovery_runs: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
max_time_hours: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
codex: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
model: z.ZodOptional<z.ZodString>;
|
|
52
|
+
model_reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
53
|
+
model_provider: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$catchall<z.ZodJSONSchema>>>;
|
|
55
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
max_cost_usd_per_scan: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
policy: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
fail_on_severity: z.ZodOptional<z.ZodEnum<{
|
|
60
|
+
critical: "critical";
|
|
61
|
+
high: "high";
|
|
62
|
+
low: "low";
|
|
63
|
+
medium: "medium";
|
|
64
|
+
}>>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
output: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
directory: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strict>>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export type ProjectConfigInput = z.infer<typeof ProjectConfigInputSchema>;
|
|
71
|
+
export type ProjectScope = z.infer<typeof ProjectScopeSchema>;
|
|
72
|
+
export declare function projectConfigJsonSchema(): {
|
|
73
|
+
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
|
74
|
+
$id?: string;
|
|
75
|
+
$anchor?: string;
|
|
76
|
+
$ref?: string;
|
|
77
|
+
$dynamicRef?: string;
|
|
78
|
+
$dynamicAnchor?: string;
|
|
79
|
+
$vocabulary?: Record<string, boolean>;
|
|
80
|
+
$defs?: Record<string, z.core.JSONSchema.JSONSchema>;
|
|
81
|
+
type?: z.core.JSONSchema.SchemaType | z.core.JSONSchema.SchemaType[];
|
|
82
|
+
additionalItems?: z.core.JSONSchema._JSONSchema;
|
|
83
|
+
unevaluatedItems?: z.core.JSONSchema._JSONSchema;
|
|
84
|
+
prefixItems?: z.core.JSONSchema._JSONSchema[];
|
|
85
|
+
items?: z.core.JSONSchema._JSONSchema | z.core.JSONSchema._JSONSchema[];
|
|
86
|
+
contains?: z.core.JSONSchema._JSONSchema;
|
|
87
|
+
additionalProperties?: z.core.JSONSchema._JSONSchema;
|
|
88
|
+
unevaluatedProperties?: z.core.JSONSchema._JSONSchema;
|
|
89
|
+
properties?: Record<string, z.core.JSONSchema._JSONSchema>;
|
|
90
|
+
patternProperties?: Record<string, z.core.JSONSchema._JSONSchema>;
|
|
91
|
+
dependentSchemas?: Record<string, z.core.JSONSchema._JSONSchema>;
|
|
92
|
+
propertyNames?: z.core.JSONSchema._JSONSchema;
|
|
93
|
+
if?: z.core.JSONSchema._JSONSchema;
|
|
94
|
+
then?: z.core.JSONSchema._JSONSchema;
|
|
95
|
+
else?: z.core.JSONSchema._JSONSchema;
|
|
96
|
+
allOf?: z.core.JSONSchema.JSONSchema[];
|
|
97
|
+
anyOf?: z.core.JSONSchema.JSONSchema[];
|
|
98
|
+
oneOf?: z.core.JSONSchema.JSONSchema[];
|
|
99
|
+
not?: z.core.JSONSchema._JSONSchema;
|
|
100
|
+
multipleOf?: number;
|
|
101
|
+
maximum?: number;
|
|
102
|
+
exclusiveMaximum?: number | boolean;
|
|
103
|
+
minimum?: number;
|
|
104
|
+
exclusiveMinimum?: number | boolean;
|
|
105
|
+
maxLength?: number;
|
|
106
|
+
minLength?: number;
|
|
107
|
+
pattern?: string;
|
|
108
|
+
maxItems?: number;
|
|
109
|
+
minItems?: number;
|
|
110
|
+
uniqueItems?: boolean;
|
|
111
|
+
maxContains?: number;
|
|
112
|
+
minContains?: number;
|
|
113
|
+
maxProperties?: number;
|
|
114
|
+
minProperties?: number;
|
|
115
|
+
required?: string[];
|
|
116
|
+
dependentRequired?: Record<string, string[]>;
|
|
117
|
+
enum?: Array<string | number | boolean | null>;
|
|
118
|
+
const?: string | number | boolean | null;
|
|
119
|
+
id?: string;
|
|
120
|
+
default?: unknown;
|
|
121
|
+
deprecated?: boolean;
|
|
122
|
+
readOnly?: boolean;
|
|
123
|
+
writeOnly?: boolean;
|
|
124
|
+
nullable?: boolean;
|
|
125
|
+
examples?: unknown[];
|
|
126
|
+
format?: string;
|
|
127
|
+
contentMediaType?: string;
|
|
128
|
+
contentEncoding?: string;
|
|
129
|
+
contentSchema?: z.core.JSONSchema.JSONSchema;
|
|
130
|
+
_prefault?: unknown;
|
|
131
|
+
"~standard": z.core.ZodStandardSchemaWithJSON<z.ZodObject<{
|
|
132
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
133
|
+
auth: z.ZodOptional<z.ZodEnum<{
|
|
134
|
+
"api-key": "api-key";
|
|
135
|
+
auto: "auto";
|
|
136
|
+
chatgpt: "chatgpt";
|
|
137
|
+
}>>;
|
|
138
|
+
scan: z.ZodOptional<z.ZodObject<{
|
|
139
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
140
|
+
deep: "deep";
|
|
141
|
+
standard: "standard";
|
|
142
|
+
}>>;
|
|
143
|
+
scope: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
144
|
+
paths: z.ZodArray<z.ZodString>;
|
|
145
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
146
|
+
diff: z.ZodObject<{
|
|
147
|
+
base: z.ZodString;
|
|
148
|
+
head: z.ZodOptional<z.ZodString>;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
151
|
+
working_tree: z.ZodObject<{
|
|
152
|
+
base: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strict>;
|
|
154
|
+
}, z.core.$strict>]>>;
|
|
155
|
+
knowledge_base: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
156
|
+
instructions_file: z.ZodOptional<z.ZodString>;
|
|
157
|
+
validation_file: z.ZodOptional<z.ZodString>;
|
|
158
|
+
deep: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
workers: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
subagents_per_worker: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
stop_after_no_new: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
stop_after_consecutive_errors: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
max_discovery_runs: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
max_time_hours: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
}, z.core.$strict>>;
|
|
166
|
+
}, z.core.$strict>>;
|
|
167
|
+
codex: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
model: z.ZodOptional<z.ZodString>;
|
|
169
|
+
model_reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
170
|
+
model_provider: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, z.core.$catchall<z.ZodJSONSchema>>>;
|
|
172
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
173
|
+
max_cost_usd_per_scan: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
}, z.core.$strict>>;
|
|
175
|
+
policy: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
fail_on_severity: z.ZodOptional<z.ZodEnum<{
|
|
177
|
+
critical: "critical";
|
|
178
|
+
high: "high";
|
|
179
|
+
low: "low";
|
|
180
|
+
medium: "medium";
|
|
181
|
+
}>>;
|
|
182
|
+
}, z.core.$strict>>;
|
|
183
|
+
output: z.ZodOptional<z.ZodObject<{
|
|
184
|
+
directory: z.ZodOptional<z.ZodString>;
|
|
185
|
+
}, z.core.$strict>>;
|
|
186
|
+
}, z.core.$strict>>;
|
|
187
|
+
title: string;
|
|
188
|
+
description: string;
|
|
189
|
+
$comment: string;
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=project-config-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config-schema.d.ts","sourceRoot":"","sources":["../src/project-config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;oBAkB7B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAwEnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAatC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DeepScanSettingsSchema, FailureSeveritySchema, ScanSettingsSchema, } from "./scan-settings.js";
|
|
3
|
+
const nonempty = z.string().min(1);
|
|
4
|
+
export const ProjectScopeSchema = z.union([
|
|
5
|
+
z.strictObject({
|
|
6
|
+
paths: z
|
|
7
|
+
.array(nonempty)
|
|
8
|
+
.min(1)
|
|
9
|
+
.describe("Literal paths relative to the selected repository."),
|
|
10
|
+
}),
|
|
11
|
+
z.strictObject({
|
|
12
|
+
diff: z.strictObject({
|
|
13
|
+
base: nonempty,
|
|
14
|
+
head: nonempty.optional().meta({ default: "HEAD" }),
|
|
15
|
+
}),
|
|
16
|
+
}),
|
|
17
|
+
z.strictObject({
|
|
18
|
+
working_tree: z.strictObject({
|
|
19
|
+
base: nonempty.optional().meta({ default: "HEAD" }),
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
23
|
+
export const ProjectConfigInputSchema = z.strictObject({
|
|
24
|
+
$schema: nonempty
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Editor schema URI or relative path. The CLI does not fetch or select a validator from this value."),
|
|
27
|
+
auth: ScanSettingsSchema.shape.auth.describe("Credential-source choice only; never a credential value."),
|
|
28
|
+
scan: z
|
|
29
|
+
.strictObject({
|
|
30
|
+
mode: ScanSettingsSchema.shape.mode,
|
|
31
|
+
scope: ProjectScopeSchema.optional().describe("One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides."),
|
|
32
|
+
knowledge_base: ScanSettingsSchema.shape.knowledgeBasePaths.describe("Context files or directories, relative to this file. An empty list selects no additional context."),
|
|
33
|
+
instructions_file: ScanSettingsSchema.shape.scanPromptFile.describe("Additional scan instructions, relative to this file."),
|
|
34
|
+
validation_file: ScanSettingsSchema.shape.validationPromptFile.describe("Custom validation instructions, relative to this file; not supported in active deep scans."),
|
|
35
|
+
deep: z
|
|
36
|
+
.strictObject({
|
|
37
|
+
workers: DeepScanSettingsSchema.shape.workers,
|
|
38
|
+
subagents_per_worker: DeepScanSettingsSchema.shape.subagents,
|
|
39
|
+
stop_after_no_new: DeepScanSettingsSchema.shape.stopAfterNoNew,
|
|
40
|
+
stop_after_consecutive_errors: DeepScanSettingsSchema.shape.stopAfterConsecutiveErrors,
|
|
41
|
+
max_discovery_runs: DeepScanSettingsSchema.shape.maxDiscoveryRuns,
|
|
42
|
+
max_time_hours: DeepScanSettingsSchema.shape.maxTimeHours,
|
|
43
|
+
})
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Deep defaults; a valid block may be retained while standard mode is selected."),
|
|
46
|
+
})
|
|
47
|
+
.optional(),
|
|
48
|
+
codex: z
|
|
49
|
+
.object({
|
|
50
|
+
model: nonempty.optional(),
|
|
51
|
+
model_reasoning_effort: nonempty.optional(),
|
|
52
|
+
model_provider: nonempty.optional(),
|
|
53
|
+
})
|
|
54
|
+
.catchall(z.json())
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("Native Codex overrides. Common key types are checked here; existing native and wrapper restrictions still apply."),
|
|
57
|
+
limits: z
|
|
58
|
+
.strictObject({
|
|
59
|
+
max_cost_usd_per_scan: ScanSettingsSchema.shape.maxCostUsd.describe("Estimated USD limit per launched scan attempt, not a total batch budget. Omit for no limit."),
|
|
60
|
+
})
|
|
61
|
+
.optional(),
|
|
62
|
+
policy: z
|
|
63
|
+
.strictObject({
|
|
64
|
+
fail_on_severity: FailureSeveritySchema.optional().describe("Exit threshold; does not filter retained findings. Omit for report-only behavior."),
|
|
65
|
+
})
|
|
66
|
+
.optional(),
|
|
67
|
+
output: z
|
|
68
|
+
.strictObject({
|
|
69
|
+
directory: ScanSettingsSchema.shape.outputDir.describe("Artifact directory relative to this file; existing outside-worktree checks still apply."),
|
|
70
|
+
})
|
|
71
|
+
.optional(),
|
|
72
|
+
});
|
|
73
|
+
export function projectConfigJsonSchema() {
|
|
74
|
+
return {
|
|
75
|
+
...z.toJSONSchema(ProjectConfigInputSchema, {
|
|
76
|
+
target: "draft-07",
|
|
77
|
+
io: "input",
|
|
78
|
+
unrepresentable: "throw",
|
|
79
|
+
}),
|
|
80
|
+
title: "Codex Security project configuration",
|
|
81
|
+
description: "Input schema for explicitly selected YAML or JSON project files. Filesystem, active scan combinations, native configuration, and runtime availability are checked separately.",
|
|
82
|
+
$comment: "Generated from ProjectConfigInputSchema. Defaults are annotations; apply defaults only after merging input layers.",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=project-config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config-schema.js","sourceRoot":"","sources":["../src/project-config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC;IACxC,CAAC,CAAC,YAAY,CAAC;QACb,KAAK,EAAE,CAAC;aACL,KAAK,CAAC,QAAQ,CAAC;aACf,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,oDAAoD,CAAC;KAClE,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACpD,CAAC;KACH,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC;YAC3B,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACpD,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,YAAY,CAAC;IACrD,OAAO,EAAE,QAAQ;SACd,QAAQ,EAAE;SACV,QAAQ,CACP,mGAAmG,CACpG;IACH,IAAI,EAA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AAkH,CACnH;IACH,MAAM,EAAE,CAAC;SACN,YAAY,CAAC;QACZ,qBAAqB,EAAE,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CACjE,6FAA6F,CAC9F;KACF,CAAC;SACD,QAAQ,EAAE;IACb,MAAM,EAAE,CAAC;SACN,YAAY,CAAC;QACZ,gBAAgB,EAAE,qBAAqB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACzD,mFAAmF,CACpF;KACF,CAAC;SACD,QAAQ,EAAE;IACb,MAAM,EAAE,CAAC;SACN,YAAY,CAAC;QACZ,SAAS,EAAE,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CACpD,yFAAyF,CAC1F;KACF,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAKH,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,GAAG,CAAC,CAAC,YAAY,CAAC,wBAAwB,EAAE;YAC1C,MAAM,EAAE,UAAU;YAClB,EAAE,EAAE,OAAO;YACX,eAAe,EAAE,OAAO;SACzB,CAAC;QACF,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EACT,+KAA+K;QACjL,QAAQ,EACN,oHAAoH;KACvH,CAAC;AACJ,CAAC","sourcesContent":["import { z } from \"zod\";\nimport {\n DeepScanSettingsSchema,\n FailureSeveritySchema,\n ScanSettingsSchema,\n} from \"./scan-settings.js\";\n\nconst nonempty = z.string().min(1);\n\nexport const ProjectScopeSchema = z.union([\n z.strictObject({\n paths: z\n .array(nonempty)\n .min(1)\n .describe(\"Literal paths relative to the selected repository.\"),\n }),\n z.strictObject({\n diff: z.strictObject({\n base: nonempty,\n head: nonempty.optional().meta({ default: \"HEAD\" }),\n }),\n }),\n z.strictObject({\n working_tree: z.strictObject({\n base: nonempty.optional().meta({ default: \"HEAD\" }),\n }),\n }),\n]);\n\nexport const ProjectConfigInputSchema = z.strictObject({\n $schema: nonempty\n .optional()\n .describe(\n \"Editor schema URI or relative path. The CLI does not fetch or select a validator from this value.\",\n ),\n auth: ScanSettingsSchema.shape.auth.describe(\n \"Credential-source choice only; never a credential value.\",\n ),\n scan: z\n .strictObject({\n mode: ScanSettingsSchema.shape.mode,\n scope: ProjectScopeSchema.optional().describe(\n \"One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides.\",\n ),\n knowledge_base: ScanSettingsSchema.shape.knowledgeBasePaths.describe(\n \"Context files or directories, relative to this file. An empty list selects no additional context.\",\n ),\n instructions_file: ScanSettingsSchema.shape.scanPromptFile.describe(\n \"Additional scan instructions, relative to this file.\",\n ),\n validation_file: ScanSettingsSchema.shape.validationPromptFile.describe(\n \"Custom validation instructions, relative to this file; not supported in active deep scans.\",\n ),\n deep: z\n .strictObject({\n workers: DeepScanSettingsSchema.shape.workers,\n subagents_per_worker: DeepScanSettingsSchema.shape.subagents,\n stop_after_no_new: DeepScanSettingsSchema.shape.stopAfterNoNew,\n stop_after_consecutive_errors:\n DeepScanSettingsSchema.shape.stopAfterConsecutiveErrors,\n max_discovery_runs: DeepScanSettingsSchema.shape.maxDiscoveryRuns,\n max_time_hours: DeepScanSettingsSchema.shape.maxTimeHours,\n })\n .optional()\n .describe(\n \"Deep defaults; a valid block may be retained while standard mode is selected.\",\n ),\n })\n .optional(),\n codex: z\n .object({\n model: nonempty.optional(),\n model_reasoning_effort: nonempty.optional(),\n model_provider: nonempty.optional(),\n })\n .catchall(z.json())\n .optional()\n .describe(\n \"Native Codex overrides. Common key types are checked here; existing native and wrapper restrictions still apply.\",\n ),\n limits: z\n .strictObject({\n max_cost_usd_per_scan: ScanSettingsSchema.shape.maxCostUsd.describe(\n \"Estimated USD limit per launched scan attempt, not a total batch budget. Omit for no limit.\",\n ),\n })\n .optional(),\n policy: z\n .strictObject({\n fail_on_severity: FailureSeveritySchema.optional().describe(\n \"Exit threshold; does not filter retained findings. Omit for report-only behavior.\",\n ),\n })\n .optional(),\n output: z\n .strictObject({\n directory: ScanSettingsSchema.shape.outputDir.describe(\n \"Artifact directory relative to this file; existing outside-worktree checks still apply.\",\n ),\n })\n .optional(),\n});\n\nexport type ProjectConfigInput = z.infer<typeof ProjectConfigInputSchema>;\nexport type ProjectScope = z.infer<typeof ProjectScopeSchema>;\n\nexport function projectConfigJsonSchema() {\n return {\n ...z.toJSONSchema(ProjectConfigInputSchema, {\n target: \"draft-07\",\n io: \"input\",\n unrepresentable: \"throw\",\n }),\n title: \"Codex Security project configuration\",\n description:\n \"Input schema for explicitly selected YAML or JSON project files. Filesystem, active scan combinations, native configuration, and runtime availability are checked separately.\",\n $comment:\n \"Generated from ProjectConfigInputSchema. Defaults are annotations; apply defaults only after merging input layers.\",\n };\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type JsonObject } from "./config.js";
|
|
2
|
+
import { type DeepScanSources } from "./deep-config.js";
|
|
3
|
+
import { type ProjectConfigInput, type ProjectScope } from "./project-config-schema.js";
|
|
4
|
+
import { DEEP_SCAN_SETTINGS, type ResolvedScanSettings, type ScanSettings } from "./scan-settings.js";
|
|
5
|
+
import { type ScanTarget } from "./targets.js";
|
|
6
|
+
export interface ProjectConfigSource {
|
|
7
|
+
path?: string;
|
|
8
|
+
directory: string;
|
|
9
|
+
input: ProjectConfigInput;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolvedProjectConfig {
|
|
12
|
+
config: {
|
|
13
|
+
codexOverrides: JsonObject;
|
|
14
|
+
};
|
|
15
|
+
options: ResolvedScanSettings;
|
|
16
|
+
sources: ConfigurationSources;
|
|
17
|
+
projectConfig?: ProjectConfigProvenance;
|
|
18
|
+
}
|
|
19
|
+
export type ConfigurationSource = "default" | "legacy" | "project" | "cli";
|
|
20
|
+
declare const PROJECT_SETTING_KEYS: {
|
|
21
|
+
readonly auth: "auth";
|
|
22
|
+
readonly mode: "scan.mode";
|
|
23
|
+
readonly target: "scan.scope";
|
|
24
|
+
readonly knowledgeBasePaths: "scan.knowledge_base";
|
|
25
|
+
readonly scanPromptFile: "scan.instructions_file";
|
|
26
|
+
readonly validationPromptFile: "scan.validation_file";
|
|
27
|
+
readonly outputDir: "output.directory";
|
|
28
|
+
readonly failureSeverity: "policy.fail_on_severity";
|
|
29
|
+
readonly maxCostUsd: "limits.max_cost_usd_per_scan";
|
|
30
|
+
};
|
|
31
|
+
type SettingProvenanceKey = (typeof PROJECT_SETTING_KEYS)[keyof typeof PROJECT_SETTING_KEYS];
|
|
32
|
+
export type ScopeProvenanceKey = "scan.scope" | "scan.scope.diff.head" | "scan.scope.working_tree.base";
|
|
33
|
+
export type ProvenanceKey = SettingProvenanceKey | ScopeProvenanceKey | `scan.deep.${(typeof DEEP_SCAN_SETTINGS)[number][2]}` | `codex.${string}`;
|
|
34
|
+
export type ConfigurationSources = Readonly<Record<SettingProvenanceKey, ConfigurationSource> & Partial<Record<ProvenanceKey, ConfigurationSource>>>;
|
|
35
|
+
export interface ProjectConfigProvenance {
|
|
36
|
+
path: string;
|
|
37
|
+
sources: ConfigurationSources;
|
|
38
|
+
}
|
|
39
|
+
/** Build a complete, immutable source map after layer and preflight resolution. */
|
|
40
|
+
export declare function configurationSources(values?: Partial<Record<ProvenanceKey, ConfigurationSource>>, deepSources?: DeepScanSources): ConfigurationSources;
|
|
41
|
+
export declare function loadProjectConfig(file: string, directory?: string): Promise<ResolvedProjectConfig>;
|
|
42
|
+
export declare function resolveProjectConfig(input: ProjectConfigInput, directory?: string): ResolvedProjectConfig;
|
|
43
|
+
export declare function readProjectConfig(file: string, directory?: string): Promise<ProjectConfigSource>;
|
|
44
|
+
export declare function projectConfigStarter(path: string, directory?: string): string;
|
|
45
|
+
export declare function resolveScanSettings(project: ProjectConfigSource | undefined, overrides: Partial<ScanSettings> & {
|
|
46
|
+
codexOverrides?: JsonObject;
|
|
47
|
+
}, directory: string, scopeSources?: Partial<Record<ScopeProvenanceKey, ConfigurationSource>>): ResolvedProjectConfig;
|
|
48
|
+
export declare function projectScopeTarget(scope: ProjectScope | undefined): ScanTarget | undefined;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../src/project-config.ts"],"names":[],"mappings":"AAYA,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAGL,kBAAkB,EAGlB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAM3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QAAE,cAAc,EAAE,UAAU,CAAA;KAAE,CAAC;IACvC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,CAAC;AAC3E,QAAA,MAAM,oBAAoB;mBAClB,MAAM;mBACN,WAAW;qBACT,YAAY;iCACA,qBAAqB;6BACzB,wBAAwB;mCAClB,sBAAsB;wBACjC,kBAAkB;8BACZ,yBAAyB;yBAC9B,8BAA8B;CACoB,CAAC;AACjE,KAAK,oBAAoB,GACvB,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AACnE,MAAM,MAAM,kBAAkB,GAC5B,YAAY,GAAG,sBAAsB,GAAG,8BAA8B,CAAC;AACzE,MAAM,MAAM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wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,SAAS,GAC9B,UAAU,GAAG,SAAS,CAKxB"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, extname, isAbsolute, relative, resolve, sep, } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import Ajv from "ajv";
|
|
5
|
+
import { parseDocument } from "yaml";
|
|
6
|
+
import { DEFAULT_CODEX_CONFIG, mergeCodexOverrides, } from "./config.js";
|
|
7
|
+
import { ConfigurationError } from "./errors.js";
|
|
8
|
+
import { DEFAULT_DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
|
|
9
|
+
import { resolveConfigPath } from "./config-path.js";
|
|
10
|
+
import { deepScanOptions } from "./deep-config.js";
|
|
11
|
+
import { projectConfigJsonSchema, } from "./project-config-schema.js";
|
|
12
|
+
import { expandHome } from "./runtime.js";
|
|
13
|
+
import { DEFAULT_SCAN_AUTH, DEFAULT_SCAN_MODE, DEEP_SCAN_SETTINGS, pickScanSettings, } from "./scan-settings.js";
|
|
14
|
+
import { DiffTarget } from "./targets.js";
|
|
15
|
+
const validateProjectConfig = new Ajv({
|
|
16
|
+
allErrors: true,
|
|
17
|
+
}).compile(projectConfigJsonSchema());
|
|
18
|
+
const PROJECT_SETTING_KEYS = {
|
|
19
|
+
auth: "auth",
|
|
20
|
+
mode: "scan.mode",
|
|
21
|
+
target: "scan.scope",
|
|
22
|
+
knowledgeBasePaths: "scan.knowledge_base",
|
|
23
|
+
scanPromptFile: "scan.instructions_file",
|
|
24
|
+
validationPromptFile: "scan.validation_file",
|
|
25
|
+
outputDir: "output.directory",
|
|
26
|
+
failureSeverity: "policy.fail_on_severity",
|
|
27
|
+
maxCostUsd: "limits.max_cost_usd_per_scan",
|
|
28
|
+
};
|
|
29
|
+
/** Build a complete, immutable source map after layer and preflight resolution. */
|
|
30
|
+
export function configurationSources(values = {}, deepSources) {
|
|
31
|
+
const sources = {
|
|
32
|
+
...Object.fromEntries(Object.values(PROJECT_SETTING_KEYS).map((key) => [key, "default"])),
|
|
33
|
+
...values,
|
|
34
|
+
};
|
|
35
|
+
for (const [name, , key] of DEEP_SCAN_SETTINGS) {
|
|
36
|
+
const source = deepSources?.[name];
|
|
37
|
+
if (source !== undefined && source !== "override")
|
|
38
|
+
sources[`scan.deep.${key}`] = source;
|
|
39
|
+
}
|
|
40
|
+
return Object.freeze(sources);
|
|
41
|
+
}
|
|
42
|
+
export async function loadProjectConfig(file, directory = process.cwd()) {
|
|
43
|
+
return resolveScanSettings(await readProjectConfig(file, directory), {}, directory);
|
|
44
|
+
}
|
|
45
|
+
export function resolveProjectConfig(input, directory = process.cwd()) {
|
|
46
|
+
requireProjectConfig(input);
|
|
47
|
+
return resolveScanSettings({ input, directory: resolve(directory) }, {}, directory);
|
|
48
|
+
}
|
|
49
|
+
export async function readProjectConfig(file, directory = process.cwd()) {
|
|
50
|
+
const path = resolve(directory, expandHome(file));
|
|
51
|
+
const extension = projectConfigExtension(path);
|
|
52
|
+
let text;
|
|
53
|
+
try {
|
|
54
|
+
text = await readFile(path, "utf8");
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new ConfigurationError(`Cannot read project configuration at ${path}.`, { cause: error });
|
|
58
|
+
}
|
|
59
|
+
let value;
|
|
60
|
+
try {
|
|
61
|
+
if (extension === ".json") {
|
|
62
|
+
value = JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const document = parseDocument(text, { prettyErrors: false });
|
|
66
|
+
if (document.errors.length > 0)
|
|
67
|
+
throw document.errors[0];
|
|
68
|
+
// Keep YAML's expansion guard while allowing repeated native profiles.
|
|
69
|
+
value = document.toJS({ maxAliasCount: 10_000 });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new ConfigurationError(`Cannot parse project configuration at ${path}.`, { cause: error });
|
|
74
|
+
}
|
|
75
|
+
requireProjectConfig(value, path);
|
|
76
|
+
return { path, directory: dirname(path), input: value };
|
|
77
|
+
}
|
|
78
|
+
function projectConfigExtension(path) {
|
|
79
|
+
const extension = extname(path).toLowerCase();
|
|
80
|
+
if (![".yaml", ".yml", ".json"].includes(extension)) {
|
|
81
|
+
throw new ConfigurationError("Project configuration must be a .yaml, .yml, or .json file.");
|
|
82
|
+
}
|
|
83
|
+
return extension;
|
|
84
|
+
}
|
|
85
|
+
export function projectConfigStarter(path, directory = process.cwd()) {
|
|
86
|
+
const schemaPath = resolve(directory, "node_modules/@openai/codex-security/schemas/project-config.schema.json");
|
|
87
|
+
const relativeSchema = relative(dirname(resolve(directory, path)), schemaPath);
|
|
88
|
+
const schema = isAbsolute(relativeSchema)
|
|
89
|
+
? pathToFileURL(schemaPath).href
|
|
90
|
+
: `${relativeSchema.startsWith(".") ? "" : "./"}${relativeSchema
|
|
91
|
+
.split(sep)
|
|
92
|
+
.join("/")}`;
|
|
93
|
+
if (projectConfigExtension(path) === ".json")
|
|
94
|
+
return `${JSON.stringify({ $schema: schema }, null, 2)}\n`;
|
|
95
|
+
return [
|
|
96
|
+
"# This file is trusted like CLI options. Keep it outside untrusted inputs.",
|
|
97
|
+
`$schema: ${schema}`,
|
|
98
|
+
"",
|
|
99
|
+
"# Uncomment the settings you want to override. Defaults remain unpinned.",
|
|
100
|
+
`# auth: ${DEFAULT_SCAN_AUTH}`,
|
|
101
|
+
"# scan:",
|
|
102
|
+
`# mode: ${DEFAULT_SCAN_MODE}`,
|
|
103
|
+
"# scope:",
|
|
104
|
+
"# paths: [src] # Relative to each selected repository.",
|
|
105
|
+
"# knowledge_base: [] # Paths relative to this file.",
|
|
106
|
+
"# instructions_file: instructions.md",
|
|
107
|
+
"# validation_file: validation.md # Standard mode only.",
|
|
108
|
+
"# deep: # Used when mode is deep.",
|
|
109
|
+
...DEEP_SCAN_SETTINGS.map(([name, , key]) => `# ${key}: ${DEFAULT_DEEP_SCAN_SETTINGS[name]}`),
|
|
110
|
+
"# codex:",
|
|
111
|
+
`# model: ${DEFAULT_CODEX_CONFIG["model"]}`,
|
|
112
|
+
`# model_reasoning_effort: ${DEFAULT_CODEX_CONFIG["model_reasoning_effort"]}`,
|
|
113
|
+
"# limits:",
|
|
114
|
+
"# max_cost_usd_per_scan: 10 # Optional limit per scan attempt.",
|
|
115
|
+
"# policy:",
|
|
116
|
+
"# fail_on_severity: high # Omitted by default (report only).",
|
|
117
|
+
"# output:",
|
|
118
|
+
"# directory: ../scan-results # Outside the selected repositories.",
|
|
119
|
+
"",
|
|
120
|
+
].join("\n");
|
|
121
|
+
}
|
|
122
|
+
function requireProjectConfig(value, path) {
|
|
123
|
+
if (!validateProjectConfig(value)) {
|
|
124
|
+
const issues = validateProjectConfig
|
|
125
|
+
.errors.map((issue) => {
|
|
126
|
+
const message = issue.keyword === "additionalProperties"
|
|
127
|
+
? `Unknown key ${issue.params["additionalProperty"]}.`
|
|
128
|
+
: issue.message;
|
|
129
|
+
return `${issue.instancePath || "configuration"}: ${message}`;
|
|
130
|
+
})
|
|
131
|
+
.join("; ");
|
|
132
|
+
throw new ConfigurationError(`Invalid project configuration${path === undefined ? "" : ` at ${path}`}: ${issues}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function resolveScanSettings(project, overrides, directory, scopeSources = {}) {
|
|
136
|
+
const file = project?.input;
|
|
137
|
+
const sources = {};
|
|
138
|
+
const choose = (key, configured, explicit) => {
|
|
139
|
+
if (explicit !== undefined) {
|
|
140
|
+
sources[key] = "cli";
|
|
141
|
+
return explicit;
|
|
142
|
+
}
|
|
143
|
+
if (configured !== undefined) {
|
|
144
|
+
sources[key] = "project";
|
|
145
|
+
return configured;
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
};
|
|
149
|
+
const projectDirectory = project?.directory ?? directory;
|
|
150
|
+
const filePath = (value) => value === undefined
|
|
151
|
+
? undefined
|
|
152
|
+
: resolveConfigPath(projectDirectory, value);
|
|
153
|
+
const cliPath = (value) => value === undefined ? undefined : resolveConfigPath(directory, value);
|
|
154
|
+
const mode = choose("scan.mode", file?.scan?.mode, overrides.mode) ?? DEFAULT_SCAN_MODE;
|
|
155
|
+
const explicitDeep = deepScanOptions({ ...overrides, mode });
|
|
156
|
+
const target = choose("scan.scope", projectScopeTarget(file?.scan?.scope), overrides.target) ?? "repository";
|
|
157
|
+
const configuredDeep = file?.scan?.deep;
|
|
158
|
+
const deep = {};
|
|
159
|
+
if (mode === "deep") {
|
|
160
|
+
for (const [name, , field] of DEEP_SCAN_SETTINGS) {
|
|
161
|
+
const value = choose(`scan.deep.${field}`, configuredDeep?.[field], explicitDeep[name]);
|
|
162
|
+
if (value !== undefined)
|
|
163
|
+
deep[name] = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const codexOverrides = mergeCodexOverrides(file?.codex ?? {}, overrides.codexOverrides ?? {});
|
|
167
|
+
const recordNativeSources = (value, source, prefix = "codex") => {
|
|
168
|
+
for (const [key, item] of Object.entries(value)) {
|
|
169
|
+
const path = `${prefix}.${key}`;
|
|
170
|
+
if (item !== null && typeof item === "object" && !Array.isArray(item)) {
|
|
171
|
+
delete sources[path];
|
|
172
|
+
recordNativeSources(item, source, path);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
for (const existing of Object.keys(sources)) {
|
|
176
|
+
if (existing.startsWith(`${path}.`))
|
|
177
|
+
delete sources[existing];
|
|
178
|
+
}
|
|
179
|
+
sources[path] = source;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
recordNativeSources(DEFAULT_CODEX_CONFIG, "default");
|
|
184
|
+
recordNativeSources(file?.codex ?? {}, "project");
|
|
185
|
+
recordNativeSources(overrides.codexOverrides ?? {}, "cli");
|
|
186
|
+
const knowledgeBasePaths = choose("scan.knowledge_base", file?.scan?.knowledge_base?.map((value) => resolveConfigPath(projectDirectory, value)), overrides.knowledgeBasePaths?.map((value) => resolveConfigPath(directory, value))) ?? [];
|
|
187
|
+
const settings = {
|
|
188
|
+
...pickScanSettings(overrides),
|
|
189
|
+
auth: choose("auth", file?.auth, overrides.auth) ?? DEFAULT_SCAN_AUTH,
|
|
190
|
+
mode,
|
|
191
|
+
target,
|
|
192
|
+
knowledgeBasePaths,
|
|
193
|
+
scanPromptFile: choose("scan.instructions_file", filePath(file?.scan?.instructions_file), cliPath(overrides.scanPromptFile)),
|
|
194
|
+
validationPromptFile: choose("scan.validation_file", filePath(file?.scan?.validation_file), cliPath(overrides.validationPromptFile)),
|
|
195
|
+
postScanPromptFile: cliPath(overrides.postScanPromptFile),
|
|
196
|
+
outputDir: choose("output.directory", filePath(file?.output?.directory), cliPath(overrides.outputDir)),
|
|
197
|
+
failureSeverity: choose("policy.fail_on_severity", file?.policy?.fail_on_severity, overrides.failureSeverity),
|
|
198
|
+
maxCostUsd: choose("limits.max_cost_usd_per_scan", file?.limits?.max_cost_usd_per_scan, overrides.maxCostUsd),
|
|
199
|
+
...deep,
|
|
200
|
+
};
|
|
201
|
+
const resolvedSources = configurationSources({ ...sources, ...scopeSources });
|
|
202
|
+
return {
|
|
203
|
+
config: { codexOverrides },
|
|
204
|
+
options: settings,
|
|
205
|
+
sources: resolvedSources,
|
|
206
|
+
...(project?.path === undefined
|
|
207
|
+
? {}
|
|
208
|
+
: { projectConfig: { path: project.path, sources: resolvedSources } }),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export function projectScopeTarget(scope) {
|
|
212
|
+
if (scope === undefined)
|
|
213
|
+
return undefined;
|
|
214
|
+
if ("paths" in scope)
|
|
215
|
+
return [...scope.paths];
|
|
216
|
+
if ("diff" in scope)
|
|
217
|
+
return DiffTarget.refs(scope.diff);
|
|
218
|
+
return DiffTarget.workingTree(scope.working_tree);
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=project-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.js","sourceRo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C,SAAS,CAAC,CAC7B;QACD,eAAe,EAAE,MAAM,CACrB,yBAAyB,EACzB,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAC9B,SAAS,CAAC,eAAe,CAC1B;QACD,UAAU,EAAE,MAAM,CAChB,8BAA8B,EAC9B,IAAI,EAAE,MAAM,EAAE,qBAAqB,EACnC,SAAS,CAAC,UAAU,CACrB;QACD,GAAG,IAAI;KACR,CAAC;IACF,MAAM,eAAe,GAAG,oBAAoB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IAC9E,OAAO;QACL,MAAM,EAAE,EAAE,cAAc,EAAE;QAC1B,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,eAAe;QACxB,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAA+B;IAE/B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport {\n dirname,\n extname,\n isAbsolute,\n relative,\n resolve,\n sep,\n} from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport Ajv from \"ajv\";\nimport { parseDocument } from \"yaml\";\nimport {\n DEFAULT_CODEX_CONFIG,\n mergeCodexOverrides,\n type JsonObject,\n} from \"./config.js\";\nimport { ConfigurationError } from \"./errors.js\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { resolveConfigPath, type AbsolutePath } from \"./config-path.js\";\nimport { deepScanOptions, type DeepScanSources } from \"./deep-config.js\";\nimport {\n projectConfigJsonSchema,\n type ProjectConfigInput,\n type ProjectScope,\n} from \"./project-config-schema.js\";\nimport { expandHome } from \"./runtime.js\";\nimport {\n DEFAULT_SCAN_AUTH,\n DEFAULT_SCAN_MODE,\n DEEP_SCAN_SETTINGS,\n pickScanSettings,\n type DeepScanOptions,\n type ResolvedScanSettings,\n type ScanSettings,\n} from \"./scan-settings.js\";\nimport { DiffTarget, type ScanTarget } from \"./targets.js\";\n\nconst validateProjectConfig = new Ajv({\n allErrors: true,\n}).compile<ProjectConfigInput>(projectConfigJsonSchema());\n\nexport interface ProjectConfigSource {\n path?: string;\n directory: string;\n input: ProjectConfigInput;\n}\n\nexport interface ResolvedProjectConfig {\n config: { codexOverrides: JsonObject };\n options: ResolvedScanSettings;\n sources: ConfigurationSources;\n projectConfig?: ProjectConfigProvenance;\n}\n\nexport type ConfigurationSource = \"default\" | \"legacy\" | \"project\" | \"cli\";\nconst PROJECT_SETTING_KEYS = {\n auth: \"auth\",\n mode: \"scan.mode\",\n target: \"scan.scope\",\n knowledgeBasePaths: \"scan.knowledge_base\",\n scanPromptFile: \"scan.instructions_file\",\n validationPromptFile: \"scan.validation_file\",\n outputDir: \"output.directory\",\n failureSeverity: \"policy.fail_on_severity\",\n maxCostUsd: \"limits.max_cost_usd_per_scan\",\n} as const satisfies Partial<Record<keyof ScanSettings, string>>;\ntype SettingProvenanceKey =\n (typeof PROJECT_SETTING_KEYS)[keyof typeof PROJECT_SETTING_KEYS];\nexport type ScopeProvenanceKey =\n \"scan.scope\" | \"scan.scope.diff.head\" | \"scan.scope.working_tree.base\";\nexport type ProvenanceKey =\n | SettingProvenanceKey\n | ScopeProvenanceKey\n | `scan.deep.${(typeof DEEP_SCAN_SETTINGS)[number][2]}`\n | `codex.${string}`;\nexport type ConfigurationSources = Readonly<\n Record<SettingProvenanceKey, ConfigurationSource> &\n Partial<Record<ProvenanceKey, ConfigurationSource>>\n>;\nexport interface ProjectConfigProvenance {\n path: string;\n sources: ConfigurationSources;\n}\n\n/** Build a complete, immutable source map after layer and preflight resolution. */\nexport function configurationSources(\n values: Partial<Record<ProvenanceKey, ConfigurationSource>> = {},\n deepSources?: DeepScanSources,\n): ConfigurationSources {\n const sources = {\n ...Object.fromEntries(\n Object.values(PROJECT_SETTING_KEYS).map((key) => [key, \"default\"]),\n ),\n ...values,\n } as Record<SettingProvenanceKey, ConfigurationSource> &\n Partial<Record<ProvenanceKey, ConfigurationSource>>;\n for (const [name, , key] of DEEP_SCAN_SETTINGS) {\n const source = deepSources?.[name];\n if (source !== undefined && source !== \"override\")\n sources[`scan.deep.${key}`] = source;\n }\n return Object.freeze(sources);\n}\n\nexport async function loadProjectConfig(\n file: string,\n directory = process.cwd(),\n): Promise<ResolvedProjectConfig> {\n return resolveScanSettings(\n await readProjectConfig(file, directory),\n {},\n directory,\n );\n}\n\nexport function resolveProjectConfig(\n input: ProjectConfigInput,\n directory = process.cwd(),\n): ResolvedProjectConfig {\n requireProjectConfig(input);\n return resolveScanSettings(\n { input, directory: resolve(directory) },\n {},\n directory,\n );\n}\n\nexport async function readProjectConfig(\n file: string,\n directory = process.cwd(),\n): Promise<ProjectConfigSource> {\n const path = resolve(directory, expandHome(file));\n const extension = projectConfigExtension(path);\n let text: string;\n try {\n text = await readFile(path, \"utf8\");\n } catch (error) {\n throw new ConfigurationError(\n `Cannot read project configuration at ${path}.`,\n { cause: error },\n );\n }\n let value: unknown;\n try {\n if (extension === \".json\") {\n value = JSON.parse(text);\n } else {\n const document = parseDocument(text, { prettyErrors: false });\n if (document.errors.length > 0) throw document.errors[0];\n // Keep YAML's expansion guard while allowing repeated native profiles.\n value = document.toJS({ maxAliasCount: 10_000 });\n }\n } catch (error) {\n throw new ConfigurationError(\n `Cannot parse project configuration at ${path}.`,\n { cause: error },\n );\n }\n requireProjectConfig(value, path);\n return { path, directory: dirname(path), input: value };\n}\n\nfunction projectConfigExtension(path: string): string {\n const extension = extname(path).toLowerCase();\n if (![\".yaml\", \".yml\", \".json\"].includes(extension)) {\n throw new ConfigurationError(\n \"Project configuration must be a .yaml, .yml, or .json file.\",\n );\n }\n return extension;\n}\n\nexport function projectConfigStarter(\n path: string,\n directory = process.cwd(),\n): string {\n const schemaPath = resolve(\n directory,\n \"node_modules/@openai/codex-security/schemas/project-config.schema.json\",\n );\n const relativeSchema = relative(\n dirname(resolve(directory, path)),\n schemaPath,\n );\n const schema = isAbsolute(relativeSchema)\n ? pathToFileURL(schemaPath).href\n : `${relativeSchema.startsWith(\".\") ? \"\" : \"./\"}${relativeSchema\n .split(sep)\n .join(\"/\")}`;\n if (projectConfigExtension(path) === \".json\")\n return `${JSON.stringify({ $schema: schema }, null, 2)}\\n`;\n return [\n \"# This file is trusted like CLI options. Keep it outside untrusted inputs.\",\n `$schema: ${schema}`,\n \"\",\n \"# Uncomment the settings you want to override. Defaults remain unpinned.\",\n `# auth: ${DEFAULT_SCAN_AUTH}`,\n \"# scan:\",\n `# mode: ${DEFAULT_SCAN_MODE}`,\n \"# scope:\",\n \"# paths: [src] # Relative to each selected repository.\",\n \"# knowledge_base: [] # Paths relative to this file.\",\n \"# instructions_file: instructions.md\",\n \"# validation_file: validation.md # Standard mode only.\",\n \"# deep: # Used when mode is deep.\",\n ...DEEP_SCAN_SETTINGS.map(\n ([name, , key]) => `# ${key}: ${DEFAULT_DEEP_SCAN_SETTINGS[name]}`,\n ),\n \"# codex:\",\n `# model: ${DEFAULT_CODEX_CONFIG[\"model\"]}`,\n `# model_reasoning_effort: ${DEFAULT_CODEX_CONFIG[\"model_reasoning_effort\"]}`,\n \"# limits:\",\n \"# max_cost_usd_per_scan: 10 # Optional limit per scan attempt.\",\n \"# policy:\",\n \"# fail_on_severity: high # Omitted by default (report only).\",\n \"# output:\",\n \"# directory: ../scan-results # Outside the selected repositories.\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction requireProjectConfig(\n value: unknown,\n path?: string,\n): asserts value is ProjectConfigInput {\n if (!validateProjectConfig(value)) {\n const issues = validateProjectConfig\n .errors!.map((issue) => {\n const message =\n issue.keyword === \"additionalProperties\"\n ? `Unknown key ${issue.params[\"additionalProperty\"]}.`\n : issue.message;\n return `${issue.instancePath || \"configuration\"}: ${message}`;\n })\n .join(\"; \");\n throw new ConfigurationError(\n `Invalid project configuration${path === undefined ? \"\" : ` at ${path}`}: ${issues}`,\n );\n }\n}\n\nexport function resolveScanSettings(\n project: ProjectConfigSource | undefined,\n overrides: Partial<ScanSettings> & { codexOverrides?: JsonObject },\n directory: string,\n scopeSources: Partial<Record<ScopeProvenanceKey, ConfigurationSource>> = {},\n): ResolvedProjectConfig {\n const file = project?.input;\n const sources: Partial<Record<ProvenanceKey, ConfigurationSource>> = {};\n const choose = <T>(\n key: ProvenanceKey,\n configured: T | undefined,\n explicit: T | undefined,\n ): T | undefined => {\n if (explicit !== undefined) {\n sources[key] = \"cli\";\n return explicit;\n }\n if (configured !== undefined) {\n sources[key] = \"project\";\n return configured;\n }\n return undefined;\n };\n const projectDirectory = project?.directory ?? directory;\n const filePath = (value: string | undefined): AbsolutePath | undefined =>\n value === undefined\n ? undefined\n : resolveConfigPath(projectDirectory, value);\n const cliPath = (value: string | undefined): AbsolutePath | undefined =>\n value === undefined ? undefined : resolveConfigPath(directory, value);\n\n const mode =\n choose(\"scan.mode\", file?.scan?.mode, overrides.mode) ?? DEFAULT_SCAN_MODE;\n const explicitDeep = deepScanOptions({ ...overrides, mode });\n const target =\n choose(\n \"scan.scope\",\n projectScopeTarget(file?.scan?.scope),\n overrides.target,\n ) ?? \"repository\";\n const configuredDeep = file?.scan?.deep;\n const deep: DeepScanOptions = {};\n if (mode === \"deep\") {\n for (const [name, , field] of DEEP_SCAN_SETTINGS) {\n const value = choose(\n `scan.deep.${field}`,\n configuredDeep?.[field],\n explicitDeep[name],\n );\n if (value !== undefined) deep[name] = value;\n }\n }\n\n const codexOverrides = mergeCodexOverrides(\n file?.codex ?? {},\n overrides.codexOverrides ?? {},\n );\n const recordNativeSources = (\n value: JsonObject,\n source: ConfigurationSource,\n prefix: \"codex\" | `codex.${string}` = \"codex\",\n ) => {\n for (const [key, item] of Object.entries(value)) {\n const path: `codex.${string}` = `${prefix}.${key}`;\n if (item !== null && typeof item === \"object\" && !Array.isArray(item)) {\n delete sources[path];\n recordNativeSources(item, source, path);\n } else {\n for (const existing of Object.keys(sources) as ProvenanceKey[]) {\n if (existing.startsWith(`${path}.`)) delete sources[existing];\n }\n sources[path] = source;\n }\n }\n };\n recordNativeSources(DEFAULT_CODEX_CONFIG, \"default\");\n recordNativeSources(file?.codex ?? {}, \"project\");\n recordNativeSources(overrides.codexOverrides ?? {}, \"cli\");\n const knowledgeBasePaths =\n choose(\n \"scan.knowledge_base\",\n file?.scan?.knowledge_base?.map((value) =>\n resolveConfigPath(projectDirectory, value),\n ),\n overrides.knowledgeBasePaths?.map((value) =>\n resolveConfigPath(directory, value),\n ),\n ) ?? [];\n const settings: ResolvedScanSettings = {\n ...pickScanSettings(overrides),\n auth: choose(\"auth\", file?.auth, overrides.auth) ?? DEFAULT_SCAN_AUTH,\n mode,\n target,\n knowledgeBasePaths,\n scanPromptFile: choose(\n \"scan.instructions_file\",\n filePath(file?.scan?.instructions_file),\n cliPath(overrides.scanPromptFile),\n ),\n validationPromptFile: choose(\n \"scan.validation_file\",\n filePath(file?.scan?.validation_file),\n cliPath(overrides.validationPromptFile),\n ),\n postScanPromptFile: cliPath(overrides.postScanPromptFile),\n outputDir: choose(\n \"output.directory\",\n filePath(file?.output?.directory),\n cliPath(overrides.outputDir),\n ),\n failureSeverity: choose(\n \"policy.fail_on_severity\",\n file?.policy?.fail_on_severity,\n overrides.failureSeverity,\n ),\n maxCostUsd: choose(\n \"limits.max_cost_usd_per_scan\",\n file?.limits?.max_cost_usd_per_scan,\n overrides.maxCostUsd,\n ),\n ...deep,\n };\n const resolvedSources = configurationSources({ ...sources, ...scopeSources });\n return {\n config: { codexOverrides },\n options: settings,\n sources: resolvedSources,\n ...(project?.path === undefined\n ? {}\n : { projectConfig: { path: project.path, sources: resolvedSources } }),\n };\n}\n\nexport function projectScopeTarget(\n scope: ProjectScope | undefined,\n): ScanTarget | undefined {\n if (scope === undefined) return undefined;\n if (\"paths\" in scope) return [...scope.paths];\n if (\"diff\" in scope) return DiffTarget.refs(scope.diff);\n return DiffTarget.workingTree(scope.working_tree);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BigIntStats } from "node:fs";
|
|
2
|
+
import type { ScanPromptSettings } from "./scan-settings.js";
|
|
3
|
+
type ResolvedScanPrompts = Pick<ScanPromptSettings, "scanPrompt" | "validationPrompt" | "postScanPrompt"> & {
|
|
4
|
+
scanPromptFile: undefined;
|
|
5
|
+
validationPromptFile: undefined;
|
|
6
|
+
postScanPromptFile: undefined;
|
|
7
|
+
};
|
|
8
|
+
/** Resolve selected files once; an inline SDK prompt overrides its file. */
|
|
9
|
+
export declare function resolveScanPrompts(options: ScanPromptSettings, repository: string | readonly string[], directory?: string): Promise<ResolvedScanPrompts>;
|
|
10
|
+
export declare function readRegularInputFile(path: string, repository: string | readonly string[], metadata?: Pick<BigIntStats, "isFile" | "dev" | "ino">): Promise<string>;
|
|
11
|
+
export declare function isOutsidePath(path: string): boolean;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=prompt-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-files.d.ts","sourceRoot":"","sources":["../src/prompt-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAatD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,KAAK,mBAAmB,GAAG,IAAI,CAC7B,kBAAkB,EAClB,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,CACrD,GAAG;IACF,cAAc,EAAE,SAAS,CAAC;IAC1B,oBAAoB,EAAE,SAAS,CAAC;IAChC,kBAAkB,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEF,4EAA4E;AAC5E,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACtC,SAAS,SAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAoC9B;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACtC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,GACrD,OAAO,CAAC,MAAM,CAAC,CA4CjB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|