{"id":18747646,"url":"https://github.com/quantum5/django-csp-advanced","last_synced_at":"2026-05-18T17:06:17.282Z","repository":{"id":57419614,"uuid":"97285194","full_name":"quantum5/django-csp-advanced","owner":"quantum5","description":"A powerful CSP middleware for Django.","archived":false,"fork":false,"pushed_at":"2022-10-30T22:42:11.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-17T07:13:07.959Z","etag":null,"topics":["content-security-policy","csp","csp-report","django","http-header","security"],"latest_commit_sha":null,"homepage":"https://quantum2.xyz/projects/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantum5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-15T01:47:16.000Z","updated_at":"2022-10-30T22:10:08.000Z","dependencies_parsed_at":"2022-09-13T07:21:53.668Z","dependency_job_id":null,"html_url":"https://github.com/quantum5/django-csp-advanced","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/quantum5/django-csp-advanced","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantum5%2Fdjango-csp-advanced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantum5%2Fdjango-csp-advanced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantum5%2Fdjango-csp-advanced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantum5%2Fdjango-csp-advanced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantum5","download_url":"https://codeload.github.com/quantum5/django-csp-advanced/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantum5%2Fdjango-csp-advanced/sbom","scorecard":{"id":755202,"data":{"date":"2025-08-11","repo":{"name":"github.com/quantum5/django-csp-advanced","commit":"5e965564745b34d9c638fe9022eaeccd4e684d2c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/21 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/quantum5/django-csp-advanced/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/quantum5/django-csp-advanced/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/quantum5/django-csp-advanced/build.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/build.yml:28","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.1.0 not signed: https://api.github.com/repos/quantum5/django-csp-advanced/releases/81501354","Warn: release artifact v0.1.0 does not have provenance: https://api.github.com/repos/quantum5/django-csp-advanced/releases/81501354"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T21:28:39.990Z","repository_id":57419614,"created_at":"2025-08-22T21:28:39.991Z","updated_at":"2025-08-22T21:28:39.991Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33184769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["content-security-policy","csp","csp-report","django","http-header","security"],"created_at":"2024-11-07T16:30:46.952Z","updated_at":"2026-05-18T17:06:17.267Z","avatar_url":"https://github.com/quantum5.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-csp-advanced [![Build Status](https://img.shields.io/travis/quantum5/django-csp-advanced.svg)](https://travis-ci.org/quantum5/django-csp-advanced) [![Coverage](https://img.shields.io/codecov/c/gh/quantum5/django-csp-advanced.svg)](https://codecov.io/gh/quantum5/django-csp-advanced)\n\nA powerful `Content-Security-Policy` (CSP) middleware for Django. This CSP middleware supports\nusing a dictionary syntax for CSP, and using callables taking arguments `(request, response)`\nto fill in parts of the dictionary.\n\nFor example, the following `settings.py` configuration:\n\n```python\nADVANCED_CSP = {\n    'block-all-mixed-content': True,\n    'frame-src': ['none'],\n    'plugin-types': ['application/pdf'],\n    'report-uri': '/dev/null',\n    'sandbox': ['allow-scripts'],\n    'script-src': ['self', 'https://dmoj.ca'],\n    'style-src': lambda request, response: ['self'],\n    'upgrade-insecure-requests': False,\n}\n```\n\ngenerates this CSP (order may differ based on dictionary hashing):\n\n```\nstyle-src 'self'; script-src 'self' https://dmoj.ca; frame-src 'none'; plugin-types application/pdf; block-all-mixed-content; sandbox allow-scripts; report-uri /dev/null\n```\n\nAnother feature is the ability to augment or replace the CSP from views:\n\n```python\ndef view(request):\n    response = HttpResponse()\n    response.csp = {'script-src': ['https://ajax.googleapis.com']}\n    return response\n```\n\nThis will add `https://ajax.googleapis.com` to the list of origins listed for `script-src` to result in something like:\n\n```\n...; script-src 'self' https://dmoj.ca https://ajax.googleapis.com; ...\n```\n\nYou can use `'override': True` to replace the CSP instead:\n\n```python\ndef view(request):\n    response = HttpResponse()\n    response.csp = {'script-src': ['self'], 'override': True}\n    return response\n```\n\nThis will replace the CSP with `script-src 'self'`.\n\nYou can also set `csp_report` on the response to add entry to the report-only CSP.\nNote that neither `csp` or `csp_report` has any effect if their global version is disabled.\nHowever, `csp` will be used to populate `Content-Security-Policy-Report-Only` if there is\nno enforced CSP policy configured, but there is a report-only policy.\n\n## Installation\n\nFirst, install the module with:\n\n```\n$ pip install django-csp-advanced\n```\n\nOr if you want the latest bleeding edge version:\n\n```\n$ pip install -e git://github.com/quantum5/django-csp-advanced.git\n```\n\nThen, add `'csp_advanced'` to `INSTALLED_APPS` and `'csp_advanced.middleware.AdvancedCSPMiddleware'`\nto `'MIDDLEWARE'` or `'MIDDLEWARE_CLASSES'` depending [on your setup](https://docs.djangoproject.com/en/dev/topics/http/middleware/).\n\nFinally, use either a dictionary or a callable taking `request, response` as either\n`ADVANCED_CSP` or `ADVANCED_CSP_REPORT_ONLY`.\n\nExamples:\n\n```python\nADVANCED_CSP = lambda request, response: {'script-src': ['self']}\n\nADVANCED_CSP_REPORT_ONLY = {'script-src': ['self']}\n\nADVANCED_CSP = {'style-src': lambda request, response: ['self']}\n```\n\nYou get the idea.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantum5%2Fdjango-csp-advanced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantum5%2Fdjango-csp-advanced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantum5%2Fdjango-csp-advanced/lists"}