Skip to content
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

Fix DeprecationWarnings #9113

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dojo/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import base64

Check warning on line 1 in dojo/models.py

View check run for this annotation

DryRunSecurity / Configured Sensitive Files Check

Sensitive File Edit

This file edit was detected to be sensitive according to the DryRun Security Configuration for this repository. Any edit to this file by an Author not in the allowedAuthors list will be considered sensitive.
import hashlib
import logging
import os
Expand Down Expand Up @@ -2563,7 +2563,7 @@

# Make sure that we have a cwe if we need one
if self.cwe == 0 and not self.test.hash_code_allows_null_cwe:
deduplicationLogger.warn(
deduplicationLogger.warning(
"Cannot compute hash_code based on configured fields because cwe is 0 for finding of title '" + self.title + "' found in file '" + str(self.file_path) +
"'. Fallback to legacy mode for this finding.")
return self.compute_hash_code_legacy()
Expand Down
24 changes: 0 additions & 24 deletions unittests/test_import_reimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ def test_zap_scan_base_active_verified(self):
# no notes expected
self.assertEqual(notes_count_before, self.db_notes_count())

return test_id

# import zap scan, testing:
# - import
# - active/verifed = False
Expand Down Expand Up @@ -179,8 +177,6 @@ def test_zap_scan_base_not_active_not_verified(self):
# no notes expected
self.assertEqual(notes_count_before, self.db_notes_count())

return test_id

# Test Scan_Date logic for Import. Reimport without a test_id cannot work for UI, so those tests are only in the API class below.

# import zap scan without dates
Expand All @@ -199,8 +195,6 @@ def test_import_default_scan_date_parser_not_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, str(timezone.localtime(timezone.now()).date()))

return test_id

# import acunetix scan with dates
# - import
# - no scan scan_date does not overrides date set by parser
Expand All @@ -217,8 +211,6 @@ def test_import_default_scan_date_parser_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, '2018-09-24')

return test_id

# import zap scan without dates
# - import
# - set scan_date overrides date not set by parser
Expand All @@ -235,8 +227,6 @@ def test_import_set_scan_date_parser_not_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, '2006-12-26')

return test_id

# import acunetix scan with dates
# - import
# - set scan_date overrides date set by parser
Expand All @@ -253,8 +243,6 @@ def test_import_set_scan_date_parser_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, '2006-12-26')

return test_id

# Test Scan_Date for reimport in UI. UI can only rupload for existing tests, non UI tests are in API class below

def test_import_reimport_no_scan_date_parser_no_date(self):
Expand Down Expand Up @@ -345,8 +333,6 @@ def test_sonar_detailed_scan_base_active_verified(self):
# no notes expected
self.assertEqual(notes_count_before, self.db_notes_count())

return test_id

# Test re-import with unique_id_from_tool_or_hash_code algorithm
# import veracode scan, testing:
# - import
Expand All @@ -368,8 +354,6 @@ def test_veracode_scan_base_active_verified(self):
# no notes expected
self.assertEqual(notes_count_before, self.db_notes_count())

return test_id

# import veracode and then reimport veracode again
# - reimport, findings stay the same, stay active
# - active = True, verified = True
Expand Down Expand Up @@ -1680,8 +1664,6 @@ def test_reimport_default_scan_date_parser_not_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, str(timezone.localtime(timezone.now()).date()))

return test_id

# reimport acunetix scan with dates (non existing test, so import is called inside DD)
# - reimport
# - deafult scan_date (today) does not overrides date set by parser
Expand All @@ -1699,8 +1681,6 @@ def test_reimport_default_scan_date_parser_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, '2018-09-24')

return test_id

# reimport zap scan without dates (non existing test, so import is called inside DD)
# - reimport
# - set scan_date overrides date not set by parser
Expand All @@ -1718,8 +1698,6 @@ def test_reimport_set_scan_date_parser_not_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, '2006-12-26')

return test_id

