From b3b77aa706416233f834847169580664a0e73ec9 Mon Sep 17 00:00:00 2001 From: kiblik <5609770+kiblik@users.noreply.github.com> Date: Thu, 2 May 2024 12:35:06 +0200 Subject: [PATCH] Ruff: add and fix PIE --- dojo/endpoint/utils.py | 2 +- dojo/engagement/views.py | 5 ----- dojo/filters.py | 10 ---------- dojo/importers/base_importer.py | 1 - dojo/importers/options.py | 1 - dojo/jira_link/helper.py | 1 - dojo/models.py | 2 -- dojo/notifications/helper.py | 1 - dojo/okta.py | 1 - dojo/product/views.py | 3 +-- dojo/templatetags/display_tags.py | 2 +- dojo/tools/burp_enterprise/parser.py | 4 ++-- dojo/tools/jfrog_xray_unified/parser.py | 2 +- dojo/tools/qualys_webapp/parser.py | 4 ++-- dojo/tools/veracode/json_parser.py | 2 +- dojo/tools/veracode_sca/parser.py | 6 +++--- dojo/tools/xanitizer/parser.py | 1 - dojo/utils.py | 3 +-- ruff.toml | 1 + tests/close_old_findings_dedupe_test.py | 2 +- tests/dedupe_test.py | 2 +- 21 files changed, 16 insertions(+), 40 deletions(-) diff --git a/dojo/endpoint/utils.py b/dojo/endpoint/utils.py index dea5db9e07..e40de5c5e1 100644 --- a/dojo/endpoint/utils.py +++ b/dojo/endpoint/utils.py @@ -93,7 +93,7 @@ def endpoint_get_or_create(**kwargs): def clean_hosts_run(apps, change): def err_log(message, html_log, endpoint_html_log, endpoint): error_suffix = 'It is not possible to migrate it. Delete or edit this endpoint.' - html_log.append({**endpoint_html_log, **{'message': message}}) + html_log.append({**endpoint_html_log, 'message': message}) logger.error(f'Endpoint (id={endpoint.pk}) {message}. {error_suffix}') broken_endpoints.add(endpoint.pk) html_log = [] diff --git a/dojo/engagement/views.py b/dojo/engagement/views.py index f0c542e2d9..2fdc7e34a4 100644 --- a/dojo/engagement/views.py +++ b/dojo/engagement/views.py @@ -459,7 +459,6 @@ def get(self, request, eid, *args, **kwargs): check = Check_List.objects.get(engagement=eng) except: check = None - pass notes = eng.notes.all() note_type_activation = Note_Type.objects.filter(is_active=True).count() if note_type_activation: @@ -531,7 +530,6 @@ def post(self, request, eid, *args, **kwargs): check = Check_List.objects.get(engagement=eng) except: check = None - pass notes = eng.notes.all() note_type_activation = Note_Type.objects.filter(is_active=True).count() if note_type_activation: @@ -636,7 +634,6 @@ def add_tests(request, eid): new_test.lead = User.objects.get(id=form['lead'].value()) except: new_test.lead = None - pass # Set status to in progress if a test is added if eng.status != "In Progress" and eng.active is True: @@ -1152,7 +1149,6 @@ def complete_checklist(request, eid): checklist = Check_List.objects.get(engagement=eng) except: checklist = None - pass add_breadcrumb( parent=eng, @@ -1174,7 +1170,6 @@ def complete_checklist(request, eid): cl.engagement = eng cl.save() form.save_m2m() - pass messages.add_message( request, messages.SUCCESS, diff --git a/dojo/filters.py b/dojo/filters.py index 0b12cc3961..624ada0ad6 100644 --- a/dojo/filters.py +++ b/dojo/filters.py @@ -1995,14 +1995,6 @@ class Meta: exclude = ['description', 'mitigation', 'impact', 'references', 'numerical_severity'] - not_tags = ModelMultipleChoiceFilter( - field_name='tags__name', - to_field_name='name', - exclude=True, - queryset=Finding.tags.tag_model.objects.all().order_by('name'), - # label='tags', # doesn't work with tagulous, need to set in __init__ below - ) - not_test__tags = ModelMultipleChoiceFilter( field_name='test__tags__name', to_field_name='name', @@ -2030,8 +2022,6 @@ class Meta: # label='tags', # doesn't work with tagulous, need to set in __init__ below ) - not_tag = CharFilter(field_name='tags__name', lookup_expr='icontains', label='Not tag name contains', exclude=True) - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.form.fields['cwe'].choices = cwe_options(self.queryset) diff --git a/dojo/importers/base_importer.py b/dojo/importers/base_importer.py index b2ff46e8f1..9eee547b9c 100644 --- a/dojo/importers/base_importer.py +++ b/dojo/importers/base_importer.py @@ -49,7 +49,6 @@ def get_findings(scan_type: str, test: Test) -> List[Finding]: TODO This should be enforced in the future, but here is not the place TODO once this enforced, this stub class should be removed """ - pass class BaseImporter(ImporterOptions): diff --git a/dojo/importers/options.py b/dojo/importers/options.py index 52b291ecaf..5ae687085a 100644 --- a/dojo/importers/options.py +++ b/dojo/importers/options.py @@ -83,7 +83,6 @@ def load_additional_options( An added hook for loading additional options to be used by children classes for the BaseImporter """ - pass def log_translation( self, diff --git a/dojo/jira_link/helper.py b/dojo/jira_link/helper.py index 49525785af..638728267f 100644 --- a/dojo/jira_link/helper.py +++ b/dojo/jira_link/helper.py @@ -1534,7 +1534,6 @@ def process_jira_project_form(request, instance=None, target=None, product=None, except Exception as e: error = True logger.exception(e) - pass else: logger.debug(jform.errors) error = True diff --git a/dojo/models.py b/dojo/models.py index 5de06d4274..040ffbe3dd 100644 --- a/dojo/models.py +++ b/dojo/models.py @@ -3055,7 +3055,6 @@ def github_conf(self): github_conf = github_product_key.conf except: github_conf = None - pass return github_conf # newer version that can work with prefetching @@ -3064,7 +3063,6 @@ def github_conf_new(self): return self.test.engagement.product.github_pkey_set.all()[0].git_conf except: return None - pass @property def has_jira_issue(self): diff --git a/dojo/notifications/helper.py b/dojo/notifications/helper.py index c89d185554..0afb0d6b36 100644 --- a/dojo/notifications/helper.py +++ b/dojo/notifications/helper.py @@ -270,7 +270,6 @@ def send_msteams_notification(event, user=None, *args, **kwargs): except Exception as e: logger.exception(e) log_alert(e, "Microsoft Teams Notification", title=kwargs['title'], description=str(e), url=kwargs['url']) - pass @dojo_async_task diff --git a/dojo/okta.py b/dojo/okta.py index 47fa718de6..68934e1d5e 100644 --- a/dojo/okta.py +++ b/dojo/okta.py @@ -88,7 +88,6 @@ def validate_and_return_id_token(self, id_token, access_token): except JWTError: if k is None and client_id == 'a-key': k = self.get_jwks_keys()[0] - pass claims = jwt.decode( id_token, diff --git a/dojo/product/views.py b/dojo/product/views.py index 9a70751ae1..47d984c833 100644 --- a/dojo/product/views.py +++ b/dojo/product/views.py @@ -226,7 +226,7 @@ def view_product(request, pid): benchmark_type__enabled=True).order_by('benchmark_type__name') sla = SLA_Configuration.objects.filter(id=prod.sla_configuration_id).first() benchAndPercent = [] - for i in range(0, len(benchmarks)): + for i in range(len(benchmarks)): desired_level, total, total_pass, total_wait, total_fail, _total_viewed = asvs_calc_level(benchmarks[i]) success_percent = round((float(total_pass) / float(total)) * 100, 2) @@ -939,7 +939,6 @@ def edit_product(request, pid): github_inst = GITHUB_PKey.objects.get(product=product) except: github_inst = None - pass if request.method == 'POST': form = ProductForm(request.POST, instance=product) diff --git a/dojo/templatetags/display_tags.py b/dojo/templatetags/display_tags.py index ed224d1b70..d7df4559bd 100644 --- a/dojo/templatetags/display_tags.py +++ b/dojo/templatetags/display_tags.py @@ -484,7 +484,7 @@ def not_specified_icon(tooltip): def stars(filled, total, tooltip): code = '' - for i in range(0, total): + for i in range(total): if i < filled: code += '