diff --git a/dojo/api_v2/permissions.py b/dojo/api_v2/permissions.py index fe508c92b1b..824b96beb51 100644 --- a/dojo/api_v2/permissions.py +++ b/dojo/api_v2/permissions.py @@ -40,20 +40,20 @@ def check_post_permission(request, post_model, post_pk, post_permission): def check_object_permission( request, - object, + obj, get_permission, put_permission, delete_permission, post_permission=None, ): if request.method == "GET": - return user_has_permission(request.user, object, get_permission) + return user_has_permission(request.user, obj, get_permission) if request.method == "PUT" or request.method == "PATCH": - return user_has_permission(request.user, object, put_permission) + return user_has_permission(request.user, obj, put_permission) if request.method == "DELETE": - return user_has_permission(request.user, object, delete_permission) + return user_has_permission(request.user, obj, delete_permission) if request.method == "POST": - return user_has_permission(request.user, object, post_permission) + return user_has_permission(request.user, obj, post_permission) return False diff --git a/dojo/api_v2/views.py b/dojo/api_v2/views.py index 90fe948b32c..3c897808ef0 100644 --- a/dojo/api_v2/views.py +++ b/dojo/api_v2/views.py @@ -2433,7 +2433,7 @@ class UserProfileView(GenericAPIView): @action( detail=True, methods=["get"], filter_backends=[], pagination_class=None, ) - def get(self, request, format=None): + def get(self, request, _=None): user = get_current_user() user_contact_info = ( user.usercontactinfo if hasattr(user, "usercontactinfo") else None diff --git a/dojo/benchmark/views.py b/dojo/benchmark/views.py index 611c690945d..eaebbe06e23 100644 --- a/dojo/benchmark/views.py +++ b/dojo/benchmark/views.py @@ -191,16 +191,16 @@ def score_asvs(product, benchmark_type): @user_is_authorized(Product, Permissions.Benchmark_Edit, "pid") -def benchmark_view(request, pid, type, cat=None): +def benchmark_view(request, pid, benchmark_type, cat=None): product = get_object_or_404(Product, id=pid) - benchmark_type = get_object_or_404(Benchmark_Type, id=type) + benchmark_type = get_object_or_404(Benchmark_Type, id=benchmark_type) benchmark_category = Benchmark_Category.objects.filter( - type=type, enabled=True, + type=benchmark_type, enabled=True, ).order_by("name") # Add requirements to the product new_benchmarks = Benchmark_Requirement.objects.filter( - category__type=type, category__type__enabled=True, enabled=True, + category__type=benchmark_type, category__type__enabled=True, enabled=True, ).exclude( id__in=Benchmark_Product.objects.filter(product=product).values_list( "control_id", flat=True, @@ -290,10 +290,10 @@ def benchmark_view(request, pid, type, cat=None): @user_is_authorized(Product, Permissions.Benchmark_Delete, "pid") -def delete(request, pid, type): +def delete(request, pid, benchmark_type): product = get_object_or_404(Product, id=pid) benchmark_product_summary = Benchmark_Product_Summary.objects.filter( - product=product, benchmark_type=type, + product=product, benchmark_type=benchmark_type, ).first() form = DeleteBenchmarkForm(instance=benchmark_product_summary) @@ -307,7 +307,7 @@ def delete(request, pid, type): ) if form.is_valid(): benchmark_product = Benchmark_Product.objects.filter( - product=product, control__category__type=type, + product=product, control__category__type=benchmark_type, ) benchmark_product.delete() benchmark_product_summary.delete() diff --git a/dojo/cred/views.py b/dojo/cred/views.py index e79dc6c6b16..1569de8a93f 100644 --- a/dojo/cred/views.py +++ b/dojo/cred/views.py @@ -583,7 +583,7 @@ def new_cred_finding(request, fid): @user_is_authorized(Cred_User, Permissions.Credential_Delete, "ttid") -def delete_cred_controller(request, destination_url, id, ttid): +def delete_cred_controller(request, destination_url, elem_id, ttid): cred = Cred_Mapping.objects.filter(pk=ttid).first() if request.method == "POST": tform = CredMappingForm(request.POST, instance=cred) @@ -637,23 +637,23 @@ def delete_cred_controller(request, destination_url, id, ttid): if destination_url == "cred": return HttpResponseRedirect(reverse(destination_url)) - return HttpResponseRedirect(reverse(destination_url, args=(id, ))) + return HttpResponseRedirect(reverse(destination_url, args=(elem_id, ))) tform = CredMappingForm(instance=cred) add_breadcrumb(title="Delete Credential", top_level=False, request=request) product_tab = None - if id: + if elem_id: product = None if destination_url == "all_cred_product": - product = get_object_or_404(Product, id=id) + product = get_object_or_404(Product, id=elem_id) elif destination_url == "view_engagement": - engagement = get_object_or_404(Engagement, id=id) + engagement = get_object_or_404(Engagement, id=elem_id) product = engagement.product elif destination_url == "view_test": - test = get_object_or_404(Test, id=id) + test = get_object_or_404(Test, id=elem_id) product = test.engagement.product elif destination_url == "view_finding": - finding = get_object_or_404(Finding, id=id) + finding = get_object_or_404(Finding, id=elem_id) product = finding.test.engagement.product product_tab = Product_Tab(product, title="Delete Credential Mapping", tab="settings") return render(request, "dojo/delete_cred_all.html", { diff --git a/dojo/engagement/views.py b/dojo/engagement/views.py index 3b515c7468a..e804144f6f0 100644 --- a/dojo/engagement/views.py +++ b/dojo/engagement/views.py @@ -1540,9 +1540,9 @@ def engagement_ics(request, eid): return response -def get_list_index(list, index): +def get_list_index(full_list, index): try: - element = list[index] + element = full_list[index] except Exception: element = None return element diff --git a/dojo/jira_link/helper.py b/dojo/jira_link/helper.py index a557a05a3c1..b336644095f 100644 --- a/dojo/jira_link/helper.py +++ b/dojo/jira_link/helper.py @@ -751,7 +751,7 @@ def prepare_jira_issue_fields( def add_jira_issue(obj, *args, **kwargs): - def failure_to_add_message(message: str, exception: Exception, object: Any) -> bool: + def failure_to_add_message(message: str, exception: Exception, _: Any) -> bool: if exception: logger.exception(exception) logger.error(message) diff --git a/dojo/management/commands/test_celery_decorator.py b/dojo/management/commands/test_celery_decorator.py index da47f147702..ed9488541fa 100644 --- a/dojo/management/commands/test_celery_decorator.py +++ b/dojo/management/commands/test_celery_decorator.py @@ -49,8 +49,8 @@ def handle(self, *args, **options): # the outside decorator only outside -def test2(clazz, id): - model = clazz.objects.get(id=id) +def test2(clazz, clazz_id): + model = clazz.objects.get(id=clazz_id) logger.debug(model) diff --git a/dojo/notes/views.py b/dojo/notes/views.py index 6dfca7895d1..d5812d17d52 100644 --- a/dojo/notes/views.py +++ b/dojo/notes/views.py @@ -20,8 +20,8 @@ logger = logging.getLogger(__name__) -def delete_note(request, id, page, objid): - note = get_object_or_404(Notes, id=id) +def delete_note(request, note_id, page, objid): + note = get_object_or_404(Notes, id=note_id) reverse_url = None object_id = None @@ -64,8 +64,8 @@ def delete_note(request, id, page, objid): return HttpResponseRedirect(reverse(reverse_url, args=(object_id, ))) -def edit_note(request, id, page, objid): - note = get_object_or_404(Notes, id=id) +def edit_note(request, note_id, page, objid): + note = get_object_or_404(Notes, id=note_id) reverse_url = None object_id = None @@ -142,8 +142,8 @@ def edit_note(request, id, page, objid): }) -def note_history(request, id, page, objid): - note = get_object_or_404(Notes, id=id) +def note_history(request, elem_id, page, objid): + note = get_object_or_404(Notes, id=elem_id) reverse_url = None object_id = None diff --git a/dojo/reports/views.py b/dojo/reports/views.py index c57931df109..3307d432c11 100644 --- a/dojo/reports/views.py +++ b/dojo/reports/views.py @@ -650,9 +650,9 @@ def prefetch_related_endpoints_for_report(endpoints): ) -def get_list_index(list, index): +def get_list_index(full_list, index): try: - element = list[index] + element = full_list[index] except Exception: element = None return element diff --git a/dojo/settings/settings.dist.py b/dojo/settings/settings.dist.py index c8320e0bff4..e9076e75074 100644 --- a/dojo/settings/settings.dist.py +++ b/dojo/settings/settings.dist.py @@ -901,10 +901,10 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param # https://djangosaml2.readthedocs.io/contents/setup.html#users-attributes-and-account-linking -def saml2_attrib_map_format(dict): +def saml2_attrib_map_format(din): dout = {} - for i in dict: - dout[i] = (dict[i],) + for i in din: + dout[i] = (din[i],) return dout diff --git a/dojo/templatetags/display_tags.py b/dojo/templatetags/display_tags.py index 94bcf80d6e5..715fd70fefb 100644 --- a/dojo/templatetags/display_tags.py +++ b/dojo/templatetags/display_tags.py @@ -579,9 +579,9 @@ def internet_accessible_icon(value): @register.filter -def get_severity_count(id, table): - if table == "test": - counts = Finding.objects.filter(test=id). \ +def get_severity_count(elem_id, table_type): + if table_type == "test": + counts = Finding.objects.filter(test=elem_id). \ prefetch_related("test__engagement__product").aggregate( total=Sum( Case(When(severity__in=("Critical", "High", "Medium", "Low"), @@ -608,8 +608,8 @@ def get_severity_count(id, table): then=Value(1)), output_field=IntegerField())), ) - elif table == "engagement": - counts = Finding.objects.filter(test__engagement=id, active=True, duplicate=False). \ + elif table_type == "engagement": + counts = Finding.objects.filter(test__engagement=elem_id, active=True, duplicate=False). \ prefetch_related("test__engagement__product").aggregate( total=Sum( Case(When(severity__in=("Critical", "High", "Medium", "Low"), @@ -636,8 +636,8 @@ def get_severity_count(id, table): then=Value(1)), output_field=IntegerField())), ) - elif table == "product": - counts = Finding.objects.filter(test__engagement__product=id). \ + elif table_type == "product": + counts = Finding.objects.filter(test__engagement__product=elem_id). \ prefetch_related("test__engagement__product").aggregate( total=Sum( Case(When(severity__in=("Critical", "High", "Medium", "Low"), @@ -695,9 +695,9 @@ def get_severity_count(id, table): "Info: " + str(info), )) - if table == "test": + if table_type == "test": display_counts.append("Total: " + str(total) + " Findings") - elif table == "engagement" or table == "product": + elif table_type == "engagement" or table_type == "product": display_counts.append("Total: " + str(total) + " Active Findings") return ", ".join([str(item) for item in display_counts]) diff --git a/dojo/tools/awssecurityhub/parser.py b/dojo/tools/awssecurityhub/parser.py index 94041a6bc14..84d3ae8aa75 100644 --- a/dojo/tools/awssecurityhub/parser.py +++ b/dojo/tools/awssecurityhub/parser.py @@ -31,7 +31,7 @@ def get_tests(self, scan_type, scan): aws_acc.append(finding.get("AwsAccountId", "No Account Found")) report_date = data.get("createdAt") test = ParserTest( - name=self.ID, type=self.ID, version="", + name=self.ID, parser_type=self.ID, version="", ) test.description = "**AWS Accounts:** " + ", ".join(set(aws_acc)) + "\n" test.description += "**Finding Origins:** " + ", ".join(set(prod)) + "\n" diff --git a/dojo/tools/deepfence_threatmapper/compliance.py b/dojo/tools/deepfence_threatmapper/compliance.py index 3e0ebb9172c..71c22d133ef 100644 --- a/dojo/tools/deepfence_threatmapper/compliance.py +++ b/dojo/tools/deepfence_threatmapper/compliance.py @@ -41,10 +41,10 @@ def get_findings(self, row, headers, test): test=test, ) - def compliance_severity(self, input): - if input == "pass" or input == "info": + def compliance_severity(self, severity_input): + if severity_input == "pass" or severity_input == "info": output = "Info" - elif input == "warn": + elif severity_input == "warn": output = "Medium" else: output = "Info" diff --git a/dojo/tools/deepfence_threatmapper/malware.py b/dojo/tools/deepfence_threatmapper/malware.py index f764a2ce4b0..a1defd18401 100644 --- a/dojo/tools/deepfence_threatmapper/malware.py +++ b/dojo/tools/deepfence_threatmapper/malware.py @@ -31,7 +31,7 @@ def get_findings(self, row, headers, test): test=test, ) - def severity(self, input): - if input is None: + def severity(self, severity_input): + if severity_input is None: return "Info" - return input.capitalize() + return severity_input.capitalize() diff --git a/dojo/tools/deepfence_threatmapper/secret.py b/dojo/tools/deepfence_threatmapper/secret.py index 2eae14bc76b..3d9f2584149 100644 --- a/dojo/tools/deepfence_threatmapper/secret.py +++ b/dojo/tools/deepfence_threatmapper/secret.py @@ -35,7 +35,7 @@ def get_findings(self, row, headers, test): finding = None return finding - def severity(self, input): - if input is None: + def severity(self, severity_input): + if severity_input is None: return "Info" - return input.capitalize() + return severity_input.capitalize() diff --git a/dojo/tools/deepfence_threatmapper/vulnerability.py b/dojo/tools/deepfence_threatmapper/vulnerability.py index b76505613af..3539518177b 100644 --- a/dojo/tools/deepfence_threatmapper/vulnerability.py +++ b/dojo/tools/deepfence_threatmapper/vulnerability.py @@ -42,7 +42,7 @@ def get_findings(self, row, headers, test): test=test, ) - def severity(self, input): - if input is None: + def severity(self, severity_input): + if severity_input is None: return "Info" - return input.capitalize() + return severity_input.capitalize() diff --git a/dojo/tools/generic/csv_parser.py b/dojo/tools/generic/csv_parser.py index 9c11133ff59..b3e9535ff3a 100644 --- a/dojo/tools/generic/csv_parser.py +++ b/dojo/tools/generic/csv_parser.py @@ -108,7 +108,7 @@ def _get_findings_csv(self, filename): def _convert_bool(self, val): return val.lower()[0:1] == "t" # bool False by default - def get_severity(self, input): - if input in ["Info", "Low", "Medium", "High", "Critical"]: - return input + def get_severity(self, severity_input): + if severity_input in ["Info", "Low", "Medium", "High", "Critical"]: + return severity_input return "Info" diff --git a/dojo/tools/generic/json_parser.py b/dojo/tools/generic/json_parser.py index e1d86eaaa6d..016c77b6bee 100644 --- a/dojo/tools/generic/json_parser.py +++ b/dojo/tools/generic/json_parser.py @@ -12,7 +12,7 @@ class GenericJSONParser: def _get_test_json(self, data): test_internal = ParserTest( name=data.get("name", self.ID), - type=data.get("type", self.ID), + parser_type=data.get("type", self.ID), version=data.get("version"), ) test_internal.findings = [] diff --git a/dojo/tools/generic/parser.py b/dojo/tools/generic/parser.py index cf03d9753bc..13504dfa874 100644 --- a/dojo/tools/generic/parser.py +++ b/dojo/tools/generic/parser.py @@ -30,7 +30,7 @@ def get_findings(self, filename, test): def get_tests(self, scan_type, filename): # if the file is a CSV just use the old function if filename.name.lower().endswith(".csv"): - test = ParserTest(name=self.ID, type=self.ID, version=None) + test = ParserTest(name=self.ID, parser_type=self.ID, version=None) test.findings = GenericCSVParser()._get_findings_csv(filename) return [test] # we manage it like a JSON file (default) diff --git a/dojo/tools/gitlab_sast/parser.py b/dojo/tools/gitlab_sast/parser.py index 1e8aa3fa00f..cf59750f334 100644 --- a/dojo/tools/gitlab_sast/parser.py +++ b/dojo/tools/gitlab_sast/parser.py @@ -37,7 +37,7 @@ def get_tests(self, scan_type, handle): test = ParserTest( name=scanner_name, - type=scanner_type, + parser_type=scanner_type, version=scanner_version, ) test.findings = self.get_items(tree) diff --git a/dojo/tools/hcl_appscan/parser.py b/dojo/tools/hcl_appscan/parser.py index 268e041a80a..7820ed15045 100644 --- a/dojo/tools/hcl_appscan/parser.py +++ b/dojo/tools/hcl_appscan/parser.py @@ -15,15 +15,15 @@ def get_label_for_scan_types(self, scan_type): def get_description_for_scan_types(self, scan_type): return "Import XML output of HCL AppScan." - def xmltreehelper(self, input): - if input.text is None: + def xmltreehelper(self, xml_input): + if xml_input.text is None: output = None - elif "\n" in input.text: + elif "\n" in xml_input.text: output = "" - for i in input: + for i in xml_input: output = output + " " + i.text else: - output = " " + input.text + output = " " + xml_input.text return output def get_findings(self, file, test): diff --git a/dojo/tools/hcl_asoc_sast/parser.py b/dojo/tools/hcl_asoc_sast/parser.py index 538cd785838..b38051f27fc 100644 --- a/dojo/tools/hcl_asoc_sast/parser.py +++ b/dojo/tools/hcl_asoc_sast/parser.py @@ -15,15 +15,15 @@ def get_label_for_scan_types(self, scan_type): def get_description_for_scan_types(self, scan_type): return "Import XML output of HCL AppScan on Cloud SAST" - def xmltreehelper(self, input): - if input.text is None: + def xmltreehelper(self, xml_input): + if xml_input.text is None: output = None - elif "\n" in input.text: + elif "\n" in xml_input.text: output = "" - for i in input: + for i in xml_input: output = output + " " + i.text else: - output = " " + input.text + output = " " + xml_input.text return output def get_findings(self, file, test): diff --git a/dojo/tools/horusec/parser.py b/dojo/tools/horusec/parser.py index ed6c8eef033..f1f08865d3c 100644 --- a/dojo/tools/horusec/parser.py +++ b/dojo/tools/horusec/parser.py @@ -41,7 +41,7 @@ def get_tests(self, scan_type, scan): data = json.load(scan) report_date = parse(data.get("createdAt")) test = ParserTest( - name=self.ID, type=self.ID, version=data.get("version").lstrip("v"), + name=self.ID, parser_type=self.ID, version=data.get("version").lstrip("v"), ) # remove the v in vX.Y.Z test.description = "\n".join( [ diff --git a/dojo/tools/kubeaudit/parser.py b/dojo/tools/kubeaudit/parser.py index 3349afa1d87..26638bd6a2f 100644 --- a/dojo/tools/kubeaudit/parser.py +++ b/dojo/tools/kubeaudit/parser.py @@ -13,12 +13,12 @@ def get_label_for_scan_types(self, scan_type): def get_description_for_scan_types(self, scan_type): return "Import JSON reports of Kubeaudit Scans." - def severity_mapping(self, input): - if input == "warning": + def severity_mapping(self, severity_input): + if severity_input == "warning": severity = "Medium" - elif input == "error": + elif severity_input == "error": severity = "High" - elif input == "info": + elif severity_input == "info": severity = "Info" else: severity = "Low" diff --git a/dojo/tools/kubescape/parser.py b/dojo/tools/kubescape/parser.py index 53140f30584..e7fcfbce414 100644 --- a/dojo/tools/kubescape/parser.py +++ b/dojo/tools/kubescape/parser.py @@ -26,14 +26,14 @@ def find_control_summary_by_id(self, data, control_id): def __hyperlink(link: str) -> str: return "[" + link + "](" + link + ")" - def severity_mapper(self, input): - if input <= 4: + def severity_mapper(self, severity_input): + if severity_input <= 4: return "Low" - if input <= 7: + if severity_input <= 7: return "Medium" - if input <= 9: + if severity_input <= 9: return "High" - if input <= 10: + if severity_input <= 10: return "Critical" return None diff --git a/dojo/tools/ms_defender/parser.py b/dojo/tools/ms_defender/parser.py index 55a5d95ef47..75589a02cad 100644 --- a/dojo/tools/ms_defender/parser.py +++ b/dojo/tools/ms_defender/parser.py @@ -137,7 +137,7 @@ def process_zip(self, vulnerability, machine): if machine["lastExternalIpAddress"] is not None: finding.unsaved_endpoints.append(Endpoint(host=str(machine["lastExternalIpAddress"]))) - def severity_check(self, input): - if input in ["Informational", "Low", "Medium", "High", "Critical"]: - return input + def severity_check(self, severity_input): + if severity_input in ["Informational", "Low", "Medium", "High", "Critical"]: + return severity_input return "Informational" diff --git a/dojo/tools/osv_scanner/parser.py b/dojo/tools/osv_scanner/parser.py index b79b4e6c5a2..e5556ac3ccf 100644 --- a/dojo/tools/osv_scanner/parser.py +++ b/dojo/tools/osv_scanner/parser.py @@ -14,8 +14,8 @@ def get_label_for_scan_types(self, scan_type): def get_description_for_scan_types(self, scan_type): return "OSV scan output can be imported in JSON format (option --format json)." - def classify_severity(self, input): - return ("Medium" if input == "MODERATE" else input.lower().capitalize()) if input != "" else "Low" + def classify_severity(self, severity_input): + return ("Medium" if severity_input == "MODERATE" else severity_input.lower().capitalize()) if severity_input != "" else "Low" def get_findings(self, file, test): try: diff --git a/dojo/tools/parser_test.py b/dojo/tools/parser_test.py index 6a28a08998c..24330f5a5be 100644 --- a/dojo/tools/parser_test.py +++ b/dojo/tools/parser_test.py @@ -1,6 +1,6 @@ class ParserTest: - def __init__(self, name: str, type: str, version: str): + def __init__(self, name: str, parser_type: str, version: str): self.name = name - self.type = type + self.type = parser_type self.version = version self.description = None diff --git a/dojo/tools/ptart/parser.py b/dojo/tools/ptart/parser.py index c52ebf4fb49..8b43919f1e9 100644 --- a/dojo/tools/ptart/parser.py +++ b/dojo/tools/ptart/parser.py @@ -27,7 +27,7 @@ def get_tests(self, scan_type, scan): test = ParserTest( name="Pen Test Report", - type="Pen Test", + parser_type="Pen Test", version="", ) diff --git a/dojo/tools/ptart/ptart_parser_tools.py b/dojo/tools/ptart/ptart_parser_tools.py index be5f0f2559b..4fee9874df3 100644 --- a/dojo/tools/ptart/ptart_parser_tools.py +++ b/dojo/tools/ptart/ptart_parser_tools.py @@ -43,9 +43,9 @@ def parse_date_added_from_hit(hit): return parse_date(date_added, PTART_DATETIME_FORMAT) -def parse_date(date, format): +def parse_date(date, date_format): try: - return datetime.strptime(date, format) if date else datetime.now() + return datetime.strptime(date, date_format) if date else datetime.now() except ValueError: return datetime.now() diff --git a/dojo/tools/redhatsatellite/parser.py b/dojo/tools/redhatsatellite/parser.py index 897273d8a18..73ef7f6b085 100644 --- a/dojo/tools/redhatsatellite/parser.py +++ b/dojo/tools/redhatsatellite/parser.py @@ -13,14 +13,14 @@ def get_label_for_scan_types(self, scan_type): def get_description_for_scan_types(self, scan_type): return "JSON Output of Red Hat Satellite." - def severity_mapping(self, input): - if input == "Critical": + def severity_mapping(self, severity_input): + if severity_input == "Critical": severity = "Critical" - elif input == "Important": + elif severity_input == "Important": severity = "High" - elif input == "Moderate": + elif severity_input == "Moderate": severity = "Medium" - elif input == "Low": + elif severity_input == "Low": severity = "Low" else: severity = "Low" @@ -73,7 +73,7 @@ def get_findings(self, filename, test): title=title, test=test, description=description, - severity=self.severity_mapping(input=severity), + severity=self.severity_mapping(severity_input=severity), mitigation=solution, dynamic_finding=True, ) diff --git a/dojo/tools/rusty_hog/parser.py b/dojo/tools/rusty_hog/parser.py index a4582106f0d..90df52e6a76 100644 --- a/dojo/tools/rusty_hog/parser.py +++ b/dojo/tools/rusty_hog/parser.py @@ -56,7 +56,7 @@ def get_tests(self, scan_type, handle): break test = ParserTest( name=parsername, - type=parsername, + parser_type=parsername, version="", ) if ( diff --git a/dojo/tools/sarif/parser.py b/dojo/tools/sarif/parser.py index 4c539583564..81ecde76821 100644 --- a/dojo/tools/sarif/parser.py +++ b/dojo/tools/sarif/parser.py @@ -46,7 +46,7 @@ def get_tests(self, scan_type, handle): for run in tree.get("runs", []): test = ParserTest( name=run["tool"]["driver"]["name"], - type=run["tool"]["driver"]["name"], + parser_type=run["tool"]["driver"]["name"], version=run["tool"]["driver"].get("version"), ) test.findings = self.__get_items_from_run(run) diff --git a/dojo/tools/scout_suite/parser.py b/dojo/tools/scout_suite/parser.py index c561bf391e3..41eec27de56 100644 --- a/dojo/tools/scout_suite/parser.py +++ b/dojo/tools/scout_suite/parser.py @@ -70,7 +70,7 @@ def get_tests(self, scan_type, handle): tests = [] test = ParserTest( name=self.ID, - type=data["provider_name"], + parser_type=data["provider_name"], version=last_run.get("version"), ) test.description = test_description diff --git a/dojo/tools/wfuzz/parser.py b/dojo/tools/wfuzz/parser.py index 4e67768bd82..96a98ab020a 100644 --- a/dojo/tools/wfuzz/parser.py +++ b/dojo/tools/wfuzz/parser.py @@ -11,14 +11,14 @@ class WFuzzParser: """A class that can be used to parse the WFuzz JSON report files""" # match HTTP error code and severity - def severity_mapper(self, input): - if 200 <= int(input) <= 299: + def severity_mapper(self, severity_input): + if 200 <= int(severity_input) <= 299: return "High" - if 300 <= int(input) <= 399: + if 300 <= int(severity_input) <= 399: return "Low" - if 400 <= int(input) <= 499: + if 400 <= int(severity_input) <= 499: return "Medium" - if int(input) >= 500: + if int(severity_input) >= 500: return "Low" return None @@ -37,7 +37,7 @@ def get_findings(self, filename, test): for item in data: url = hyperlink.parse(item["url"]) return_code = item.get("code", None) - severity = "Low" if return_code is None else self.severity_mapper(input=return_code) + severity = "Low" if return_code is None else self.severity_mapper(severity_input=return_code) description = f"The URL {url.to_text()} must not be exposed\n Please review your configuration\n" dupe_key = hashlib.sha256( (url.to_text() + str(return_code)).encode("utf-8"), diff --git a/dojo/utils.py b/dojo/utils.py index 206d561151e..d2a598ddc42 100644 --- a/dojo/utils.py +++ b/dojo/utils.py @@ -1776,8 +1776,8 @@ def truncate_with_dots(the_string, max_length_including_dots): return (the_string[:max_length_including_dots - 3] + "..." if len(the_string) > max_length_including_dots else the_string) -def max_safe(list): - return max(i for i in list if i is not None) +def max_safe(full_list): + return max(i for i in full_list if i is not None) def get_full_url(relative_url): @@ -2383,45 +2383,45 @@ def delete_chunk(self, objects, **kwargs): @dojo_async_task @app.task - def delete(self, object, **kwargs): - logger.debug("ASYNC_DELETE: Deleting " + self.get_object_name(object) + ": " + str(object)) - model_list = self.mapping.get(self.get_object_name(object), None) + def delete(self, obj, **kwargs): + logger.debug("ASYNC_DELETE: Deleting " + self.get_object_name(obj) + ": " + str(obj)) + model_list = self.mapping.get(self.get_object_name(obj), None) if model_list: # The object to be deleted was found in the object list - self.crawl(object, model_list) + self.crawl(obj, model_list) else: # The object is not supported in async delete, delete normally - logger.debug("ASYNC_DELETE: " + self.get_object_name(object) + " async delete not supported. Deleteing normally: " + str(object)) - object.delete() + logger.debug("ASYNC_DELETE: " + self.get_object_name(obj) + " async delete not supported. Deleteing normally: " + str(obj)) + obj.delete() @dojo_async_task @app.task - def crawl(self, object, model_list, **kwargs): - logger.debug("ASYNC_DELETE: Crawling " + self.get_object_name(object) + ": " + str(object)) + def crawl(self, obj, model_list, **kwargs): + logger.debug("ASYNC_DELETE: Crawling " + self.get_object_name(obj) + ": " + str(obj)) for model_info in model_list: model = model_info[0] model_query = model_info[1] - filter_dict = {model_query: object} + filter_dict = {model_query: obj} objects_to_delete = model.objects.filter(**filter_dict) logger.debug("ASYNC_DELETE: Deleting " + str(len(objects_to_delete)) + " " + self.get_object_name(model) + "s in chunks") chunks = self.chunk_list(model, objects_to_delete) for chunk in chunks: logger.debug(f"deleting {len(chunk)} {self.get_object_name(model)}") self.delete_chunk(chunk) - self.delete_chunk([object]) - logger.debug("ASYNC_DELETE: Successfully deleted " + self.get_object_name(object) + ": " + str(object)) + self.delete_chunk([obj]) + logger.debug("ASYNC_DELETE: Successfully deleted " + self.get_object_name(obj) + ": " + str(obj)) - def chunk_list(self, model, list): + def chunk_list(self, model, full_list): chunk_size = get_setting("ASYNC_OBEJECT_DELETE_CHUNK_SIZE") # Break the list of objects into "chunk_size" lists - chunk_list = [list[i:i + chunk_size] for i in range(0, len(list), chunk_size)] + chunk_list = [full_list[i:i + chunk_size] for i in range(0, len(full_list), chunk_size)] logger.debug("ASYNC_DELETE: Split " + self.get_object_name(model) + " into " + str(len(chunk_list)) + " chunks of " + str(chunk_size)) return chunk_list - def get_object_name(self, object): - if object.__class__.__name__ == "ModelBase": - return object.__name__ - return object.__class__.__name__ + def get_object_name(self, obj): + if obj.__class__.__name__ == "ModelBase": + return obj.__name__ + return obj.__class__.__name__ @receiver(user_logged_in) diff --git a/ruff.toml b/ruff.toml index a4a2daa69ff..c324d809455 100644 --- a/ruff.toml +++ b/ruff.toml @@ -43,7 +43,7 @@ select = [ "ASYNC", "S1", "S2", "S5", "S7", "S311", "FBT001", "FBT003", - "A003", "A004", "A005", "A006", + "A002", "A003", "A004", "A005", "A006", "COM", "C4", "T10", diff --git a/tests/announcement_banner_test.py b/tests/announcement_banner_test.py index 4e01d13e9b0..051a8fa9319 100644 --- a/tests/announcement_banner_test.py +++ b/tests/announcement_banner_test.py @@ -10,9 +10,9 @@ class AnnouncementBannerTest(BaseTestCase): - def __init__(self, method_name, type): + def __init__(self, method_name, anno_type): super().__init__(method_name) - self.type = type + self.type = anno_type def test_setup(self): driver = self.driver diff --git a/tests/base_test_class.py b/tests/base_test_class.py index 7fcc3a6f203..2b9556e6db8 100644 --- a/tests/base_test_class.py +++ b/tests/base_test_class.py @@ -258,9 +258,9 @@ def is_element_by_css_selector_present(self, selector, text=None): return False - def is_element_by_id_present(self, id): + def is_element_by_id_present(self, elem_id): try: - self.driver.find_element(By.ID, id) + self.driver.find_element(By.ID, elem_id) return True except NoSuchElementException: return False @@ -285,24 +285,24 @@ def is_text_present_on_page(self, text): body = self.driver.find_element(By.TAG_NAME, "body") return re.search(text, body.text) - def element_exists_by_id(self, id): - elems = self.driver.find_elements(By.ID, id) + def element_exists_by_id(self, elem_id): + elems = self.driver.find_elements(By.ID, elem_id) return len(elems) > 0 - def change_system_setting(self, id, enable=True): - logger.info("changing system setting " + id + " enable: " + str(enable)) + def change_system_setting(self, setting_id, enable=True): + logger.info("changing system setting " + setting_id + " enable: " + str(enable)) driver = self.driver driver.get(self.base_url + "system_settings") - is_enabled = driver.find_element(By.ID, id).is_selected() + is_enabled = driver.find_element(By.ID, setting_id).is_selected() if (enable and not is_enabled) or (not enable and is_enabled): - # driver.find_element(By.XPATH, '//*[@id=' + id + ']').click() - driver.find_element(By.ID, id).click() + # driver.find_element(By.XPATH, '//*[@id=' + setting_id + ']').click() + driver.find_element(By.ID, setting_id).click() # save settings driver.find_element(By.CSS_SELECTOR, "input.btn.btn-primary").click() # check if it's enabled after reload - is_enabled = driver.find_element(By.ID, id).is_selected() + is_enabled = driver.find_element(By.ID, setting_id).is_selected() if enable: self.assertTrue(is_enabled) @@ -312,11 +312,11 @@ def change_system_setting(self, id, enable=True): return is_enabled - def enable_system_setting(self, id): - return self.change_system_setting(id, enable=True) + def enable_system_setting(self, setting_id): + return self.change_system_setting(setting_id, enable=True) - def disable_system_setting(self, id): - return self.change_system_setting(id, enable=False) + def disable_system_setting(self, setting_id): + return self.change_system_setting(setting_id, enable=False) def enable_jira(self): return self.enable_system_setting("id_enable_jira") diff --git a/tests/notifications_test.py b/tests/notifications_test.py index d71067ce68b..421c38099d5 100644 --- a/tests/notifications_test.py +++ b/tests/notifications_test.py @@ -11,9 +11,9 @@ class NotificationTest(BaseTestCase): - def __init__(self, method_name, type): + def __init__(self, method_name, notif_type): super().__init__(method_name) - self.type = type + self.type = notif_type def enable_notification(self): driver = self.driver diff --git a/unittests/dojo_test_case.py b/unittests/dojo_test_case.py index d22073e2730..cc6ac4afa91 100644 --- a/unittests/dojo_test_case.py +++ b/unittests/dojo_test_case.py @@ -122,16 +122,16 @@ def create_test(self, engagement=None, scan_type=None, title=None, *args, descri test.save() return test - def get_test(self, id): - return Test.objects.get(id=id) + def get_test(self, test_id): + return Test.objects.get(id=test_id) def get_test_api(self, test_id): response = self.client.patch(reverse("engagement-list") + f"{test_id}/") self.assertEqual(200, response.status_code, response.content[:1000]) return response.data - def get_engagement(self, id): - return Engagement.objects.get(id=id) + def get_engagement(self, eng_id): + return Engagement.objects.get(id=eng_id) def get_engagement_api(self, engagement_id): response = self.client.patch(reverse("engagement-list") + f"{engagement_id}/") diff --git a/unittests/test_deduplication_logic.py b/unittests/test_deduplication_logic.py index 319c0761312..81d568eadb9 100644 --- a/unittests/test_deduplication_logic.py +++ b/unittests/test_deduplication_logic.py @@ -159,7 +159,7 @@ def tearDown(self): def test_identical_legacy(self): # 24 is already a duplicate of 22 let's see what happens if we create an identical finding (but reset status) # expect: marked as duplicate - finding_new, finding_24 = self.copy_and_reset_finding(id=24) + finding_new, finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.save(dedupe_option=True) self.assert_finding(finding_new, not_pk=24, duplicate=True, duplicate_finding_id=finding_24.duplicate_finding.id, hash_code=finding_24.hash_code) @@ -178,7 +178,7 @@ def test_identical_ordering_legacy(self): self.assert_finding(finding_23, duplicate=False, hash_code=finding_22.hash_code) # create a copy of 22 - finding_new, finding_22 = self.copy_and_reset_finding(id=22) + finding_new, finding_22 = self.copy_and_reset_finding(find_id=22) finding_new.save() self.assert_finding(finding_new, not_pk=22, duplicate=True, duplicate_finding_id=finding_22.id, hash_code=finding_22.hash_code) @@ -187,7 +187,7 @@ def test_identical_ordering_legacy(self): def test_identical_except_title_legacy(self): # 24 is already a duplicate of 22, let's see what happens if we create an identical finding with different title (and reset status) # expect: NOT marked as duplicate as title is part of hash_code calculation - finding_new, finding_4 = self.copy_and_reset_finding(id=4) + finding_new, finding_4 = self.copy_and_reset_finding(find_id=4) finding_new.title = "the best title" finding_new.save(dedupe_option=True) @@ -196,7 +196,7 @@ def test_identical_except_title_legacy(self): def test_identical_except_description_legacy(self): # 24 is already a duplicate of 22, let's see what happens if we create an identical finding with different description (and reset status) # expect: not marked as duplicate as legacy sees description as leading for hash_code - finding_new, finding_24 = self.copy_and_reset_finding(id=24) + finding_new, finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.description = "useless finding" finding_new.save(dedupe_option=True) @@ -205,7 +205,7 @@ def test_identical_except_description_legacy(self): def test_identical_except_line_legacy(self): # 24 is already a duplicate of 22, let's see what happens if we create an identical finding with different line (and reset status) # expect: not marked as duplicate - finding_new, finding_24 = self.copy_and_reset_finding(id=24) + finding_new, finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.line = 666 finding_new.save(dedupe_option=True) @@ -214,7 +214,7 @@ def test_identical_except_line_legacy(self): def test_identical_except_filepath_legacy(self): # 24 is already a duplicate of 22, let's see what happens if we create an identical finding with different file_path (and reset status) # expect: not marked as duplicate - finding_new, finding_24 = self.copy_and_reset_finding(id=24) + finding_new, finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.file_path = "/dev/null" Finding.objects.get(id=22) @@ -228,7 +228,7 @@ def test_dedupe_inside_engagement_legacy(self): # make a copy and store it in engagement 2, test 4 # should not result in being marked as duplicate as it crosses engagement boundaries # both test 3 and 4 are ZAP scans (cross scanner dedupe is still not working very well) - finding_new, finding_22 = self.copy_and_reset_finding(id=22) + finding_new, finding_22 = self.copy_and_reset_finding(find_id=22) # create new engagment + test in same product test_new, _eng_new = self.create_new_test_and_engagment_from_finding(finding_22) @@ -242,7 +242,7 @@ def test_dedupe_not_inside_engagement_legacy(self): # make a copy and store it in engagement 2, test 4 # should result in being marked as duplicate as dedupe inside engagement is set to False # both test 3 and 4 are ZAP scans (cross scanner dedupe is still not working very well) - finding_new, finding_22 = self.copy_and_reset_finding(id=22) + finding_new, finding_22 = self.copy_and_reset_finding(find_id=22) # dedupe_inside_engagment must be false before cloning engagement self.set_dedupe_inside_engagement(False) @@ -256,7 +256,7 @@ def test_dedupe_not_inside_engagement_legacy(self): # legacy: if file_path and line or both empty and there are no endpoints, no dedupe will happen. Is this desirable or a BUG? def test_identical_no_filepath_no_line_no_endpoints_legacy(self): - finding_new, _finding_22 = self.copy_and_reset_finding(id=22) + finding_new, _finding_22 = self.copy_and_reset_finding(find_id=22) finding_new.file_path = None finding_new.line = None finding_new.save(dedupe_option=True) @@ -264,11 +264,11 @@ def test_identical_no_filepath_no_line_no_endpoints_legacy(self): self.assert_finding(finding_new, not_pk=22, duplicate=False) def test_identical_legacy_with_identical_endpoints_static(self): - finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(id=24, static=True, dynamic=False) # has myhost.com, myhost2.com + finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24, static=True, dynamic=False) # has myhost.com, myhost2.com finding_new.save() # create an identical copy of the new finding with the same endpoints. it should be marked as duplicate - finding_new2, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new2, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new2.save(dedupe_option=False) ep1 = Endpoint(product=finding_new2.test.engagement.product, finding=finding_new2, host="myhost.com", protocol="https") @@ -282,11 +282,11 @@ def test_identical_legacy_with_identical_endpoints_static(self): self.assert_finding(finding_new2, not_pk=finding_new.pk, duplicate=True, duplicate_finding_id=finding_new.id, hash_code=finding_new.hash_code, not_hash_code=finding_24.hash_code) def test_identical_legacy_extra_endpoints_static(self): - finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(id=24, static=True, dynamic=False) # has myhost.com, myhost2.com + finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24, static=True, dynamic=False) # has myhost.com, myhost2.com finding_new.save() # create a new finding with 3 endpoints (so 1 extra) - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) ep1 = Endpoint(product=finding_new3.test.engagement.product, finding=finding_new3, host="myhost.com", protocol="https") ep1.save() @@ -304,11 +304,11 @@ def test_identical_legacy_extra_endpoints_static(self): self.assert_finding(finding_new3, not_pk=finding_new.pk, duplicate=True, duplicate_finding_id=finding_new.id, hash_code=finding_new.hash_code, not_hash_code=finding_24.hash_code) def test_identical_legacy_different_endpoints_static(self): - finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(id=24, static=True, dynamic=False) # has myhost.com, myhost2.com + finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24, static=True, dynamic=False) # has myhost.com, myhost2.com finding_new.save() # create an identical copy of the new finding, but with different endpoints - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) ep1 = Endpoint(product=finding_new3.test.engagement.product, finding=finding_new3, host="myhost4.com", protocol="https") ep1.save() @@ -323,11 +323,11 @@ def test_identical_legacy_different_endpoints_static(self): self.assert_finding(finding_new3, not_pk=finding_new.pk, duplicate=False, hash_code=finding_new.hash_code, not_hash_code=finding_24.hash_code) def test_identical_legacy_no_endpoints_static(self): - finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(id=24, static=True, dynamic=False) # has myhost.com, myhost2.com + finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24, static=True, dynamic=False) # has myhost.com, myhost2.com finding_new.save() # create an identical copy of the new finding, but with 1 extra endpoint. should not be marked as duplicate - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) finding_new3.save() @@ -335,11 +335,11 @@ def test_identical_legacy_no_endpoints_static(self): self.assert_finding(finding_new3, not_pk=finding_new.pk, duplicate=False, hash_code=finding_new.hash_code, not_hash_code=finding_24.hash_code) def test_identical_legacy_with_identical_endpoints_dynamic(self): - finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(id=24, static=True, dynamic=False) # has myhost.com, myhost2.com + finding_new, finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24, static=True, dynamic=False) # has myhost.com, myhost2.com finding_new.save() # create an identical copy of the new finding. it should be marked as duplicate - finding_new2, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new2, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new2.save(dedupe_option=False) ep1 = Endpoint(product=finding_new2.test.engagement.product, finding=finding_new2, host="myhost.com", protocol="https") @@ -353,11 +353,11 @@ def test_identical_legacy_with_identical_endpoints_dynamic(self): self.assert_finding(finding_new2, not_pk=finding_new.pk, duplicate=True, duplicate_finding_id=finding_new.id, hash_code=finding_new.hash_code, not_hash_code=finding_24.hash_code) def test_identical_legacy_extra_endpoints_dynamic(self): - finding_new, _finding_24 = self.copy_and_reset_finding_add_endpoints(id=24) + finding_new, _finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24) finding_new.save() # create an identical copy of the new finding, but with 1 extra endpoint. - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) ep1 = Endpoint(product=finding_new3.test.engagement.product, finding=finding_new3, host="myhost.com", protocol="https") ep1.save() @@ -381,11 +381,11 @@ def test_identical_legacy_different_endpoints_dynamic(self): # create a new finding with 3 endpoints (so 1 extra) # expect: not marked as duplicate as endpoints need to be 100% equal for dynamic findings (host+port) # hash_code not affected by endpoints - finding_new, _finding_24 = self.copy_and_reset_finding_add_endpoints(id=24) + finding_new, _finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24) finding_new.save() # create an identical copy of the new finding, but with 1 extra endpoint. should not be marked as duplicate - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) ep1 = Endpoint(product=finding_new3.test.engagement.product, finding=finding_new3, host="myhost4.com", protocol="https") ep1.save() @@ -400,11 +400,11 @@ def test_identical_legacy_different_endpoints_dynamic(self): self.assert_finding(finding_new3, not_pk=finding_new.pk, duplicate=False, hash_code=finding_new.hash_code) def test_identical_legacy_no_endpoints_dynamic(self): - finding_new, _finding_24 = self.copy_and_reset_finding_add_endpoints(id=24) + finding_new, _finding_24 = self.copy_and_reset_finding_add_endpoints(find_id=24) finding_new.save() # create an identical copy of the new finding, but with no endpoints - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) finding_new3.save() @@ -419,7 +419,7 @@ def test_identical_hash_code(self): # 4 is already a duplicate of 2, let's see what happens if we create an identical finding (but reset status) # 2 has an endpoint ftp://localhost, 4 has no endpoint # expect: marked as duplicate - finding_new, finding_4 = self.copy_and_reset_finding(id=4) + finding_new, finding_4 = self.copy_and_reset_finding(find_id=4) finding_new.save(dedupe_option=True) if (settings.DEDUPE_ALGO_ENDPOINT_FIELDS == []): @@ -428,7 +428,7 @@ def test_identical_hash_code(self): else: self.assert_finding(finding_new, not_pk=4, duplicate=False, duplicate_finding_id=None, hash_code=finding_4.hash_code) - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) finding_new.save(dedupe_option=True) self.assert_finding(finding_new, not_pk=2, duplicate=True, duplicate_finding_id=finding_4.duplicate_finding.id, hash_code=finding_2.hash_code) @@ -448,7 +448,7 @@ def test_identical_ordering_hash_code(self): self.assert_finding(finding_3, duplicate=False, hash_code=finding_2.hash_code) # create a copy of 2 - finding_new, finding_2 = self.copy_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_and_reset_finding(find_id=2) finding_new.save() self.assert_finding(finding_new, not_pk=2, duplicate=True, duplicate_finding_id=finding_2.id, hash_code=finding_2.hash_code) @@ -460,7 +460,7 @@ def test_identical_ordering_hash_code(self): def test_identical_except_title_hash_code(self): # 4 is already a duplicate of 2, let's see what happens if we create an identical finding with different title (and reset status) # expect: NOT marked as duplicate as title is part of hash_code calculation - finding_new, finding_4 = self.copy_and_reset_finding(id=4) + finding_new, finding_4 = self.copy_and_reset_finding(find_id=4) finding_new.title = "the best title" finding_new.save(dedupe_option=True) @@ -470,7 +470,7 @@ def test_identical_except_description_hash_code(self): # 4 is already a duplicate of 2, let's see what happens if we create an identical finding with different description (and reset status) # 2 has an endpoint ftp://localhost, 4 has no endpoint # expect: marked as duplicate - finding_new, finding_4 = self.copy_and_reset_finding(id=4) + finding_new, finding_4 = self.copy_and_reset_finding(find_id=4) finding_new.description = "useless finding" finding_new.save(dedupe_option=True) @@ -481,7 +481,7 @@ def test_identical_except_description_hash_code(self): else: self.assert_finding(finding_new, not_pk=4, duplicate=False, duplicate_finding_id=None, hash_code=finding_4.hash_code) - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) finding_new.save(dedupe_option=True) self.assert_finding(finding_new, not_pk=2, duplicate=True, duplicate_finding_id=finding_4.duplicate_finding.id, hash_code=finding_2.hash_code) @@ -490,7 +490,7 @@ def test_identical_except_line_hash_code(self): # 4 is already a duplicate of 2, let's see what happens if we create an identical finding with different line (and reset status) # 2 has an endpoint ftp://localhost, 4 has no endpoint # expect: marked as duplicate - finding_new, finding_4 = self.copy_and_reset_finding(id=4) + finding_new, finding_4 = self.copy_and_reset_finding(find_id=4) finding_new.line = 666 finding_new.save(dedupe_option=True) @@ -500,7 +500,7 @@ def test_identical_except_line_hash_code(self): else: self.assert_finding(finding_new, not_pk=4, duplicate=False, duplicate_finding_id=None, hash_code=finding_4.hash_code) - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) finding_new.line = 666 finding_new.save(dedupe_option=True) self.assert_finding(finding_new, not_pk=2, duplicate=True, duplicate_finding_id=finding_4.duplicate_finding.id, hash_code=finding_2.hash_code) @@ -509,7 +509,7 @@ def test_identical_except_line_hash_code(self): def test_identical_except_filepath_hash_code(self): # 4 is already a duplicate of 2, let's see what happens if we create an identical finding with different file_path (and reset status) # expect: marked as duplicate - finding_new, finding_4 = self.copy_and_reset_finding(id=4) + finding_new, finding_4 = self.copy_and_reset_finding(find_id=4) finding_new.file_path = "/dev/null" finding_new.save(dedupe_option=True) @@ -519,7 +519,7 @@ def test_identical_except_filepath_hash_code(self): else: self.assert_finding(finding_new, not_pk=4, duplicate=False, duplicate_finding_id=None, hash_code=finding_4.hash_code) - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) finding_new.file_path = "/dev/null" finding_new.save(dedupe_option=True) self.assert_finding(finding_new, not_pk=2, duplicate=True, duplicate_finding_id=finding_4.duplicate_finding.id, hash_code=finding_2.hash_code) @@ -529,7 +529,7 @@ def test_dedupe_inside_engagement_hash_code(self): # make a copy and store it in engagement 2, test 4 # should not result in being marked as duplicate as it crosses engagement boundaries # both test 3 and 4 are ZAP scans (cross scanner dedupe is still not working very well) - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) finding_new.test = Test.objects.get(id=4) finding_new.save(dedupe_option=True) @@ -542,7 +542,7 @@ def test_dedupe_not_inside_engagement_hash_code(self): # both test 3 and 4 are ZAP scans (cross scanner dedupe is still not working very well) self.set_dedupe_inside_engagement(False) - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) finding_new.test = Test.objects.get(id=4) finding_new.save(dedupe_option=True) @@ -551,7 +551,7 @@ def test_dedupe_not_inside_engagement_hash_code(self): # hash_code: if file_path and line or both empty and there are no endpoints, dedupe should happen (as opposed to legacy dedupe) @unittest.skip("Test is not valid because finding 2 has an endpoint.") def test_identical_no_filepath_no_line_no_endpoints_hash_code(self): - finding_new, finding_2 = self.copy_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_and_reset_finding(find_id=2) finding_new.file_path = None finding_new.line = None finding_new.save(dedupe_option=True) @@ -560,7 +560,7 @@ def test_identical_no_filepath_no_line_no_endpoints_hash_code(self): def test_identical_hash_code_with_identical_endpoints(self): # create an identical copy of the new finding, with the same endpoints - finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(id=2) # has ftp://localhost + finding_new, finding_2 = self.copy_with_endpoints_without_dedupe_and_reset_finding(find_id=2) # has ftp://localhost finding_new.save(dedupe_option=True) # expect: marked as duplicate of original finding 2 (because finding 4 is a duplicate of finding 2 in sample data), hash_code not affected by endpoints (endpoints are not anymore in ZAP configuration for hash_code) @@ -571,7 +571,7 @@ def test_dedupe_algo_endpoint_fields_host_port_identical(self): settings.DEDUPE_ALGO_ENDPOINT_FIELDS = ["host", "port"] # create an identical copy of the new finding, with the same endpoints but different path - finding_new, finding_2 = self.copy_and_reset_finding(id=2) # finding_2 has host ftp://localhost + finding_new, finding_2 = self.copy_and_reset_finding(find_id=2) # finding_2 has host ftp://localhost finding_new.save() ep = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="localhost", protocol="ftp", path="local") @@ -590,7 +590,7 @@ def test_dedupe_algo_endpoint_field_path_different(self): settings.DEDUPE_ALGO_ENDPOINT_FIELDS = ["path"] # create an identical copy of the new finding, with the same endpoints but different path - finding_new, finding_2 = self.copy_and_reset_finding(id=2) # finding_2 has host ftp://localhost + finding_new, finding_2 = self.copy_and_reset_finding(find_id=2) # finding_2 has host ftp://localhost finding_new.save() ep = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="localhost", protocol="ftp", path="local") @@ -608,7 +608,7 @@ def test_identical_hash_code_with_intersect_endpoints(self): dedupe_algo_endpoint_fields = settings.DEDUPE_ALGO_ENDPOINT_FIELDS settings.DEDUPE_ALGO_ENDPOINT_FIELDS = ["host", "port"] # ep1: https://myhost.com, ep2: https://myhost2.com - finding_new, finding_2 = self.copy_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_and_reset_finding(find_id=2) finding_new.save(dedupe_option=False) ep1 = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="myhost.com", protocol="https") ep1.save() @@ -621,7 +621,7 @@ def test_identical_hash_code_with_intersect_endpoints(self): self.assert_finding(finding_new, not_pk=finding_2.pk, duplicate=False, hash_code=finding_2.hash_code) # create an identical copy of the new finding without original endpoints, but with 3 extra endpoints. - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) ep1 = Endpoint(product=finding_new3.test.engagement.product, finding=finding_new3, host="myhost4.com", protocol="https") ep1.save() @@ -645,7 +645,7 @@ def test_identical_hash_code_with_different_endpoints(self): dedupe_algo_endpoint_fields = settings.DEDUPE_ALGO_ENDPOINT_FIELDS settings.DEDUPE_ALGO_ENDPOINT_FIELDS = ["host", "port"] # ep1: https://myhost.com, ep2: https://myhost2.com - finding_new, finding_2 = self.copy_and_reset_finding(id=2) + finding_new, finding_2 = self.copy_and_reset_finding(find_id=2) finding_new.save(dedupe_option=False) ep1 = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="myhost.com", protocol="https") ep1.save() @@ -658,7 +658,7 @@ def test_identical_hash_code_with_different_endpoints(self): self.assert_finding(finding_new, not_pk=finding_2.pk, duplicate=False, hash_code=finding_2.hash_code) # create an identical copy of the new finding without original endpoints, but with 3 extra endpoints. - finding_new3, finding_new = self.copy_and_reset_finding(id=finding_new.id) + finding_new3, finding_new = self.copy_and_reset_finding(find_id=finding_new.id) finding_new3.save(dedupe_option=False) ep1 = Endpoint(product=finding_new3.test.engagement.product, finding=finding_new3, host="myhost4.com", protocol="https") ep1.save() @@ -682,7 +682,7 @@ def test_identical_hash_code_with_different_endpoints(self): # # unique_id algo uses id from tool. hash_code is still calculated, according to legacy field config Checkmarx detailed scan def test_identical_unique_id(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.save() # expect duplicate @@ -690,7 +690,7 @@ def test_identical_unique_id(self): def test_different_unique_id_unique_id(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.unique_id_from_tool = "9999" finding_new.save() @@ -699,7 +699,7 @@ def test_different_unique_id_unique_id(self): def test_identical_ordering_unique_id(self): # create identical copy - finding_new, finding_125 = self.copy_and_reset_finding(id=125) + finding_new, finding_125 = self.copy_and_reset_finding(find_id=125) finding_new.save() # expect duplicate, but of 124 as that is first in the list, but it's newer then 125. feature or BUG? @@ -707,7 +707,7 @@ def test_identical_ordering_unique_id(self): def test_title_description_line_filepath_different_unique_id(self): # create identical copy, change some fields - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.title = "another title" finding_new.unsaved_vulnerability_ids = ["CVE-2020-12345"] finding_new.cwe = "456" @@ -719,7 +719,7 @@ def test_title_description_line_filepath_different_unique_id(self): def test_title_description_line_filepath_different_and_id_different_unique_id(self): # create identical copy, change some fields - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.title = "another title" finding_new.unsaved_vulnerability_ids = ["CVE-2020-12345"] finding_new.cwe = "456" @@ -732,7 +732,7 @@ def test_title_description_line_filepath_different_and_id_different_unique_id(se def test_dedupe_not_inside_engagement_unique_id(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) # first setup some finding with same unique_id in different engagement, but same test_type finding_22 = Finding.objects.get(id=22) @@ -751,7 +751,7 @@ def test_dedupe_not_inside_engagement_unique_id(self): def test_dedupe_inside_engagement_unique_id(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) # first setup some finding with same unique_id in same engagement, but different test (same test_type) finding_new.test = Test.objects.get(id=66) @@ -762,7 +762,7 @@ def test_dedupe_inside_engagement_unique_id(self): def test_dedupe_inside_engagement_unique_id2(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) # first setup some finding with same unique_id in different engagement, but same test_type self.set_dedupe_inside_engagement(False) @@ -782,7 +782,7 @@ def test_dedupe_inside_engagement_unique_id2(self): def test_dedupe_same_id_different_test_type_unique_id(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) # first setup some finding from a different test_Type, but with the same unique_id_from_tool finding_22 = Finding.objects.get(id=22) @@ -798,7 +798,7 @@ def test_dedupe_same_id_different_test_type_unique_id(self): def test_identical_different_endpoints_unique_id(self): # create identical copy - finding_new, finding_124 = self.copy_and_reset_finding(id=124) + finding_new, finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.save(dedupe_option=False) ep1 = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="myhost.com", protocol="https") @@ -813,7 +813,7 @@ def test_identical_different_endpoints_unique_id(self): def test_identical_unique_id_or_hash_code(self): # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.save() # expect duplicate as uid matches @@ -823,7 +823,7 @@ def test_identical_unique_id_or_hash_code(self): def test_identical_unique_id_or_hash_code_bug(self): # create identical copy finding_124 = Finding.objects.get(id=124) - finding_new, _finding_224 = self.copy_and_reset_finding(id=224) + finding_new, _finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.title = finding_124.title # use title from 124 to get matching hashcode finding_new.save() @@ -832,7 +832,7 @@ def test_identical_unique_id_or_hash_code_bug(self): def test_different_unique_id_unique_id_or_hash_code(self): # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.unique_id_from_tool = "9999" finding_new.save() @@ -840,7 +840,7 @@ def test_different_unique_id_unique_id_or_hash_code(self): self.assert_finding(finding_new, not_pk=224, duplicate=True, duplicate_finding_id=finding_224.id, hash_code=finding_224.hash_code) # but if we change title and thus hash_code, it should no longer matchs - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.unique_id_from_tool = "9999" finding_new.title = "no no no no no no" finding_new.save() @@ -850,7 +850,7 @@ def test_different_unique_id_unique_id_or_hash_code(self): def test_identical_ordering_unique_id_or_hash_code(self): # create identical copy - finding_new, finding_225 = self.copy_and_reset_finding(id=225) + finding_new, finding_225 = self.copy_and_reset_finding(find_id=225) finding_new.save() # expect duplicate, but of 124 as that is first in the list, but it's newer then 225. feature or BUG? @@ -858,7 +858,7 @@ def test_identical_ordering_unique_id_or_hash_code(self): def test_title_description_line_filepath_different_unique_id_or_hash_code(self): # create identical copy, change some fields - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.title = "another title" finding_new.unsaved_vulnerability_ids = ["CVE-2020-12345"] finding_new.cwe = "456" @@ -870,7 +870,7 @@ def test_title_description_line_filepath_different_unique_id_or_hash_code(self): def test_title_description_line_filepath_different_and_id_different_unique_id_or_hash_code(self): # create identical copy, change some fields - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.title = "another title" finding_new.unsaved_vulnerability_ids = ["CVE-2020-12345"] finding_new.cwe = "456" @@ -883,7 +883,7 @@ def test_title_description_line_filepath_different_and_id_different_unique_id_or def test_dedupe_not_inside_engagement_same_hash_unique_id_or_hash_code(self): # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) # first setup some finding with same unique_id in different engagement, but same test_type, same hash finding_22 = Finding.objects.get(id=22) @@ -903,7 +903,7 @@ def test_dedupe_not_inside_engagement_same_hash_unique_id_or_hash_code(self): def test_dedupe_not_inside_engagement_same_hash_unique_id_or_hash_code2(self): # create identical copy # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) # first setup some finding with same unique_id in different engagement, different test_type, same hash_code finding_22 = Finding.objects.get(id=22) @@ -923,7 +923,7 @@ def test_dedupe_not_inside_engagement_same_hash_unique_id_or_hash_code2(self): def test_dedupe_inside_engagement_unique_id_or_hash_code(self): # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) # first setup some finding with same unique_id in same engagement, but different test (same test_type) finding_new.test = Test.objects.get(id=66) @@ -934,7 +934,7 @@ def test_dedupe_inside_engagement_unique_id_or_hash_code(self): def test_dedupe_inside_engagement_unique_id_or_hash_code2(self): # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) # first setup some finding with same unique_id in different engagement, but same scan_type self.set_dedupe_inside_engagement(False) @@ -956,7 +956,7 @@ def test_dedupe_inside_engagement_unique_id_or_hash_code2(self): def test_dedupe_same_id_different_test_type_unique_id_or_hash_code(self): # create identical copy - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) # first setup some finding from a different test_Type, but with the same unique_id_from_tool finding_22 = Finding.objects.get(id=22) @@ -972,7 +972,7 @@ def test_dedupe_same_id_different_test_type_unique_id_or_hash_code(self): self.assert_finding(finding_new, not_pk=224, duplicate=False, not_hash_code=finding_224.hash_code) # same scenario but with idencital hash_code as 224 leads to being marked as duplicate of 224 - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) # first setup some finding from a different test_Type, but with the same unique_id_from_tool finding_22 = Finding.objects.get(id=22) @@ -988,7 +988,7 @@ def test_dedupe_same_id_different_test_type_unique_id_or_hash_code(self): def test_identical_different_endpoints_unique_id_or_hash_code(self): # create identical copy, so unique id is the same - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.save(dedupe_option=False) ep1 = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="myhost.com", protocol="https") @@ -1003,7 +1003,7 @@ def test_identical_different_endpoints_unique_id_or_hash_code(self): self.assert_finding(finding_new, not_pk=224, duplicate=False, duplicate_finding_id=None, hash_code=finding_224.hash_code) # same scenario, now with different uid. and different endpoints, but hash will be different due the endpoints because we set dynamic_finding to True - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.save(dedupe_option=False) ep1 = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="myhost.com", protocol="https") @@ -1020,7 +1020,7 @@ def test_identical_different_endpoints_unique_id_or_hash_code(self): self.assert_finding(finding_new, not_pk=224, duplicate=False, hash_code=finding_224.hash_code) # same scenario, now with different uid. and different endpoints - finding_new, finding_224 = self.copy_and_reset_finding(id=224) + finding_new, finding_224 = self.copy_and_reset_finding(find_id=224) finding_new.save(dedupe_option=False) ep1 = Endpoint(product=finding_new.test.engagement.product, finding=finding_new, host="myhost.com", protocol="https") @@ -1040,7 +1040,7 @@ def test_identical_different_endpoints_unique_id_or_hash_code(self): # # hash_code currently is only created on finding creation and after that never changed. feature or BUG? def test_hash_code_onetime(self): - finding_new, _finding_2 = self.copy_and_reset_finding(id=2) + finding_new, _finding_2 = self.copy_and_reset_finding(find_id=2) self.assertEqual(finding_new.hash_code, None) finding_new.save() @@ -1061,7 +1061,7 @@ def test_hash_code_onetime(self): def test_identical_legacy_dedupe_option_true_false(self): # 24 is already a duplicate of 22 let's see what happens if we create an identical finding (but reset status) # expect: not marked as duplicate with dedupe_option-False - finding_new, finding_24 = self.copy_and_reset_finding(id=24) + finding_new, finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.save(dedupe_option=False) self.assert_finding(finding_new, not_pk=24, duplicate=False, hash_code=None) @@ -1072,7 +1072,7 @@ def test_identical_legacy_dedupe_option_true_false(self): def test_duplicate_after_modification(self): # we copy a finding but change some important fields so it's no longer a duplicate # expect: not marked as duplicate with dedupe_option-False - finding_new, finding_24 = self.copy_and_reset_finding(id=24) + finding_new, finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.title = "new_title" finding_new.unsaved_vulnerability_ids = [999] finding_new.save(dedupe_option=True) @@ -1087,7 +1087,7 @@ def test_duplicate_after_modification(self): def test_case_sensitiveness_hash_code_computation(self): # hash_code calculation is case sensitive. feature or BUG? - finding_new, finding_22 = self.copy_and_reset_finding(id=22) + finding_new, finding_22 = self.copy_and_reset_finding(find_id=22) finding_new.title = finding_22.title.upper() finding_new.save(dedupe_option=True) self.assert_finding(finding_new, not_pk=22, duplicate=True, duplicate_finding_id=finding_22.id, hash_code=finding_22.hash_code) @@ -1099,7 +1099,7 @@ def test_title_case(self): # it will fail if someone removes title casing and force them to think about the implications # ideally we will switch to case-in-sensitive hash_code computation. # this could be a relatively small impact change as saving findings (currently) doesn't recompute the hash_code - finding_new, _finding_24 = self.copy_and_reset_finding(id=24) + finding_new, _finding_24 = self.copy_and_reset_finding(find_id=24) finding_new.title = "the quick brown fox jumps over the lazy dog" finding_new.save(dedupe_option=True) self.assertEqual(finding_new.title, "The Quick Brown Fox Jumps Over the Lazy Dog") @@ -1107,7 +1107,7 @@ def test_title_case(self): def test_hash_code_without_dedupe(self): # if dedupe is disabled, hash_code should still be calculated self.enable_dedupe(enable=False) - finding_new, _finding_124 = self.copy_and_reset_finding(id=124) + finding_new, _finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.save(dedupe_option=False) # save skips hash_code generation if dedupe_option==False @@ -1117,7 +1117,7 @@ def test_hash_code_without_dedupe(self): self.assertIsNotNone(finding_new.hash_code) - finding_new, _finding_124 = self.copy_and_reset_finding(id=124) + finding_new, _finding_124 = self.copy_and_reset_finding(find_id=124) finding_new.save() # by default hash_code should be generated @@ -1187,8 +1187,8 @@ def log_summary(self, product=None, engagement=None, test=None): if not product and not engagement and not test: self.log_all_products() - def copy_and_reset_finding(self, id): - org = Finding.objects.get(id=id) + def copy_and_reset_finding(find_idself, find_id): + org = Finding.objects.get(id=find_id) new = org new.pk = None new.duplicate = False @@ -1196,10 +1196,10 @@ def copy_and_reset_finding(self, id): new.active = True new.hash_code = None # return unsaved new finding and reloaded existing finding - return new, Finding.objects.get(id=id) + return new, Finding.objects.get(id=find_id) - def copy_with_endpoints_without_dedupe_and_reset_finding(self, id): - finding_new, finding_org = self.copy_and_reset_finding(id=id) + def copy_with_endpoints_without_dedupe_and_reset_finding(self, find_id): + finding_new, finding_org = self.copy_and_reset_finding(find_id=find_id) # first save without dedupe to avoid hash_code calculation to happen without endpoints finding_new.save(dedupe_option=False) for ep in finding_org.endpoints.all(): @@ -1208,8 +1208,8 @@ def copy_with_endpoints_without_dedupe_and_reset_finding(self, id): # return saved new finding and reloaded existing finding return finding_new, finding_org - def copy_and_reset_finding_add_endpoints(self, id, static=False, dynamic=True): - finding_new, finding_org = self.copy_and_reset_finding(id=id) + def copy_and_reset_finding_add_endpoints(self, find_id, static=False, dynamic=True): + finding_new, finding_org = self.copy_and_reset_finding(find_id=find_id) # remove file_path and line as we now have endpoints finding_new.file_path = None finding_new.line = None @@ -1225,19 +1225,19 @@ def copy_and_reset_finding_add_endpoints(self, id, static=False, dynamic=True): finding_new.endpoints.add(ep2) return finding_new, finding_org - def copy_and_reset_test(self, id): - org = Test.objects.get(id=id) + def copy_and_reset_test(self, test_id): + org = Test.objects.get(id=test_id) new = org new.pk = None # return unsaved new finding and reloaded existing finding - return new, Test.objects.get(id=id) + return new, Test.objects.get(id=test_id) - def copy_and_reset_engagement(self, id): - org = Engagement.objects.get(id=id) + def copy_and_reset_engagement(self, eng_id): + org = Engagement.objects.get(id=eng_id) new = org new.pk = None # return unsaved new finding and reloaded existing finding - return new, Engagement.objects.get(id=id) + return new, Engagement.objects.get(id=eng_id) def assert_finding(self, finding, not_pk=None, duplicate=False, duplicate_finding_id=None, hash_code=None, not_hash_code=None): if hash_code: @@ -1265,9 +1265,9 @@ def set_dedupe_inside_engagement(self, deduplication_on_engagement): eng.save() def create_new_test_and_engagment_from_finding(self, finding): - eng_new, _eng = self.copy_and_reset_engagement(id=finding.test.engagement.id) + eng_new, _eng = self.copy_and_reset_engagement(eng_id=finding.test.engagement.id) eng_new.save() - test_new, _test = self.copy_and_reset_test(id=finding.test.id) + test_new, _test = self.copy_and_reset_test(test_id=finding.test.id) test_new.engagement = eng_new test_new.save() return test_new, eng_new diff --git a/unittests/test_false_positive_history_logic.py b/unittests/test_false_positive_history_logic.py index 04fca655b58..ca71754eecd 100644 --- a/unittests/test_false_positive_history_logic.py +++ b/unittests/test_false_positive_history_logic.py @@ -144,7 +144,7 @@ def tearDown(self): # Finding 2 in Product 2, Engagement 1, Test 3 def test_fp_history_equal_hash_code_same_test(self): # Copy finding 2 and store it in the same test (to test retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -153,7 +153,7 @@ def test_fp_history_equal_hash_code_same_test(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it in the same test - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.save() # Assert that both findings belongs to the same test and are marked as fp self.assert_finding(find_created_before_mark, false_p=True, not_pk=2, test_id=3, hash_code=find_2.hash_code) @@ -164,7 +164,7 @@ def test_fp_history_equal_hash_code_same_test_non_retroactive(self): # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 2 and store it in the same test (to test disabled retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -173,7 +173,7 @@ def test_fp_history_equal_hash_code_same_test_non_retroactive(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it in the same test - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.save() # Assert that both findings belongs to the same test and only one of them is marked as fp self.assert_finding(find_created_before_mark, false_p=False, not_pk=2, test_id=3, hash_code=find_2.hash_code) @@ -188,7 +188,7 @@ def test_fp_history_equal_hash_code_same_test_dedupe_enabled(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it in the same test - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.save() # Assert that finding belongs to the same test and is NOT marked as fp self.assert_finding(find_created_after_mark, false_p=False, not_pk=2, test_id=3, hash_code=find_2.hash_code) @@ -197,7 +197,7 @@ def test_fp_history_equal_hash_code_same_test_dedupe_enabled(self): # Finding 7 in Product 2, Engagement 1, Test 3 (has a different hash code) def test_fp_history_different_hash_code_same_test(self): # Copy finding 7 and store it in the same test (to test retroactive replication) - find_created_before_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_before_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -206,7 +206,7 @@ def test_fp_history_different_hash_code_same_test(self): find_2.false_p = True find_2.save() # Copy finding 7 and store it in the same test - find_created_after_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_after_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_after_mark.save() # Assert that both findings belongs to the same test and are NOT marked as fp self.assert_finding(find_created_before_mark, false_p=False, not_pk=7, test_id=3, not_hash_code=find_2.hash_code) @@ -217,7 +217,7 @@ def test_fp_history_different_hash_code_same_test(self): # Finding 2 in Product 2, Engagement 1, Test 3 def test_fp_history_equal_hash_code_same_engagement_different_test(self): # Copy finding 2 and store it at Product 2, Engagement 1, Test 14 (to test retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.test = Test.objects.get(id=14) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -227,7 +227,7 @@ def test_fp_history_equal_hash_code_same_engagement_different_test(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 2, Engagement 1, Test 14 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=14) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and are marked as fp @@ -239,7 +239,7 @@ def test_fp_history_equal_hash_code_same_engagement_different_test_non_retroacti # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 2 and store it at Product 2, Engagement 1, Test 14 (to test disabled retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.test = Test.objects.get(id=14) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -249,7 +249,7 @@ def test_fp_history_equal_hash_code_same_engagement_different_test_non_retroacti find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 2, Engagement 1, Test 14 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=14) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and only one of them is marked as fp @@ -265,7 +265,7 @@ def test_fp_history_equal_hash_code_same_engagement_different_test_dedupe_enable find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 2, Engagement 1, Test 14 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=14) find_created_after_mark.save() # Assert that finding belongs to the same engagement but in a different test and is NOT marked as fp @@ -275,7 +275,7 @@ def test_fp_history_equal_hash_code_same_engagement_different_test_dedupe_enable # Finding 7 in Product 2, Engagement 1, Test 3 (has a different hash code) def test_fp_history_different_hash_code_same_engagement_different_test(self): # Copy finding 7 and store it at Product 2, Engagement 1, Test 14 (to test retroactive replication) - find_created_before_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_before_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_before_mark.test = Test.objects.get(id=14) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -285,7 +285,7 @@ def test_fp_history_different_hash_code_same_engagement_different_test(self): find_2.false_p = True find_2.save() # Copy finding 7 and store it at Product 2, Engagement 1, Test 14 - find_created_after_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_after_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_after_mark.test = Test.objects.get(id=14) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and are NOT marked as fp @@ -297,7 +297,7 @@ def test_fp_history_different_hash_code_same_engagement_different_test(self): # Finding 2 in Product 2, Engagement 1, Test 3 def test_fp_history_equal_hash_code_same_product_different_engagement(self): # Copy finding 2 and store it at Product 2, Engagement 4, Test 4 (to test retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.test = Test.objects.get(id=4) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -307,7 +307,7 @@ def test_fp_history_equal_hash_code_same_product_different_engagement(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 2, Engagement 4, Test 4 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=4) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and are marked as fp @@ -319,7 +319,7 @@ def test_fp_history_equal_hash_code_same_product_different_engagement_non_retroa # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 2 and store it at Product 2, Engagement 4, Test 4 (to test disabled retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.test = Test.objects.get(id=4) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -329,7 +329,7 @@ def test_fp_history_equal_hash_code_same_product_different_engagement_non_retroa find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 2, Engagement 4, Test 4 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=4) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and only one of them is marked as fp @@ -345,7 +345,7 @@ def test_fp_history_equal_hash_code_same_product_different_engagement_dedupe_ena find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 2, Engagement 4, Test 4 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=4) find_created_after_mark.save() # Assert that finding belongs to the same engagement but in a different test and is NOT marked as fp @@ -355,7 +355,7 @@ def test_fp_history_equal_hash_code_same_product_different_engagement_dedupe_ena # Finding 7 in Product 2, Engagement 1, Test 3 (has a different hash code) def test_fp_history_different_hash_code_same_product_different_engagement(self): # Copy finding 7 and store it at Product 2, Engagement 4, Test 4 (to test retroactive replication) - find_created_before_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_before_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_before_mark.test = Test.objects.get(id=4) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -365,7 +365,7 @@ def test_fp_history_different_hash_code_same_product_different_engagement(self): find_2.false_p = True find_2.save() # Copy finding 7 and store it at Product 2, Engagement 4, Test 4 - find_created_after_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_after_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_after_mark.test = Test.objects.get(id=4) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and are NOT marked as fp @@ -377,7 +377,7 @@ def test_fp_history_different_hash_code_same_product_different_engagement(self): # Finding 2 in Product 2, Engagement 1, Test 3 def test_fp_history_equal_hash_code_different_product(self): # Copy finding 2 and store it at Product 1, Engagement 2, Test 13 (to test retroactive replication) - find_created_before_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_before_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_before_mark.test = Test.objects.get(id=13) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -387,7 +387,7 @@ def test_fp_history_equal_hash_code_different_product(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 1, Engagement 2, Test 13 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=13) find_created_after_mark.save() # Assert that both findings belongs to a different product and are NOT marked as fp @@ -403,7 +403,7 @@ def test_fp_history_equal_hash_code_different_product_dedupe_enabled(self): find_2.false_p = True find_2.save() # Copy finding 2 and store it at Product 1, Engagement 2, Test 13 - find_created_after_mark, find_2 = self.copy_and_reset_finding(id=2) + find_created_after_mark, find_2 = self.copy_and_reset_finding(find_id=2) find_created_after_mark.test = Test.objects.get(id=13) find_created_after_mark.save() # Assert that finding belongs to a different product and is NOT marked as fp @@ -413,7 +413,7 @@ def test_fp_history_equal_hash_code_different_product_dedupe_enabled(self): # Finding 7 in Product 2, Engagement 1, Test 3 (has a different hash code) def test_fp_history_different_hash_code_different_product(self): # Copy finding 7 and store it at Product 1, Engagement 2, Test 13 (to test retroactive replication) - find_created_before_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_before_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_before_mark.test = Test.objects.get(id=13) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -423,7 +423,7 @@ def test_fp_history_different_hash_code_different_product(self): find_2.false_p = True find_2.save() # Copy finding 7 and store it at Product 1, Engagement 2, Test 13 - find_created_after_mark, _find_7 = self.copy_and_reset_finding(id=7) + find_created_after_mark, _find_7 = self.copy_and_reset_finding(find_id=7) find_created_after_mark.test = Test.objects.get(id=13) find_created_after_mark.save() # Assert that both findings belongs to a different product and are NOT marked as fp @@ -439,7 +439,7 @@ def test_fp_history_different_hash_code_different_product(self): # Finding 124 in Product 2, Engagement 5, Test 55 def test_fp_history_equal_unique_id_same_test(self): # Copy finding 124 and store it in the same test (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -448,7 +448,7 @@ def test_fp_history_equal_unique_id_same_test(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it in the same test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.save() # Assert that both findings belongs to the same test and are marked as fp self.assert_finding(find_created_before_mark, false_p=True, not_pk=124, test_id=55, unique_id_from_tool=find_124.unique_id_from_tool) @@ -459,7 +459,7 @@ def test_fp_history_equal_unique_id_same_test_non_retroactive(self): # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 124 and store it in the same test (to test disabled retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -468,7 +468,7 @@ def test_fp_history_equal_unique_id_same_test_non_retroactive(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it in the same test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.save() # Assert that both findings belongs to the same test and only one of them is marked as fp self.assert_finding(find_created_before_mark, false_p=False, not_pk=124, test_id=55, unique_id_from_tool=find_124.unique_id_from_tool) @@ -483,7 +483,7 @@ def test_fp_history_equal_unique_id_same_test_dedupe_enabled(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it in the same test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.save() # Assert that finding belongs to the same test and is NOT marked as fp self.assert_finding(find_created_after_mark, false_p=False, not_pk=124, test_id=55, unique_id_from_tool=find_124.unique_id_from_tool) @@ -491,7 +491,7 @@ def test_fp_history_equal_unique_id_same_test_dedupe_enabled(self): # Finding 124 in Product 2, Engagement 5, Test 55 def test_fp_history_different_unique_id_same_test(self): # Copy finding 124, change unique_id and store it in the same test (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -501,7 +501,7 @@ def test_fp_history_different_unique_id_same_test(self): find_124.false_p = True find_124.save() # Copy finding 124, change unique_id and store it in the same test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark = self.change_finding_unique_id(find_created_after_mark) find_created_after_mark.save() # Assert that both findings belongs to the same test and are NOT marked as fp @@ -513,7 +513,7 @@ def test_fp_history_different_unique_id_same_test(self): # Finding 124 in Product 2, Engagement 5, Test 55 def test_fp_history_equal_unique_id_same_engagement_different_test(self): # Copy finding 124 and store it at Product 2, Engagement 5, Test 66 (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.test = Test.objects.get(id=66) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -523,7 +523,7 @@ def test_fp_history_equal_unique_id_same_engagement_different_test(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, Engagement 5, Test 66 - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = Test.objects.get(id=66) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and are marked as fp @@ -535,7 +535,7 @@ def test_fp_history_equal_unique_id_same_engagement_different_test_non_retroacti # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 124 and store it at Product 2, Engagement 5, Test 66 (to test disabled retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.test = Test.objects.get(id=66) find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -545,7 +545,7 @@ def test_fp_history_equal_unique_id_same_engagement_different_test_non_retroacti find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, Engagement 5, Test 66 - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = Test.objects.get(id=66) find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and only one of them is marked as fp @@ -561,7 +561,7 @@ def test_fp_history_equal_unique_id_same_engagement_different_test_dedupe_enable find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, Engagement 5, Test 66 - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = Test.objects.get(id=66) find_created_after_mark.save() # Assert that finding belongs to the same engagement but in a different test and is NOT marked as fp @@ -570,7 +570,7 @@ def test_fp_history_equal_unique_id_same_engagement_different_test_dedupe_enable # Finding 124 in Product 2, Engagement 5, Test 55 def test_fp_history_different_unique_id_same_engagement_different_test(self): # Copy finding 124, change unique_id and store it at Product 2, Engagement 5, Test 66 (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.test = Test.objects.get(id=66) find_created_before_mark.save() @@ -581,7 +581,7 @@ def test_fp_history_different_unique_id_same_engagement_different_test(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, Engagement 5, Test 66 - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.unique_id_from_tool = "somefakeid123" find_created_after_mark.test = Test.objects.get(id=66) find_created_after_mark.save() @@ -597,7 +597,7 @@ def test_fp_history_equal_unique_id_same_product_different_engagement(self): find_124 = Finding.objects.get(id=124) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_124) # Copy finding 124 and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -606,7 +606,7 @@ def test_fp_history_equal_unique_id_same_product_different_engagement(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same product but in a different engagement and are marked as fp @@ -621,7 +621,7 @@ def test_fp_history_equal_unique_id_same_product_different_engagement_non_retroa find_124 = Finding.objects.get(id=124) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_124) # Copy finding 124 and store it at Product 2, New Engagement, New Test (to test disabled retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -630,7 +630,7 @@ def test_fp_history_equal_unique_id_same_product_different_engagement_non_retroa find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same product but in a different engagement and only one of them is marked as fp @@ -648,7 +648,7 @@ def test_fp_history_equal_unique_id_same_product_different_engagement_dedupe_ena find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that finding belongs to the same product but in a different engagement and is NOT marked as fp @@ -660,7 +660,7 @@ def test_fp_history_different_unique_id_same_product_different_engagement(self): find_124 = Finding.objects.get(id=124) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_124) # Copy finding 124, change unique_id and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.test = test_new find_created_before_mark.save() @@ -670,7 +670,7 @@ def test_fp_history_different_unique_id_same_product_different_engagement(self): find_124.false_p = True find_124.save() # Copy finding 124, change unique_id and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark = self.change_finding_unique_id(find_created_after_mark) find_created_after_mark.test = test_new find_created_after_mark.save() @@ -686,7 +686,7 @@ def test_fp_history_equal_unique_id_different_product(self): find_124 = Finding.objects.get(id=124) test_new, _eng_new, _product_new = self.create_new_test_and_engagment_and_product_from_finding(find_124) # Copy finding 124 and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -695,7 +695,7 @@ def test_fp_history_equal_unique_id_different_product(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same product but in a different engagement and are NOT marked as fp @@ -713,7 +713,7 @@ def test_fp_history_equal_unique_id_different_product_dedupe_enabled(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that finding belongs to the same product but in a different engagement and is NOT marked as fp @@ -725,7 +725,7 @@ def test_fp_history_different_unique_id_different_product(self): find_124 = Finding.objects.get(id=124) test_new, _eng_new, _product_new = self.create_new_test_and_engagment_and_product_from_finding(find_124) # Copy finding 124 and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_before_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_before_mark.unique_id_from_tool = "somefakeid123" find_created_before_mark.test = test_new find_created_before_mark.save() @@ -735,7 +735,7 @@ def test_fp_history_different_unique_id_different_product(self): find_124.false_p = True find_124.save() # Copy finding 124 and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_124 = self.copy_and_reset_finding(id=124) + find_created_after_mark, find_124 = self.copy_and_reset_finding(find_id=124) find_created_after_mark.unique_id_from_tool = "somefakeid123" find_created_after_mark.test = test_new find_created_after_mark.save() @@ -752,13 +752,13 @@ def test_fp_history_different_unique_id_different_product(self): # Finding 224 in Product 2, Engagement 5, Test 77 def test_fp_history_equal_unique_id_or_hash_code_same_test(self): # Copy finding 224, change hash_code, and store it in the same test (to test retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it in the same test (to test retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.save() # Makes sure that the copy is not a false positive @@ -768,11 +768,11 @@ def test_fp_history_equal_unique_id_or_hash_code_same_test(self): find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it in the same test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it in the same test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.save() # Assert that both findings has a different hash_code, an equal unique_id, @@ -789,13 +789,13 @@ def test_fp_history_equal_unique_id_or_hash_code_same_test_non_retroactive(self) # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 224, change hash_code, and store it in the same test (to test disabled retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it in the same test (to test disabled retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.save() # Makes sure that the copy is not a false positive @@ -805,11 +805,11 @@ def test_fp_history_equal_unique_id_or_hash_code_same_test_non_retroactive(self) find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it in the same test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it in the same test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.save() # Assert that both findings has a different hash_code, an equal unique_id, @@ -830,11 +830,11 @@ def test_fp_history_equal_unique_id_or_hash_code_same_test_dedupe_enabled(self): find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it in the same test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it in the same test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.save() # Assert that finding has a different hash_code, an equal unique_id, @@ -847,7 +847,7 @@ def test_fp_history_equal_unique_id_or_hash_code_same_test_dedupe_enabled(self): # Finding 224 in Product 2, Engagement 5, Test 77 def test_fp_history_different_unique_id_or_hash_code_same_test(self): # Copy finding 224, change hash_code, change unique_id and store it in the same test (to test retroactive replication) - find_created_before_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark = self.change_finding_hash_code(find_created_before_mark) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.save() @@ -858,7 +858,7 @@ def test_fp_history_different_unique_id_or_hash_code_same_test(self): find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, change unique_id and store it in the same test - find_created_after_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark = self.change_finding_hash_code(find_created_after_mark) find_created_after_mark = self.change_finding_unique_id(find_created_after_mark) find_created_after_mark.save() @@ -872,14 +872,14 @@ def test_fp_history_different_unique_id_or_hash_code_same_test(self): # Finding 224 in Product 2, Engagement 5, Test 77 def test_fp_history_equal_unique_id_or_hash_code_same_engagement_different_test(self): # Copy finding 224, change hash_code, and store it at Product 2, Engagement 5, Test 88 (to test retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.test = Test.objects.get(id=88) find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it at Product 2, Engagement 5, Test 88 (to test retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.test = Test.objects.get(id=88) find_created_before_mark_diff_unique_id.save() @@ -890,12 +890,12 @@ def test_fp_history_equal_unique_id_or_hash_code_same_engagement_different_test( find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = Test.objects.get(id=88) find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = Test.objects.get(id=88) find_created_after_mark_diff_unique_id.save() @@ -913,14 +913,14 @@ def test_fp_history_equal_unique_id_or_hash_code_same_engagement_different_test_ # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 224, change hash_code, and store it at Product 2, Engagement 5, Test 88 (to test disabled retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.test = Test.objects.get(id=88) find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it at Product 2, Engagement 5, Test 88 (to test disabled retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.test = Test.objects.get(id=88) find_created_before_mark_diff_unique_id.save() @@ -931,12 +931,12 @@ def test_fp_history_equal_unique_id_or_hash_code_same_engagement_different_test_ find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = Test.objects.get(id=88) find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = Test.objects.get(id=88) find_created_after_mark_diff_unique_id.save() @@ -958,12 +958,12 @@ def test_fp_history_equal_unique_id_or_hash_code_same_engagement_different_test_ find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = Test.objects.get(id=88) find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = Test.objects.get(id=88) find_created_after_mark_diff_unique_id.save() @@ -977,7 +977,7 @@ def test_fp_history_equal_unique_id_or_hash_code_same_engagement_different_test_ # Finding 224 in Product 2, Engagement 5, Test 77 def test_fp_history_different_unique_id_or_hash_code_same_engagement_different_test(self): # Copy finding 224, change hash_code, change unique_id and store it at Product 2, Engagement 5, Test 88 (to test retroactive replication) - find_created_before_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark = self.change_finding_hash_code(find_created_before_mark) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.test = Test.objects.get(id=88) @@ -989,7 +989,7 @@ def test_fp_history_different_unique_id_or_hash_code_same_engagement_different_t find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, change unique_id and store it at Product 2, Engagement 5, Test 88 - find_created_after_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark = self.change_finding_hash_code(find_created_after_mark) find_created_after_mark = self.change_finding_unique_id(find_created_after_mark) find_created_after_mark.test = Test.objects.get(id=88) @@ -1007,14 +1007,14 @@ def test_fp_history_equal_unique_id_or_hash_code_same_product_different_engageme find_224 = Finding.objects.get(id=224) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_224) # Copy finding 224, change hash_code, and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.test = test_new find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.test = test_new find_created_before_mark_diff_unique_id.save() @@ -1025,12 +1025,12 @@ def test_fp_history_equal_unique_id_or_hash_code_same_product_different_engageme find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at Product 2, New Engagement, New Test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = test_new find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at Product 2, New Engagement, New Test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = test_new find_created_after_mark_diff_unique_id.save() @@ -1051,14 +1051,14 @@ def test_fp_history_equal_unique_id_or_hash_code_same_product_different_engageme find_224 = Finding.objects.get(id=224) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_224) # Copy finding 224, change hash_code, and store it at Product 2, New Engagement, New Test (to test disabled retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.test = test_new find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it at Product 2, New Engagement, New Test (to test disabled retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.test = test_new find_created_before_mark_diff_unique_id.save() @@ -1069,12 +1069,12 @@ def test_fp_history_equal_unique_id_or_hash_code_same_product_different_engageme find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at Product 2, New Engagement, New Test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = test_new find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at Product 2, New Engagement, New Test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = test_new find_created_after_mark_diff_unique_id.save() @@ -1099,12 +1099,12 @@ def test_fp_history_equal_unique_id_or_hash_code_same_product_different_engageme find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at Product 2, New Engagement, New Test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = test_new find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at Product 2, New Engagement, New Test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = test_new find_created_after_mark_diff_unique_id.save() @@ -1121,7 +1121,7 @@ def test_fp_history_different_unique_id_or_hash_code_same_product_different_enga find_224 = Finding.objects.get(id=224) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_224) # Copy finding 224, change hash_code, change unique_id and store it at Product 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark = self.change_finding_hash_code(find_created_before_mark) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.test = test_new @@ -1133,7 +1133,7 @@ def test_fp_history_different_unique_id_or_hash_code_same_product_different_enga find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, change unique_id and store it at Product 2, New Engagement, New Test - find_created_after_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark = self.change_finding_hash_code(find_created_after_mark) find_created_after_mark = self.change_finding_unique_id(find_created_after_mark) find_created_after_mark.test = test_new @@ -1151,14 +1151,14 @@ def test_fp_history_equal_unique_id_or_hash_code_different_product(self): find_224 = Finding.objects.get(id=224) test_new, _eng_new, _product_new = self.create_new_test_and_engagment_and_product_from_finding(find_224) # Copy finding 224, change hash_code, and store it at New Product, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_hash_code = self.change_finding_hash_code(find_created_before_mark_diff_hash_code) find_created_before_mark_diff_hash_code.test = test_new find_created_before_mark_diff_hash_code.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_hash_code, false_p=False) # Copy finding 224, change unique_id, and store it at New Product, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark_diff_unique_id = self.change_finding_unique_id(find_created_before_mark_diff_unique_id) find_created_before_mark_diff_unique_id.test = test_new find_created_before_mark_diff_unique_id.save() @@ -1169,12 +1169,12 @@ def test_fp_history_equal_unique_id_or_hash_code_different_product(self): find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at New Product, New Engagement, New Test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = test_new find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at New Product, New Engagement, New Test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = test_new find_created_after_mark_diff_unique_id.save() @@ -1199,12 +1199,12 @@ def test_fp_history_equal_unique_id_or_hash_code_different_product_dedupe_enable find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, and store it at New Product, New Engagement, New Test - find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_hash_code, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_hash_code = self.change_finding_hash_code(find_created_after_mark_diff_hash_code) find_created_after_mark_diff_hash_code.test = test_new find_created_after_mark_diff_hash_code.save() # Copy finding 224, change unique_id, and store it at New Product, New Engagement, New Test - find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark_diff_unique_id, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark_diff_unique_id = self.change_finding_unique_id(find_created_after_mark_diff_unique_id) find_created_after_mark_diff_unique_id.test = test_new find_created_after_mark_diff_unique_id.save() @@ -1221,7 +1221,7 @@ def test_fp_history_different_unique_id_or_hash_code_different_product(self): find_224 = Finding.objects.get(id=224) test_new, _eng_new, _product_new = self.create_new_test_and_engagment_and_product_from_finding(find_224) # Copy finding 224, change hash_code, change unique_id and store it at New Product, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_before_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_before_mark = self.change_finding_hash_code(find_created_before_mark) find_created_before_mark = self.change_finding_unique_id(find_created_before_mark) find_created_before_mark.test = test_new @@ -1233,7 +1233,7 @@ def test_fp_history_different_unique_id_or_hash_code_different_product(self): find_224.false_p = True find_224.save() # Copy finding 224, change hash_code, change unique_id and store it at New Product, New Engagement, New Test - find_created_after_mark, find_224 = self.copy_and_reset_finding(id=224) + find_created_after_mark, find_224 = self.copy_and_reset_finding(find_id=224) find_created_after_mark = self.change_finding_hash_code(find_created_after_mark) find_created_after_mark = self.change_finding_unique_id(find_created_after_mark) find_created_after_mark.test = test_new @@ -1252,7 +1252,7 @@ def test_fp_history_different_unique_id_or_hash_code_different_product(self): # Finding 22 in Product 2, Engagement 3, Test 33 def test_fp_history_equal_legacy_same_test(self): # Copy finding 22 and store it in the same test (to test retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -1261,7 +1261,7 @@ def test_fp_history_equal_legacy_same_test(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it in the same test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.save() # Assert that both findings belongs to the same test and are marked as fp self.assert_finding(find_created_before_mark, false_p=True, not_pk=22, test_id=33, title=find_22.title, severity=find_22.severity) @@ -1272,7 +1272,7 @@ def test_fp_history_equal_legacy_same_test_non_retroactive(self): # Disable retroactive FP history self.disable_retroactive_false_positive_history() # Copy finding 22 and store it in the same test (to test disabled retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark, false_p=False) @@ -1281,7 +1281,7 @@ def test_fp_history_equal_legacy_same_test_non_retroactive(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it in the same test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.save() # Assert that both findings belongs to the same test and only one of them is marked as fp self.assert_finding(find_created_before_mark, false_p=False, not_pk=22, test_id=33, title=find_22.title, severity=find_22.severity) @@ -1296,7 +1296,7 @@ def test_fp_history_equal_legacy_same_test_dedupe_enabled(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it in the same test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.save() # Assert that finding belongs to the same test and is NOT marked as fp self.assert_finding(find_created_after_mark, false_p=False, not_pk=22, test_id=33, title=find_22.title, severity=find_22.severity) @@ -1304,13 +1304,13 @@ def test_fp_history_equal_legacy_same_test_dedupe_enabled(self): # Finding 22 in Product 2, Engagement 3, Test 33 def test_fp_history_different_legacy_same_test(self): # Copy finding 22, change title and store it in the same test (to test retroactive replication) - find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_title = self.change_finding_title(find_created_before_mark_diff_title) find_created_before_mark_diff_title.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_title, false_p=False) # Copy finding 22, change severity and store it in the same test (to test retroactive replication) - find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_severity = self.change_finding_severity(find_created_before_mark_diff_severity) find_created_before_mark_diff_severity.save() # Makes sure that the copy is not a false positive @@ -1320,11 +1320,11 @@ def test_fp_history_different_legacy_same_test(self): find_22.false_p = True find_22.save() # Copy finding 22, change title and store it in the same test - find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_title = self.change_finding_title(find_created_after_mark_diff_title) find_created_after_mark_diff_title.save() # Copy finding 22, change severity and store it in the same test - find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_severity = self.change_finding_severity(find_created_after_mark_diff_severity) find_created_after_mark_diff_severity.save() # Assert that both findings has a different title , an equal severity, @@ -1344,7 +1344,7 @@ def test_fp_history_equal_legacy_same_engagement_different_test(self): find_22 = Finding.objects.get(id=22) test_new = self.create_new_test_from_finding(find_22) # Copy finding 22 and store it at Produt 2, Engagement 3, New Test (to test retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -1354,7 +1354,7 @@ def test_fp_history_equal_legacy_same_engagement_different_test(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it at Produt 2, Engagement 3, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and are marked as fp @@ -1369,7 +1369,7 @@ def test_fp_history_equal_legacy_same_engagement_different_test_non_retroactive( find_22 = Finding.objects.get(id=22) test_new = self.create_new_test_from_finding(find_22) # Copy finding 22 and store it at Produt 2, Engagement 3, New Test (to test disabled retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -1379,7 +1379,7 @@ def test_fp_history_equal_legacy_same_engagement_different_test_non_retroactive( find_22.false_p = True find_22.save() # Copy finding 22 and store it at Produt 2, Engagement 3, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same engagement but in a different test and only one of them is marked as fp @@ -1398,7 +1398,7 @@ def test_fp_history_equal_legacy_same_engagement_different_test_dedupe_enabled(s find_22.false_p = True find_22.save() # Copy finding 22 and store it at Produt 2, Engagement 3, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that finding belongs to the same engagement but in a different test and is NOT marked as fp @@ -1410,14 +1410,14 @@ def test_fp_history_different_legacy_same_engagement_different_test(self): find_22 = Finding.objects.get(id=22) test_new = self.create_new_test_from_finding(find_22) # Copy finding 22, change title and store it at Produt 2, Engagement 3, New Test (to test retroactive replication) - find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_title = self.change_finding_title(find_created_before_mark_diff_title) find_created_before_mark_diff_title.test = test_new find_created_before_mark_diff_title.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_title, false_p=False) # Copy finding 22, change severity and store it at Produt 2, Engagement 3, New Test (to test retroactive replication) - find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_severity = self.change_finding_severity(find_created_before_mark_diff_severity) find_created_before_mark_diff_severity.test = test_new find_created_before_mark_diff_severity.save() @@ -1428,12 +1428,12 @@ def test_fp_history_different_legacy_same_engagement_different_test(self): find_22.false_p = True find_22.save() # Copy finding 22, change severity and store it at Produt 2, Engagement 3, New Test - find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_title = self.change_finding_title(find_created_after_mark_diff_title) find_created_after_mark_diff_title.test = test_new find_created_after_mark_diff_title.save() # Copy finding 22, change severity and store it at Produt 2, Engagement 3, New Test - find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_severity = self.change_finding_severity(find_created_after_mark_diff_severity) find_created_after_mark_diff_severity.test = test_new find_created_after_mark_diff_severity.save() @@ -1454,7 +1454,7 @@ def test_fp_history_equal_legacy_same_product_different_engagement(self): find_22 = Finding.objects.get(id=22) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_22) # Copy finding 22 and store it at Produt 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -1464,7 +1464,7 @@ def test_fp_history_equal_legacy_same_product_different_engagement(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it at Produt 2, New Engagement, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same product but in a different engagement and are marked as fp @@ -1479,7 +1479,7 @@ def test_fp_history_equal_legacy_same_product_different_engagement_non_retroacti find_22 = Finding.objects.get(id=22) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_22) # Copy finding 22 and store it at Produt 2, New Engagement, New Test (to test disabled retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -1489,7 +1489,7 @@ def test_fp_history_equal_legacy_same_product_different_engagement_non_retroacti find_22.false_p = True find_22.save() # Copy finding 22 and store it at Produt 2, New Engagement, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to the same product but in a different engagement and only one of them is marked as fp @@ -1508,7 +1508,7 @@ def test_fp_history_equal_legacy_same_product_different_engagement_dedupe_enable find_22.false_p = True find_22.save() # Copy finding 22 and store it at Produt 2, New Engagement, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that finding belongs to the same product but in a different engagement and is NOT marked as fp @@ -1520,14 +1520,14 @@ def test_fp_history_different_legacy_same_product_different_engagement(self): find_22 = Finding.objects.get(id=22) test_new, _eng_new = self.create_new_test_and_engagment_from_finding(find_22) # Copy finding 22, change title and store it at Produt 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_title = self.change_finding_title(find_created_before_mark_diff_title) find_created_before_mark_diff_title.test = test_new find_created_before_mark_diff_title.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_title, false_p=False) # Copy finding 22, change severity and store it at Produt 2, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_severity = self.change_finding_severity(find_created_before_mark_diff_severity) find_created_before_mark_diff_severity.test = test_new find_created_before_mark_diff_severity.save() @@ -1538,12 +1538,12 @@ def test_fp_history_different_legacy_same_product_different_engagement(self): find_22.false_p = True find_22.save() # Copy finding 22, change severity and store it at Produt 2, New Engagement, New Test - find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_title = self.change_finding_title(find_created_after_mark_diff_title) find_created_after_mark_diff_title.test = test_new find_created_after_mark_diff_title.save() # Copy finding 22, change severity and store it at Produt 2, New Engagement, New Test - find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_severity = self.change_finding_severity(find_created_after_mark_diff_severity) find_created_after_mark_diff_severity.test = test_new find_created_after_mark_diff_severity.save() @@ -1564,7 +1564,7 @@ def test_fp_history_equal_legacy_different_product(self): find_22 = Finding.objects.get(id=22) test_new, _eng_new, _product_new = self.create_new_test_and_engagment_and_product_from_finding(find_22) # Copy finding 22 and store it at New Produt, New Engagement, New Test (to test retroactive replication) - find_created_before_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark.test = test_new find_created_before_mark.save() # Makes sure that the copy is not a false positive @@ -1574,7 +1574,7 @@ def test_fp_history_equal_legacy_different_product(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it at New Produt, New Engagement, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that both findings belongs to a different product and are NOT marked as fp @@ -1593,7 +1593,7 @@ def test_fp_history_equal_legacy_different_product_dedupe_enabled(self): find_22.false_p = True find_22.save() # Copy finding 22 and store it at New Produt, New Engagement, New Test - find_created_after_mark, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark.test = test_new find_created_after_mark.save() # Assert that finding belongs to a different product and is NOT marked as fp @@ -1605,14 +1605,14 @@ def test_fp_history_different_legacy_different_product(self): find_22 = Finding.objects.get(id=22) test_new, _eng_new, _product_new = self.create_new_test_and_engagment_and_product_from_finding(find_22) # Copy finding 22, change title and store it at New Produt, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_title = self.change_finding_title(find_created_before_mark_diff_title) find_created_before_mark_diff_title.test = test_new find_created_before_mark_diff_title.save() # Makes sure that the copy is not a false positive self.assert_finding(find_created_before_mark_diff_title, false_p=False) # Copy finding 22, change severity and store it at New Produt, New Engagement, New Test (to test retroactive replication) - find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_before_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_before_mark_diff_severity = self.change_finding_severity(find_created_before_mark_diff_severity) find_created_before_mark_diff_severity.test = test_new find_created_before_mark_diff_severity.save() @@ -1623,12 +1623,12 @@ def test_fp_history_different_legacy_different_product(self): find_22.false_p = True find_22.save() # Copy finding 22, change severity and store it at New Produt, New Engagement, New Test - find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_title, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_title = self.change_finding_title(find_created_after_mark_diff_title) find_created_after_mark_diff_title.test = test_new find_created_after_mark_diff_title.save() # Copy finding 22, change severity and store it at New Produt, New Engagement, New Test - find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(id=22) + find_created_after_mark_diff_severity, find_22 = self.copy_and_reset_finding(find_id=22) find_created_after_mark_diff_severity = self.change_finding_severity(find_created_after_mark_diff_severity) find_created_after_mark_diff_severity.test = test_new find_created_after_mark_diff_severity.save() @@ -1707,8 +1707,8 @@ def log_summary(self, product=None, engagement=None, test=None): if not product and not engagement and not test: self.log_all_products() - def copy_and_reset_finding(self, id): - org = Finding.objects.get(id=id) + def copy_and_reset_finding(find_idself, find_id): + org = Finding.objects.get(id=find_id) new = org new.pk = None new.duplicate = False @@ -1717,29 +1717,29 @@ def copy_and_reset_finding(self, id): new.active = True new.hash_code = None # return unsaved new finding and reloaded existing finding - return new, Finding.objects.get(id=id) + return new, Finding.objects.get(id=find_id) - def copy_and_reset_test(self, id): - org = Test.objects.get(id=id) + def copy_and_reset_test(self, test_id): + org = Test.objects.get(id=test_id) new = org new.pk = None # return unsaved new test and reloaded existing test - return new, Test.objects.get(id=id) + return new, Test.objects.get(id=test_id) - def copy_and_reset_engagement(self, id): - org = Engagement.objects.get(id=id) + def copy_and_reset_engagement(self, eng_id): + org = Engagement.objects.get(id=eng_id) new = org new.pk = None # return unsaved new engagement and reloaded existing engagement - return new, Engagement.objects.get(id=id) + return new, Engagement.objects.get(id=eng_id) - def copy_and_reset_product(self, id): - org = Product.objects.get(id=id) + def copy_and_reset_product(self, prod_id): + org = Product.objects.get(id=prod_id) new = org new.pk = None new.name = f"{org.name} (Copy {datetime.now()})" # return unsaved new product and reloaded existing product - return new, Product.objects.get(id=id) + return new, Product.objects.get(id=prod_id) def change_finding_hash_code(self, finding): return self.change_finding_title(finding) @@ -1824,25 +1824,25 @@ def set_dedupe_inside_engagement(self, deduplication_on_engagement): eng.save() def create_new_test_from_finding(self, finding): - test_new, _test = self.copy_and_reset_test(id=finding.test.id) + test_new, _test = self.copy_and_reset_test(test_id=finding.test.id) test_new.save() return test_new def create_new_test_and_engagment_from_finding(self, finding): - eng_new, _eng = self.copy_and_reset_engagement(id=finding.test.engagement.id) + eng_new, _eng = self.copy_and_reset_engagement(eng_id=finding.test.engagement.id) eng_new.save() - test_new, _test = self.copy_and_reset_test(id=finding.test.id) + test_new, _test = self.copy_and_reset_test(test_id=finding.test.id) test_new.engagement = eng_new test_new.save() return test_new, eng_new def create_new_test_and_engagment_and_product_from_finding(self, finding): - product_new, _product = self.copy_and_reset_product(id=finding.test.engagement.product.id) + product_new, _product = self.copy_and_reset_product(prod_id=finding.test.engagement.product.id) product_new.save() - eng_new, _eng = self.copy_and_reset_engagement(id=finding.test.engagement.id) + eng_new, _eng = self.copy_and_reset_engagement(eng_id=finding.test.engagement.id) eng_new.product = product_new eng_new.save() - test_new, _test = self.copy_and_reset_test(id=finding.test.id) + test_new, _test = self.copy_and_reset_test(test_id=finding.test.id) test_new.engagement = eng_new test_new.save() return test_new, eng_new, product_new diff --git a/unittests/test_rest_framework.py b/unittests/test_rest_framework.py index 9b58a538e43..0edd26925d6 100644 --- a/unittests/test_rest_framework.py +++ b/unittests/test_rest_framework.py @@ -291,9 +291,9 @@ def _check_helper(check): # print('_check_type ok for: %s: %s' % (schema, obj)) - def _with_prefix(self, prefix, callable, *args): + def _with_prefix(self, prefix, callable_function, *args): self._push_prefix(prefix) - callable(*args) + callable_function(*args) self._pop_prefix() def check(self, schema, obj):