@@ -59,7 +59,8 @@ csp-generator <url> [options]
5959| ` --allow-unsafe-eval ` | boolean | false | Add 'unsafe-eval' to 'script-src' |
6060| ` --require-trusted-types ` | boolean | false | Add "require-trusted-types-for 'script'" to the CSP |
6161| ` --use-strict-dynamic ` | boolean | false | Add 'strict-dynamic' to script-src |
62- | ` --use-nonce ` | boolean | false | Generate and use nonces for inline scripts |
62+ | ` --use-nonce ` | boolean | true | Generate and use a random nonce for inline scripts (recommended) |
63+ | ` --custom-nonce ` | string | | Use a custom nonce value instead of a random one |
6364| ` --use-hashes ` | boolean | false | Generate hashes for inline content |
6465| ` --upgrade-insecure-requests ` | boolean | true | Force HTTPS upgrades |
6566| ` --block-mixed-content ` | boolean | true | Block mixed content |
@@ -78,6 +79,16 @@ Generate CSP with default settings:
7879csp-generator https://example.com
7980```
8081
82+ Use a custom nonce:
83+ ``` bash
84+ csp-generator https://example.com --custom-nonce my-custom-nonce
85+ ```
86+
87+ Or with environment variable:
88+ ``` bash
89+ CSP_CUSTOM_NONCE=my-custom-nonce csp-generator https://example.com
90+ ```
91+
8192Enable unsafe inline styles and strict dynamic:
8293``` bash
8394csp-generator https://example.com \
@@ -174,7 +185,8 @@ The browser version provides the same functionality as the CLI but uses native b
174185### Security Options
175186
176187- ` CSP_USE_STRICT_DYNAMIC ` : Add 'strict-dynamic' to script-src (default: false)
177- - ` CSP_USE_NONCE ` : Generate and use nonces for inline scripts (default: false)
188+ - ` CSP_USE_NONCE ` : Generate and use nonces for inline scripts (default: true)
189+ - ` CSP_CUSTOM_NONCE ` : Use a custom nonce value instead of a random one
178190- ` CSP_USE_HASHES ` : Generate hashes for inline content (default: false)
179191- ` CSP_UPGRADE_INSECURE_REQUESTS ` : Force HTTPS upgrades (default: true)
180192- ` CSP_BLOCK_MIXED_CONTENT ` : Block mixed content (default: true)
0 commit comments