@jamesbrightman/pretty-csp 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +21 -0
- package/README.md +112 -2
- package/dist/chunk-JAXLODN4.js +559 -0
- package/dist/chunk-JAXLODN4.js.map +1 -0
- package/dist/chunk-KWWYRHIP.js +224 -0
- package/dist/chunk-KWWYRHIP.js.map +1 -0
- package/dist/chunk-YMAXUCI4.js +66 -0
- package/dist/chunk-YMAXUCI4.js.map +1 -0
- package/dist/cli.cjs +1049 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +328 -0
- package/dist/cli.js.map +1 -0
- package/dist/index-CvwFjLiu.d.cts +426 -0
- package/dist/index-CvwFjLiu.d.ts +426 -0
- package/dist/index.cjs +830 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.cjs +309 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +38 -0
- package/dist/testing.d.ts +38 -0
- package/dist/testing.js +10 -0
- package/dist/testing.js.map +1 -0
- package/package.json +102 -4
- package/website/static/img/how-it-works.svg +34 -0
- package/website/static/img/pretty-csp-icon.svg +6 -0
- package/website/static/img/pretty-csp-logo.svg +12 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
NONCE: () => NONCE,
|
|
24
|
+
NONE: () => NONE,
|
|
25
|
+
Policy: () => Policy,
|
|
26
|
+
REPORT_SAMPLE: () => REPORT_SAMPLE,
|
|
27
|
+
SELF: () => SELF,
|
|
28
|
+
STRICT_DYNAMIC: () => STRICT_DYNAMIC,
|
|
29
|
+
WASM_UNSAFE_EVAL: () => WASM_UNSAFE_EVAL,
|
|
30
|
+
audit: () => audit,
|
|
31
|
+
baseDirectives: () => baseDirectives,
|
|
32
|
+
baseSchema: () => baseSchema,
|
|
33
|
+
cspHash: () => cspHash,
|
|
34
|
+
definePolicy: () => definePolicy,
|
|
35
|
+
defineRuleSet: () => defineRuleSet,
|
|
36
|
+
generateNonce: () => generateNonce,
|
|
37
|
+
matchPolicy: () => matchPolicy,
|
|
38
|
+
policyConfigSchema: () => policyConfigSchema,
|
|
39
|
+
resourceDirectives: () => resourceDirectives,
|
|
40
|
+
ruleSetSchema: () => ruleSetSchema,
|
|
41
|
+
rulesSchema: () => rulesSchema,
|
|
42
|
+
sourceEntrySchema: () => sourceEntrySchema,
|
|
43
|
+
unsafeEval: () => unsafeEval,
|
|
44
|
+
unsafeHashes: () => unsafeHashes,
|
|
45
|
+
unsafeInline: () => unsafeInline
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(src_exports);
|
|
48
|
+
|
|
49
|
+
// src/schemas.ts
|
|
50
|
+
var import_zod = require("zod");
|
|
51
|
+
|
|
52
|
+
// src/keywords.ts
|
|
53
|
+
var SELF = "'self'";
|
|
54
|
+
var NONE = "'none'";
|
|
55
|
+
var NONCE = "'nonce-{nonce}'";
|
|
56
|
+
var STRICT_DYNAMIC = "'strict-dynamic'";
|
|
57
|
+
var REPORT_SAMPLE = "'report-sample'";
|
|
58
|
+
var WASM_UNSAFE_EVAL = "'wasm-unsafe-eval'";
|
|
59
|
+
function generateNonce() {
|
|
60
|
+
const bytes = new Uint8Array(16);
|
|
61
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
62
|
+
return btoa(String.fromCharCode(...bytes));
|
|
63
|
+
}
|
|
64
|
+
var unsafeInline = ({ reason }) => ({
|
|
65
|
+
source: "'unsafe-inline'",
|
|
66
|
+
reason
|
|
67
|
+
});
|
|
68
|
+
var unsafeEval = ({ reason }) => ({
|
|
69
|
+
source: "'unsafe-eval'",
|
|
70
|
+
reason
|
|
71
|
+
});
|
|
72
|
+
var unsafeHashes = ({ reason }) => ({
|
|
73
|
+
source: "'unsafe-hashes'",
|
|
74
|
+
reason
|
|
75
|
+
});
|
|
76
|
+
var cspHash = (algorithm, digest) => `'${algorithm}-${digest}'`;
|
|
77
|
+
|
|
78
|
+
// src/schemas.ts
|
|
79
|
+
var resourceDirectives = {
|
|
80
|
+
scripts: "script-src",
|
|
81
|
+
connect: "connect-src",
|
|
82
|
+
images: "img-src",
|
|
83
|
+
styles: "style-src",
|
|
84
|
+
fonts: "font-src",
|
|
85
|
+
frames: "frame-src",
|
|
86
|
+
forms: "form-action",
|
|
87
|
+
media: "media-src",
|
|
88
|
+
workers: "worker-src",
|
|
89
|
+
manifest: "manifest-src"
|
|
90
|
+
};
|
|
91
|
+
var baseDirectives = {
|
|
92
|
+
default: "default-src",
|
|
93
|
+
objects: "object-src",
|
|
94
|
+
baseUri: "base-uri",
|
|
95
|
+
frameAncestors: "frame-ancestors"
|
|
96
|
+
};
|
|
97
|
+
var risky = /* @__PURE__ */ new Set(["'unsafe-inline'", "'unsafe-eval'", "'unsafe-hashes'"]);
|
|
98
|
+
var keywords = /* @__PURE__ */ new Set([
|
|
99
|
+
"'self'",
|
|
100
|
+
"'none'",
|
|
101
|
+
"'strict-dynamic'",
|
|
102
|
+
"'report-sample'",
|
|
103
|
+
"'wasm-unsafe-eval'",
|
|
104
|
+
...risky
|
|
105
|
+
]);
|
|
106
|
+
function isSource(value) {
|
|
107
|
+
if (!value || /[\x00-\x20\x7f;,]/.test(value) || /^[a-z][a-z0-9+.-]*\/\//i.test(value))
|
|
108
|
+
return false;
|
|
109
|
+
if (keywords.has(value.toLowerCase()) || value === NONCE || value === "*" || /^[a-z][a-z0-9+.-]*:\/\/\*(?::(?:\d+|\*))?(?:\/[^\s;,#?]*)?$/i.test(value))
|
|
110
|
+
return true;
|
|
111
|
+
if (/^'(nonce-[A-Za-z0-9+/_-]+={0,2}|sha(256|384|512)-[A-Za-z0-9+/_-]+={0,2})'$/i.test(
|
|
112
|
+
value
|
|
113
|
+
))
|
|
114
|
+
return true;
|
|
115
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:$/.test(value)) return true;
|
|
116
|
+
return /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:\*\.)?(?:[a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+(?::(?:\d+|\*))?(?:\/[^\s;,#?]*)?$/i.test(
|
|
117
|
+
value
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
var sourceStringSchema = import_zod.z.string().refine(isSource, "Invalid CSP source expression");
|
|
121
|
+
var sourceEntrySchema = import_zod.z.union([
|
|
122
|
+
sourceStringSchema.refine(
|
|
123
|
+
(s) => !risky.has(s.toLowerCase()),
|
|
124
|
+
"Risky keyword requires a reason"
|
|
125
|
+
),
|
|
126
|
+
import_zod.z.object({ source: sourceStringSchema, reason: import_zod.z.string().trim().min(1) }).strict()
|
|
127
|
+
]);
|
|
128
|
+
var sourceList = import_zod.z.array(sourceEntrySchema).min(1);
|
|
129
|
+
var sourceListDirectives = /* @__PURE__ */ new Set([
|
|
130
|
+
...Object.values(resourceDirectives),
|
|
131
|
+
...Object.values(baseDirectives),
|
|
132
|
+
"script-src-elem",
|
|
133
|
+
"script-src-attr",
|
|
134
|
+
"style-src-elem",
|
|
135
|
+
"style-src-attr",
|
|
136
|
+
"child-src"
|
|
137
|
+
]);
|
|
138
|
+
var rawDirectives = import_zod.z.record(
|
|
139
|
+
import_zod.z.string().regex(/^[a-z][a-z0-9-]*$/).refine(
|
|
140
|
+
(name) => sourceListDirectives.has(name),
|
|
141
|
+
"Unsupported raw directive; only known source-list directives are supported"
|
|
142
|
+
),
|
|
143
|
+
sourceList
|
|
144
|
+
);
|
|
145
|
+
var reserved = /* @__PURE__ */ new Set([
|
|
146
|
+
"report-uri",
|
|
147
|
+
"report-to",
|
|
148
|
+
"upgrade-insecure-requests"
|
|
149
|
+
]);
|
|
150
|
+
var baseOnly = /* @__PURE__ */ new Set([...Object.values(baseDirectives), ...reserved]);
|
|
151
|
+
var ruleShape = Object.fromEntries(
|
|
152
|
+
Object.keys(resourceDirectives).map((key) => [key, sourceList.optional()])
|
|
153
|
+
);
|
|
154
|
+
var rulesSchema = import_zod.z.object({ ...ruleShape, directives: rawDirectives.optional() }).strict().refine(
|
|
155
|
+
(rules) => Object.entries(rules).some(
|
|
156
|
+
([key, value]) => key === "directives" ? Object.keys(value ?? {}).length > 0 : value !== void 0
|
|
157
|
+
),
|
|
158
|
+
"At least one resource directive is required"
|
|
159
|
+
).superRefine((rules, ctx) => {
|
|
160
|
+
for (const directive of Object.keys(rules.directives ?? {})) {
|
|
161
|
+
if (baseOnly.has(directive))
|
|
162
|
+
ctx.addIssue({
|
|
163
|
+
code: "custom",
|
|
164
|
+
path: ["directives", directive],
|
|
165
|
+
message: "Base-only or reserved directive"
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
var baseSchema = import_zod.z.object({
|
|
170
|
+
...ruleShape,
|
|
171
|
+
default: sourceList.optional(),
|
|
172
|
+
objects: sourceList.optional(),
|
|
173
|
+
baseUri: sourceList.optional(),
|
|
174
|
+
frameAncestors: sourceList.optional(),
|
|
175
|
+
upgradeInsecureRequests: import_zod.z.boolean().optional(),
|
|
176
|
+
directives: rawDirectives.optional()
|
|
177
|
+
}).strict().superRefine((base, ctx) => {
|
|
178
|
+
for (const directive of Object.keys(base.directives ?? {})) {
|
|
179
|
+
if (reserved.has(directive))
|
|
180
|
+
ctx.addIssue({
|
|
181
|
+
code: "custom",
|
|
182
|
+
path: ["directives", directive],
|
|
183
|
+
message: "Use the dedicated configuration field for this directive"
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
var ruleSetSchema = import_zod.z.object({
|
|
188
|
+
name: import_zod.z.string().trim().min(1),
|
|
189
|
+
purpose: import_zod.z.string().trim().min(1),
|
|
190
|
+
owner: import_zod.z.string().trim().min(1).optional(),
|
|
191
|
+
docs: import_zod.z.url().optional(),
|
|
192
|
+
tags: import_zod.z.array(import_zod.z.string().trim().min(1)).optional(),
|
|
193
|
+
reviewBy: import_zod.z.iso.date().optional(),
|
|
194
|
+
enabled: import_zod.z.boolean().default(true),
|
|
195
|
+
rules: rulesSchema
|
|
196
|
+
}).strict();
|
|
197
|
+
var reportingSchema = import_zod.z.object({
|
|
198
|
+
uri: import_zod.z.url().refine(
|
|
199
|
+
(value) => !/[\x00-\x20\x7f;,]/.test(value),
|
|
200
|
+
"Invalid reporting value"
|
|
201
|
+
).optional(),
|
|
202
|
+
to: import_zod.z.string().regex(/^[A-Za-z0-9_-]+$/).optional()
|
|
203
|
+
}).strict();
|
|
204
|
+
var policyConfigSchema = import_zod.z.object({
|
|
205
|
+
base: baseSchema.default({}),
|
|
206
|
+
ruleSets: import_zod.z.array(ruleSetSchema).default([]),
|
|
207
|
+
reporting: reportingSchema.optional()
|
|
208
|
+
}).strict().superRefine((config, ctx) => {
|
|
209
|
+
const names = /* @__PURE__ */ new Set();
|
|
210
|
+
config.ruleSets.forEach((rule, i) => {
|
|
211
|
+
if (names.has(rule.name))
|
|
212
|
+
ctx.addIssue({
|
|
213
|
+
code: "custom",
|
|
214
|
+
path: ["ruleSets", i, "name"],
|
|
215
|
+
message: `Duplicate rule set name: ${rule.name}`
|
|
216
|
+
});
|
|
217
|
+
names.add(rule.name);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// src/matching/index.ts
|
|
222
|
+
var friendly = {
|
|
223
|
+
scripts: "script-src",
|
|
224
|
+
connect: "connect-src",
|
|
225
|
+
images: "img-src",
|
|
226
|
+
styles: "style-src",
|
|
227
|
+
fonts: "font-src",
|
|
228
|
+
frames: "frame-src",
|
|
229
|
+
forms: "form-action",
|
|
230
|
+
media: "media-src",
|
|
231
|
+
workers: "worker-src",
|
|
232
|
+
manifest: "manifest-src",
|
|
233
|
+
default: "default-src",
|
|
234
|
+
objects: "object-src",
|
|
235
|
+
baseUri: "base-uri",
|
|
236
|
+
frameAncestors: "frame-ancestors"
|
|
237
|
+
};
|
|
238
|
+
var fallbacks = {
|
|
239
|
+
"script-src-elem": ["script-src-elem", "script-src", "default-src"],
|
|
240
|
+
"script-src-attr": ["script-src-attr", "script-src", "default-src"],
|
|
241
|
+
"style-src-elem": ["style-src-elem", "style-src", "default-src"],
|
|
242
|
+
"style-src-attr": ["style-src-attr", "style-src", "default-src"],
|
|
243
|
+
"worker-src": ["worker-src", "child-src", "script-src", "default-src"],
|
|
244
|
+
"frame-src": ["frame-src", "child-src", "default-src"]
|
|
245
|
+
};
|
|
246
|
+
for (const name of [
|
|
247
|
+
"script-src",
|
|
248
|
+
"style-src",
|
|
249
|
+
"child-src",
|
|
250
|
+
"connect-src",
|
|
251
|
+
"font-src",
|
|
252
|
+
"img-src",
|
|
253
|
+
"manifest-src",
|
|
254
|
+
"media-src",
|
|
255
|
+
"object-src"
|
|
256
|
+
]) {
|
|
257
|
+
fallbacks[name] = [name, "default-src"];
|
|
258
|
+
}
|
|
259
|
+
for (const name of [
|
|
260
|
+
"default-src",
|
|
261
|
+
"form-action",
|
|
262
|
+
"base-uri",
|
|
263
|
+
"frame-ancestors"
|
|
264
|
+
])
|
|
265
|
+
fallbacks[name] = [name];
|
|
266
|
+
function decision(status, effectiveDirective, reason, matchedSource) {
|
|
267
|
+
return {
|
|
268
|
+
status,
|
|
269
|
+
allowed: status === "indeterminate" ? null : status === "allowed",
|
|
270
|
+
...effectiveDirective && { effectiveDirective },
|
|
271
|
+
...reason && { reason },
|
|
272
|
+
...matchedSource && { matchedSource }
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function schemeMatches(source, target) {
|
|
276
|
+
source = source.toLowerCase();
|
|
277
|
+
target = target.toLowerCase();
|
|
278
|
+
return source === target || source === "http" && target === "https" || source === "ws" && ["wss", "http", "https"].includes(target) || source === "wss" && target === "https";
|
|
279
|
+
}
|
|
280
|
+
function scheme(url) {
|
|
281
|
+
return url.protocol.slice(0, -1).toLowerCase();
|
|
282
|
+
}
|
|
283
|
+
function defaultPort(s) {
|
|
284
|
+
return { http: "80", https: "443", ws: "80", wss: "443", ftp: "21" }[s];
|
|
285
|
+
}
|
|
286
|
+
function selfMatches(url, origin) {
|
|
287
|
+
if (scheme(url) === "blob") return false;
|
|
288
|
+
if (origin.origin !== "null" && origin.origin === url.origin) return true;
|
|
289
|
+
const os = scheme(origin), us = scheme(url);
|
|
290
|
+
const portsMatch = origin.port === url.port || !origin.port && !url.port;
|
|
291
|
+
return origin.hostname !== "" && origin.hostname === url.hostname && portsMatch && (us === "https" || us === "wss" || os === "http" && (us === "http" || us === "ws"));
|
|
292
|
+
}
|
|
293
|
+
function segmentBytes(segment) {
|
|
294
|
+
const bytes = [];
|
|
295
|
+
for (let i = 0; i < segment.length; ) {
|
|
296
|
+
const encoded = segment.slice(i).match(/^%([0-9a-f]{2})/i);
|
|
297
|
+
if (encoded) {
|
|
298
|
+
bytes.push(parseInt(encoded[1], 16));
|
|
299
|
+
i += 3;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const point = segment.codePointAt(i);
|
|
303
|
+
const character = String.fromCodePoint(point);
|
|
304
|
+
bytes.push(...new TextEncoder().encode(character));
|
|
305
|
+
i += character.length;
|
|
306
|
+
}
|
|
307
|
+
return bytes.join(",");
|
|
308
|
+
}
|
|
309
|
+
function pathMatches(pattern, target) {
|
|
310
|
+
if (!pattern || pattern === "/" && !target) return true;
|
|
311
|
+
const a = pattern.split("/"), b = target.split("/");
|
|
312
|
+
if (a.length > b.length || !pattern.endsWith("/") && a.length !== b.length)
|
|
313
|
+
return false;
|
|
314
|
+
if (pattern.endsWith("/")) a.pop();
|
|
315
|
+
return a.every((part, i) => segmentBytes(part) === segmentBytes(b[i]));
|
|
316
|
+
}
|
|
317
|
+
function sourceMatches(source, url, origin, redirectCount) {
|
|
318
|
+
const lower = source.toLowerCase(), targetScheme = scheme(url);
|
|
319
|
+
if (lower === "'self'")
|
|
320
|
+
return origin ? selfMatches(url, origin) ? "yes" : "no" : "unknown";
|
|
321
|
+
if (source === "*")
|
|
322
|
+
return ["http", "https"].includes(targetScheme) ? "yes" : origin ? scheme(origin) === targetScheme ? "yes" : "no" : "unknown";
|
|
323
|
+
const schemeOnly = source.match(/^([a-z][a-z0-9+.-]*):$/i);
|
|
324
|
+
if (schemeOnly)
|
|
325
|
+
return schemeMatches(schemeOnly[1], targetScheme) ? "yes" : "no";
|
|
326
|
+
const host = source.match(
|
|
327
|
+
/^(?:([a-z][a-z0-9+.-]*):\/\/)?(\*|(?:\*\.)?[a-z0-9.-]+)(?::(\*|[0-9]+))?(\/[^?#]*)?$/i
|
|
328
|
+
);
|
|
329
|
+
if (!host) return "no";
|
|
330
|
+
const [, explicitScheme, patternHost, port, path] = host;
|
|
331
|
+
if (!url.hostname || /^\[/.test(url.hostname) || /^\d+(?:\.\d+){3}$/.test(url.hostname))
|
|
332
|
+
return "no";
|
|
333
|
+
if (!explicitScheme && !origin) return "unknown";
|
|
334
|
+
if (!schemeMatches(explicitScheme ?? scheme(origin), targetScheme))
|
|
335
|
+
return "no";
|
|
336
|
+
const domain = url.hostname.toLowerCase(), pattern = patternHost.toLowerCase();
|
|
337
|
+
if (pattern !== "*" && !(pattern.startsWith("*.") ? domain.endsWith(pattern.slice(1)) : domain === pattern))
|
|
338
|
+
return "no";
|
|
339
|
+
if (port !== "*") {
|
|
340
|
+
const targetPort = url.port || void 0;
|
|
341
|
+
if (port === void 0 ? targetPort !== void 0 : Number(port) !== Number(targetPort ?? defaultPort(targetScheme)))
|
|
342
|
+
return "no";
|
|
343
|
+
}
|
|
344
|
+
if (path && !pathMatches(path, url.pathname)) {
|
|
345
|
+
if (redirectCount === void 0) return "unknown";
|
|
346
|
+
if (redirectCount === 0) return "no";
|
|
347
|
+
}
|
|
348
|
+
return "yes";
|
|
349
|
+
}
|
|
350
|
+
function matchPolicy(directives, directive, input, options = {}) {
|
|
351
|
+
const requested = friendly[directive] ?? directive.toLowerCase();
|
|
352
|
+
const name = requested === "script-src" ? "script-src-elem" : requested === "style-src" ? "style-src-elem" : requested;
|
|
353
|
+
const chain = fallbacks[name];
|
|
354
|
+
if (!chain)
|
|
355
|
+
return decision(
|
|
356
|
+
"indeterminate",
|
|
357
|
+
void 0,
|
|
358
|
+
"Unsupported directive or inline check"
|
|
359
|
+
);
|
|
360
|
+
const effective = chain.find(
|
|
361
|
+
(key) => Object.prototype.hasOwnProperty.call(directives, key)
|
|
362
|
+
);
|
|
363
|
+
if (!effective)
|
|
364
|
+
return decision("allowed", void 0, "No applicable directive");
|
|
365
|
+
if (name.endsWith("-attr"))
|
|
366
|
+
return decision(
|
|
367
|
+
"indeterminate",
|
|
368
|
+
effective,
|
|
369
|
+
"Inline checks require element content and context"
|
|
370
|
+
);
|
|
371
|
+
if (name === "frame-ancestors")
|
|
372
|
+
return decision(
|
|
373
|
+
"indeterminate",
|
|
374
|
+
effective,
|
|
375
|
+
"Frame enforcement depends on the complete ancestor chain"
|
|
376
|
+
);
|
|
377
|
+
if (options.redirectCount !== void 0 && (!Number.isInteger(options.redirectCount) || options.redirectCount < 0))
|
|
378
|
+
throw new TypeError("redirectCount must be a non-negative integer");
|
|
379
|
+
let url, origin;
|
|
380
|
+
try {
|
|
381
|
+
url = new URL(input);
|
|
382
|
+
if (options.origin !== void 0) {
|
|
383
|
+
origin = new URL(options.origin);
|
|
384
|
+
if (origin.origin === "null") throw new Error("opaque");
|
|
385
|
+
}
|
|
386
|
+
} catch {
|
|
387
|
+
throw new TypeError("Expected an absolute URL and a non-opaque origin");
|
|
388
|
+
}
|
|
389
|
+
const sources = directives[effective];
|
|
390
|
+
const script = name === "script-src" || name === "script-src-elem";
|
|
391
|
+
const style = name === "style-src" || name === "style-src-elem";
|
|
392
|
+
const hasNoncePlaceholder = sources.includes("'nonce-{nonce}'");
|
|
393
|
+
const nonceSources = sources.filter(
|
|
394
|
+
(s) => /^'nonce-[a-z0-9+/_=-]+'$/i.test(s)
|
|
395
|
+
);
|
|
396
|
+
const hashes = sources.filter(
|
|
397
|
+
(s) => /^'sha(256|384|512)-[a-z0-9+/_=-]+'$/i.test(s)
|
|
398
|
+
);
|
|
399
|
+
if ((script || style) && options.nonce && (nonceSources.some((s) => s.slice(7, -1) === options.nonce) || hasNoncePlaceholder && options.policyNonce !== void 0 && options.nonce === options.policyNonce))
|
|
400
|
+
return decision("allowed", effective, "Matching request nonce");
|
|
401
|
+
if (script && options.integrity?.length && options.integrity.every(
|
|
402
|
+
(token) => hashes.some((hash) => {
|
|
403
|
+
const [hashAlg, hashDigest] = hash.slice(1, -1).split("-", 2);
|
|
404
|
+
const [tokenAlg, tokenDigest] = token.split("-", 2);
|
|
405
|
+
return hashAlg?.toLowerCase() === tokenAlg?.toLowerCase() && hashDigest !== void 0 && hashDigest === tokenDigest;
|
|
406
|
+
})
|
|
407
|
+
))
|
|
408
|
+
return decision("allowed", effective, "Matching integrity metadata");
|
|
409
|
+
const missingNonce = (script || style) && (nonceSources.length > 0 && options.nonce === void 0 || hasNoncePlaceholder && (options.nonce === void 0 || options.nonce !== "" && options.policyNonce === void 0));
|
|
410
|
+
const missingIntegrity = script && hashes.length > 0 && options.integrity === void 0;
|
|
411
|
+
if (script && sources.some((s) => s.toLowerCase() === "'strict-dynamic'")) {
|
|
412
|
+
if (options.parserInserted === false)
|
|
413
|
+
return decision(
|
|
414
|
+
"allowed",
|
|
415
|
+
effective,
|
|
416
|
+
"Non-parser-inserted script under strict-dynamic"
|
|
417
|
+
);
|
|
418
|
+
if (options.parserInserted === void 0 || missingNonce || missingIntegrity)
|
|
419
|
+
return decision(
|
|
420
|
+
"indeterminate",
|
|
421
|
+
effective,
|
|
422
|
+
"Script nonce, integrity or parser metadata is missing"
|
|
423
|
+
);
|
|
424
|
+
return decision(
|
|
425
|
+
"blocked",
|
|
426
|
+
effective,
|
|
427
|
+
"Parser-inserted script has no matching nonce or integrity metadata"
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
let unknown = false;
|
|
431
|
+
for (const source of sources) {
|
|
432
|
+
const match = sourceMatches(source, url, origin, options.redirectCount);
|
|
433
|
+
if (match === "yes")
|
|
434
|
+
return decision("allowed", effective, void 0, source);
|
|
435
|
+
if (match === "unknown") unknown = true;
|
|
436
|
+
}
|
|
437
|
+
if (unknown || missingNonce || missingIntegrity)
|
|
438
|
+
return decision(
|
|
439
|
+
"indeterminate",
|
|
440
|
+
effective,
|
|
441
|
+
"Origin, redirect count, nonce or integrity metadata is missing"
|
|
442
|
+
);
|
|
443
|
+
return decision("blocked", effective, "No source matched");
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// src/core.ts
|
|
447
|
+
var import_zod2 = require("zod");
|
|
448
|
+
function freeze(value) {
|
|
449
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
450
|
+
Object.values(value).forEach(freeze);
|
|
451
|
+
Object.freeze(value);
|
|
452
|
+
}
|
|
453
|
+
return value;
|
|
454
|
+
}
|
|
455
|
+
function defineRuleSet(input) {
|
|
456
|
+
const parsed = ruleSetSchema.safeParse(input);
|
|
457
|
+
if (!parsed.success) {
|
|
458
|
+
const name = typeof input?.name === "string" ? input.name : "<unnamed>";
|
|
459
|
+
const detail = parsed.error.issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`).join("; ");
|
|
460
|
+
throw new import_zod2.z.ZodError(
|
|
461
|
+
parsed.error.issues.map((issue) => ({
|
|
462
|
+
...issue,
|
|
463
|
+
message: `RuleSet "${name}" - ${detail}`
|
|
464
|
+
}))
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
return freeze(parsed.data);
|
|
468
|
+
}
|
|
469
|
+
function entryValue(entry) {
|
|
470
|
+
return typeof entry === "string" ? entry : entry.source;
|
|
471
|
+
}
|
|
472
|
+
function entryReason(entry) {
|
|
473
|
+
return typeof entry === "string" ? void 0 : entry.reason;
|
|
474
|
+
}
|
|
475
|
+
var Policy = class _Policy {
|
|
476
|
+
config;
|
|
477
|
+
constructor(input) {
|
|
478
|
+
const result = policyConfigSchema.safeParse(input);
|
|
479
|
+
if (!result.success) {
|
|
480
|
+
throw new import_zod2.z.ZodError(
|
|
481
|
+
result.error.issues.map((issue) => {
|
|
482
|
+
const index = issue.path[0] === "ruleSets" && typeof issue.path[1] === "number" ? issue.path[1] : void 0;
|
|
483
|
+
const name = index === void 0 ? void 0 : input.ruleSets?.[index]?.name;
|
|
484
|
+
return name ? {
|
|
485
|
+
...issue,
|
|
486
|
+
message: `RuleSet "${name}" - ${issue.path.slice(2).join(".")}: ${issue.message}`
|
|
487
|
+
} : issue;
|
|
488
|
+
})
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
const config = result.data;
|
|
492
|
+
this.config = freeze(config);
|
|
493
|
+
Object.freeze(this);
|
|
494
|
+
}
|
|
495
|
+
/** Sources and their contributing rule sets. Duplicate values retain all contributors. */
|
|
496
|
+
explain() {
|
|
497
|
+
const rows = [];
|
|
498
|
+
const add = (directive, entries, ruleSet) => {
|
|
499
|
+
for (const entry of entries) {
|
|
500
|
+
const reason = entryReason(entry);
|
|
501
|
+
rows.push({
|
|
502
|
+
directive,
|
|
503
|
+
source: entryValue(entry),
|
|
504
|
+
ruleSet,
|
|
505
|
+
...reason === void 0 ? {} : { reason }
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
const collect = (rules, name) => {
|
|
510
|
+
for (const [key, value] of Object.entries(rules)) {
|
|
511
|
+
if (key === "directives" && value) {
|
|
512
|
+
for (const [directive, entries] of Object.entries(
|
|
513
|
+
value
|
|
514
|
+
))
|
|
515
|
+
add(directive, entries, name);
|
|
516
|
+
} else if (Array.isArray(value)) {
|
|
517
|
+
const directive = resourceDirectives[key] ?? baseDirectives[key];
|
|
518
|
+
if (directive) add(directive, value, name);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
collect(this.config.base, "base");
|
|
523
|
+
for (const set of this.config.ruleSets)
|
|
524
|
+
if (set.enabled) collect(set.rules, set.name);
|
|
525
|
+
return rows.sort(
|
|
526
|
+
(a, b) => a.directive.localeCompare(b.directive, "en") || a.source.localeCompare(b.source, "en") || a.ruleSet.localeCompare(b.ruleSet, "en") || (a.reason ?? "").localeCompare(b.reason ?? "", "en")
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
/** Merged sources, deduplicated without changing path syntax. */
|
|
530
|
+
toObject() {
|
|
531
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
532
|
+
for (const row of this.explain())
|
|
533
|
+
(map[row.directive] ??= /* @__PURE__ */ new Set()).add(row.source);
|
|
534
|
+
if (this.config.base.upgradeInsecureRequests)
|
|
535
|
+
map["upgrade-insecure-requests"] = /* @__PURE__ */ new Set();
|
|
536
|
+
if (this.config.reporting?.uri)
|
|
537
|
+
map["report-uri"] = /* @__PURE__ */ new Set([this.config.reporting.uri]);
|
|
538
|
+
if (this.config.reporting?.to)
|
|
539
|
+
map["report-to"] = /* @__PURE__ */ new Set([this.config.reporting.to]);
|
|
540
|
+
return Object.fromEntries(
|
|
541
|
+
Object.entries(map).sort(([a], [b]) => a.localeCompare(b, "en")).map(([key, values]) => [key, Array.from(values).sort()])
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
/** Evaluate a URL with explicit uncertainty when browser context is missing. */
|
|
545
|
+
allows(directive, url, options = {}) {
|
|
546
|
+
const result = matchPolicy(this.toObject(), directive, url, options);
|
|
547
|
+
const contributors = result.matchedSource && result.effectiveDirective ? this.explain().filter(
|
|
548
|
+
(row) => row.directive === result.effectiveDirective && row.source === result.matchedSource
|
|
549
|
+
) : [];
|
|
550
|
+
return contributors.length ? { ...result, contributors } : result;
|
|
551
|
+
}
|
|
552
|
+
/** Render a header value. Pretty output is for display only and is not a valid HTTP header value. */
|
|
553
|
+
toHeader(options = {}) {
|
|
554
|
+
const directives = this.toObject();
|
|
555
|
+
const hasNonce = Object.values(directives).some(
|
|
556
|
+
(sources) => sources.includes(NONCE)
|
|
557
|
+
);
|
|
558
|
+
if (hasNonce && (!options.nonce || !/^[A-Za-z0-9+/_-]+={0,2}$/.test(options.nonce)))
|
|
559
|
+
throw new Error("A valid base64 nonce is required");
|
|
560
|
+
return Object.entries(directives).map(([directive, values]) => {
|
|
561
|
+
const rendered = values.map(
|
|
562
|
+
(value) => value === NONCE ? `'nonce-${options.nonce}'` : value
|
|
563
|
+
);
|
|
564
|
+
return directive + (rendered.length ? ` ${rendered.join(" ")}` : "");
|
|
565
|
+
}).join(options.pretty ? ";\n" : "; ");
|
|
566
|
+
}
|
|
567
|
+
withRuleSet(ruleSets) {
|
|
568
|
+
const additions = Array.isArray(ruleSets) ? ruleSets : [ruleSets];
|
|
569
|
+
return new _Policy({
|
|
570
|
+
...this.config,
|
|
571
|
+
ruleSets: [...this.config.ruleSets, ...additions]
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
without(name) {
|
|
575
|
+
return new _Policy({
|
|
576
|
+
...this.config,
|
|
577
|
+
ruleSets: this.config.ruleSets.filter((set) => set.name !== name)
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
function definePolicy(input) {
|
|
582
|
+
return new Policy(input);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/audit/index.ts
|
|
586
|
+
var sourceFindings = (policy, directive, source, ruleId, severity, message, fix) => {
|
|
587
|
+
const owners = policy.explain().filter((row) => row.directive === directive && row.source === source);
|
|
588
|
+
return owners.length ? owners.map(({ ruleSet }) => ({
|
|
589
|
+
ruleId,
|
|
590
|
+
severity,
|
|
591
|
+
message,
|
|
592
|
+
fix,
|
|
593
|
+
directive,
|
|
594
|
+
source,
|
|
595
|
+
ruleSet
|
|
596
|
+
})) : [{ ruleId, severity, message, fix, directive, source }];
|
|
597
|
+
};
|
|
598
|
+
function audit(policy, options = {}) {
|
|
599
|
+
const object = policy.toObject();
|
|
600
|
+
const findings = [];
|
|
601
|
+
const add = (id, severity, message, fix, directive) => findings.push({
|
|
602
|
+
ruleId: id,
|
|
603
|
+
severity,
|
|
604
|
+
message,
|
|
605
|
+
fix,
|
|
606
|
+
...directive ? { directive } : {}
|
|
607
|
+
});
|
|
608
|
+
if (!object["script-src"] && !object["default-src"])
|
|
609
|
+
add(
|
|
610
|
+
"missing-script-src",
|
|
611
|
+
"high",
|
|
612
|
+
"Some script execution is unrestricted.",
|
|
613
|
+
"Restrict script-src or default-src.",
|
|
614
|
+
"script-src"
|
|
615
|
+
);
|
|
616
|
+
for (const directive of [
|
|
617
|
+
"script-src",
|
|
618
|
+
"script-src-elem",
|
|
619
|
+
"script-src-attr",
|
|
620
|
+
"default-src"
|
|
621
|
+
]) {
|
|
622
|
+
const sources = object[directive];
|
|
623
|
+
if (!sources) continue;
|
|
624
|
+
const isFallback = directive === "default-src" && object["script-src"] !== void 0;
|
|
625
|
+
if (isFallback) continue;
|
|
626
|
+
const hasNonceOrHash = sources.some(
|
|
627
|
+
(s) => /^'(nonce-|sha(?:256|384|512)-)/i.test(s)
|
|
628
|
+
);
|
|
629
|
+
for (const source of sources.filter(
|
|
630
|
+
(s) => s.toLowerCase() === "'unsafe-inline'" && !hasNonceOrHash
|
|
631
|
+
))
|
|
632
|
+
findings.push(
|
|
633
|
+
...sourceFindings(
|
|
634
|
+
policy,
|
|
635
|
+
directive,
|
|
636
|
+
source,
|
|
637
|
+
"script-unsafe-inline",
|
|
638
|
+
"high",
|
|
639
|
+
"Inline scripts are permitted.",
|
|
640
|
+
"Use nonces or hashes and remove unsafe-inline."
|
|
641
|
+
)
|
|
642
|
+
);
|
|
643
|
+
for (const source of sources.filter(
|
|
644
|
+
(s) => s.toLowerCase() === "'unsafe-eval'"
|
|
645
|
+
))
|
|
646
|
+
findings.push(
|
|
647
|
+
...sourceFindings(
|
|
648
|
+
policy,
|
|
649
|
+
directive,
|
|
650
|
+
source,
|
|
651
|
+
"script-unsafe-eval",
|
|
652
|
+
"high",
|
|
653
|
+
"Dynamic JavaScript evaluation is permitted.",
|
|
654
|
+
"Remove unsafe-eval and replace dynamic evaluation."
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
if (directive !== "script-src-attr" && sources.some((source) => source.toLowerCase() === "'strict-dynamic'")) {
|
|
658
|
+
for (const source of sources) {
|
|
659
|
+
if (source.toLowerCase() === "'self'" || source === "*" || /^[a-z][a-z0-9+.-]*:$/i.test(source) || /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:\*|[a-z0-9*.-]+)(?::(?:\*|\d+))?(?:\/[^\s]*)?$/i.test(
|
|
660
|
+
source
|
|
661
|
+
)) {
|
|
662
|
+
findings.push(
|
|
663
|
+
...sourceFindings(
|
|
664
|
+
policy,
|
|
665
|
+
directive,
|
|
666
|
+
source,
|
|
667
|
+
"ignored-by-strict-dynamic",
|
|
668
|
+
"info",
|
|
669
|
+
"Modern browsers ignore this source for scripts under strict-dynamic.",
|
|
670
|
+
"Remove it if legacy browser fallback is not needed."
|
|
671
|
+
)
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
for (const source of sources)
|
|
677
|
+
if (["*", "https:", "http:", "data:"].includes(source.toLowerCase()) || /^(?:https?:\/\/)?\*(?::(?:\*|\d+))?(?:\/[^\s]*)?$/i.test(source))
|
|
678
|
+
findings.push(
|
|
679
|
+
...sourceFindings(
|
|
680
|
+
policy,
|
|
681
|
+
directive,
|
|
682
|
+
source,
|
|
683
|
+
"script-wildcard",
|
|
684
|
+
"high",
|
|
685
|
+
"A broad script source may permit attacker-controlled scripts.",
|
|
686
|
+
"Restrict script sources and prefer nonces or hashes."
|
|
687
|
+
)
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
const objects = object["object-src"] ?? object["default-src"];
|
|
691
|
+
if (!objects || objects.length !== 1 || objects[0]?.toLowerCase() !== "'none'")
|
|
692
|
+
add(
|
|
693
|
+
"missing-object-src",
|
|
694
|
+
"high",
|
|
695
|
+
"Object embedding is not explicitly blocked.",
|
|
696
|
+
"Set object-src to 'none'.",
|
|
697
|
+
"object-src"
|
|
698
|
+
);
|
|
699
|
+
const broad = (sources) => !sources || sources.some(
|
|
700
|
+
(source) => source === "*" || /^[a-z][a-z0-9+.-]*:$/i.test(source) || /^(?:https?:\/\/)?\*(?::(?:\*|\d+))?(?:\/[^\s]*)?$/i.test(source)
|
|
701
|
+
);
|
|
702
|
+
if (broad(object["base-uri"]))
|
|
703
|
+
add(
|
|
704
|
+
"missing-base-uri",
|
|
705
|
+
"medium",
|
|
706
|
+
"The document base URL is not sufficiently restricted.",
|
|
707
|
+
"Set base-uri to 'none' or 'self'.",
|
|
708
|
+
"base-uri"
|
|
709
|
+
);
|
|
710
|
+
if (broad(object["frame-ancestors"]))
|
|
711
|
+
add(
|
|
712
|
+
"missing-frame-ancestors",
|
|
713
|
+
"medium",
|
|
714
|
+
"Embedding by other sites is not sufficiently restricted.",
|
|
715
|
+
"Restrict frame-ancestors to trusted origins.",
|
|
716
|
+
"frame-ancestors"
|
|
717
|
+
);
|
|
718
|
+
const knownBypassDomains = [
|
|
719
|
+
"google.com",
|
|
720
|
+
"googleapis.com",
|
|
721
|
+
"googleusercontent.com",
|
|
722
|
+
"gstatic.com"
|
|
723
|
+
];
|
|
724
|
+
for (const row of policy.explain()) {
|
|
725
|
+
if (["script-src", "script-src-elem", "default-src"].includes(row.directive)) {
|
|
726
|
+
const host = row.source.match(/^(?:https?:\/\/)?(?:\*\.)?([a-z0-9.-]+)/i)?.[1]?.toLowerCase();
|
|
727
|
+
if (host && knownBypassDomains.some(
|
|
728
|
+
(domain) => host === domain || host.endsWith(`.${domain}`)
|
|
729
|
+
)) {
|
|
730
|
+
findings.push({
|
|
731
|
+
ruleId: "bypass-host",
|
|
732
|
+
severity: "medium",
|
|
733
|
+
directive: row.directive,
|
|
734
|
+
source: row.source,
|
|
735
|
+
ruleSet: row.ruleSet,
|
|
736
|
+
message: "This script host may expose JSONP or script gadgets that weaken host allowlists.",
|
|
737
|
+
fix: "Review the host for JSONP endpoints and script gadgets; prefer nonce or hash authorization."
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
if (/^http:/i.test(row.source))
|
|
742
|
+
findings.push({
|
|
743
|
+
ruleId: "insecure-scheme",
|
|
744
|
+
severity: "medium",
|
|
745
|
+
directive: row.directive,
|
|
746
|
+
source: row.source,
|
|
747
|
+
ruleSet: row.ruleSet,
|
|
748
|
+
message: "An insecure HTTP source is permitted.",
|
|
749
|
+
fix: "Use HTTPS where possible."
|
|
750
|
+
});
|
|
751
|
+
if (/^(?:https?:\/\/)?\*\.[a-z0-9-]+(?::(?:\*|\d+))?(?:\/|$)/i.test(
|
|
752
|
+
row.source
|
|
753
|
+
) || /^https?:\/\/\*\.(?:amazonaws\.com|azurewebsites\.net)(?:[/:]|$)/i.test(
|
|
754
|
+
row.source
|
|
755
|
+
))
|
|
756
|
+
findings.push({
|
|
757
|
+
ruleId: "broad-wildcard",
|
|
758
|
+
severity: "medium",
|
|
759
|
+
directive: row.directive,
|
|
760
|
+
source: row.source,
|
|
761
|
+
ruleSet: row.ruleSet,
|
|
762
|
+
message: "A wildcard covers an unusually broad or shared domain.",
|
|
763
|
+
fix: "List the specific trusted hosts."
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
if (!object["report-uri"] && !object["report-to"])
|
|
767
|
+
add(
|
|
768
|
+
"no-reporting",
|
|
769
|
+
"low",
|
|
770
|
+
"No reporting destination is configured.",
|
|
771
|
+
"Configure reporting and its endpoint."
|
|
772
|
+
);
|
|
773
|
+
const today = (options.now ?? /* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
774
|
+
for (const set of policy.config.ruleSets.filter((s) => s.enabled)) {
|
|
775
|
+
if (!set.owner)
|
|
776
|
+
findings.push({
|
|
777
|
+
ruleId: "ruleset-metadata",
|
|
778
|
+
severity: "low",
|
|
779
|
+
ruleSet: set.name,
|
|
780
|
+
message: "Rule set has no owner.",
|
|
781
|
+
fix: "Assign an owner."
|
|
782
|
+
});
|
|
783
|
+
if (set.reviewBy && set.reviewBy < today)
|
|
784
|
+
findings.push({
|
|
785
|
+
ruleId: "ruleset-metadata",
|
|
786
|
+
severity: "low",
|
|
787
|
+
ruleSet: set.name,
|
|
788
|
+
message: "Rule set review date has passed.",
|
|
789
|
+
fix: "Review permissions regularly."
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
for (const rule of options.rules ?? []) findings.push(...rule.check(policy));
|
|
793
|
+
for (const suppression of options.suppressions ?? [])
|
|
794
|
+
if (!suppression.reason.trim() || !suppression.ruleId || !suppression.ruleSet)
|
|
795
|
+
throw new Error(
|
|
796
|
+
"Audit suppressions require a rule id, rule set and reason"
|
|
797
|
+
);
|
|
798
|
+
return findings.filter(
|
|
799
|
+
(finding) => !(options.suppressions ?? []).some(
|
|
800
|
+
(s) => s.ruleId === finding.ruleId && s.ruleSet === finding.ruleSet
|
|
801
|
+
)
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
805
|
+
0 && (module.exports = {
|
|
806
|
+
NONCE,
|
|
807
|
+
NONE,
|
|
808
|
+
Policy,
|
|
809
|
+
REPORT_SAMPLE,
|
|
810
|
+
SELF,
|
|
811
|
+
STRICT_DYNAMIC,
|
|
812
|
+
WASM_UNSAFE_EVAL,
|
|
813
|
+
audit,
|
|
814
|
+
baseDirectives,
|
|
815
|
+
baseSchema,
|
|
816
|
+
cspHash,
|
|
817
|
+
definePolicy,
|
|
818
|
+
defineRuleSet,
|
|
819
|
+
generateNonce,
|
|
820
|
+
matchPolicy,
|
|
821
|
+
policyConfigSchema,
|
|
822
|
+
resourceDirectives,
|
|
823
|
+
ruleSetSchema,
|
|
824
|
+
rulesSchema,
|
|
825
|
+
sourceEntrySchema,
|
|
826
|
+
unsafeEval,
|
|
827
|
+
unsafeHashes,
|
|
828
|
+
unsafeInline
|
|
829
|
+
});
|
|
830
|
+
//# sourceMappingURL=index.cjs.map
|