From 7e9190ae7598010b60dfe5553cb9c339e3155e61 Mon Sep 17 00:00:00 2001 From: Jino Tesauro Date: Mon, 27 Oct 2025 12:17:58 -0500 Subject: [PATCH 1/2] Added code, tested on the api, not tested in pro-ui yet --- dojo/api_v2/serializers.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dojo/api_v2/serializers.py b/dojo/api_v2/serializers.py index 5de0698edee..eb7c7a08a2f 100644 --- a/dojo/api_v2/serializers.py +++ b/dojo/api_v2/serializers.py @@ -1692,6 +1692,9 @@ class FindingSerializer(serializers.ModelSerializer): many=True, read_only=True, source="risk_acceptance_set", ) push_to_jira = serializers.BooleanField(default=False) + found_by = serializers.PrimaryKeyRelatedField( + queryset=Test_Type.objects.all(), many=True, + ) age = serializers.IntegerField(read_only=True) sla_days_remaining = serializers.IntegerField(read_only=True, allow_null=True) finding_meta = FindingMetaSerializer(read_only=True, many=True) @@ -1774,6 +1777,18 @@ def update(self, instance, validated_data): if parsed_vulnerability_ids: save_vulnerability_ids(instance, parsed_vulnerability_ids) + # Get found_by from validated_data + found_by = validated_data.pop("found_by", None) + + # Handle updates to found_by data + if found_by: + instance.found_by.clear() + instance.found_by.add(*found_by) + # If there is no argument entered for found_by, the user would like to clear out the values on the Finding's found_by field + # Findings still maintain original found_by value associated with their test + else: + instance.found_by.clear() + instance = super().update( instance, validated_data, ) From ce7b737cdfe10cfd0ea339295c51be1c85de9bbd Mon Sep 17 00:00:00 2001 From: Jino Tesauro <53376807+Jino-T@users.noreply.github.com> Date: Tue, 28 Oct 2025 10:46:26 -0500 Subject: [PATCH 2/2] Update dojo/api_v2/serializers.py Use found_by.set to better replace values Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com> --- dojo/api_v2/serializers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dojo/api_v2/serializers.py b/dojo/api_v2/serializers.py index eb7c7a08a2f..806a8a1453a 100644 --- a/dojo/api_v2/serializers.py +++ b/dojo/api_v2/serializers.py @@ -1779,16 +1779,14 @@ def update(self, instance, validated_data): # Get found_by from validated_data found_by = validated_data.pop("found_by", None) - # Handle updates to found_by data if found_by: - instance.found_by.clear() - instance.found_by.add(*found_by) + instance.found_by.set(found_by) # If there is no argument entered for found_by, the user would like to clear out the values on the Finding's found_by field # Findings still maintain original found_by value associated with their test - else: + # In the event the user does not supply the found_by field at all, we do not modify it + elif isinstance(found_by, list) and len(found_by) == 0: instance.found_by.clear() - instance = super().update( instance, validated_data, )