{"id":17981594,"url":"https://github.com/meshy/django-sans-db","last_synced_at":"2026-03-05T06:31:49.712Z","repository":{"id":38016783,"uuid":"291343346","full_name":"meshy/django-sans-db","owner":"meshy","description":"Limit database access in Django code and template renders","archived":false,"fork":false,"pushed_at":"2023-09-01T22:37:38.000Z","size":211,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-12T03:41:15.344Z","etag":null,"topics":["database","django","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/django-sans-db/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meshy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-29T20:22:08.000Z","updated_at":"2023-04-17T08:09:51.000Z","dependencies_parsed_at":"2024-10-29T18:35:22.711Z","dependency_job_id":null,"html_url":"https://github.com/meshy/django-sans-db","commit_stats":{"total_commits":94,"total_committers":3,"mean_commits":"31.333333333333332","dds":0.08510638297872342,"last_synced_commit":"b8f559f9c1e1ba546266abcdcc4d556813d77ebd"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/meshy/django-sans-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meshy%2Fdjango-sans-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meshy%2Fdjango-sans-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meshy%2Fdjango-sans-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meshy%2Fdjango-sans-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meshy","download_url":"https://codeload.github.com/meshy/django-sans-db/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meshy%2Fdjango-sans-db/sbom","scorecard":{"id":637246,"data":{"date":"2025-08-11","repo":{"name":"github.com/meshy/django-sans-db","commit":"debfadce9452656b78e634319d8579f8cb9c0a16"},"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":"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":"Code-Review","score":1,"reason":"Found 1/6 approved changesets -- score normalized to 1","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":"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/release-to-pypi.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/meshy/django-sans-db/release-to-pypi.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-to-pypi.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/meshy/django-sans-db/release-to-pypi.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/meshy/django-sans-db/tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/meshy/django-sans-db/tests.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/release-to-pypi.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/release-to-pypi.yml:23","Warn: pipCommand not pinned by hash: .github/workflows/tests.yml:51","Warn: pipCommand not pinned by hash: .github/workflows/tests.yml:52","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release-to-pypi.yml:1","Warn: no topLevel permission defined: .github/workflows/tests.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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"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":-1,"reason":"no releases found","details":null,"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"18 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2023-13 / GHSA-2hrw-hx67-34x6","Warn: Project is vulnerable to: PYSEC-2023-225 / GHSA-7h4p-27mh-hmrw","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: PYSEC-2023-226 / GHSA-h8gc-pgj2-vjm3","Warn: Project is vulnerable to: PYSEC-2023-100 / GHSA-jh3w-4vvf-mjgr","Warn: Project is vulnerable to: PYSEC-2023-12 / GHSA-q2jf-h9jm-m7p4","Warn: Project is vulnerable to: PYSEC-2023-222 / GHSA-qmf9-6jqf-j8fq","Warn: Project is vulnerable to: PYSEC-2023-61 / GHSA-r3xc-prgr-mg9p","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2024-47 / GHSA-vm8q-m57g-pff3","Warn: Project is vulnerable to: PYSEC-2024-28 / GHSA-xxj9-f6rv-m3x4","Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-cx63-2mw6-8hw5","Warn: Project is vulnerable to: PYSEC-2022-43012 / GHSA-r9hx-vwmv-q579","Warn: Project is vulnerable to: GHSA-2m57-hf25-phgg","Warn: Project is vulnerable to: PYSEC-2023-87 / GHSA-rrm6-wvj7-cwh2","Warn: Project is vulnerable to: PYSEC-2024-187 / GHSA-rqc4-2hc7-8c8v","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T09:34:04.272Z","repository_id":38016783,"created_at":"2025-08-21T09:34:04.272Z","updated_at":"2025-08-21T09:34:04.272Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30112231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["database","django","python"],"created_at":"2024-10-29T18:11:23.252Z","updated_at":"2026-03-05T06:31:49.689Z","avatar_url":"https://github.com/meshy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django sans DB\n\nTools for limiting access to the database in parts of your Django code.\n\n## Installation\n\n```\npip install django-sans-db\n```\n\nIf you wish to use the `{% sansdb %}` template tag,\nyou will need to add `\"sans_db\"` to your `INSTALLED_APPS`.\n\n## Usage\n\n### Context manager\n\nYou can block access to your database for a section of your code using `block_db`:\n\n```python\nfrom sans_db.context_managers import block_db\n\nUser.objects.create(...)  # Works outside of block_db()\nwith block_db():\n    User.objects.get()  # Raises DatabaseAccessBlocked\n```\n\nIf you have multiple entries in your Django `DATABASES` setting,\nthen `block_db` will default to blocking all of them.\n\nIf you wish to block access to a subset of your databases,\npass a list of their aliases (the keys in the `DATABASES` dictionary).\n\n```python\nfrom sans_db.context_managers import block_db\n\nwith block_db(databases=[\"replica\"]):\n    User.objects.using(\"primary\").create(...)  # This DB isn't blocked.\n    User.objects.using(\"replica\").get()  # Raises DatabaseAccessBlocked\n```\n\n\n### Decorator\n\nYou can decorate functions and methods with `block_db` to block database access in them. Eg:\n\n```python\nfrom sans_db.context_managers import block_db\n\nclass MyClass:\n    def allowed(self):\n        User.objects.create(...)  # Works outside of block_db()\n\n    @block_db()\n    def not_allowed(self):\n        User.objects.create(...)  # Raises DatabaseAccessBlocked\n```\n\n\n### Template backend\n\nYou can block access to the database when rendering Django templates with our custom template backend.\n\nNote: Currently, only Django templates are supported.\n\nYou can block database access in all of your templates\nby setting your templates backend to `\"sans_db.template_backends.django_sans_db.DjangoTemplatesSansDB\"`\n\nFor example:\n\n```python\n# settings.py\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"sans_db.template_backends.django_sans_db.DjangoTemplatesSansDB\",\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {...},\n    },\n]\n```\n\nAttempts to query the database will now cause a `sans_db.exceptions.DatabaseAccessBlocked` to be raised.\n\nPlease refer to Django's docs on [support for template engines](https://docs.djangoproject.com/en/4.0/topics/templates/#support-for-template-engines)\nfor details on how to set this up as a secondary template renderer.\n\n\n### Template tag\n\nYou can block DB access in a portion of your template\nby wrapping it with the `{% sansdb %}` template tag.\n\nThe template tag accepts database aliases as either strings, or variables.\nIf passed as a variable, either strings or iterables of strings are accepted.\nIf no aliases are passed, all databases will be blocked.\n\nNote: `DatabaseAccessBlocked` is raised when an attempt is made to access the DB.\n\nTo block all databases:\n\n```django\n{% load sansdb %}\n{% sansdb %}\n    {# ... #}\n{% endsansdb %}\n```\n\nTo block a list of databases named in the template:\n\n```django\n{% load sansdb %}\n{% sansdb \"second_db\" \"third_db\" %}\n    {# ... #}\n{% endsansdb %}\n```\n\nTo block a list of databases from a context variable:\n\n```django\n{% load sansdb %}\n{% sansdb databases %}\n    {# ... #}\n{% endsansdb %}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeshy%2Fdjango-sans-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeshy%2Fdjango-sans-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeshy%2Fdjango-sans-db/lists"}