# reimport acunetix scan with dates (non existing test, so import is called inside DD)
# - reimport
# - set scan_date overrides date set by parser
Expand All @@ -1737,8 +1715,6 @@ def test_reimport_set_scan_date_parser_sets_date(self):
date = findings['results'][0]['date']
self.assertEqual(date, '2006-12-26')

return test_id


class ImportReimportTestUI(DojoAPITestCase, ImportReimportMixin):
fixtures = ['dojo_testdata.json']
Expand Down
22 changes: 0 additions & 22 deletions unittests/test_jira_import_and_pushing_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ def test_import_no_push_to_jira(self):
test_id = import0['test']
self.assert_jira_issue_count_in_test(test_id, 0)
self.assert_jira_group_issue_count_in_test(test_id, 0)
return test_id

def test_import_with_push_to_jira_is_false(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=False, verified=True)
test_id = import0['test']
self.assert_jira_issue_count_in_test(test_id, 0)
self.assert_jira_group_issue_count_in_test(test_id, 0)
return test_id

def test_import_with_push_to_jira(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=True, verified=True)
Expand All @@ -88,7 +86,6 @@ def test_import_with_push_to_jira(self):
self.assert_jira_group_issue_count_in_test(test_id, 0)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_groups_push_to_jira(self):
# 7 findings, 5 unique component_name+component_version
Expand All @@ -99,7 +96,6 @@ def test_import_with_groups_push_to_jira(self):
self.assert_jira_group_issue_count_in_test(test_id, 3)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_push_to_jira_epic_as_issue_type(self):
jira_instance = JIRA_Instance.objects.get(id=2)
Expand All @@ -113,7 +109,6 @@ def test_import_with_push_to_jira_epic_as_issue_type(self):
self.assert_jira_group_issue_count_in_test(test_id, 0)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_no_push_to_jira_but_push_all(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -123,7 +118,6 @@ def test_import_no_push_to_jira_but_push_all(self):
self.assert_jira_group_issue_count_in_test(test_id, 0)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_groups_no_push_to_jira_but_push_all(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -133,7 +127,6 @@ def test_import_with_groups_no_push_to_jira_but_push_all(self):
self.assert_jira_group_issue_count_in_test(test_id, 3)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_push_to_jira_is_false_but_push_all(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -143,7 +136,6 @@ def test_import_with_push_to_jira_is_false_but_push_all(self):
self.assert_jira_group_issue_count_in_test(test_id, 0)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_groups_with_push_to_jira_is_false_but_push_all(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -153,7 +145,6 @@ def test_import_with_groups_with_push_to_jira_is_false_but_push_all(self):
self.assert_jira_group_issue_count_in_test(test_id, 3)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_no_push_to_jira_reimport_no_push_to_jira(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, verified=True)
Expand All @@ -164,7 +155,6 @@ def test_import_no_push_to_jira_reimport_no_push_to_jira(self):
reimport = self.reimport_scan_with_params(test_id, self.zap_sample5_filename, verified=True)
self.assert_jira_issue_count_in_test(test_id, 0)
self.assert_jira_group_issue_count_in_test(test_id, 0)
return test_id

def test_import_no_push_to_jira_reimport_push_to_jira_false(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, verified=True)
Expand All @@ -175,7 +165,6 @@ def test_import_no_push_to_jira_reimport_push_to_jira_false(self):
reimport = self.reimport_scan_with_params(test_id, self.zap_sample5_filename, push_to_jira=False, verified=True)
self.assert_jira_issue_count_in_test(test_id, 0)
self.assert_jira_group_issue_count_in_test(test_id, 0)
return test_id

def test_import_no_push_to_jira_reimport_with_push_to_jira(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, verified=True)
Expand All @@ -188,7 +177,6 @@ def test_import_no_push_to_jira_reimport_with_push_to_jira(self):
self.assert_jira_group_issue_count_in_test(test_id, 0)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_groups_no_push_to_jira_reimport_with_push_to_jira(self):
import0 = self.import_scan_with_params(self.npm_groups_sample_filename, scan_type='NPM Audit Scan', group_by='component_name+component_version', verified=True)
Expand All @@ -201,7 +189,6 @@ def test_import_with_groups_no_push_to_jira_reimport_with_push_to_jira(self):
self.assert_jira_group_issue_count_in_test(test_id, 3)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_no_push_to_jira_reimport_no_push_to_jira_but_push_all_issues(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -215,7 +202,6 @@ def test_import_no_push_to_jira_reimport_no_push_to_jira_but_push_all_issues(sel
self.assert_jira_group_issue_count_in_test(test_id, 0)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_groups_no_push_to_jira_reimport_no_push_to_jira_but_push_all_issues(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -229,7 +215,6 @@ def test_import_with_groups_no_push_to_jira_reimport_no_push_to_jira_but_push_al
self.assert_jira_group_issue_count_in_test(test_id, 3)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_no_push_to_jira_reimport_push_to_jira_is_false_but_push_all_issues(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -246,7 +231,6 @@ def test_import_no_push_to_jira_reimport_push_to_jira_is_false_but_push_all_issu
# self.assert_jira_updated_map_changed(test_id, updated_map)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_with_groups_no_push_to_jira_reimport_push_to_jira_is_false_but_push_all_issues(self):
self.set_jira_push_all_issues(self.get_engagement(1))
Expand All @@ -264,7 +248,6 @@ def test_import_with_groups_no_push_to_jira_reimport_push_to_jira_is_false_but_p
self.assert_jira_updated_map_unchanged(test_id, updated_map)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_push_to_jira_reimport_with_push_to_jira(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=True, verified=True)
Expand All @@ -283,7 +266,6 @@ def test_import_push_to_jira_reimport_with_push_to_jira(self):
# self.assert_jira_updated_change(pre_jira_status, post_jira_status)
# by asserting full cassette is played we know issues have been updated in JIRA
self.assert_cassette_played()
return test_id

def test_import_twice_push_to_jira(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=True, verified=True)
Expand Down Expand Up @@ -492,7 +474,6 @@ def test_import_with_push_to_jira_add_comment(self):
self.assertEqual(len(self.get_jira_comments(finding_id)), 1)
# by asserting full cassette is played we know all calls to JIRA have been made as expected
self.assert_cassette_played()
return test_id

def test_import_add_comments_then_push_to_jira(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=False, verified=True)
Expand All @@ -512,7 +493,6 @@ def test_import_add_comments_then_push_to_jira(self):
self.assertEqual(len(self.get_jira_comments(finding_id)), 2)
# by asserting full cassette is played we know all calls to JIRA have been made as expected
self.assert_cassette_played()
return test_id

def test_import_with_push_to_jira_add_tags(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=True, verified=True)
Expand All @@ -538,7 +518,6 @@ def test_import_with_push_to_jira_add_tags(self):

# by asserting full cassette is played we know all calls to JIRA have been made as expected
self.assert_cassette_played()
return test_id

def test_import_with_push_to_jira_update_tags(self):
import0 = self.import_scan_with_params(self.zap_sample5_filename, push_to_jira=True, verified=True)
Expand Down Expand Up @@ -576,7 +555,6 @@ def test_import_with_push_to_jira_update_tags(self):

# by asserting full cassette is played we know all calls to JIRA have been made as expected
self.assert_cassette_played()
return test_id

def test_engagement_epic_creation(self):
eng = self.get_engagement(3)
Expand Down
2 changes: 1 addition & 1 deletion unittests/tools/test_stackhawk_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def __assertFindingEquals(
self.assertEqual(severity, actual_finding.severity)
self.assertEqual("View this finding in the StackHawk platform at:\n[" + finding_url + '](' + finding_url + ')',
actual_finding.description)
self.assertRegexpMatches(
self.assertRegex(
actual_finding.steps_to_reproduce,
"Use a specific message link and click 'Validate' to see the cURL!.*"
)
Expand Down