-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requirements.in for automatic requirements.txt gen with hashed, CSP r…
…eport-to feature WIP
- Loading branch information
Showing
12 changed files
with
1,795 additions
and
999 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
django | ||
django-bootstrap5 | ||
django-cors-headers | ||
django-enumfields | ||
django-extensions | ||
django-icons | ||
django-picklefield | ||
django-widget-tweaks | ||
djangorestframework | ||
djangorestframework-simplejwt | ||
drf-spectacular | ||
drf-spectacular-sidecar | ||
onekey-client | ||
python-decouple | ||
redis | ||
weasyprint | ||
pylookyloo | ||
pillow | ||
ipwhois | ||
dnspython | ||
pypandora | ||
pyvulnerabilitylookup | ||
defusedxml | ||
matplotlib | ||
beautifulsoup4 | ||
python3-nmap | ||
pycrypto | ||
cryptography | ||
blake2signer |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 5.1.5 on 2025-01-24 15:49 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('testing', '0004_testreport'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CSPReport', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('allowed_origin', models.URLField(help_text='The domain allowed to send reports to this endpoint.')), | ||
('endpoint_uuid', models.CharField(editable=False, max_length=64, unique=True)), | ||
('report_data', models.JSONField(default=dict)), | ||
('timestamp', models.DateTimeField(auto_now_add=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'constraints': [models.UniqueConstraint(fields=('user', 'allowed_origin'), name='unique_user_domain')], | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<div class="container py-4"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-8"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h2 class="card-title mb-0">Create CSP Report Endpoint</h2> | ||
</div> | ||
<div class="card-body"> | ||
{% if error %} | ||
<div class="alert alert-danger">{{ error }}</div> | ||
{% endif %} | ||
|
||
{% if endpoint_url %} | ||
<div class="alert alert-success"> | ||
<h4 class="alert-heading">Endpoint Created Successfully!</h4> | ||
<p>Your CSP report endpoint URL is:</p> | ||
<div class="input-group mb-3"> | ||
<input type="text" class="form-control" value="{{ endpoint_url }}" id="endpoint-url" readonly> | ||
<button class="btn btn-outline-secondary" type="button" onclick="copyToClipboard('endpoint-url')"> | ||
Copy | ||
</button> | ||
</div> | ||
|
||
<hr> | ||
<p>Add these headers to your website's configuration:</p> | ||
<div class="bg-light p-3 rounded"> | ||
<code class="d-block">Content-Security-Policy-Report-Only: default-src 'self'; report-uri {{ endpoint_url }};</code> | ||
<small class="text-muted">Use this header to test your CSP without enforcing it</small> | ||
|
||
<code class="d-block mt-3">Content-Security-Policy: default-src 'self'; report-uri {{ endpoint_url }};</code> | ||
<small class="text-muted">Use this header to enforce your CSP</small> | ||
</div> | ||
</div> | ||
{% endif %} | ||
|
||
<form method="POST" class="mt-4"> | ||
{% csrf_token %} | ||
<div class="mb-3"> | ||
<label for="allowed_origin" class="form-label">Allowed Origin:</label> | ||
<input type="url" class="form-control" id="allowed_origin" name="allowed_origin" | ||
placeholder="https://example.com" required> | ||
<div class="form-text">Enter the domain that will be sending CSP reports</div> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Create Endpoint</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
function copyToClipboard(elementId) { | ||
const element = document.getElementById(elementId); | ||
element.select(); | ||
document.execCommand('copy'); | ||
|
||
// Optional: Show feedback | ||
const button = element.nextElementSibling; | ||
const originalText = button.innerText; | ||
button.innerText = 'Copied!'; | ||
setTimeout(() => button.innerText = originalText, 2000); | ||
} | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{# manage_csp_endpoints.html #} | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<div class="container"> | ||
<h2>Manage CSP Report Endpoints</h2> | ||
<a href="{% url 'create_csp_endpoint' %}" class="btn btn-primary mb-3">Create New Endpoint</a> | ||
|
||
{% if endpoints %} | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Allowed Origin</th> | ||
<th>Endpoint URL</th> | ||
<th>Created</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for endpoint in endpoints %} | ||
<tr> | ||
<td>{{ endpoint.allowed_origin }}</td> | ||
<td>https://testing.nc3.lu/uri-report/{{ endpoint.endpoint_uuid }}/</td> | ||
<td>{{ endpoint.timestamp|date:"Y-m-d H:i" }}</td> | ||
<td> | ||
<a href="{% url 'view_csp_reports' endpoint.endpoint_uuid %}" class="btn btn-sm btn-info">View Reports</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<p>No CSP report endpoints configured yet.</p> | ||
{% endif %} | ||
</div> | ||
{% endblock %} | ||
|
||
{# create_csp_endpoint.html #} | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<div class="container"> | ||
<h2>Create CSP Report Endpoint</h2> | ||
|
||
{% if error %} | ||
<div class="alert alert-danger">{{ error }}</div> | ||
{% endif %} | ||
|
||
{% if endpoint_url %} | ||
<div class="alert alert-success"> | ||
<h4>Endpoint Created Successfully!</h4> | ||
<p>Your CSP report endpoint URL is:</p> | ||
<code>{{ endpoint_url }}</code> | ||
<p class="mt-3">Add this to your Content-Security-Policy header:</p> | ||
<code>report-uri {{ endpoint_url }};</code> | ||
</div> | ||
{% endif %} | ||
|
||
<form method="POST" class="mt-4"> | ||
{% csrf_token %} | ||
<div class="form-group"> | ||
<label for="allowed_origin">Allowed Origin:</label> | ||
<input type="url" class="form-control" id="allowed_origin" name="allowed_origin" | ||
placeholder="https://example.com" required> | ||
<small class="form-text text-muted">Enter the domain that will be sending CSP reports</small> | ||
</div> | ||
<button type="submit" class="btn btn-primary mt-3">Create Endpoint</button> | ||
</form> | ||
</div> | ||
{% endblock %} | ||
|
||
{# view_csp_reports.html #} | ||
{% extends "base.html" %} | ||
{% block content %} | ||
<div class="container"> | ||
<h2>CSP Reports for {{ endpoint.allowed_origin }}</h2> | ||
|
||
{% if reports %} | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Timestamp</th> | ||
<th>Violation Details</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for report in reports %} | ||
<tr> | ||
<td>{{ report.timestamp|date:"Y-m-d H:i:s" }}</td> | ||
<td> | ||
<pre><code>{{ report.report_data|json }}</code></pre> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<p>No CSP violation reports received yet.</p> | ||
{% endif %} | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.