NGINX Content-Security-Policy header generator
This tool will generate Content-Security-Policy headers for a NGINX configuration file from import domains in HTML files.
Usage
To generate Content-Security-Policy headers from HTML files in a path you can use the following command:
nginxcsp /path/to/html/files --out /path/to/nginx.conf --override
the command will generate Content-Security-Policy, X-Content-Security-Policy and X-WebKit-CSP headers for all server blocks of your nginx.conf file and remove the past ones. The headers will be generate from the tags in your html files, for example if you have an HTML file with the tag <script src="https://cdnjs.cloudflare.com/some-script.js"></script> you would get the header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudfare.com; img-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; object-src 'self'".
If you would like to create only the Content-Security-Policy header you can use the flag --csp, the same applies for X-Content-Security-Policy with --xcsp and for X-WebKit-CSP with --xwebkit.
You can get all the usage help using nginxcsp -h:
usage: nginxcsp html_path
Search content loading sources in HTML files and Content-Security-Policy
headers automatically.
positional arguments:
html_path the path of the HTML files
optional arguments:
-h, --help show this help message and exit
--out OUT NGINX configuration file to output the generated
headers
--server_name SERVER_NAME
the server_name in the NGINX server block to add CSP
headers
--port PORT the port from "listen {port}" line in a NGINX server
block to add CSP headers
--override flag to override the headers in the out file
--csp flag to generate only the Content-Security-Policy
header
--xcsp flag to generate only the X-Content-Security-Policy
header
--xwebkit flag to generate only the X-WebKit-CSP header
Metadata
Release files for nginxcsp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nginxcsp-0.1.0.tar.gz | 10.8 kB | Without provenance | Details for nginxcsp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nginxcsp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nginxcsp-0.1.0-py3-none-any.whl |
Total release size: 27.4 kB
Release files / nginxcsp-0.1.0.tar.gz
| Download URL | nginxcsp-0.1.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
432b65ac50710257db0f49b575057b25552d016e55d67cbcbda1445a4be6f2d9
|
|
BLAKE2b-256 checksum How to use checksums |
88bc4aba3450102ad196b9871626451f8601cbccc746b729ec91a93eedab65e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Release files / nginxcsp-0.1.0-py3-none-any.whl
| Download URL | nginxcsp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc4af13a9a974bec1b481f49f1c18bf966cdf93d761a80f2ae10ee2c75b9bb28
|
|
BLAKE2b-256 checksum How to use checksums |
5b6ad6e862288ecc9a2bb436129e662f6f9092b13a4430dacfe104f83f1e3714
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for nginxcsp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.