Skip to content

Commit 3c4c866

Browse files
committed
Ruff: fix Q004
1 parent a574422 commit 3c4c866

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

dojo/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ class System_Settings(models.Model):
553553
default=True,
554554
blank=False,
555555
verbose_name=_("Password must contain one special character"),
556-
help_text=_("Requires user passwords to contain at least one special character (()[]{}|\\`~!@#$%^&*_-+=;:\'\",<>./?)."))
556+
help_text=_("Requires user passwords to contain at least one special character (()[]{}|\\`~!@#$%^&*_-+=;:'\",<>./?)."))
557557
lowercase_character_required = models.BooleanField(
558558
default=True,
559559
blank=False,

dojo/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2059,11 +2059,11 @@ def get_current_request():
20592059

20602060

20612061
def create_bleached_link(url, title):
2062-
link = '<a href=\"'
2062+
link = '<a href="'
20632063
link += url
2064-
link += '\" target=\"_blank\" title=\"'
2064+
link += '" target="_blank" title="'
20652065
link += title
2066-
link += '\">'
2066+
link += '">'
20672067
link += title
20682068
link += '</a>'
20692069
return bleach.clean(link, tags={'a'}, attributes={'a': ['href', 'target', 'title']})
@@ -2399,7 +2399,7 @@ def get_password_requirements_string():
23992399
if bool(get_system_setting('number_character_required')):
24002400
s += ', one number (0-9)'
24012401
if bool(get_system_setting('special_character_required')):
2402-
s += ', one special character (()[]{}|\\`~!@#$%^&*_-+=;:\'\",<>./?)'
2402+
s += ', one special character (()[]{}|\\`~!@#$%^&*_-+=;:\'",<>./?)'
24032403

24042404
if s.count(', ') == 1:
24052405
password_requirements_string = s.rsplit(', ', 1)[0] + ' and ' + s.rsplit(', ', 1)[1]

unittests/test_apiv2_endpoint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_endpoint_missing_host_product(self):
1919
"host": "FOO.BAR"
2020
}, format='json')
2121
self.assertEqual(r.status_code, 400, r.content[:1000])
22-
self.assertIn("Attribute \'product\' is required", r.content.decode("utf-8"))
22+
self.assertIn("Attribute 'product' is required", r.content.decode("utf-8"))
2323

