@shieldaai/security-watch 0.0.0-stage → 1.0.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/CHANGELOG.md +170 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +202 -0
- package/README.md +394 -2
- package/SECURITY.md +62 -0
- package/dist/assessment.d.ts +16 -0
- package/dist/assessment.js +569 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1105 -0
- package/dist/config.d.ts +302 -0
- package/dist/config.js +381 -0
- package/dist/coverage.d.ts +4 -0
- package/dist/coverage.js +11 -0
- package/dist/cve-now.d.ts +35 -0
- package/dist/cve-now.js +1002 -0
- package/dist/cvss4.d.ts +3 -0
- package/dist/cvss4.js +39 -0
- package/dist/delivery.d.ts +58 -0
- package/dist/delivery.js +687 -0
- package/dist/ecosystems.d.ts +48 -0
- package/dist/ecosystems.js +332 -0
- package/dist/engine.d.ts +80 -0
- package/dist/engine.js +388 -0
- package/dist/everyday-words.d.ts +11 -0
- package/dist/everyday-words.js +256 -0
- package/dist/health.d.ts +24 -0
- package/dist/health.js +122 -0
- package/dist/heartbeat.d.ts +13 -0
- package/dist/heartbeat.js +74 -0
- package/dist/http.d.ts +15 -0
- package/dist/http.js +280 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +23 -0
- package/dist/inventory-evidence.d.ts +10 -0
- package/dist/inventory-evidence.js +206 -0
- package/dist/inventory.d.ts +276 -0
- package/dist/inventory.js +336 -0
- package/dist/lock.d.ts +3 -0
- package/dist/lock.js +112 -0
- package/dist/maintenance.d.ts +48 -0
- package/dist/maintenance.js +295 -0
- package/dist/matching.d.ts +29 -0
- package/dist/matching.js +537 -0
- package/dist/models.d.ts +33 -0
- package/dist/models.js +932 -0
- package/dist/operations.d.ts +17 -0
- package/dist/operations.js +117 -0
- package/dist/pilot-cases.d.ts +171 -0
- package/dist/pilot-cases.js +330 -0
- package/dist/pilot-input.d.ts +16 -0
- package/dist/pilot-input.js +125 -0
- package/dist/pilot-recall.d.ts +166 -0
- package/dist/pilot-recall.js +231 -0
- package/dist/pilot-report.d.ts +113 -0
- package/dist/pilot-report.js +279 -0
- package/dist/pilot-responses.d.ts +111 -0
- package/dist/pilot-responses.js +159 -0
- package/dist/providers.d.ts +209 -0
- package/dist/providers.js +459 -0
- package/dist/python-version.d.ts +3 -0
- package/dist/python-version.js +30 -0
- package/dist/rehearsal.d.ts +440 -0
- package/dist/rehearsal.js +372 -0
- package/dist/sbom.d.ts +13 -0
- package/dist/sbom.js +193 -0
- package/dist/setup.d.ts +113 -0
- package/dist/setup.js +100 -0
- package/dist/source-error.d.ts +38 -0
- package/dist/source-error.js +71 -0
- package/dist/sources.d.ts +3 -0
- package/dist/sources.js +1725 -0
- package/dist/store.d.ts +96 -0
- package/dist/store.js +953 -0
- package/dist/types.d.ts +404 -0
- package/dist/types.js +1 -0
- package/dist/util.d.ts +29 -0
- package/dist/util.js +94 -0
- package/dist/vendor/cvss4-reference.d.ts +2 -0
- package/dist/vendor/cvss4-reference.js +789 -0
- package/dist/vendor-sources.d.ts +24 -0
- package/dist/vendor-sources.js +56 -0
- package/dist/word-filter.d.ts +3 -0
- package/dist/word-filter.js +3291 -0
- package/docs/alert-outcome-evaluation.md +150 -0
- package/docs/compatibility.md +35 -0
- package/docs/configuration.md +666 -0
- package/docs/cvss-v4-support.md +41 -0
- package/docs/offline-advisory-preview.md +114 -0
- package/docs/offline-rehearsal.md +44 -0
- package/docs/pilot-cases.md +58 -0
- package/docs/pilot-recall.md +124 -0
- package/docs/pilot-report.md +52 -0
- package/docs/validation/alert-outcome-evaluation-2026-11-05.json +2935 -0
- package/docs/validation/cvss-v4-reference-parity-2026-11-05.json +93 -0
- package/docs/validation/rehearsal-accepted-2026-11-05.json +175 -0
- package/docs/validation/rehearsal-unknown-2026-11-05.json +175 -0
- package/docs/vendor/cvss-v4-LICENSE.txt +22 -0
- package/docs/vendor/cvss-v4-provenance.json +38 -0
- package/examples/advisories.json +17 -0
- package/examples/agent-advisories-2026.json +145 -0
- package/examples/agent-advisory-cases-2026.json +397 -0
- package/examples/common-systems.yaml +243 -0
- package/examples/libraries.example.txt +18 -0
- package/examples/libraries.example.yaml +40 -0
- package/examples/library-watch.example.yaml +27 -0
- package/examples/offline-advisory-preview.mjs +42 -0
- package/examples/rehearsal.json +75 -0
- package/examples/security-watch.example.yaml +86 -0
- package/examples/systems.example.yaml +35 -0
- package/package.json +85 -4
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Config } from './types.js';
|
|
3
|
+
export declare const configSchema: z.ZodObject<{
|
|
4
|
+
version: z.ZodLiteral<1>;
|
|
5
|
+
inventory: z.ZodDefault<z.ZodString>;
|
|
6
|
+
database: z.ZodDefault<z.ZodString>;
|
|
7
|
+
poll_interval_minutes: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
news_lookback_minutes: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
inventory_stale_days: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
digest_interval_hours: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
sources: z.ZodDefault<z.ZodObject<{
|
|
12
|
+
cve_now: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
+
hacker_news: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
osv: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
github: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
github_token_env: z.ZodDefault<z.ZodString>;
|
|
17
|
+
kev: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
feeds: z.ZodDefault<z.ZodArray<z.ZodURL>>;
|
|
19
|
+
vendor_feeds: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
20
|
+
nodejs: "nodejs";
|
|
21
|
+
php: "php";
|
|
22
|
+
python: "python";
|
|
23
|
+
}>>>;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
models: z.ZodDefault<z.ZodObject<{
|
|
26
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
27
|
+
analysis: z.ZodOptional<z.ZodPipe<z.ZodObject<{
|
|
28
|
+
provider: z.ZodEnum<{
|
|
29
|
+
anthropic: "anthropic";
|
|
30
|
+
"azure-openai": "azure-openai";
|
|
31
|
+
cerebras: "cerebras";
|
|
32
|
+
cohere: "cohere";
|
|
33
|
+
deepseek: "deepseek";
|
|
34
|
+
fireworks: "fireworks";
|
|
35
|
+
gemini: "gemini";
|
|
36
|
+
groq: "groq";
|
|
37
|
+
huggingface: "huggingface";
|
|
38
|
+
litellm: "litellm";
|
|
39
|
+
lmstudio: "lmstudio";
|
|
40
|
+
mistral: "mistral";
|
|
41
|
+
nvidia: "nvidia";
|
|
42
|
+
ollama: "ollama";
|
|
43
|
+
openai: "openai";
|
|
44
|
+
"openai-compatible": "openai-compatible";
|
|
45
|
+
openrouter: "openrouter";
|
|
46
|
+
perplexity: "perplexity";
|
|
47
|
+
sambanova: "sambanova";
|
|
48
|
+
together: "together";
|
|
49
|
+
vllm: "vllm";
|
|
50
|
+
xai: "xai";
|
|
51
|
+
}>;
|
|
52
|
+
disclosure_profile: z.ZodDefault<z.ZodEnum<{
|
|
53
|
+
"deployment-context": "deployment-context";
|
|
54
|
+
minimal: "minimal";
|
|
55
|
+
}>>;
|
|
56
|
+
output_format: z.ZodDefault<z.ZodEnum<{
|
|
57
|
+
auto: "auto";
|
|
58
|
+
json_object: "json_object";
|
|
59
|
+
json_schema: "json_schema";
|
|
60
|
+
prompt: "prompt";
|
|
61
|
+
}>>;
|
|
62
|
+
model: z.ZodString;
|
|
63
|
+
api_key_env: z.ZodOptional<z.ZodString>;
|
|
64
|
+
endpoint: z.ZodOptional<z.ZodURL>;
|
|
65
|
+
allow_private_endpoint: z.ZodDefault<z.ZodBoolean>;
|
|
66
|
+
input_usd_per_million: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
output_usd_per_million: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
69
|
+
provider: "anthropic" | "azure-openai" | "cerebras" | "cohere" | "deepseek" | "fireworks" | "gemini" | "groq" | "huggingface" | "litellm" | "lmstudio" | "mistral" | "nvidia" | "ollama" | "openai" | "openai-compatible" | "openrouter" | "perplexity" | "sambanova" | "together" | "vllm" | "xai";
|
|
70
|
+
disclosure_profile: "deployment-context" | "minimal";
|
|
71
|
+
output_format: "auto" | "json_object" | "json_schema" | "prompt";
|
|
72
|
+
model: string;
|
|
73
|
+
endpoint?: string | undefined;
|
|
74
|
+
allow_private_endpoint: boolean;
|
|
75
|
+
input_usd_per_million?: number | undefined;
|
|
76
|
+
output_usd_per_million?: number | undefined;
|
|
77
|
+
api_key_env: string;
|
|
78
|
+
}, {
|
|
79
|
+
provider: "anthropic" | "azure-openai" | "cerebras" | "cohere" | "deepseek" | "fireworks" | "gemini" | "groq" | "huggingface" | "litellm" | "lmstudio" | "mistral" | "nvidia" | "ollama" | "openai" | "openai-compatible" | "openrouter" | "perplexity" | "sambanova" | "together" | "vllm" | "xai";
|
|
80
|
+
disclosure_profile: "deployment-context" | "minimal";
|
|
81
|
+
output_format: "auto" | "json_object" | "json_schema" | "prompt";
|
|
82
|
+
model: string;
|
|
83
|
+
api_key_env?: string | undefined;
|
|
84
|
+
endpoint?: string | undefined;
|
|
85
|
+
allow_private_endpoint: boolean;
|
|
86
|
+
input_usd_per_million?: number | undefined;
|
|
87
|
+
output_usd_per_million?: number | undefined;
|
|
88
|
+
}>>>;
|
|
89
|
+
verification: z.ZodOptional<z.ZodPipe<z.ZodObject<{
|
|
90
|
+
provider: z.ZodEnum<{
|
|
91
|
+
anthropic: "anthropic";
|
|
92
|
+
"azure-openai": "azure-openai";
|
|
93
|
+
cerebras: "cerebras";
|
|
94
|
+
cohere: "cohere";
|
|
95
|
+
deepseek: "deepseek";
|
|
96
|
+
fireworks: "fireworks";
|
|
97
|
+
gemini: "gemini";
|
|
98
|
+
groq: "groq";
|
|
99
|
+
huggingface: "huggingface";
|
|
100
|
+
litellm: "litellm";
|
|
101
|
+
lmstudio: "lmstudio";
|
|
102
|
+
mistral: "mistral";
|
|
103
|
+
nvidia: "nvidia";
|
|
104
|
+
ollama: "ollama";
|
|
105
|
+
openai: "openai";
|
|
106
|
+
"openai-compatible": "openai-compatible";
|
|
107
|
+
openrouter: "openrouter";
|
|
108
|
+
perplexity: "perplexity";
|
|
109
|
+
sambanova: "sambanova";
|
|
110
|
+
together: "together";
|
|
111
|
+
vllm: "vllm";
|
|
112
|
+
xai: "xai";
|
|
113
|
+
}>;
|
|
114
|
+
disclosure_profile: z.ZodDefault<z.ZodEnum<{
|
|
115
|
+
"deployment-context": "deployment-context";
|
|
116
|
+
minimal: "minimal";
|
|
117
|
+
}>>;
|
|
118
|
+
output_format: z.ZodDefault<z.ZodEnum<{
|
|
119
|
+
auto: "auto";
|
|
120
|
+
json_object: "json_object";
|
|
121
|
+
json_schema: "json_schema";
|
|
122
|
+
prompt: "prompt";
|
|
123
|
+
}>>;
|
|
124
|
+
model: z.ZodString;
|
|
125
|
+
api_key_env: z.ZodOptional<z.ZodString>;
|
|
126
|
+
endpoint: z.ZodOptional<z.ZodURL>;
|
|
127
|
+
allow_private_endpoint: z.ZodDefault<z.ZodBoolean>;
|
|
128
|
+
input_usd_per_million: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
output_usd_per_million: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
131
|
+
provider: "anthropic" | "azure-openai" | "cerebras" | "cohere" | "deepseek" | "fireworks" | "gemini" | "groq" | "huggingface" | "litellm" | "lmstudio" | "mistral" | "nvidia" | "ollama" | "openai" | "openai-compatible" | "openrouter" | "perplexity" | "sambanova" | "together" | "vllm" | "xai";
|
|
132
|
+
disclosure_profile: "deployment-context" | "minimal";
|
|
133
|
+
output_format: "auto" | "json_object" | "json_schema" | "prompt";
|
|
134
|
+
model: string;
|
|
135
|
+
endpoint?: string | undefined;
|
|
136
|
+
allow_private_endpoint: boolean;
|
|
137
|
+
input_usd_per_million?: number | undefined;
|
|
138
|
+
output_usd_per_million?: number | undefined;
|
|
139
|
+
api_key_env: string;
|
|
140
|
+
}, {
|
|
141
|
+
provider: "anthropic" | "azure-openai" | "cerebras" | "cohere" | "deepseek" | "fireworks" | "gemini" | "groq" | "huggingface" | "litellm" | "lmstudio" | "mistral" | "nvidia" | "ollama" | "openai" | "openai-compatible" | "openrouter" | "perplexity" | "sambanova" | "together" | "vllm" | "xai";
|
|
142
|
+
disclosure_profile: "deployment-context" | "minimal";
|
|
143
|
+
output_format: "auto" | "json_object" | "json_schema" | "prompt";
|
|
144
|
+
model: string;
|
|
145
|
+
api_key_env?: string | undefined;
|
|
146
|
+
endpoint?: string | undefined;
|
|
147
|
+
allow_private_endpoint: boolean;
|
|
148
|
+
input_usd_per_million?: number | undefined;
|
|
149
|
+
output_usd_per_million?: number | undefined;
|
|
150
|
+
}>>>;
|
|
151
|
+
daily_request_limit: z.ZodDefault<z.ZodNumber>;
|
|
152
|
+
daily_token_limit: z.ZodDefault<z.ZodNumber>;
|
|
153
|
+
daily_budget_usd: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
max_input_chars: z.ZodDefault<z.ZodNumber>;
|
|
155
|
+
max_output_tokens: z.ZodDefault<z.ZodNumber>;
|
|
156
|
+
timeout_seconds: z.ZodDefault<z.ZodNumber>;
|
|
157
|
+
}, z.core.$strict>>;
|
|
158
|
+
policy: z.ZodPipe<z.ZodDefault<z.ZodObject<{
|
|
159
|
+
library: z.ZodDefault<z.ZodObject<{
|
|
160
|
+
levels: z.ZodArray<z.ZodEnum<{
|
|
161
|
+
critical: "critical";
|
|
162
|
+
high: "high";
|
|
163
|
+
low: "low";
|
|
164
|
+
medium: "medium";
|
|
165
|
+
unknown: "unknown";
|
|
166
|
+
}>>;
|
|
167
|
+
basis: z.ZodDefault<z.ZodEnum<{
|
|
168
|
+
priority: "priority";
|
|
169
|
+
source_severity: "source_severity";
|
|
170
|
+
}>>;
|
|
171
|
+
channels: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
172
|
+
email: "email";
|
|
173
|
+
slack: "slack";
|
|
174
|
+
}>>>;
|
|
175
|
+
}, z.core.$strict>>;
|
|
176
|
+
product: z.ZodDefault<z.ZodObject<{
|
|
177
|
+
levels: z.ZodArray<z.ZodEnum<{
|
|
178
|
+
critical: "critical";
|
|
179
|
+
high: "high";
|
|
180
|
+
low: "low";
|
|
181
|
+
medium: "medium";
|
|
182
|
+
unknown: "unknown";
|
|
183
|
+
}>>;
|
|
184
|
+
basis: z.ZodDefault<z.ZodEnum<{
|
|
185
|
+
priority: "priority";
|
|
186
|
+
source_severity: "source_severity";
|
|
187
|
+
}>>;
|
|
188
|
+
channels: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
189
|
+
email: "email";
|
|
190
|
+
slack: "slack";
|
|
191
|
+
}>>>;
|
|
192
|
+
}, z.core.$strict>>;
|
|
193
|
+
news: z.ZodDefault<z.ZodObject<{
|
|
194
|
+
levels: z.ZodArray<z.ZodEnum<{
|
|
195
|
+
critical: "critical";
|
|
196
|
+
high: "high";
|
|
197
|
+
low: "low";
|
|
198
|
+
medium: "medium";
|
|
199
|
+
unknown: "unknown";
|
|
200
|
+
}>>;
|
|
201
|
+
basis: z.ZodDefault<z.ZodEnum<{
|
|
202
|
+
priority: "priority";
|
|
203
|
+
source_severity: "source_severity";
|
|
204
|
+
}>>;
|
|
205
|
+
channels: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
206
|
+
email: "email";
|
|
207
|
+
slack: "slack";
|
|
208
|
+
}>>>;
|
|
209
|
+
}, z.core.$strict>>;
|
|
210
|
+
urgent_unknown: z.ZodDefault<z.ZodBoolean>;
|
|
211
|
+
exploited_override: z.ZodDefault<z.ZodBoolean>;
|
|
212
|
+
malware_override: z.ZodDefault<z.ZodBoolean>;
|
|
213
|
+
ai_dismissals: z.ZodOptional<z.ZodEnum<{
|
|
214
|
+
record: "record";
|
|
215
|
+
review: "review";
|
|
216
|
+
}>>;
|
|
217
|
+
review_before_news_suppression: z.ZodOptional<z.ZodBoolean>;
|
|
218
|
+
health_channels: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
219
|
+
email: "email";
|
|
220
|
+
slack: "slack";
|
|
221
|
+
}>>>;
|
|
222
|
+
}, z.core.$strict>>, z.ZodTransform<{
|
|
223
|
+
library: {
|
|
224
|
+
levels: ("critical" | "high" | "low" | "medium" | "unknown")[];
|
|
225
|
+
basis: "priority" | "source_severity";
|
|
226
|
+
channels: ("email" | "slack")[];
|
|
227
|
+
};
|
|
228
|
+
product: {
|
|
229
|
+
levels: ("critical" | "high" | "low" | "medium" | "unknown")[];
|
|
230
|
+
basis: "priority" | "source_severity";
|
|
231
|
+
channels: ("email" | "slack")[];
|
|
232
|
+
};
|
|
233
|
+
news: {
|
|
234
|
+
levels: ("critical" | "high" | "low" | "medium" | "unknown")[];
|
|
235
|
+
basis: "priority" | "source_severity";
|
|
236
|
+
channels: ("email" | "slack")[];
|
|
237
|
+
};
|
|
238
|
+
urgent_unknown: boolean;
|
|
239
|
+
exploited_override: boolean;
|
|
240
|
+
malware_override: boolean;
|
|
241
|
+
health_channels: ("email" | "slack")[];
|
|
242
|
+
ai_dismissals: "record" | "review";
|
|
243
|
+
}, {
|
|
244
|
+
library: {
|
|
245
|
+
levels: ("critical" | "high" | "low" | "medium" | "unknown")[];
|
|
246
|
+
basis: "priority" | "source_severity";
|
|
247
|
+
channels: ("email" | "slack")[];
|
|
248
|
+
};
|
|
249
|
+
product: {
|
|
250
|
+
levels: ("critical" | "high" | "low" | "medium" | "unknown")[];
|
|
251
|
+
basis: "priority" | "source_severity";
|
|
252
|
+
channels: ("email" | "slack")[];
|
|
253
|
+
};
|
|
254
|
+
news: {
|
|
255
|
+
levels: ("critical" | "high" | "low" | "medium" | "unknown")[];
|
|
256
|
+
basis: "priority" | "source_severity";
|
|
257
|
+
channels: ("email" | "slack")[];
|
|
258
|
+
};
|
|
259
|
+
urgent_unknown: boolean;
|
|
260
|
+
exploited_override: boolean;
|
|
261
|
+
malware_override: boolean;
|
|
262
|
+
ai_dismissals?: "record" | "review" | undefined;
|
|
263
|
+
review_before_news_suppression?: boolean | undefined;
|
|
264
|
+
health_channels: ("email" | "slack")[];
|
|
265
|
+
}>>;
|
|
266
|
+
notifications: z.ZodDefault<z.ZodObject<{
|
|
267
|
+
slack: z.ZodOptional<z.ZodObject<{
|
|
268
|
+
webhook_url_env: z.ZodString;
|
|
269
|
+
}, z.core.$strict>>;
|
|
270
|
+
email: z.ZodOptional<z.ZodObject<{
|
|
271
|
+
smtp_url_env: z.ZodString;
|
|
272
|
+
from: z.ZodEmail;
|
|
273
|
+
to: z.ZodArray<z.ZodEmail>;
|
|
274
|
+
}, z.core.$strict>>;
|
|
275
|
+
max_attempts: z.ZodDefault<z.ZodNumber>;
|
|
276
|
+
}, z.core.$strict>>;
|
|
277
|
+
monitoring: z.ZodOptional<z.ZodObject<{
|
|
278
|
+
heartbeat_url_env: z.ZodString;
|
|
279
|
+
interval_seconds: z.ZodDefault<z.ZodNumber>;
|
|
280
|
+
allow_private_endpoint: z.ZodDefault<z.ZodBoolean>;
|
|
281
|
+
}, z.core.$strict>>;
|
|
282
|
+
maintenance: z.ZodOptional<z.ZodObject<{
|
|
283
|
+
interval_hours: z.ZodDefault<z.ZodNumber>;
|
|
284
|
+
retention: z.ZodOptional<z.ZodObject<{
|
|
285
|
+
analysis_cache_days: z.ZodOptional<z.ZodNumber>;
|
|
286
|
+
evidence_history_days: z.ZodOptional<z.ZodNumber>;
|
|
287
|
+
finding_history_days: z.ZodOptional<z.ZodNumber>;
|
|
288
|
+
accepted_delivery_days: z.ZodOptional<z.ZodNumber>;
|
|
289
|
+
inactive_findings_days: z.ZodOptional<z.ZodNumber>;
|
|
290
|
+
unreferenced_evidence_days: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
batch_size: z.ZodDefault<z.ZodNumber>;
|
|
292
|
+
}, z.core.$strict>>;
|
|
293
|
+
backup: z.ZodOptional<z.ZodObject<{
|
|
294
|
+
directory: z.ZodString;
|
|
295
|
+
keep: z.ZodDefault<z.ZodNumber>;
|
|
296
|
+
max_bytes: z.ZodDefault<z.ZodNumber>;
|
|
297
|
+
}, z.core.$strict>>;
|
|
298
|
+
}, z.core.$strict>>;
|
|
299
|
+
}, z.core.$strict>;
|
|
300
|
+
export declare function parseConfig(value: unknown): Config;
|
|
301
|
+
export declare function missingCredentials(config: Config): string[];
|
|
302
|
+
export declare function loadConfig(path: string): Config;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { parse } from 'yaml';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { isIP } from 'node:net';
|
|
6
|
+
import { privateAddress } from './http.js';
|
|
7
|
+
import { PROVIDER_IDS, providerDefinition, allowsMissingKey, modelOutputFormat, modelEndpoint, } from './providers.js';
|
|
8
|
+
/**
|
|
9
|
+
* A host that is plainly on this machine or a private network; cleartext HTTP is allowed only there.
|
|
10
|
+
* An address is judged by its range. A name cannot be resolved here, so it is accepted when it has
|
|
11
|
+
* no public form: a single label (a container or service name), a special-use or private suffix, or
|
|
12
|
+
* a last label that cannot be a public top-level domain (`ollama.ml-tools`). The request itself is
|
|
13
|
+
* refused if such a name turns out to resolve to a public address.
|
|
14
|
+
*/
|
|
15
|
+
function localHost(hostname) {
|
|
16
|
+
const host = hostname
|
|
17
|
+
.replace(/^\[|\]$/g, '')
|
|
18
|
+
.toLowerCase()
|
|
19
|
+
.replace(/\.$/, '');
|
|
20
|
+
if (isIP(host))
|
|
21
|
+
return privateAddress(host);
|
|
22
|
+
if (!host || /^[0-9.]+$/.test(host))
|
|
23
|
+
return false;
|
|
24
|
+
const last = host.slice(host.lastIndexOf('.') + 1);
|
|
25
|
+
return (host === 'localhost' ||
|
|
26
|
+
!host.includes('.') ||
|
|
27
|
+
/\.(?:localhost|local|internal|intranet|private|corp|lan|home|home\.arpa|test|svc|cluster\.local|ts\.net)$/.test(host) ||
|
|
28
|
+
// Public top-level domains are letters only, or punycode.
|
|
29
|
+
(/[0-9_-]/.test(last) && !last.startsWith('xn--')));
|
|
30
|
+
}
|
|
31
|
+
/** Two model settings that reach the same model at the same address, however each is written. */
|
|
32
|
+
function sameModel(first, second) {
|
|
33
|
+
const address = (spec) => {
|
|
34
|
+
try {
|
|
35
|
+
const url = new URL(modelEndpoint(spec));
|
|
36
|
+
let path = url.pathname;
|
|
37
|
+
try {
|
|
38
|
+
path = decodeURIComponent(path);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Keep the path as written.
|
|
42
|
+
}
|
|
43
|
+
// A trailing dot on the host, doubled or trailing slashes, percent-encoding and letter case
|
|
44
|
+
// are different spellings of one address.
|
|
45
|
+
let host = url.hostname.toLowerCase().replace(/\.$/, '');
|
|
46
|
+
// Every name for this machine is one address.
|
|
47
|
+
if (['localhost', '[::1]', '0.0.0.0', '[::]'].includes(host) ||
|
|
48
|
+
host.endsWith('.localhost') ||
|
|
49
|
+
/^127\.\d+\.\d+\.\d+$/.test(host) ||
|
|
50
|
+
/^\[::ffff:7f[0-9a-f]{2}:[0-9a-f]{1,4}\]$/.test(host))
|
|
51
|
+
host = 'localhost';
|
|
52
|
+
return `${url.protocol}//${host}:${url.port}${path.replace(/\/+/g, '/').replace(/\/$/, '').toLowerCase()}`;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return (spec.endpoint ?? '').trim().toLowerCase();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// "models/gemini-x" and "gemini-x", or "library/llama3", "llama3" and "llama3:latest", are one model.
|
|
59
|
+
const name = (spec) => spec.model
|
|
60
|
+
.toLowerCase()
|
|
61
|
+
.replace(/^(?:models|library)\//, '')
|
|
62
|
+
.replace(/:latest$/, '');
|
|
63
|
+
return name(first) === name(second) && address(first) === address(second);
|
|
64
|
+
}
|
|
65
|
+
const envName = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
|
|
66
|
+
const severity = z.enum(['unknown', 'low', 'medium', 'high', 'critical']);
|
|
67
|
+
const channels = z
|
|
68
|
+
.array(z.enum(['slack', 'email']))
|
|
69
|
+
.max(2)
|
|
70
|
+
.refine((a) => new Set(a).size === a.length, 'Duplicate channel');
|
|
71
|
+
const retentionDays = z.number().int().min(1).max(3650).optional();
|
|
72
|
+
const model = z
|
|
73
|
+
.object({
|
|
74
|
+
provider: z.enum(PROVIDER_IDS),
|
|
75
|
+
disclosure_profile: z.enum(['minimal', 'deployment-context']).default('minimal'),
|
|
76
|
+
output_format: z.enum(['auto', 'json_schema', 'json_object', 'prompt']).default('auto'),
|
|
77
|
+
model: z.string().min(1).max(200),
|
|
78
|
+
api_key_env: envName.optional(),
|
|
79
|
+
endpoint: z.url().optional(),
|
|
80
|
+
allow_private_endpoint: z.boolean().default(false),
|
|
81
|
+
input_usd_per_million: z.number().nonnegative().max(10000).optional(),
|
|
82
|
+
output_usd_per_million: z.number().nonnegative().max(10000).optional(),
|
|
83
|
+
})
|
|
84
|
+
.strict()
|
|
85
|
+
.transform((spec) => ({
|
|
86
|
+
...spec,
|
|
87
|
+
api_key_env: spec.api_key_env ?? providerDefinition(spec.provider).apiKeyEnv,
|
|
88
|
+
}));
|
|
89
|
+
const rule = z
|
|
90
|
+
.object({
|
|
91
|
+
levels: z.array(severity).min(1),
|
|
92
|
+
basis: z.enum(['source_severity', 'priority']).default('priority'),
|
|
93
|
+
channels: channels.default([]),
|
|
94
|
+
})
|
|
95
|
+
.strict();
|
|
96
|
+
export const configSchema = z
|
|
97
|
+
.object({
|
|
98
|
+
version: z.literal(1),
|
|
99
|
+
inventory: z.string().min(1).default('./systems.yaml'),
|
|
100
|
+
database: z.string().min(1).default('./data/watch.db'),
|
|
101
|
+
poll_interval_minutes: z.number().int().min(1).max(1440).default(15),
|
|
102
|
+
news_lookback_minutes: z.number().int().min(1).max(10080).default(60),
|
|
103
|
+
inventory_stale_days: z.number().min(1).max(365).default(7),
|
|
104
|
+
digest_interval_hours: z.number().int().min(1).max(168).default(24),
|
|
105
|
+
sources: z
|
|
106
|
+
.object({
|
|
107
|
+
cve_now: z.boolean().default(true),
|
|
108
|
+
hacker_news: z.boolean().default(true),
|
|
109
|
+
osv: z.boolean().default(false),
|
|
110
|
+
github: z.boolean().default(false),
|
|
111
|
+
github_token_env: envName.default('GITHUB_TOKEN'),
|
|
112
|
+
kev: z.boolean().default(false),
|
|
113
|
+
feeds: z.array(z.url()).max(30).default([]),
|
|
114
|
+
vendor_feeds: z
|
|
115
|
+
.array(z.enum(['nodejs', 'python', 'php']))
|
|
116
|
+
.max(3)
|
|
117
|
+
.refine((values) => new Set(values).size === values.length, 'Duplicate vendor feed')
|
|
118
|
+
.default([]),
|
|
119
|
+
})
|
|
120
|
+
.strict()
|
|
121
|
+
.default({
|
|
122
|
+
cve_now: true,
|
|
123
|
+
hacker_news: true,
|
|
124
|
+
osv: false,
|
|
125
|
+
github: false,
|
|
126
|
+
github_token_env: 'GITHUB_TOKEN',
|
|
127
|
+
kev: false,
|
|
128
|
+
feeds: [],
|
|
129
|
+
vendor_feeds: [],
|
|
130
|
+
}),
|
|
131
|
+
models: z
|
|
132
|
+
.object({
|
|
133
|
+
enabled: z.boolean().default(false),
|
|
134
|
+
analysis: model.optional(),
|
|
135
|
+
verification: model.optional(),
|
|
136
|
+
daily_request_limit: z.number().int().min(1).max(10000).default(100),
|
|
137
|
+
daily_token_limit: z.number().int().min(100).max(10_000_000).default(1_000_000),
|
|
138
|
+
daily_budget_usd: z.number().positive().max(10000).optional(),
|
|
139
|
+
max_input_chars: z.number().int().min(1000).max(100_000).default(12_000),
|
|
140
|
+
max_output_tokens: z.number().int().min(128).max(8192).default(1500),
|
|
141
|
+
timeout_seconds: z.number().int().min(1).max(120).default(45),
|
|
142
|
+
})
|
|
143
|
+
.strict()
|
|
144
|
+
.default({
|
|
145
|
+
enabled: false,
|
|
146
|
+
daily_request_limit: 100,
|
|
147
|
+
daily_token_limit: 1_000_000,
|
|
148
|
+
max_input_chars: 12000,
|
|
149
|
+
max_output_tokens: 1500,
|
|
150
|
+
timeout_seconds: 45,
|
|
151
|
+
}),
|
|
152
|
+
policy: z
|
|
153
|
+
.object({
|
|
154
|
+
library: rule.default({ levels: ['critical'], basis: 'source_severity', channels: [] }),
|
|
155
|
+
product: rule.default({ levels: ['high', 'critical'], basis: 'priority', channels: [] }),
|
|
156
|
+
news: rule.default({ levels: ['high', 'critical'], basis: 'priority', channels: [] }),
|
|
157
|
+
urgent_unknown: z.boolean().default(true),
|
|
158
|
+
exploited_override: z.boolean().default(true),
|
|
159
|
+
malware_override: z.boolean().default(true),
|
|
160
|
+
ai_dismissals: z.enum(['review', 'record']).optional(),
|
|
161
|
+
review_before_news_suppression: z.boolean().optional(),
|
|
162
|
+
health_channels: channels.default([]),
|
|
163
|
+
})
|
|
164
|
+
.strict()
|
|
165
|
+
.default({
|
|
166
|
+
library: { levels: ['critical'], basis: 'source_severity', channels: [] },
|
|
167
|
+
product: { levels: ['high', 'critical'], basis: 'priority', channels: [] },
|
|
168
|
+
news: { levels: ['high', 'critical'], basis: 'priority', channels: [] },
|
|
169
|
+
urgent_unknown: true,
|
|
170
|
+
exploited_override: true,
|
|
171
|
+
malware_override: true,
|
|
172
|
+
ai_dismissals: 'review',
|
|
173
|
+
health_channels: [],
|
|
174
|
+
})
|
|
175
|
+
.superRefine((policy, ctx) => {
|
|
176
|
+
if (policy.ai_dismissals !== undefined &&
|
|
177
|
+
policy.review_before_news_suppression !== undefined &&
|
|
178
|
+
policy.ai_dismissals !== (policy.review_before_news_suppression ? 'review' : 'record'))
|
|
179
|
+
ctx.addIssue({
|
|
180
|
+
code: 'custom',
|
|
181
|
+
message: 'Conflicting AI dismissal policies; use ai_dismissals only.',
|
|
182
|
+
});
|
|
183
|
+
})
|
|
184
|
+
.transform(({ review_before_news_suppression, ...policy }) => ({
|
|
185
|
+
...policy,
|
|
186
|
+
ai_dismissals: policy.ai_dismissals ?? (review_before_news_suppression === false ? 'record' : 'review'),
|
|
187
|
+
})),
|
|
188
|
+
notifications: z
|
|
189
|
+
.object({
|
|
190
|
+
slack: z.object({ webhook_url_env: envName }).strict().optional(),
|
|
191
|
+
email: z
|
|
192
|
+
.object({ smtp_url_env: envName, from: z.email(), to: z.array(z.email()).min(1).max(20) })
|
|
193
|
+
.strict()
|
|
194
|
+
.optional(),
|
|
195
|
+
max_attempts: z.number().int().min(1).max(10).default(3),
|
|
196
|
+
})
|
|
197
|
+
.strict()
|
|
198
|
+
.default({ max_attempts: 3 }),
|
|
199
|
+
monitoring: z
|
|
200
|
+
.object({
|
|
201
|
+
heartbeat_url_env: envName,
|
|
202
|
+
interval_seconds: z.number().int().min(30).max(3600).default(60),
|
|
203
|
+
allow_private_endpoint: z.boolean().default(false),
|
|
204
|
+
})
|
|
205
|
+
.strict()
|
|
206
|
+
.optional(),
|
|
207
|
+
maintenance: z
|
|
208
|
+
.object({
|
|
209
|
+
interval_hours: z.number().int().min(1).max(168).default(24),
|
|
210
|
+
retention: z
|
|
211
|
+
.object({
|
|
212
|
+
analysis_cache_days: retentionDays,
|
|
213
|
+
evidence_history_days: retentionDays,
|
|
214
|
+
finding_history_days: retentionDays,
|
|
215
|
+
accepted_delivery_days: retentionDays,
|
|
216
|
+
inactive_findings_days: retentionDays,
|
|
217
|
+
unreferenced_evidence_days: retentionDays,
|
|
218
|
+
batch_size: z.number().int().min(1).max(10000).default(1000),
|
|
219
|
+
})
|
|
220
|
+
.strict()
|
|
221
|
+
.refine((value) => Object.entries(value).some(([key, days]) => key !== 'batch_size' && days !== undefined), 'Choose at least one retention period')
|
|
222
|
+
.optional(),
|
|
223
|
+
backup: z
|
|
224
|
+
.object({
|
|
225
|
+
directory: z.string().trim().min(1).max(4096),
|
|
226
|
+
keep: z.number().int().min(1).max(365).default(7),
|
|
227
|
+
max_bytes: z
|
|
228
|
+
.number()
|
|
229
|
+
.int()
|
|
230
|
+
.min(1)
|
|
231
|
+
.max(20 * 1024 ** 3)
|
|
232
|
+
.default(512 * 1024 ** 2),
|
|
233
|
+
})
|
|
234
|
+
.strict()
|
|
235
|
+
.optional(),
|
|
236
|
+
})
|
|
237
|
+
.strict()
|
|
238
|
+
.refine((value) => value.retention !== undefined || value.backup !== undefined, 'Configure retention or backups')
|
|
239
|
+
.optional(),
|
|
240
|
+
})
|
|
241
|
+
.strict()
|
|
242
|
+
.superRefine((config, ctx) => {
|
|
243
|
+
const { analysis, verification } = config.models;
|
|
244
|
+
if (analysis && verification && sameModel(analysis, verification))
|
|
245
|
+
ctx.addIssue({
|
|
246
|
+
code: 'custom',
|
|
247
|
+
message: 'The verification model must differ from the analysis model; an identical model only repeats the first answer. Remove models.verification or choose another model.',
|
|
248
|
+
path: ['models', 'verification'],
|
|
249
|
+
});
|
|
250
|
+
if (config.models.enabled && !config.models.analysis)
|
|
251
|
+
ctx.addIssue({
|
|
252
|
+
code: 'custom',
|
|
253
|
+
message: 'Enabled models require an analysis model',
|
|
254
|
+
path: ['models', 'analysis'],
|
|
255
|
+
});
|
|
256
|
+
for (const [name, spec] of Object.entries({
|
|
257
|
+
analysis: config.models.analysis,
|
|
258
|
+
verification: config.models.verification,
|
|
259
|
+
})) {
|
|
260
|
+
if (!spec)
|
|
261
|
+
continue;
|
|
262
|
+
const definition = providerDefinition(spec.provider);
|
|
263
|
+
if (!definition.endpoint && !spec.endpoint)
|
|
264
|
+
ctx.addIssue({
|
|
265
|
+
code: 'custom',
|
|
266
|
+
message: 'This provider requires an endpoint',
|
|
267
|
+
path: ['models', name, 'endpoint'],
|
|
268
|
+
});
|
|
269
|
+
if (definition.local && !spec.allow_private_endpoint)
|
|
270
|
+
ctx.addIssue({
|
|
271
|
+
code: 'custom',
|
|
272
|
+
message: 'Local provider requires allow_private_endpoint: true',
|
|
273
|
+
path: ['models', name, 'allow_private_endpoint'],
|
|
274
|
+
});
|
|
275
|
+
try {
|
|
276
|
+
modelOutputFormat(spec);
|
|
277
|
+
if (spec.endpoint || definition.endpoint)
|
|
278
|
+
modelEndpoint(spec);
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
ctx.addIssue({ code: 'custom', message: error.message, path: ['models', name] });
|
|
282
|
+
}
|
|
283
|
+
if (config.models.daily_budget_usd !== undefined &&
|
|
284
|
+
(spec.input_usd_per_million === undefined || spec.output_usd_per_million === undefined))
|
|
285
|
+
ctx.addIssue({
|
|
286
|
+
code: 'custom',
|
|
287
|
+
message: 'A dollar budget requires input and output pricing for every configured model',
|
|
288
|
+
path: ['models', name],
|
|
289
|
+
});
|
|
290
|
+
if (spec.endpoint) {
|
|
291
|
+
const url = new URL(spec.endpoint);
|
|
292
|
+
if (url.username ||
|
|
293
|
+
url.password ||
|
|
294
|
+
url.search ||
|
|
295
|
+
url.hash ||
|
|
296
|
+
(url.protocol !== 'https:' && !(spec.allow_private_endpoint && localHost(url.hostname))) ||
|
|
297
|
+
!['https:', 'http:'].includes(url.protocol))
|
|
298
|
+
ctx.addIssue({
|
|
299
|
+
code: 'custom',
|
|
300
|
+
message: 'Endpoint must be HTTPS, with no credentials/query/fragment; only an explicit private or local endpoint may use HTTP',
|
|
301
|
+
path: ['models', name, 'endpoint'],
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const used = new Set([
|
|
306
|
+
...config.policy.library.channels,
|
|
307
|
+
...config.policy.product.channels,
|
|
308
|
+
...config.policy.news.channels,
|
|
309
|
+
...config.policy.health_channels,
|
|
310
|
+
]);
|
|
311
|
+
for (const channel of used)
|
|
312
|
+
if (!config.notifications[channel])
|
|
313
|
+
ctx.addIssue({
|
|
314
|
+
code: 'custom',
|
|
315
|
+
message: `Missing ${channel} notification configuration`,
|
|
316
|
+
path: ['notifications', channel],
|
|
317
|
+
});
|
|
318
|
+
for (const feed of config.sources.feeds) {
|
|
319
|
+
const url = new URL(feed);
|
|
320
|
+
if (url.protocol !== 'https:' || url.username || url.password)
|
|
321
|
+
ctx.addIssue({
|
|
322
|
+
code: 'custom',
|
|
323
|
+
message: 'Feeds must be public HTTPS URLs without credentials',
|
|
324
|
+
path: ['sources', 'feeds'],
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
export function parseConfig(value) {
|
|
329
|
+
return configSchema.parse(value);
|
|
330
|
+
}
|
|
331
|
+
export function missingCredentials(config) {
|
|
332
|
+
const missing = [];
|
|
333
|
+
if (config.monitoring && !process.env[config.monitoring.heartbeat_url_env])
|
|
334
|
+
missing.push(config.monitoring.heartbeat_url_env);
|
|
335
|
+
if (config.models.enabled)
|
|
336
|
+
for (const spec of [config.models.analysis, config.models.verification]) {
|
|
337
|
+
if (spec && !process.env[spec.api_key_env] && !allowsMissingKey(spec))
|
|
338
|
+
missing.push(spec.api_key_env);
|
|
339
|
+
}
|
|
340
|
+
const destinations = new Set([
|
|
341
|
+
...config.policy.library.channels,
|
|
342
|
+
...config.policy.news.channels,
|
|
343
|
+
...config.policy.product.channels,
|
|
344
|
+
...config.policy.health_channels,
|
|
345
|
+
]);
|
|
346
|
+
for (const channel of destinations) {
|
|
347
|
+
const spec = config.notifications[channel];
|
|
348
|
+
if (spec) {
|
|
349
|
+
const env = 'webhook_url_env' in spec ? spec.webhook_url_env : spec.smtp_url_env;
|
|
350
|
+
if (!process.env[env])
|
|
351
|
+
missing.push(env);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return [...new Set(missing)];
|
|
355
|
+
}
|
|
356
|
+
export function loadConfig(path) {
|
|
357
|
+
if (statSync(path).size > 1_048_576)
|
|
358
|
+
throw new Error('Configuration exceeds 1 MiB');
|
|
359
|
+
const raw = readFileSync(path, 'utf8');
|
|
360
|
+
// Substitute parsed scalar values only, so an environment value cannot inject YAML syntax.
|
|
361
|
+
function substitute(value) {
|
|
362
|
+
if (typeof value === 'string')
|
|
363
|
+
return value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_all, name) => {
|
|
364
|
+
const replacement = process.env[name];
|
|
365
|
+
if (replacement === undefined)
|
|
366
|
+
throw new Error(`Missing configuration variable ${name}`);
|
|
367
|
+
return replacement;
|
|
368
|
+
});
|
|
369
|
+
if (Array.isArray(value))
|
|
370
|
+
return value.map(substitute);
|
|
371
|
+
if (value && typeof value === 'object')
|
|
372
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, substitute(v)]));
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
const config = parseConfig(substitute(parse(raw, { maxAliasCount: 0 })));
|
|
376
|
+
config.inventory = resolve(dirname(resolve(path)), config.inventory);
|
|
377
|
+
config.database = resolve(dirname(resolve(path)), config.database);
|
|
378
|
+
if (config.maintenance?.backup)
|
|
379
|
+
config.maintenance.backup.directory = resolve(dirname(resolve(path)), config.maintenance.backup.directory);
|
|
380
|
+
return config;
|
|
381
|
+
}
|