CSP Observer
CSP Observer is a Django app that monitors incoming Content Security Policy (CSP) reports for your site. It tries to detect security/privacy issues and notifies your visitors.
Installation
- In
settings.pyadd "csp_observer" to yourINSTALLED_APPS:INSTALLED_APPS = [ ... 'csp_observer', ] - Also in
settings.pyadd the following entry toMIDDLEWARE:
Please make sure that it is the last entry in the middlewares, otherwise another installed middleware could interfere with the operation of CSP Observer.MIDDLEWARE = [ ... 'csp_observer.middleware.CspReportMiddleware', ] - Include the url configuration in your
urls.py:
You can change this path but keep in mind, that this path determines the access URL to the admin dashboard. Example: If you change the path for CSP Observer tofrom django.urls import path, include urlpatterns = [ ... path('csp/', include('csp_observer.urls')), ]path('cspobserver/', ...), the admin dashboard will now be accessible at/cspobserver/admin. - Run
python manage.py migrateto create the necessary database tables. - The basic installation is finished! View the Configuration section for more information on how to configure the app.
Admin Interface
A basic administration interface is available under /csp/admin
Commands
List of commands integrated into manage.py:
| Command | Description |
|---|---|
cleanunused |
Removes old sessions and reports from the database. Should be run regularly. |
updaterules |
Updates the rules from the central rule repository. |
Configuration
Overview of all available settings and their default values:
| Setting | Default | Description |
|---|---|---|
| REPORT_ONLY | True |
Wether to enforce the CSP rules or only report them. |
| ENABLED_PATHS | ["/"] |
An array of paths for which the CSP header should be set. |
| CSP_POLICIES | {'default-src': ["'self'"],'script-src': ["'self'", "'unsafe-inline'"],'connect-src': ["'self'"],} |
A disctionary of CSP policies that should be applied. Key is the name of the directive and value is a list of expressions. |
| USE_NEW_API | False |
Whether to enable the new Reporting API or use the old report-uri directive |
| USE_SCRIPT_NONCE | True |
Add nonce to all script tags to catch inline script violations |
| USE_STYLE_NONCE | True |
Add nonce to all style tags to catch inline style violations |
| SESSION_KEEP_DAYS | 14 |
The number of days sessions should be kept in the database. |
| IS_MASTER_COLLECTOR | False |
Indicates if the instance should function as a central collector of CSP reports for multiple other instances. |
| AUTHORIZED_REPORTERS | [] |
A list of domains that are allowed send their CSP reports to the master. Example: ['http://127.0.0.1:8000', 'https://example.com'] |
| REMOTE_SECRET | '' |
A shared secret that must be the same for the master collector and all reporters. |
| REMOTE_REPORTING | False |
Wether to use a central remote collector or not. |
| REMOTE_CSP_OBSERVER_URL | '' |
The URL of the remote collector instance. Must be the path to the csp_observer app, as defined in urls.py. Example: http://example.com/csp |
| CLIENTUI_VISIBILITY | always |
Choose if the client popup should always be visible (always) or only if a problem has been detected (minimized) |
| RULE_UPDATE_FILE | https://raw.githubusercontent.com/flxn/csp-observer-data/master/rules.json |
The path to the file that contains the global rule database |
| RULE_UPDATE_INTERVAL | 21600 |
The minimum number of seconds before a new rule update is allowed |
| VOLUNTARY_DATA_SHARING_URL | https://csp-observer-reports.flxn.de |
The URL that the unknown report data of the data sharing is sent to. |
Metadata
Release files for django-csp-observer 1.0.2
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 |
|---|---|---|---|---|
| django-csp-observer-1.0.2.tar.gz | 260.6 kB | Without provenance | Details for django-csp-observer-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_csp_observer-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for django_csp_observer-1.0.2-py3-none-any.whl |
Total release size: 532.7 kB
Release files / django-csp-observer-1.0.2.tar.gz
| Download URL | django-csp-observer-1.0.2.tar.gz |
|---|---|
| Size | 260.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4575f8750425eda6900a98d5a334545d43fcb0515d8aead4cab2f55148ed0e2
|
|
BLAKE2b-256 checksum How to use checksums |
9c81992c6337b9251f72bd45eda579565fbd9cf502ffc8e81731ce88d3762317
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Release files / django_csp_observer-1.0.2-py3-none-any.whl
| Download URL | django_csp_observer-1.0.2-py3-none-any.whl |
|---|---|
| Size | 272.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0e5d69f4a875a247c4a195c4824af554f8584e2571ba04e118c2fed3fde07ad
|
|
BLAKE2b-256 checksum How to use checksums |
1861c58a82539b8ffe5a0d1cc71ae2a2261422c27c9214664d381de2ad7640bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Security for django-csp-observer 1.0.2
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.