-
-
Notifications
You must be signed in to change notification settings - Fork 995
Add .well-known/security.txt file #2062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Policy: https://www.djangoproject.com/security/ | ||
Contact: https://www.djangoproject.com/security/ | ||
Expires: 2026-12-31T00:00:00.000Z | ||
Encryption: https://keys.openpgp.org/vks/v1/by-fingerprint/AF3516D27D0621171E0CCE25FCB84B8D1D17F80B | ||
Preferred-Languages: en | ||
|
||
# Hello security researcher! | ||
# We appreciate your help in keeping Django secure. | ||
# Please report security issues that concern the Django website (djangoproject.com) to ops@djangoproject.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to contradict the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could change this with the website WG email: |
||
# This helps us make sure your report is seen by the right people. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,8 @@ | ||||||||||||||||||||||||||
from datetime import datetime, timedelta | ||||||||||||||||||||||||||
from http import HTTPStatus | ||||||||||||||||||||||||||
from io import StringIO | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
from django.conf import settings | ||||||||||||||||||||||||||
from django.core.management import call_command | ||||||||||||||||||||||||||
from django.test import TestCase | ||||||||||||||||||||||||||
from django.urls import NoReverseMatch, get_resolver | ||||||||||||||||||||||||||
|
@@ -164,3 +166,40 @@ def test_single_h1_per_page(self): | |||||||||||||||||||||||||
response = self.client.get(url) | ||||||||||||||||||||||||||
self.assertEqual(response.status_code, 200) | ||||||||||||||||||||||||||
self.assertContains(response, "<h1", count=1) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class SecurityTxtFileTests(TestCase): | ||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||
Tests for the security.txt file. | ||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
def test_security_txt_not_expired(self): | ||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||
The security.txt file should not be expired. | ||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||
FILE_PATH = settings.BASE_DIR / ".well-known" / "security.txt" | ||||||||||||||||||||||||||
with open(FILE_PATH) as f: | ||||||||||||||||||||||||||
content = f.read() | ||||||||||||||||||||||||||
Comment on lines
+181
to
+182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we have a
Suggested change
(and remove a level of indentation for the rest of the method) |
||||||||||||||||||||||||||
# Read the line that starts with "Expires:", and parse the date. | ||||||||||||||||||||||||||
for line in content.splitlines(): | ||||||||||||||||||||||||||
if line.startswith("Expires:"): | ||||||||||||||||||||||||||
expires = line.strip("Expires: ") | ||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||
self.fail("No Expires line found in security.txt") | ||||||||||||||||||||||||||
Comment on lines
+183
to
+189
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect use of a
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
expires_date = datetime.strptime( | ||||||||||||||||||||||||||
expires, | ||||||||||||||||||||||||||
"%Y-%m-%dT%H:%M:%S.%fZ", | ||||||||||||||||||||||||||
).date() | ||||||||||||||||||||||||||
Comment on lines
+191
to
+194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use
Suggested change
|
||||||||||||||||||||||||||
# We should ideally be two weeks early with updating - active over reactive | ||||||||||||||||||||||||||
cutoff = (datetime.now() - timedelta(days=15)).date() | ||||||||||||||||||||||||||
self.assertGreater( | ||||||||||||||||||||||||||
expires_date, | ||||||||||||||||||||||||||
cutoff, | ||||||||||||||||||||||||||
"The security.txt file is close to expiring. \ | ||||||||||||||||||||||||||
Please update the 'Expires' line in to confirm the contents are \ | ||||||||||||||||||||||||||
still accurate: {}".format( | ||||||||||||||||||||||||||
FILE_PATH | ||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||
Comment on lines
+200
to
+204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'E501 line too long' is set up in this project (one that I generally disable) – any suggestions on how to clean this up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could build the string outside of the assert method or shorten the message. Is a test needed for this though? How about a calendar reminder? It seems like one day this will start failing the test suite on every PR/commit. |
||||||||||||||||||||||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of a future maintainer, it would be nice to document where one could find a link to the most up-to-date key. I was going to suggest a comment above this line, but I'm not sure if that's the best place for such documentation 🤔 (happy to hear other suggestions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this file might be a good place for putting that comment, since this file is targetted more towards people who want to report a security issue. It should ideally be there somewhere in a readme for contributors and maintainers. Maybe SECURITY.md (which I am planning on adding)?