@@ -1692,6 +1692,9 @@ class FindingSerializer(serializers.ModelSerializer):
16921692 many = True , read_only = True , source = "risk_acceptance_set" ,
16931693 )
16941694 push_to_jira = serializers .BooleanField (default = False )
1695+ found_by = serializers .PrimaryKeyRelatedField (
1696+ queryset = Test_Type .objects .all (), many = True ,
1697+ )
16951698 age = serializers .IntegerField (read_only = True )
16961699 sla_days_remaining = serializers .IntegerField (read_only = True , allow_null = True )
16971700 finding_meta = FindingMetaSerializer (read_only = True , many = True )
@@ -1774,6 +1777,16 @@ def update(self, instance, validated_data):
17741777 if parsed_vulnerability_ids :
17751778 save_vulnerability_ids (instance , parsed_vulnerability_ids )
17761779
1780+ # Get found_by from validated_data
1781+ found_by = validated_data .pop ("found_by" , None )
1782+ # Handle updates to found_by data
1783+ if found_by :
1784+ instance .found_by .set (found_by )
1785+ # 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
1786+ # Findings still maintain original found_by value associated with their test
1787+ # In the event the user does not supply the found_by field at all, we do not modify it
1788+ elif isinstance (found_by , list ) and len (found_by ) == 0 :
1789+ instance .found_by .clear ()
17771790 instance = super ().update (
17781791 instance , validated_data ,
17791792 )
0 commit comments