You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make V3 the new master version of this plugin (#31)
* Allow different policies on individual HtmlWebpackPlugin instances (#26)
* renaming disableCspPlugin to cspPlugin.enabled to be more inline with the main enabled setting
* Adding the option to allow individual policies on a specific html webpack plugin instance
* Updating README to reflect the new changes
* Adding nonce attrs to external scripts where their host hasnt been defined in the CSP already (#27)
* Adding nonce attrs to external scripts where their host hasnt been defined in the CSP already
* Making sure that nonces are included when strict-dynamic is set, even if the domain has been whitelisted. Also validating static sources
* If plugin is disabled, we should not modify the html at all (#28)
* If plugin is disabled, we should not modify the html at all
* Updating readme to reflect new recommendation of not including a blank meta tag - it will be added for us
* 3.0.0-beta.1
* Fine Grain control for hashes and nonces (#29)
* Changing devAllowUnsafe to be more fine-grain by allowing the dev to decide when to allow hashes and nonces
* Updating readme to reflect new options
* 3.0.0-beta.2
This `CspHtmlWebpackPlugin` accepts 2 params with the following structure:
40
-
*`{object}` Policy (optional) - a flat object which defines your CSP policy. Valid keys and values can be found on the [MDN CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) page. Values can either be a string or an array of strings.
41
-
*`{object}` Additional Options (optional) - a flat object with the optional configuration options:
42
-
*`{boolean}` devAllowUnsafe - if you as the developer want to allow `unsafe-inline`/`unsafe-eval` and _not_ include hashes for inline scripts. If any hashes are included in the policy, modern browsers ignore the `unsafe-inline` rule.
43
-
*`{boolean|Function}` enabled - if false, or the function returns false, the empty CSP tag will be stripped from the html output. The `htmlPluginData` is passed into the function as it's first param.
44
-
*`{string}` hashingMethod - accepts 'sha256', 'sha384', 'sha512' - your node version must also accept this hashing method.
45
35
46
-
_Note: CSP runs on all files created by HTMLWebpackPlugin. You can disable it for a particular instance by setting `disableCspPlugin` to `true` in the HTMLWebpackPlugin options
36
+
-`{object}` Policy (optional) - a flat object which defines your CSP policy. Valid keys and values can be found on the [MDN CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) page. Values can either be a string or an array of strings.
37
+
-`{object}` Additional Options (optional) - a flat object with the optional configuration options:
38
+
-`{boolean|Function}` enabled - if false, or the function returns false, the empty CSP tag will be stripped from the html output.
39
+
- The `htmlPluginData` is passed into the function as it's first param.
40
+
- If `enabled` is set the false, it will disable generating a CSP for all instances of `HtmlWebpackPlugin` in your webpack config.
41
+
-`{string}` hashingMethod - accepts 'sha256', 'sha384', 'sha512' - your node version must also accept this hashing method.
42
+
-`{object}` hashEnabled - a `<string, boolean>` entry for which policy rules are allowed to include hashes
43
+
-`{object}` nonceEnabled - a `<string, boolean>` entry for which policy rules are allowed to include nonces
44
+
45
+
The plugin also adds a new config option onto each `HtmlWebpackPlugin` instance:
46
+
47
+
-`{object}` cspPlugin - an object containing the following properties:
48
+
-`{boolean}` enabled - if false, the CSP tag will be removed from the HTML which this HtmlWebpackPlugin instance is generating.
49
+
-`{object}` policy - A custom policy which should be applied only to this instance of the HtmlWebpackPlugin
50
+
-`{object}` hashEnabled - a `<string, boolean>` entry for which policy rules are allowed to include hashes
51
+
-`{object}` nonceEnabled - a `<string, boolean>` entry for which policy rules are allowed to include nonces
52
+
53
+
Note that policies and `hashEnabled` / `nonceEnabled` are merged in the following order:
54
+
55
+
```
56
+
> HtmlWebpackPlugin cspPlugin.policy
57
+
> CspHtmlWebpackPlugin policy
58
+
> CspHtmlWebpackPlugin defaultPolicy
59
+
```
60
+
61
+
If 2 policies have the same key/policy rule, the former policy will override the latter policy. Entries in a specific rule will not be merged; they will be replaced.
47
62
48
63
#### Default Policy:
49
64
@@ -63,11 +78,40 @@ _Note: CSP runs on all files created by HTMLWebpackPlugin. You can disable it fo
0 commit comments