django-octo-security 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_octo_security-0.1.0/.github/workflows/ci.yml +39 -0
- django_octo_security-0.1.0/.github/workflows/publish.yml +29 -0
- django_octo_security-0.1.0/.gitignore +30 -0
- django_octo_security-0.1.0/LICENSE +21 -0
- django_octo_security-0.1.0/PKG-INFO +129 -0
- django_octo_security-0.1.0/README.md +109 -0
- django_octo_security-0.1.0/TESTING.md +50 -0
- django_octo_security-0.1.0/audits/AUDITS.md +3 -0
- django_octo_security-0.1.0/config/__init__.py +0 -0
- django_octo_security-0.1.0/config/asgi.py +16 -0
- django_octo_security-0.1.0/config/settings.py +135 -0
- django_octo_security-0.1.0/config/urls.py +24 -0
- django_octo_security-0.1.0/config/wsgi.py +16 -0
- django_octo_security-0.1.0/features/environment.py +19 -0
- django_octo_security-0.1.0/features/security_audit.feature +16 -0
- django_octo_security-0.1.0/features/steps/security_steps.py +83 -0
- django_octo_security-0.1.0/manage.py +23 -0
- django_octo_security-0.1.0/performance/locust_load_report.pdf +0 -0
- django_octo_security-0.1.0/performance/locustfile.py +9 -0
- django_octo_security-0.1.0/pyproject.toml +44 -0
- django_octo_security-0.1.0/pytest.ini +4 -0
- django_octo_security-0.1.0/requirements-dev.lock +130 -0
- django_octo_security-0.1.0/requirements.lock +20 -0
- django_octo_security-0.1.0/revision.zip +0 -0
- django_octo_security-0.1.0/src/django_octo_security/__init__.py +3 -0
- django_octo_security-0.1.0/src/django_octo_security/admin.py +131 -0
- django_octo_security-0.1.0/src/django_octo_security/apps.py +7 -0
- django_octo_security-0.1.0/src/django_octo_security/migrations/0001_initial.py +70 -0
- django_octo_security-0.1.0/src/django_octo_security/migrations/__init__.py +0 -0
- django_octo_security-0.1.0/src/django_octo_security/models.py +34 -0
- django_octo_security-0.1.0/src/django_octo_security/scanner.py +139 -0
- django_octo_security-0.1.0/src/django_octo_security/templates/admin/django_octo_security/cveauditscan/change_list.html +11 -0
- django_octo_security-0.1.0/src/django_octo_security/templates/security_audit.html +58 -0
- django_octo_security-0.1.0/src/django_octo_security/tests.py +1 -0
- django_octo_security-0.1.0/src/django_octo_security/urls.py +8 -0
- django_octo_security-0.1.0/src/django_octo_security/views.py +15 -0
- django_octo_security-0.1.0/templates/security_audit.html +58 -0
- django_octo_security-0.1.0/tests/__init__.py +0 -0
- django_octo_security-0.1.0/tests/settings.py +44 -0
- django_octo_security-0.1.0/tests/test_security_core.py +46 -0
- django_octo_security-0.1.0/tests/urls.py +5 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "main" ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
qa-pipeline:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout repository
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup Rye
|
|
18
|
+
uses: eifinger/setup-rye@v4
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
|
|
22
|
+
- name: Synchronize dependencies (including dev-dependencies)
|
|
23
|
+
run: rye sync
|
|
24
|
+
|
|
25
|
+
- name: Run database migrations
|
|
26
|
+
env:
|
|
27
|
+
PYTHONPATH: src
|
|
28
|
+
run: rye run python manage.py migrate
|
|
29
|
+
|
|
30
|
+
- name: Execute Unit & Query-Count Suite (pytest)
|
|
31
|
+
env:
|
|
32
|
+
PYTHONPATH: src
|
|
33
|
+
run: rye run pytest
|
|
34
|
+
|
|
35
|
+
- name: Execute Behavioral Specifications (behave)
|
|
36
|
+
env:
|
|
37
|
+
PYTHONPATH: src
|
|
38
|
+
run: rye run behave
|
|
39
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
pypi-publish:
|
|
9
|
+
name: Build and publish distribution to PyPI
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment:
|
|
12
|
+
name: pypi
|
|
13
|
+
url: https://pypi.org
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Rye
|
|
22
|
+
uses: eifinger/setup-rye@v4
|
|
23
|
+
|
|
24
|
+
- name: Build distribution packages
|
|
25
|
+
run: rye build
|
|
26
|
+
|
|
27
|
+
- name: Publish package to PyPI via Trusted Publisher
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
29
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# python generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# ==========================================
|
|
10
|
+
# Rye / Python Environment
|
|
11
|
+
# ==========================================
|
|
12
|
+
.venv/
|
|
13
|
+
.python-version
|
|
14
|
+
.project-id
|
|
15
|
+
__pycache__/
|
|
16
|
+
*.pyc
|
|
17
|
+
*.pyo
|
|
18
|
+
*.pyd
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
|
|
23
|
+
# ==========================================
|
|
24
|
+
# Django Local Configurations & Media
|
|
25
|
+
# ==========================================
|
|
26
|
+
.env
|
|
27
|
+
local_settings.py
|
|
28
|
+
media/
|
|
29
|
+
staticfiles/
|
|
30
|
+
db.sqlite3
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jeanpmodev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: django-octo-security
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Enterprise-ready Django runtime security and zero-dependency environment CVE audit module under the Django-Octo architecture.
|
|
5
|
+
Project-URL: Homepage, https://github.com/jeanpmodev/django_octo_security
|
|
6
|
+
Project-URL: Repository, https://github.com/jeanpmodev/django_octo_security
|
|
7
|
+
Author-email: jeanpmodev <jeanpmodev@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: audit,cve,django,hardening,osv,security,vulnerability-scanner
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Security
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Requires-Dist: django>=6.1.2
|
|
18
|
+
Requires-Dist: python-dotenv
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# django_octo_security
|
|
22
|
+
|
|
23
|
+
[](LICENSE)
|
|
24
|
+
[](https://python.org)
|
|
25
|
+
[](https://djangoproject.com)
|
|
26
|
+
[](https://astral.sh)
|
|
27
|
+

|
|
28
|
+
[](https://djangopackages.org/packages/p/django_octo_security/)
|
|
29
|
+
[](https://github.com/jeanpmodev/django_octo_security/blob/main/TESTING.md)
|
|
30
|
+
[](https://github.com/jeanpmodev/django_octo_security/blob/main/TESTING.md)
|
|
31
|
+
[](https://github.com/jeanpmodev/django_octo_security/blob/main/performance/locust_load_report.pdf)
|
|
32
|
+
[](https://github.com/jeanpmodev/django_octo_security/actions/workflows/ci.yml)
|
|
33
|
+
[](https://peps.python.org/pep-0008/)
|
|
34
|
+
[](https://pypi.org/project/django-octo-security/#provenance)
|
|
35
|
+
|
|
36
|
+
**Enterprise-ready, non-intrusive Django runtime security posture and zero-dependency environment CVE audit module under the Django-Octo architecture.**
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Core Philosophy: Non-Intrusive Dual Access
|
|
41
|
+
|
|
42
|
+
`django-octo-security` is engineered to plug into any existing Django application **without altering your host project's native logic, templates, or root routes**:
|
|
43
|
+
|
|
44
|
+
1. **Public/Internal Posture Endpoint (`/security-audit/`):** Single-query database lookup (`CveAuditScan.objects.first()`) rendering enforced HTTP security headers and the latest environment vulnerability audit status.
|
|
45
|
+
2. **Native Django Admin Integration (`Security > CVE Checker`):** Automatically registers a dedicated administrative module in the left sidebar of `/admin/` with one-click environment scanning (`Run CVE Environment Audit`), querying the official **OSV.dev** vulnerability database via Python standard library (`importlib.metadata` + `urllib.request`) with **zero external runtime dependencies**.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Security & Audit Architecture
|
|
50
|
+
|
|
51
|
+
| Layer | Mechanism / Target | Engineering Purpose |
|
|
52
|
+
| :--- | :--- | :--- |
|
|
53
|
+
| **01** | **Clickjacking Shield** | Enforces `X-Frame-Options: DENY` to prevent unauthorized iframe embedding. |
|
|
54
|
+
| **02** | **MIME Sniffing Guard** | Enforces `X-Content-Type-Options: nosniff` against content-type confusion attacks. |
|
|
55
|
+
| **03** | **Referrer Isolation** | Applies `Referrer-Policy: strict-origin-when-cross-origin` to prevent token leakage. |
|
|
56
|
+
| **04** | **Single-Query Posture View** | Renders `/security-audit/` in a single ORM query for high-throughput scalability. |
|
|
57
|
+
| **05** | **Runtime Introspection** | Reads active virtual environment packages via native `importlib.metadata`. |
|
|
58
|
+
| **06** | **Batch OSV Vulnerability Query** | Cross-references all installed PyPI packages against `api.osv.dev/v1/querybatch`. |
|
|
59
|
+
| **07** | **Advisory Enrichment & Fixes** | Resolves CVE aliases, patched versions, and official references per vulnerability. |
|
|
60
|
+
| **08** | **Immutable Audit Persistence** | Stores historical snapshots (`CveAuditScan`) directly in the host database. |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Plug-and-Play Installation
|
|
65
|
+
|
|
66
|
+
Install the official package directly into any modern Django (`>=6.1.2`) and Python (`>=3.12`) infrastructure using **pip** or **Rye**:
|
|
67
|
+
|
|
68
|
+
### 1. Clone & Synchronize Environment
|
|
69
|
+
Clone the repository and trigger the Rust-backed Rye environment compiler to lock and synchronize dependencies:
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/jeanpmodev/django_octo_security.git
|
|
72
|
+
cd django_octo_security
|
|
73
|
+
rye sync
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### 2. Register in `settings.py`
|
|
78
|
+
Add `"django_octo_security"` to your `INSTALLED_APPS`:
|
|
79
|
+
```python
|
|
80
|
+
INSTALLED_APPS = [
|
|
81
|
+
# ... your existing apps
|
|
82
|
+
"django_octo_security",
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Include the Audit Route in `urls.py`
|
|
87
|
+
Including the module at the root preserves your host application's homepage (`/`) and mounts the posture report at `/security-audit/`:
|
|
88
|
+
```python
|
|
89
|
+
from django.contrib import admin
|
|
90
|
+
from django.urls import include, path
|
|
91
|
+
|
|
92
|
+
urlpatterns = [
|
|
93
|
+
path("admin/", admin.site.urls),
|
|
94
|
+
path("", include("django_octo_security.urls")),
|
|
95
|
+
]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. Apply Migrations
|
|
99
|
+
```bash
|
|
100
|
+
python3 manage.py migrate
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### 5. Initialize Runtime Service
|
|
105
|
+
Fire up the local development engine instance:
|
|
106
|
+
```bash
|
|
107
|
+
python3 manage.py runserver
|
|
108
|
+
```
|
|
109
|
+
Navigate to `127.0.0.1:8000/security-audit/` to inspect live.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
* **Security Posture Screen:** Navigate to `http://127.0.0.1:8000/security-audit/` to inspect active HTTP security policies and the latest environment CVE audit badge.
|
|
116
|
+
* **Admin CVE Checker:** Log in to `http://127.0.0.1:8000/admin/`, open **Security > CVE Checker** in the left navigation bar, and click **Run CVE Environment Audit** at the top right to scan all installed Python packages in real time.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## Quality Assurance & Testing
|
|
122
|
+
|
|
123
|
+
This module is backed by a dedicated QA suite covering **Unit & Query-Count Tests (`pytest`)**, **BDD Specifications (`behave`)**, and **Load Testing (`locust`)**. To keep the core package minimal, test dependencies are installed on demand—see [TESTING.md](TESTING.md) for instructions and benchmark reports.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## 📄 License & Ecosystem Blueprint
|
|
127
|
+
|
|
128
|
+
Distributed under the permissive terms of the **MIT License**.
|
|
129
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# django_octo_security
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://python.org)
|
|
5
|
+
[](https://djangoproject.com)
|
|
6
|
+
[](https://astral.sh)
|
|
7
|
+

|
|
8
|
+
[](https://djangopackages.org/packages/p/django_octo_security/)
|
|
9
|
+
[](https://github.com/jeanpmodev/django_octo_security/blob/main/TESTING.md)
|
|
10
|
+
[](https://github.com/jeanpmodev/django_octo_security/blob/main/TESTING.md)
|
|
11
|
+
[](https://github.com/jeanpmodev/django_octo_security/blob/main/performance/locust_load_report.pdf)
|
|
12
|
+
[](https://github.com/jeanpmodev/django_octo_security/actions/workflows/ci.yml)
|
|
13
|
+
[](https://peps.python.org/pep-0008/)
|
|
14
|
+
[](https://pypi.org/project/django-octo-security/#provenance)
|
|
15
|
+
|
|
16
|
+
**Enterprise-ready, non-intrusive Django runtime security posture and zero-dependency environment CVE audit module under the Django-Octo architecture.**
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Core Philosophy: Non-Intrusive Dual Access
|
|
21
|
+
|
|
22
|
+
`django-octo-security` is engineered to plug into any existing Django application **without altering your host project's native logic, templates, or root routes**:
|
|
23
|
+
|
|
24
|
+
1. **Public/Internal Posture Endpoint (`/security-audit/`):** Single-query database lookup (`CveAuditScan.objects.first()`) rendering enforced HTTP security headers and the latest environment vulnerability audit status.
|
|
25
|
+
2. **Native Django Admin Integration (`Security > CVE Checker`):** Automatically registers a dedicated administrative module in the left sidebar of `/admin/` with one-click environment scanning (`Run CVE Environment Audit`), querying the official **OSV.dev** vulnerability database via Python standard library (`importlib.metadata` + `urllib.request`) with **zero external runtime dependencies**.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Security & Audit Architecture
|
|
30
|
+
|
|
31
|
+
| Layer | Mechanism / Target | Engineering Purpose |
|
|
32
|
+
| :--- | :--- | :--- |
|
|
33
|
+
| **01** | **Clickjacking Shield** | Enforces `X-Frame-Options: DENY` to prevent unauthorized iframe embedding. |
|
|
34
|
+
| **02** | **MIME Sniffing Guard** | Enforces `X-Content-Type-Options: nosniff` against content-type confusion attacks. |
|
|
35
|
+
| **03** | **Referrer Isolation** | Applies `Referrer-Policy: strict-origin-when-cross-origin` to prevent token leakage. |
|
|
36
|
+
| **04** | **Single-Query Posture View** | Renders `/security-audit/` in a single ORM query for high-throughput scalability. |
|
|
37
|
+
| **05** | **Runtime Introspection** | Reads active virtual environment packages via native `importlib.metadata`. |
|
|
38
|
+
| **06** | **Batch OSV Vulnerability Query** | Cross-references all installed PyPI packages against `api.osv.dev/v1/querybatch`. |
|
|
39
|
+
| **07** | **Advisory Enrichment & Fixes** | Resolves CVE aliases, patched versions, and official references per vulnerability. |
|
|
40
|
+
| **08** | **Immutable Audit Persistence** | Stores historical snapshots (`CveAuditScan`) directly in the host database. |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Plug-and-Play Installation
|
|
45
|
+
|
|
46
|
+
Install the official package directly into any modern Django (`>=6.1.2`) and Python (`>=3.12`) infrastructure using **pip** or **Rye**:
|
|
47
|
+
|
|
48
|
+
### 1. Clone & Synchronize Environment
|
|
49
|
+
Clone the repository and trigger the Rust-backed Rye environment compiler to lock and synchronize dependencies:
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/jeanpmodev/django_octo_security.git
|
|
52
|
+
cd django_octo_security
|
|
53
|
+
rye sync
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### 2. Register in `settings.py`
|
|
58
|
+
Add `"django_octo_security"` to your `INSTALLED_APPS`:
|
|
59
|
+
```python
|
|
60
|
+
INSTALLED_APPS = [
|
|
61
|
+
# ... your existing apps
|
|
62
|
+
"django_octo_security",
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Include the Audit Route in `urls.py`
|
|
67
|
+
Including the module at the root preserves your host application's homepage (`/`) and mounts the posture report at `/security-audit/`:
|
|
68
|
+
```python
|
|
69
|
+
from django.contrib import admin
|
|
70
|
+
from django.urls import include, path
|
|
71
|
+
|
|
72
|
+
urlpatterns = [
|
|
73
|
+
path("admin/", admin.site.urls),
|
|
74
|
+
path("", include("django_octo_security.urls")),
|
|
75
|
+
]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 4. Apply Migrations
|
|
79
|
+
```bash
|
|
80
|
+
python3 manage.py migrate
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### 5. Initialize Runtime Service
|
|
85
|
+
Fire up the local development engine instance:
|
|
86
|
+
```bash
|
|
87
|
+
python3 manage.py runserver
|
|
88
|
+
```
|
|
89
|
+
Navigate to `127.0.0.1:8000/security-audit/` to inspect live.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
* **Security Posture Screen:** Navigate to `http://127.0.0.1:8000/security-audit/` to inspect active HTTP security policies and the latest environment CVE audit badge.
|
|
96
|
+
* **Admin CVE Checker:** Log in to `http://127.0.0.1:8000/admin/`, open **Security > CVE Checker** in the left navigation bar, and click **Run CVE Environment Audit** at the top right to scan all installed Python packages in real time.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## Quality Assurance & Testing
|
|
102
|
+
|
|
103
|
+
This module is backed by a dedicated QA suite covering **Unit & Query-Count Tests (`pytest`)**, **BDD Specifications (`behave`)**, and **Load Testing (`locust`)**. To keep the core package minimal, test dependencies are installed on demand—see [TESTING.md](TESTING.md) for instructions and benchmark reports.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## 📄 License & Ecosystem Blueprint
|
|
107
|
+
|
|
108
|
+
Distributed under the permissive terms of the **MIT License**.
|
|
109
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Quality Assurance & Testing Methodology
|
|
2
|
+
|
|
3
|
+
[](#2-unit--query-count-validation-pytest)
|
|
4
|
+
[](#3-behavioral--bdd-specifications-behave)
|
|
5
|
+
[](performance/locust_load_report.pdf)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. On-Demand QA Setup
|
|
10
|
+
Inside an isolated virtual environment, install the validation stack:
|
|
11
|
+
```bash
|
|
12
|
+
rye add pytest pytest-django behave locust
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 2. Unit & Query-Count Validation (`pytest`)
|
|
18
|
+
Verifies schema migrations, OSV API vulnerability batch parsing, advisory enrichment, and enforces the **Single Database Lookup (`assertNumQueries(1)`)** contract on `/security-audit/`:
|
|
19
|
+
```bash
|
|
20
|
+
PYTHONPATH=src rye run pytest
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 3. Behavioral / BDD Specifications (`behave`)
|
|
26
|
+
Executes Gherkin scenarios (`features/security_audit.feature`) validating the runtime posture endpoint and CVE environment audit scanner end-to-end:
|
|
27
|
+
```bash
|
|
28
|
+
PYTHONPATH=src rye run behave
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 4. Load & Concurrency Stress Benchmark (`locust`)
|
|
34
|
+
Simulates concurrent requests hitting the live `/security-audit/` posture endpoint to verify zero-error stability under load:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Terminal 1: Start runtime service
|
|
38
|
+
rye run python3 manage.py runserver --noreload
|
|
39
|
+
|
|
40
|
+
# Terminal 2: Execute headless load benchmark
|
|
41
|
+
rye run locust -f performance/locustfile.py --headless -u 20 -r 5 -t 10s --host http://127.0.0.1:8000
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Benchmark Summary
|
|
45
|
+
* **Failure Rate:** `0.00%` (HTTP 200 OK across all posture audit requests)
|
|
46
|
+
* **Query Overhead:** Strict `1 query` per request (`CveAuditScan.objects.first()`)
|
|
47
|
+
* **Detailed Metrics:** Available in the exported report below.
|
|
48
|
+
|
|
49
|
+
**[View Official Locust Load Test Report (PDF)](performance/locust_load_report.pdf)**
|
|
50
|
+
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASGI config for config project.
|
|
3
|
+
|
|
4
|
+
It exposes the ASGI callable as a module-level variable named ``application``.
|
|
5
|
+
|
|
6
|
+
For more information on this file, see
|
|
7
|
+
https://docs.djangoproject.com/en/6.1/howto/deployment/asgi/
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
from django.core.asgi import get_asgi_application
|
|
13
|
+
|
|
14
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
|
15
|
+
|
|
16
|
+
application = get_asgi_application()
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Django settings for config project.
|
|
3
|
+
|
|
4
|
+
Generated by 'django-admin startproject' using Django 6.1.2.
|
|
5
|
+
|
|
6
|
+
For more information on this file, see
|
|
7
|
+
https://docs.djangoproject.com/en/6.1/topics/settings/
|
|
8
|
+
|
|
9
|
+
For the full list of settings and their values, see
|
|
10
|
+
https://docs.djangoproject.com/en/6.1/ref/settings/
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import os
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from dotenv import load_dotenv
|
|
16
|
+
|
|
17
|
+
# 1. First, build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
18
|
+
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
19
|
+
|
|
20
|
+
# 2. Then, load environment variables from the .env file using BASE_DIR
|
|
21
|
+
load_dotenv(BASE_DIR / ".env")
|
|
22
|
+
|
|
23
|
+
# Quick-start development settings - unsuitable for production
|
|
24
|
+
# See https://docs.djangoproject.com/en/6.1/howto/deployment/checklist/
|
|
25
|
+
|
|
26
|
+
# SECURITY WARNING: keep the secret key used in production secret!
|
|
27
|
+
SECRET_KEY = os.getenv(
|
|
28
|
+
"SECRET_KEY", "django-insecure-production-fallback-key-change-in-env"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
# SECURITY WARNING: don't run with debug turned on in production!
|
|
32
|
+
DEBUG = True
|
|
33
|
+
|
|
34
|
+
ALLOWED_HOSTS = []
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Application definition
|
|
38
|
+
|
|
39
|
+
INSTALLED_APPS = [
|
|
40
|
+
"django.contrib.admin",
|
|
41
|
+
"django.contrib.auth",
|
|
42
|
+
"django.contrib.contenttypes",
|
|
43
|
+
"django.contrib.sessions",
|
|
44
|
+
"django.contrib.messages",
|
|
45
|
+
"django.contrib.staticfiles",
|
|
46
|
+
"django_octo_security",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
MIDDLEWARE = [
|
|
50
|
+
"django.middleware.security.SecurityMiddleware",
|
|
51
|
+
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
52
|
+
"django.middleware.common.CommonMiddleware",
|
|
53
|
+
"django.middleware.csrf.CsrfViewMiddleware",
|
|
54
|
+
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
55
|
+
"django.contrib.messages.middleware.MessageMiddleware",
|
|
56
|
+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
ROOT_URLCONF = "config.urls"
|
|
60
|
+
|
|
61
|
+
TEMPLATES = [
|
|
62
|
+
{
|
|
63
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
64
|
+
"DIRS": [BASE_DIR / "templates"],
|
|
65
|
+
"APP_DIRS": True,
|
|
66
|
+
"OPTIONS": {
|
|
67
|
+
"context_processors": [
|
|
68
|
+
"django.template.context_processors.debug",
|
|
69
|
+
"django.template.context_processors.request",
|
|
70
|
+
"django.contrib.auth.context_processors.auth",
|
|
71
|
+
"django.contrib.messages.context_processors.messages",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
WSGI_APPLICATION = "config.wsgi.application"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# Database
|
|
81
|
+
# https://docs.djangoproject.com/en/6.1/ref/settings/#databases
|
|
82
|
+
|
|
83
|
+
DATABASES = {
|
|
84
|
+
"default": {
|
|
85
|
+
"ENGINE": "django.db.backends.sqlite3",
|
|
86
|
+
"NAME": BASE_DIR / "db.sqlite3",
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# Password validation
|
|
92
|
+
# https://docs.djangoproject.com/en/6.1/ref/settings/#auth-password-validators
|
|
93
|
+
|
|
94
|
+
AUTH_PASSWORD_VALIDATORS = [
|
|
95
|
+
{
|
|
96
|
+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# Internationalization
|
|
111
|
+
# https://docs.djangoproject.com/en/6.1/topics/i18n/
|
|
112
|
+
|
|
113
|
+
LANGUAGE_CODE = "en-us"
|
|
114
|
+
|
|
115
|
+
TIME_ZONE = "UTC"
|
|
116
|
+
|
|
117
|
+
USE_I18N = True
|
|
118
|
+
|
|
119
|
+
USE_TZ = True
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# Static files (CSS, JavaScript, Images)
|
|
123
|
+
# https://docs.djangoproject.com/en/6.1/howto/static-files/
|
|
124
|
+
|
|
125
|
+
STATIC_URL = "static/"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# Email
|
|
129
|
+
# https://docs.djangoproject.com/en/6.1/topics/email/#topic-email-configuration
|
|
130
|
+
|
|
131
|
+
MAILERS = {
|
|
132
|
+
"default": {
|
|
133
|
+
"BACKEND": "django.core.mail.backends.console.EmailBackend",
|
|
134
|
+
},
|
|
135
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
URL configuration for config project.
|
|
3
|
+
|
|
4
|
+
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
5
|
+
https://docs.djangoproject.com/en/6.1/topics/http/urls/
|
|
6
|
+
Examples:
|
|
7
|
+
Function views
|
|
8
|
+
1. Add an import: from my_app import views
|
|
9
|
+
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
10
|
+
Class-based views
|
|
11
|
+
1. Add an import: from other_app.views import Home
|
|
12
|
+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
13
|
+
Including another URLconf
|
|
14
|
+
1. Import the include() function: from django.urls import include, path
|
|
15
|
+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from django.contrib import admin
|
|
19
|
+
from django.urls import path, include
|
|
20
|
+
|
|
21
|
+
urlpatterns = [
|
|
22
|
+
path("admin/", admin.site.urls),
|
|
23
|
+
path("", include("django_octo_security.urls")),
|
|
24
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
WSGI config for config project.
|
|
3
|
+
|
|
4
|
+
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
5
|
+
|
|
6
|
+
For more information on this file, see
|
|
7
|
+
https://docs.djangoproject.com/en/6.1/howto/deployment/wsgi/
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
from django.core.wsgi import get_wsgi_application
|
|
13
|
+
|
|
14
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
|
15
|
+
|
|
16
|
+
application = get_wsgi_application()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import django
|
|
3
|
+
|
|
4
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
|
|
5
|
+
django.setup()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def before_all(context):
|
|
9
|
+
from django.test.utils import setup_test_environment, setup_databases
|
|
10
|
+
|
|
11
|
+
setup_test_environment()
|
|
12
|
+
context.old_config = setup_databases(verbosity=0, interactive=False)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def after_all(context):
|
|
16
|
+
from django.test.utils import teardown_databases, teardown_test_environment
|
|
17
|
+
|
|
18
|
+
teardown_databases(context.old_config, verbosity=0)
|
|
19
|
+
teardown_test_environment()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: Django-Octo Security Runtime and CVE Audit
|
|
2
|
+
As a system administrator
|
|
3
|
+
I want to verify security headers and audit installed Python packages for CVEs
|
|
4
|
+
So that the application maintains high security compliance without impacting runtime performance
|
|
5
|
+
|
|
6
|
+
Scenario: Render security audit endpoint with single query
|
|
7
|
+
Given the database has a clean CVE audit scan recorded
|
|
8
|
+
When a client requests the "/security-audit/" endpoint
|
|
9
|
+
Then the response status code should be 200
|
|
10
|
+
And the security showcase page should display "CLEAN"
|
|
11
|
+
|
|
12
|
+
Scenario: Detect vulnerabilities in installed packages via OSV scanner
|
|
13
|
+
Given the environment has a vulnerable package "django" at version "6.1.0"
|
|
14
|
+
When the CVE environment audit scanner executes
|
|
15
|
+
Then the audit status should be "VULNERABLE"
|
|
16
|
+
And the audit report should contain "PYSEC-2026-001"
|