2424
r = self.client.post(reverse('endpoint-list'), {
2525
"product": 1

unittests/test_finding_model.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_get_sast_source_file_path_with_link_and_source_code_management_uri(self
3030
finding.test = test
3131
finding.sast_source_file_path = 'SastSourceFilePath'
3232
engagement.source_code_management_uri = 'URL'
33-
self.assertEqual('<a href=\"URL/SastSourceFilePath\" target=\"_blank\" title=\"SastSourceFilePath\">SastSourceFilePath</a>', finding.get_sast_source_file_path_with_link())
33+
self.assertEqual('<a href="URL/SastSourceFilePath" target="_blank" title="SastSourceFilePath">SastSourceFilePath</a>', finding.get_sast_source_file_path_with_link())
3434

3535
def test_get_file_path_with_link_no_file_path(self):
3636
finding = Finding()
@@ -53,7 +53,7 @@ def test_get_file_path_with_link_and_source_code_management_uri(self):
5353
finding.test = test
5454
finding.file_path = 'FilePath'
5555
engagement.source_code_management_uri = 'URL'
56-
self.assertEqual('<a href=\"URL/FilePath\" target=\"_blank\" title=\"FilePath\">FilePath</a>', finding.get_file_path_with_link())
56+
self.assertEqual('<a href="URL/FilePath" target="_blank" title="FilePath">FilePath</a>', finding.get_file_path_with_link())
5757

5858
def test_get_file_path_with_link_and_source_code_management_uri_github_no_scm_type_with_details_and_line(self):
5959
# checks that for github.com in uri dojo makes correct url to browse on github
@@ -68,7 +68,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_github_no_scm_ty
6868
finding.file_path = 'some-folder/some-file.ext'
6969
finding.line = 5432
7070
engagement.source_code_management_uri = 'https://github.com/some-test-account/some-test-repo'
71-
self.assertEqual('<a href=\"https://github.com/some-test-account/some-test-repo/blob/some-commit-hash/some-folder/some-file.ext#L5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
71+
self.assertEqual('<a href="https://github.com/some-test-account/some-test-repo/blob/some-commit-hash/some-folder/some-file.ext#L5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
7272

7373
def test_get_file_path_with_link_and_source_code_management_uri_github_with_scm_type_with_details_and_line(self):
7474
# checks that for github in custom field dojo makes correct url to browse on github
@@ -92,7 +92,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_github_with_scm_
9292
finding.line = 5432
9393

9494
engagement.source_code_management_uri = 'https://github.com/some-test-account/some-test-repo'
95-
self.assertEqual('<a href=\"https://github.com/some-test-account/some-test-repo/blob/some-commit-hash/some-folder/some-file.ext#L5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
95+
self.assertEqual('<a href="https://github.com/some-test-account/some-test-repo/blob/some-commit-hash/some-folder/some-file.ext#L5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
9696

9797
def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_public_project_with_no_details_and_line(self):
9898
# checks that for public bitbucket (bitbucket.org) in custom field
@@ -115,7 +115,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_public
115115
finding.line = 5432
116116

117117
engagement.source_code_management_uri = 'https://bb.example.com/some-test-user/some-test-repo.git'
118-
self.assertEqual('<a href=\"https://bb.example.com/some-test-user/some-test-repo/src/master/some-folder/some-file.ext#lines-5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
118+
self.assertEqual('<a href="https://bb.example.com/some-test-user/some-test-repo/src/master/some-folder/some-file.ext#lines-5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
119119

120120
def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_public_project_with_commithash_and_line(self):
121121
# checks that for public bitbucket (bitbucket.org) in custom field and existing commit hash in finding
@@ -139,7 +139,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_public
139139
finding.line = 5432
140140

141141
engagement.source_code_management_uri = 'https://bb.example.com/some-test-user/some-test-repo.git'
142-
self.assertEqual('<a href=\"https://bb.example.com/some-test-user/some-test-repo/src/some-commit-hash/some-folder/some-file.ext#lines-5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
142+
self.assertEqual('<a href="https://bb.example.com/some-test-user/some-test-repo/src/some-commit-hash/some-folder/some-file.ext#lines-5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
143143

144144
def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_standalone_project_with_commithash_and_line(self):
145145
# checks that for standalone bitbucket in custom field and existing commit hash in finding
@@ -163,7 +163,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_standa
163163
finding.line = 5432
164164

165165
engagement.source_code_management_uri = 'https://bb.example.com/scm/some-test-project/some-test-repo.git'
166-
self.assertEqual('<a href=\"https://bb.example.com/projects/some-test-project/repos/some-test-repo/browse/some-folder/some-file.ext?at=some-commit-hash#5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
166+
self.assertEqual('<a href="https://bb.example.com/projects/some-test-project/repos/some-test-repo/browse/some-folder/some-file.ext?at=some-commit-hash#5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
167167

168168
def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_standalone_project_with_branchtag_and_line(self):
169169
# checks that for standalone bitbucket in custom field and existing branch/tag in finding
@@ -187,7 +187,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_standa
187187
finding.line = 5432
188188

189189
engagement.source_code_management_uri = 'https://bb.example.com/scm/some-test-project/some-test-repo.git'
190-
self.assertEqual('<a href=\"https://bb.example.com/projects/some-test-project/repos/some-test-repo/browse/some-folder/some-file.ext?at=some-branch#5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
190+
self.assertEqual('<a href="https://bb.example.com/projects/some-test-project/repos/some-test-repo/browse/some-folder/some-file.ext?at=some-branch#5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
191191

192192
def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_standalone_user_with_branchtag_and_line(self):
193193
# checks that for standalone bitbucket in custom field and existing branch/tag in finding
@@ -212,7 +212,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_bitbucket_standa
212212

213213
engagement.source_code_management_uri = 'https://bb.example.com/scm/~some-user/some-test-repo.git'
214214

215-
self.assertEqual('<a href=\"https://bb.example.com/users/some-user/repos/some-test-repo/browse/some-folder/some-file.ext?at=some-branch#5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
215+
self.assertEqual('<a href="https://bb.example.com/users/some-user/repos/some-test-repo/browse/some-folder/some-file.ext?at=some-branch#5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
216216

217217
def test_get_file_path_with_link_and_source_code_management_uri_gitea_or_codeberg_project_with_no_details_and_line(self):
218218
# checks that for gitea and codeberg in custom field
@@ -235,7 +235,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_gitea_or_codeber
235235
finding.line = 5432
236236

237237
engagement.source_code_management_uri = 'https://bb.example.com/some-test-user/some-test-repo.git'
238-
self.assertEqual('<a href=\"https://bb.example.com/some-test-user/some-test-repo/src/master/some-folder/some-file.ext#L5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
238+
self.assertEqual('<a href="https://bb.example.com/some-test-user/some-test-repo/src/master/some-folder/some-file.ext#L5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
239239

240240
def test_get_file_path_with_link_and_source_code_management_uri_gitea_or_codeberg_project_with_commithash_and_line(self):
241241
# checks that for gitea and codeberg in custom field and existing commit hash in finding
@@ -259,7 +259,7 @@ def test_get_file_path_with_link_and_source_code_management_uri_gitea_or_codeber
259259
finding.line = 5432
260260

261261
engagement.source_code_management_uri = 'https://bb.example.com/some-test-user/some-test-repo.git'
262-
self.assertEqual('<a href=\"https://bb.example.com/some-test-user/some-test-repo/src/some-commit-hash/some-folder/some-file.ext#L5432" target=\"_blank\" title=\"some-folder/some-file.ext\">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
262+
self.assertEqual('<a href="https://bb.example.com/some-test-user/some-test-repo/src/some-commit-hash/some-folder/some-file.ext#L5432" target="_blank" title="some-folder/some-file.ext">some-folder/some-file.ext</a>', finding.get_file_path_with_link())
263263

264264
def test_get_file_path_with_xss_attack(self):
265265
test = Test()
@@ -283,32 +283,32 @@ def test_get_references_with_links_no_links(self):
283283
def test_get_references_with_links_simple_url(self):
284284
finding = Finding()
285285
finding.references = 'URL: https://www.example.com'
286-
self.assertEqual('URL: <a href=\"https://www.example.com\" target=\"_blank\" title=\"https://www.example.com\">https://www.example.com</a>', finding.get_references_with_links())
286+
self.assertEqual('URL: <a href="https://www.example.com" target="_blank" title="https://www.example.com">https://www.example.com</a>', finding.get_references_with_links())
287287

288288
def test_get_references_with_links_url_with_port(self):
289289
finding = Finding()
290290
finding.references = 'http://www.example.com:8080'
291-
self.assertEqual('<a href=\"http://www.example.com:8080\" target=\"_blank\" title=\"http://www.example.com:8080\">http://www.example.com:8080</a>', finding.get_references_with_links())
291+
self.assertEqual('<a href="http://www.example.com:8080" target="_blank" title="http://www.example.com:8080">http://www.example.com:8080</a>', finding.get_references_with_links())
292292

293293
def test_get_references_with_links_url_with_path(self):
294294
finding = Finding()
295295
finding.references = 'URL https://www.example.com/path/part2 behind URL'
296-
self.assertEqual('URL <a href=\"https://www.example.com/path/part2\" target=\"_blank\" title=\"https://www.example.com/path/part2\">https://www.example.com/path/part2</a> behind URL', finding.get_references_with_links())
296+
self.assertEqual('URL <a href="https://www.example.com/path/part2" target="_blank" title="https://www.example.com/path/part2">https://www.example.com/path/part2</a> behind URL', finding.get_references_with_links())
297297

298298
def test_get_references_with_links_complicated_url_with_parameter(self):
299299
finding = Finding()
300300
finding.references = 'URL:https://www.example.com/path?param1=abc&_param2=xyz'
301-
self.assertEqual('URL:<a href=\"https://www.example.com/path?param1=abc&amp;_param2=xyz\" target=\"_blank\" title=\"https://www.example.com/path?param1=abc&amp;_param2=xyz\">https://www.example.com/path?param1=abc&amp;_param2=xyz</a>', finding.get_references_with_links())
301+
self.assertEqual('URL:<a href="https://www.example.com/path?param1=abc&amp;_param2=xyz" target="_blank" title="https://www.example.com/path?param1=abc&amp;_param2=xyz">https://www.example.com/path?param1=abc&amp;_param2=xyz</a>', finding.get_references_with_links())
302302

303303
def test_get_references_with_links_two_urls(self):
304304
finding = Finding()
305305
finding.references = 'URL1: https://www.example.com URL2: https://info.example.com'
306-
self.assertEqual('URL1: <a href=\"https://www.example.com\" target=\"_blank\" title=\"https://www.example.com\">https://www.example.com</a> URL2: <a href=\"https://info.example.com\" target=\"_blank\" title=\"https://info.example.com\">https://info.example.com</a>', finding.get_references_with_links())
306+
self.assertEqual('URL1: <a href="https://www.example.com" target="_blank" title="https://www.example.com">https://www.example.com</a> URL2: <a href="https://info.example.com" target="_blank" title="https://info.example.com">https://info.example.com</a>', finding.get_references_with_links())
307307

308308
def test_get_references_with_links_linebreak(self):
309309
finding = Finding()
310310
finding.references = 'https://www.example.com\nhttps://info.example.com'
311-
self.assertEqual('<a href=\"https://www.example.com\" target=\"_blank\" title=\"https://www.example.com\">https://www.example.com</a>\n<a href=\"https://info.example.com\" target=\"_blank\" title=\"https://info.example.com\">https://info.example.com</a>', finding.get_references_with_links())
311+
self.assertEqual('<a href="https://www.example.com" target="_blank" title="https://www.example.com">https://www.example.com</a>\n<a href="https://info.example.com" target="_blank" title="https://info.example.com">https://info.example.com</a>', finding.get_references_with_links())
312312

313313
def test_get_references_with_links_markdown(self):
314314
finding = Finding()

0 commit comments

Comments
 (0)