@mouryaamit/nx-polystack 1.2.4 → 1.2.6
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/dist/src/cli/commands/csp.d.ts +8 -0
- package/dist/src/cli/commands/csp.js +74 -3
- package/dist/src/cli/commands/csp.js.map +1 -1
- package/dist/src/cli/help.js +3 -0
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/launcher.js +1 -1
- package/dist/src/cli/launcher.js.map +1 -1
- package/dist/src/executors/build/executor.js +27 -4
- package/dist/src/executors/build/executor.js.map +1 -1
- package/dist/src/executors/build/schema.d.ts +7 -0
- package/dist/src/executors/build/schema.json +41 -1
- package/dist/src/generators/app/files/angular/server/README.md__template__ +3 -1
- package/dist/src/lib/csp/allowlist.d.ts +17 -0
- package/dist/src/lib/csp/allowlist.js +117 -3
- package/dist/src/lib/csp/allowlist.js.map +1 -1
- package/dist/src/lib/csp/import.js +21 -3
- package/dist/src/lib/csp/import.js.map +1 -1
- package/dist/src/lib/csp/render.d.ts +10 -5
- package/dist/src/lib/csp/render.js +72 -22
- package/dist/src/lib/csp/render.js.map +1 -1
- package/dist/src/lib/env-encryption/prepare.d.ts +4 -3
- package/dist/src/lib/env-encryption/prepare.js +4 -4
- package/dist/src/lib/env-encryption/prepare.js.map +1 -1
- package/dist/src/lib/hardening/strip.d.ts +1 -0
- package/dist/src/lib/hardening/strip.js +3 -3
- package/dist/src/lib/hardening/strip.js.map +1 -1
- package/dist/src/lib/helpers/inject-nonce.d.ts +36 -5
- package/dist/src/lib/helpers/inject-nonce.js +155 -41
- package/dist/src/lib/helpers/inject-nonce.js.map +1 -1
- package/dist/src/lib/helpers/inject-sri.d.ts +8 -0
- package/dist/src/lib/helpers/inject-sri.js +72 -56
- package/dist/src/lib/helpers/inject-sri.js.map +1 -1
- package/dist/src/lib/html/tags.d.ts +42 -0
- package/dist/src/lib/html/tags.js +173 -0
- package/dist/src/lib/html/tags.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../../../src/lib/hardening/strip.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,mCAAoC;AA8BpC,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC7B,
|
|
1
|
+
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../../../src/lib/hardening/strip.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,uCAAqD;AAErD,mCAAoC;AA8BpC,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC7B,sDAAsD;AACtD,MAAM,aAAa,GAAG,4BAA4B,CAAC;AACnD,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,cAAc,GAAG,+CAA+C,CAAC;AAEvE;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,CAAe;IAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,MAAM,GAAgB,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAClE,IAAI,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAElE,MAAM,OAAO,GAAG,IAAA,iBAAS,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IACxE,oFAAoF;IACpF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE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AAC;AACd,CAAC"}
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
export interface InjectNonceOptions {
|
|
2
|
-
/** Directory to recursively scan for *.html files. */
|
|
3
|
-
distDir: string;
|
|
4
|
-
}
|
|
5
1
|
/** Filled per request by the server config `pstack csp` writes (Apache SSI, Nginx sub_filter). */
|
|
6
2
|
export declare const NONCE_SSI_PLACEHOLDER = "<!--#echo var=\"CSP_NONCE\" -->";
|
|
7
|
-
|
|
3
|
+
/** Which tags get the nonce: all = every script, style and stylesheet link; legacy = inline scripts, every link, every style. */
|
|
4
|
+
export type NonceTags = 'all' | 'legacy';
|
|
5
|
+
export type NoncePosition = 'end' | 'after-tag-name';
|
|
6
|
+
export interface NonceSettings {
|
|
7
|
+
/** What the server replaces per request. Default NONCE_SSI_PLACEHOLDER. */
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
tags?: NonceTags;
|
|
10
|
+
/** Where the attribute goes: after the last attribute (default) or right after the tag name. */
|
|
11
|
+
position?: NoncePosition;
|
|
12
|
+
/** Text replaced by the placeholder anywhere in the page (e.g. "random-csp-nonce"). */
|
|
13
|
+
replaceTokens?: string[];
|
|
14
|
+
/** Add <meta property="csp-nonce" content="…"> to <head> (default true). */
|
|
15
|
+
addMeta?: boolean;
|
|
16
|
+
/** Pages to rewrite, relative to the served root (default ["index.html"]). */
|
|
17
|
+
files?: string[];
|
|
18
|
+
/** Remove HTML comments (SSI directives and IE conditionals stay) from those pages. */
|
|
19
|
+
stripComments?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface InjectNonceOptions extends NonceSettings {
|
|
22
|
+
/** The build output folder; pages are found under its served root (itself or browser/). */
|
|
23
|
+
distDir: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_NONCE_FILES: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Checks the nonce settings of a release target; throws naming the option. Returns them with the
|
|
28
|
+
* defaults filled in.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveNonceSettings(raw: NonceSettings | undefined): Required<NonceSettings>;
|
|
31
|
+
/** The page with the nonce placeholder where the settings say. */
|
|
32
|
+
export declare function injectNonceIntoHtml(input: string, settings: Required<NonceSettings>, file?: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Writes the nonce placeholder into the served pages (index.html by default) under distDir's
|
|
35
|
+
* served root. Nothing else is touched: third-party pages under assets/ are never served through
|
|
36
|
+
* SSI, so a placeholder there would stay raw.
|
|
37
|
+
*/
|
|
38
|
+
export declare function injectCspNonce(opts: InjectNonceOptions): string[];
|
|
@@ -1,59 +1,173 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.injectCspNonce = exports.NONCE_SSI_PLACEHOLDER = void 0;
|
|
3
|
+
exports.injectCspNonce = exports.injectNonceIntoHtml = exports.resolveNonceSettings = exports.DEFAULT_NONCE_FILES = exports.NONCE_SSI_PLACEHOLDER = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
const files_1 = require("../hardening/files");
|
|
8
|
+
const strip_1 = require("../hardening/strip");
|
|
9
|
+
const tags_1 = require("../html/tags");
|
|
7
10
|
/** Filled per request by the server config `pstack csp` writes (Apache SSI, Nginx sub_filter). */
|
|
8
11
|
exports.NONCE_SSI_PLACEHOLDER = '<!--#echo var="CSP_NONCE" -->';
|
|
12
|
+
exports.DEFAULT_NONCE_FILES = ['index.html'];
|
|
9
13
|
/** Nonce values left in a page by hand that stand for "fill me in" (as runtime/csp-nonce reads them). */
|
|
10
14
|
const PLACEHOLDER_NONCE = /((?<![\w-])nonce\s*=\s*)(["'])(random-csp-nonce|nonce|csp-nonce|\{\{[^"']*\}\}|\$\{[^"']*\}|%[^"']*%)\2/gi;
|
|
15
|
+
/**
|
|
16
|
+
* Checks the nonce settings of a release target; throws naming the option. Returns them with the
|
|
17
|
+
* defaults filled in.
|
|
18
|
+
*/
|
|
19
|
+
function resolveNonceSettings(raw) {
|
|
20
|
+
const s = raw ?? {};
|
|
21
|
+
if (typeof s !== 'object' || Array.isArray(s))
|
|
22
|
+
throw new Error('nonce must be an object');
|
|
23
|
+
const placeholder = s.placeholder ?? exports.NONCE_SSI_PLACEHOLDER;
|
|
24
|
+
if (typeof placeholder !== 'string' || !placeholder.trim() || /[\r\n]/.test(placeholder)) {
|
|
25
|
+
throw new Error('nonce.placeholder must be one non-empty line');
|
|
26
|
+
}
|
|
27
|
+
const tags = s.tags ?? 'all';
|
|
28
|
+
if (tags !== 'all' && tags !== 'legacy')
|
|
29
|
+
throw new Error('nonce.tags must be "all" or "legacy"');
|
|
30
|
+
const position = s.position ?? 'end';
|
|
31
|
+
if (position !== 'end' && position !== 'after-tag-name') {
|
|
32
|
+
throw new Error('nonce.position must be "end" or "after-tag-name"');
|
|
33
|
+
}
|
|
34
|
+
const replaceTokens = s.replaceTokens ?? [];
|
|
35
|
+
if (!Array.isArray(replaceTokens) ||
|
|
36
|
+
!replaceTokens.every((t) => typeof t === 'string' && /^[A-Za-z0-9_-]{4,}$/.test(t))) {
|
|
37
|
+
throw new Error('nonce.replaceTokens must be a list of tokens (letters, digits, _ and -, at least 4)');
|
|
38
|
+
}
|
|
39
|
+
const files = s.files ?? exports.DEFAULT_NONCE_FILES;
|
|
40
|
+
if (!Array.isArray(files) || files.length === 0) {
|
|
41
|
+
throw new Error('nonce.files must be a non-empty list of .html files');
|
|
42
|
+
}
|
|
43
|
+
for (const f of files) {
|
|
44
|
+
const norm = typeof f === 'string' ? path.posix.normalize(f.replace(/\\/g, '/')) : '';
|
|
45
|
+
if (!norm.endsWith('.html') ||
|
|
46
|
+
norm.startsWith('/') ||
|
|
47
|
+
norm.startsWith('..') ||
|
|
48
|
+
norm === 'assets' ||
|
|
49
|
+
norm.startsWith('assets/')) {
|
|
50
|
+
throw new Error(`nonce.files: "${f}" must be an .html file under the served root, not under assets/`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
placeholder,
|
|
55
|
+
tags,
|
|
56
|
+
position,
|
|
57
|
+
replaceTokens,
|
|
58
|
+
addMeta: s.addMeta ?? true,
|
|
59
|
+
files,
|
|
60
|
+
stripComments: s.stripComments ?? false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.resolveNonceSettings = resolveNonceSettings;
|
|
64
|
+
function wantsNonce(tag, mode) {
|
|
65
|
+
if (tag.name === 'style')
|
|
66
|
+
return true;
|
|
67
|
+
if (tag.name === 'script')
|
|
68
|
+
return mode === 'all' || !(0, tags_1.attr)(tag, 'src');
|
|
69
|
+
if (tag.name === 'link') {
|
|
70
|
+
if (mode === 'legacy')
|
|
71
|
+
return true;
|
|
72
|
+
return /(^|\s)stylesheet(\s|$)/i.test((0, tags_1.attr)(tag, 'rel')?.value ?? '');
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
/** The quote character of the string the text at `at` sits in on its line, if any. */
|
|
77
|
+
function enclosingQuote(text, at, length) {
|
|
78
|
+
const lineStart = text.lastIndexOf('\n', at - 1) + 1;
|
|
79
|
+
let lineEnd = text.indexOf('\n', at + length);
|
|
80
|
+
if (lineEnd < 0)
|
|
81
|
+
lineEnd = text.length;
|
|
82
|
+
const before = text.slice(lineStart, at);
|
|
83
|
+
const after = text.slice(at + length, lineEnd);
|
|
84
|
+
// The nearest quote before the token is open when it appears an odd number of times before it
|
|
85
|
+
// and closes after it on the same line.
|
|
86
|
+
let best;
|
|
87
|
+
for (const q of ['"', "'", '`']) {
|
|
88
|
+
const pos = before.lastIndexOf(q);
|
|
89
|
+
if (pos < 0 || before.split(q).length % 2 !== 0 || !after.includes(q))
|
|
90
|
+
continue;
|
|
91
|
+
if (!best || pos > best.pos)
|
|
92
|
+
best = { q, pos };
|
|
93
|
+
}
|
|
94
|
+
return best?.q;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Replaces every whole token by the placeholder in one pass (a token is not matched inside a
|
|
98
|
+
* longer word or inside text an earlier replacement inserted); refuses a token inside quotes that
|
|
99
|
+
* the placeholder also uses, as the replaced text would end that string.
|
|
100
|
+
*/
|
|
101
|
+
function replaceTokens(html, tokens, placeholder, file) {
|
|
102
|
+
if (tokens.length === 0)
|
|
103
|
+
return html;
|
|
104
|
+
const alternation = [...tokens]
|
|
105
|
+
.sort((a, b) => b.length - a.length)
|
|
106
|
+
.map((t) => t.replace(/[-]/g, '\\-'))
|
|
107
|
+
.join('|');
|
|
108
|
+
const re = new RegExp(`(?<![A-Za-z0-9_-])(?:${alternation})(?![A-Za-z0-9_-])`, 'g');
|
|
109
|
+
return html.replace(re, (token, at) => {
|
|
110
|
+
const q = enclosingQuote(html, at, token.length);
|
|
111
|
+
if (q && placeholder.includes(q)) {
|
|
112
|
+
const line = html.slice(0, at).split('\n').length;
|
|
113
|
+
throw new Error(`${file}:${line}: "${token}" is inside ${q}…${q}, and the nonce placeholder ` +
|
|
114
|
+
`${placeholder} holds ${q}: the replaced text would end that string. Change the ` +
|
|
115
|
+
'quotes in the page or nonce.placeholder.');
|
|
116
|
+
}
|
|
117
|
+
return placeholder;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/** The page with the nonce placeholder where the settings say. */
|
|
121
|
+
function injectNonceIntoHtml(input, settings, file = 'index.html') {
|
|
122
|
+
let html = settings.stripComments ? (0, strip_1.stripHtmlComments)(input) : input;
|
|
123
|
+
// Placeholder nonces already in the page get the server-filled one (double-quoted) first, so a
|
|
124
|
+
// nonce='random-csp-nonce' attribute is never seen as a token in single quotes.
|
|
125
|
+
html = html.replace(PLACEHOLDER_NONCE, (_m, a) => `${a}"${settings.placeholder}"`);
|
|
126
|
+
html = replaceTokens(html, settings.replaceTokens, settings.placeholder, file);
|
|
127
|
+
const insertions = [];
|
|
128
|
+
const nonceAttr = `nonce="${settings.placeholder}"`;
|
|
129
|
+
for (const tag of (0, tags_1.scanTags)(html)) {
|
|
130
|
+
if (!wantsNonce(tag, settings.tags) || (0, tags_1.attr)(tag, 'nonce'))
|
|
131
|
+
continue;
|
|
132
|
+
insertions.push(settings.position === 'after-tag-name'
|
|
133
|
+
? { at: tag.nameEnd, text: ` ${nonceAttr}` }
|
|
134
|
+
: { at: tag.attrsEnd, text: ` ${nonceAttr}` });
|
|
135
|
+
}
|
|
136
|
+
html = (0, tags_1.applyInsertions)(html, insertions);
|
|
137
|
+
if (settings.addMeta && !/property="csp-nonce"/.test(html)) {
|
|
138
|
+
const head = (0, tags_1.scanTags)(html).find((t) => t.name === 'head');
|
|
139
|
+
if (head) {
|
|
140
|
+
const meta = `<meta property="csp-nonce" content="${settings.placeholder}">`;
|
|
141
|
+
html = (0, tags_1.applyInsertions)(html, [{ at: head.end, text: `\n ${meta}` }]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return html;
|
|
145
|
+
}
|
|
146
|
+
exports.injectNonceIntoHtml = injectNonceIntoHtml;
|
|
147
|
+
/**
|
|
148
|
+
* Writes the nonce placeholder into the served pages (index.html by default) under distDir's
|
|
149
|
+
* served root. Nothing else is touched: third-party pages under assets/ are never served through
|
|
150
|
+
* SSI, so a placeholder there would stay raw.
|
|
151
|
+
*/
|
|
11
152
|
function injectCspNonce(opts) {
|
|
12
153
|
if (!fs.existsSync(opts.distDir)) {
|
|
13
154
|
throw new Error(`injectCspNonce: distDir not found: ${opts.distDir}`);
|
|
14
155
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
html = html.replace(/<style\b((?:[^>]*?)?)>/g, (full, attrs) => {
|
|
28
|
-
if (/(?<![\w-])nonce\s*=/.test(attrs))
|
|
29
|
-
return full;
|
|
30
|
-
const trimmed = attrs.trimEnd();
|
|
31
|
-
return `<style${trimmed ? trimmed : ''} nonce="${exports.NONCE_SSI_PLACEHOLDER}">`;
|
|
32
|
-
});
|
|
33
|
-
// Add nonce to <link rel="stylesheet"> tags
|
|
34
|
-
html = html.replace(/<link\b((?:[^>]*?)\brel\s*=\s*["']stylesheet["'](?:[^>]*?))>/g, (full, attrs) => {
|
|
35
|
-
if (/(?<![\w-])nonce\s*=/.test(attrs))
|
|
36
|
-
return full;
|
|
37
|
-
return `<link${attrs} nonce="${exports.NONCE_SSI_PLACEHOLDER}">`;
|
|
38
|
-
});
|
|
39
|
-
// Add <meta property="csp-nonce"> inside <head>
|
|
40
|
-
if (!/property="csp-nonce"/.test(html)) {
|
|
41
|
-
const metaTag = `<meta property="csp-nonce" content="${exports.NONCE_SSI_PLACEHOLDER}">`;
|
|
42
|
-
if (/<head[^>]*>/i.test(html)) {
|
|
43
|
-
html = html.replace(/<head([^>]*)>/i, `<head$1>\n ${metaTag}`);
|
|
44
|
-
}
|
|
156
|
+
const settings = resolveNonceSettings(opts);
|
|
157
|
+
const root = (0, files_1.servedRoot)(opts.distDir);
|
|
158
|
+
const written = [];
|
|
159
|
+
for (const rel of settings.files) {
|
|
160
|
+
const file = path.join(root, rel);
|
|
161
|
+
if (!fs.existsSync(file))
|
|
162
|
+
continue;
|
|
163
|
+
const html = fs.readFileSync(file, 'utf8');
|
|
164
|
+
const out = injectNonceIntoHtml(html, settings, rel);
|
|
165
|
+
if (out !== html) {
|
|
166
|
+
fs.writeFileSync(file, out, 'utf8');
|
|
167
|
+
written.push(rel);
|
|
45
168
|
}
|
|
46
|
-
fs.writeFileSync(htmlFile, html, 'utf8');
|
|
47
169
|
}
|
|
170
|
+
return written;
|
|
48
171
|
}
|
|
49
172
|
exports.injectCspNonce = injectCspNonce;
|
|
50
|
-
function* walkHtml(dir) {
|
|
51
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
52
|
-
const full = path.join(dir, entry.name);
|
|
53
|
-
if (entry.isDirectory())
|
|
54
|
-
yield* walkHtml(full);
|
|
55
|
-
else if (entry.isFile() && full.endsWith('.html'))
|
|
56
|
-
yield full;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
173
|
//# sourceMappingURL=inject-nonce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-nonce.js","sourceRoot":"","sources":["../../../../src/lib/helpers/inject-nonce.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;
|
|
1
|
+
{"version":3,"file":"inject-nonce.js","sourceRoot":"","sources":["../../../../src/lib/helpers/inject-nonce.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,8CAAgD;AAChD,8CAAuD;AACvD,uCAAmF;AAEnF,kGAAkG;AACrF,QAAA,qBAAqB,GAAG,+BAA+B,CAAC;AA2BxD,QAAA,mBAAmB,GAAG,CAAC,YAAY,CAAC,CAAC;AAElD,yGAAyG;AACzG,MAAM,iBAAiB,GACrB,2GAA2G,CAAC;AAE9G;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,GAA8B;IACjE,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC;IACpB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC1F,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,6BAAqB,CAAC;IAC3D,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QACxF,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;KACjE;IACD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC;IAC7B,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,QAAQ;QAAE,MAAM,IAAI,KAA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EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QACnC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QACrD,IAAI,GAAG,KAAK,IAAI,EAAE;YAChB,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnB;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAlBD,wCAkBC"}
|
|
@@ -7,5 +7,13 @@ export interface InjectSriOptions {
|
|
|
7
7
|
* were stripped or obfuscated). Default false: tags that have one are left alone.
|
|
8
8
|
*/
|
|
9
9
|
refresh?: boolean;
|
|
10
|
+
/** Pages to rewrite, relative to the served root (default ["index.html"]); assets/ never. */
|
|
11
|
+
files?: string[];
|
|
10
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Adds integrity/crossorigin to the scripts and stylesheets of the served pages (index.html by
|
|
15
|
+
* default) under distDir's served root, and with refresh recomputes integrity Angular wrote. Tags
|
|
16
|
+
* are parsed (quotes and SSI directives respected) and edited in place: nothing else in a tag
|
|
17
|
+
* moves.
|
|
18
|
+
*/
|
|
11
19
|
export declare function injectSri(opts: InjectSriOptions): void;
|
|
@@ -5,69 +5,94 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
6
|
const fs = tslib_1.__importStar(require("fs"));
|
|
7
7
|
const path = tslib_1.__importStar(require("path"));
|
|
8
|
+
const files_1 = require("../hardening/files");
|
|
9
|
+
const tags_1 = require("../html/tags");
|
|
10
|
+
const inject_nonce_1 = require("./inject-nonce");
|
|
11
|
+
const isRemote = (url) => /^(?:[a-z]+:)?\/\//i.test(url) || /^[a-z]+:/i.test(url);
|
|
12
|
+
/**
|
|
13
|
+
* Adds integrity/crossorigin to the scripts and stylesheets of the served pages (index.html by
|
|
14
|
+
* default) under distDir's served root, and with refresh recomputes integrity Angular wrote. Tags
|
|
15
|
+
* are parsed (quotes and SSI directives respected) and edited in place: nothing else in a tag
|
|
16
|
+
* moves.
|
|
17
|
+
*/
|
|
8
18
|
function injectSri(opts) {
|
|
9
19
|
if (!fs.existsSync(opts.distDir)) {
|
|
10
20
|
throw new Error(`injectSri: distDir not found: ${opts.distDir}`);
|
|
11
21
|
}
|
|
12
22
|
const allowlist = new Set(opts.cdnAllowlist);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (/\bintegrity\s*=/.test(full))
|
|
30
|
-
return full;
|
|
31
|
-
const hash = resolveHash(href, htmlFile, opts.distDir, allowlist);
|
|
32
|
-
if (!hash)
|
|
33
|
-
return full;
|
|
34
|
-
return `<link${allAttrs.replace(href, href)} integrity="${hash}" crossorigin="anonymous">`;
|
|
35
|
-
});
|
|
36
|
-
fs.writeFileSync(htmlFile, html, 'utf8');
|
|
23
|
+
const root = (0, files_1.servedRoot)(opts.distDir);
|
|
24
|
+
let files;
|
|
25
|
+
try {
|
|
26
|
+
files = (0, inject_nonce_1.resolveNonceSettings)({ files: opts.files ?? inject_nonce_1.DEFAULT_NONCE_FILES }).files;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error(`injectSri: ${err.message.replace('nonce.files', 'files')}`);
|
|
30
|
+
}
|
|
31
|
+
for (const rel of files) {
|
|
32
|
+
const htmlFile = path.join(root, rel);
|
|
33
|
+
if (!fs.existsSync(htmlFile))
|
|
34
|
+
continue;
|
|
35
|
+
const html = fs.readFileSync(htmlFile, 'utf8');
|
|
36
|
+
const out = sriHtml(html, htmlFile, opts.distDir, allowlist, opts.refresh ?? false);
|
|
37
|
+
if (out !== html)
|
|
38
|
+
fs.writeFileSync(htmlFile, out, 'utf8');
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
exports.injectSri = injectSri;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
function sriHtml(html, htmlFile, distDir, allowlist, refresh) {
|
|
43
|
+
const edits = [];
|
|
44
|
+
for (const tag of (0, tags_1.scanTags)(html)) {
|
|
45
|
+
if (tag.name !== 'script' && tag.name !== 'link')
|
|
46
|
+
continue;
|
|
47
|
+
const urlAttr = (0, tags_1.attr)(tag, tag.name === 'script' ? 'src' : 'href');
|
|
48
|
+
const url = urlAttr?.value;
|
|
49
|
+
if (!urlAttr || !url)
|
|
50
|
+
continue;
|
|
51
|
+
const integrity = (0, tags_1.attr)(tag, 'integrity');
|
|
52
|
+
const crossorigin = (0, tags_1.attr)(tag, 'crossorigin');
|
|
53
|
+
if (integrity) {
|
|
54
|
+
if (!refresh || isRemote(url))
|
|
55
|
+
continue;
|
|
56
|
+
const hash = resolveHash(url, htmlFile, distDir, new Set());
|
|
57
|
+
// A stale hash makes the browser refuse the file: fail instead of shipping it.
|
|
58
|
+
if (!hash) {
|
|
59
|
+
throw new Error(`injectSri: ${path.basename(htmlFile)} has an integrity for ${url}, which is not a file ` +
|
|
60
|
+
'under the output; its hash cannot be refreshed (a deployUrl is not supported with sri)');
|
|
61
|
+
}
|
|
62
|
+
edits.push({ start: integrity.start, end: integrity.end, text: `integrity="${hash}"` });
|
|
63
|
+
if (!crossorigin) {
|
|
64
|
+
edits.push({ start: tag.attrsEnd, end: tag.attrsEnd, text: ' crossorigin="anonymous"' });
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
53
67
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
if (tag.name === 'link' && !/(^|\s)stylesheet(\s|$)/i.test((0, tags_1.attr)(tag, 'rel')?.value ?? '')) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const hash = resolveHash(url, htmlFile, distDir, allowlist);
|
|
72
|
+
if (!hash)
|
|
73
|
+
continue;
|
|
74
|
+
const added = ` integrity="${hash}"${crossorigin ? '' : ' crossorigin="anonymous"'}`;
|
|
75
|
+
// Scripts: right after src (as before); links: after the last attribute.
|
|
76
|
+
const at = tag.name === 'script' ? urlAttr.end : tag.attrsEnd;
|
|
77
|
+
edits.push({ start: at, end: at, text: added });
|
|
78
|
+
}
|
|
79
|
+
let out = html;
|
|
80
|
+
for (const e of edits.sort((a, b) => b.start - a.start || b.end - a.end)) {
|
|
81
|
+
out = out.slice(0, e.start) + e.text + out.slice(e.end);
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
59
84
|
}
|
|
60
85
|
function resolveHash(src, htmlFile, distDir, allowlist) {
|
|
61
86
|
const isExternal = /^https?:\/\//.test(src);
|
|
62
87
|
if (isExternal) {
|
|
63
88
|
if (!allowlist.has(src))
|
|
64
89
|
return null;
|
|
65
|
-
//
|
|
90
|
+
// A local mirror next to the page (the served root), else at the top of the output.
|
|
66
91
|
const basename = src.split('/').pop() ?? '';
|
|
67
|
-
const local = path.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return sha384(local);
|
|
92
|
+
const local = [path.dirname(htmlFile), distDir]
|
|
93
|
+
.map((d) => path.join(d, basename))
|
|
94
|
+
.find((f) => basename && fs.existsSync(f));
|
|
95
|
+
return local ? sha384(local) : null;
|
|
71
96
|
}
|
|
72
97
|
const local = path.resolve(path.dirname(htmlFile), src);
|
|
73
98
|
const resolved = path.resolve(distDir);
|
|
@@ -80,13 +105,4 @@ function sha384(file) {
|
|
|
80
105
|
const digest = crypto.createHash('sha384').update(buf).digest('base64');
|
|
81
106
|
return `sha384-${digest}`;
|
|
82
107
|
}
|
|
83
|
-
function* walkHtml(dir) {
|
|
84
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
85
|
-
const full = path.join(dir, entry.name);
|
|
86
|
-
if (entry.isDirectory())
|
|
87
|
-
yield* walkHtml(full);
|
|
88
|
-
else if (entry.isFile() && full.endsWith('.html'))
|
|
89
|
-
yield full;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
108
|
//# sourceMappingURL=inject-sri.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-sri.js","sourceRoot":"","sources":["../../../../src/lib/helpers/inject-sri.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,+CAAyB;AACzB,mDAA6B;
|
|
1
|
+
{"version":3,"file":"inject-sri.js","sourceRoot":"","sources":["../../../../src/lib/helpers/inject-sri.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,+CAAyB;AACzB,mDAA6B;AAE7B,8CAAgD;AAChD,uCAA8C;AAE9C,iDAA2E;AAe3E,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAsB;IAC9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;KAClE;IACD,MAAM,S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
|
|
2
|
+
* A small HTML start-tag scanner for the build's index.html rewrites (nonce, SRI).
|
|
3
|
+
*
|
|
4
|
+
* - A quoted attribute value ends at its own closing quote; an SSI directive (`<!--#…-->`) inside
|
|
5
|
+
* it is skipped whole, so `nonce="<!--#echo var="X" -->"` is one value.
|
|
6
|
+
* - Comments are skipped; the content of <script>/<style> (raw text) is not scanned for tags.
|
|
7
|
+
* - Offsets let callers insert text without rebuilding (and so without reformatting) a tag.
|
|
8
|
+
*/
|
|
9
|
+
export interface HtmlAttribute {
|
|
10
|
+
/** Lower-case name. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Value without quotes (raw, entities not decoded); undefined for a bare attribute. */
|
|
13
|
+
value?: string;
|
|
14
|
+
/** Offset of the attribute name. */
|
|
15
|
+
start: number;
|
|
16
|
+
/** Offset just after the attribute (after the closing quote of its value). */
|
|
17
|
+
end: number;
|
|
18
|
+
}
|
|
19
|
+
export interface HtmlTag {
|
|
20
|
+
/** Lower-case tag name. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Offset of `<`. */
|
|
23
|
+
start: number;
|
|
24
|
+
/** Offset just after `>`. */
|
|
25
|
+
end: number;
|
|
26
|
+
/** Offset just after the tag name. */
|
|
27
|
+
nameEnd: number;
|
|
28
|
+
/** Offset after the last attribute (or the name), before any whitespace, `/` and `>`. */
|
|
29
|
+
attrsEnd: number;
|
|
30
|
+
attrs: HtmlAttribute[];
|
|
31
|
+
}
|
|
32
|
+
/** Plain comments outside tags and raw text; SSI (`<!--#`) and IE conditionals stay. */
|
|
33
|
+
export declare function stripHtmlCommentsSafe(html: string): string;
|
|
34
|
+
/** Every start tag in document order. */
|
|
35
|
+
export declare function scanTags(html: string): HtmlTag[];
|
|
36
|
+
export declare const attr: (tag: HtmlTag, name: string) => HtmlAttribute | undefined;
|
|
37
|
+
export interface Insertion {
|
|
38
|
+
at: number;
|
|
39
|
+
text: string;
|
|
40
|
+
}
|
|
41
|
+
/** html with every insertion applied (offsets refer to the original text). */
|
|
42
|
+
export declare function applyInsertions(html: string, insertions: Insertion[]): string;
|