Skip to content

Commit 95c642b

Browse files
bwbroersmamxsasha
authored andcommitted
security.txt full url in finding
Fixes #1314
1 parent 1ae6393 commit 95c642b

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# AddField Generated by Django 3.2.24 on 2024-03-09 12:49
2+
# Manually created SQL migration to handle old reports
3+
4+
from django.db import migrations # , models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("checks", "0015_auto_20240212_1616"),
10+
]
11+
12+
operations = [
13+
# migrations.AddField(
14+
# model_name='domaintestappsecpriv',
15+
# name='securitytxt_found_url',
16+
# field=models.CharField(max_length=8000, null=True),
17+
# ),
18+
migrations.RunSQL(
19+
sql=[
20+
"ALTER TABLE checks_domaintestappsecpriv ADD COLUMN securitytxt_found_url VARCHAR(8000);",
21+
"UPDATE checks_domaintestappsecpriv SET securitytxt_found_url=securitytxt_found_host WHERE securitytxt_enabled;",
22+
],
23+
reverse_sql=[
24+
"ALTER TABLE checks_domaintestappsecpriv DROP COLUMN securitytxt_found_url;",
25+
],
26+
),
27+
]

checks/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ class DomainTestAppsecpriv(BaseTestModel):
721721
securitytxt_recommendations = ListField(default=[])
722722
securitytxt_score = models.IntegerField(null=True)
723723
securitytxt_found_host = models.CharField(null=True, max_length=255)
724+
# 8000 from https://www.rfc-editor.org/rfc/rfc9110#section-4.1-5
725+
securitytxt_found_url = models.CharField(null=True, max_length=8000)
724726

725727
def __dir__(self):
726728
return [
@@ -753,6 +755,7 @@ def __dir__(self):
753755
"securitytxt_recommendations",
754756
"securitytxt_score",
755757
"securitytxt_found_host",
758+
"securitytxt_found_url",
756759
]
757760

758761
def get_web_api_details(self):
@@ -772,6 +775,7 @@ def get_web_api_details(self):
772775
"securitytxt_errors": self.securitytxt_errors,
773776
"securitytxt_recommendations": self.securitytxt_recommendations,
774777
"securitytxt_found_host": self.securitytxt_found_host,
778+
"securitytxt_found_url": self.securitytxt_found_url,
775779
}
776780

777781
class Meta:

checks/tasks/appsecpriv.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def save_results(model, results, addr, domain):
125125
model.securitytxt_errors = result.get("securitytxt_errors")
126126
model.securitytxt_recommendations = result.get("securitytxt_recommendations")
127127
model.securitytxt_found_host = result.get("securitytxt_found_host")
128+
model.securitytxt_found_url = result.get("securitytxt_found_url")
128129
model.content_security_policy_enabled = result.get("content_security_policy_enabled")
129130
model.content_security_policy_score = result.get("content_security_policy_score")
130131
model.content_security_policy_values = result.get("content_security_policy_values")
@@ -190,7 +191,7 @@ def build_report(model, category):
190191
default_message = [
191192
{
192193
"msgid": "retrieved-from",
193-
"context": {"hostname": model.securitytxt_found_host},
194+
"context": {"url": model.securitytxt_found_url},
194195
}
195196
]
196197
else:

checks/tasks/securitytxt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def parser_format(parser_messages):
129129
"securitytxt_enabled": False,
130130
"securitytxt_score": scoring.WEB_APPSECPRIV_SECURITYTXT_BAD,
131131
"securitytxt_found_host": result.found_host,
132+
"securitytxt_found_url": None,
132133
"securitytxt_errors": result.errors,
133134
"securitytxt_recommendations": [],
134135
}
@@ -142,6 +143,7 @@ def parser_format(parser_messages):
142143
"securitytxt_enabled": True,
143144
"securitytxt_score": score,
144145
"securitytxt_found_host": result.found_host,
146+
"securitytxt_found_url": result.found_url,
145147
"securitytxt_errors": errors,
146148
"securitytxt_recommendations": parser_format(parser.recommendations + parser.notifications),
147149
}

translations/en/main.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ msgid "detail tech data http-securitytxt requested-from"
20222022
msgstr "security.txt requested from {hostname}."
20232023

20242024
msgid "detail tech data http-securitytxt retrieved-from"
2025-
msgstr "security.txt retrieved from {hostname}."
2025+
msgstr "security.txt retrieved from {url}."
20262026

20272027
msgid "detail tech data http-securitytxt signed_format_issue"
20282028
msgstr ""

translations/nl/main.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ msgid "detail tech data http-securitytxt requested-from"
20412041
msgstr "security.txt opgevraagd van {hostname}."
20422042

20432043
msgid "detail tech data http-securitytxt retrieved-from"
2044-
msgstr "security.txt opgehaald van {hostname}."
2044+
msgstr "security.txt opgehaald van {url}."
20452045

20462046
msgid "detail tech data http-securitytxt signed_format_issue"
20472047
msgstr ""

0 commit comments

Comments
 (0)