@@ -2065,7 +2065,6 @@ class CommonImportScanSerializer(serializers.Serializer):
20652065 help_text = "Override the verified setting from the tool." ,
20662066 )
20672067
2068- scan_type = serializers .ChoiceField (choices = get_choices_sorted ())
20692068 # TODO: why do we allow only existing endpoints?
20702069 endpoint_to_add = serializers .PrimaryKeyRelatedField (
20712070 queryset = Endpoint .objects .all (),
@@ -2093,26 +2092,8 @@ class CommonImportScanSerializer(serializers.Serializer):
20932092 lead = serializers .PrimaryKeyRelatedField (
20942093 allow_null = True , default = None , queryset = User .objects .all (),
20952094 )
2096- tags = TagListSerializerField (
2097- required = False , allow_empty = True , help_text = "Add tags that help describe this scan." ,
2098- )
2099- close_old_findings = serializers .BooleanField (
2100- required = False ,
2101- default = False ,
2102- help_text = "Select if old findings no longer present in the report get closed as mitigated when importing. "
2103- "If service has been set, only the findings for this service will be closed." ,
2104- )
2105- close_old_findings_product_scope = serializers .BooleanField (
2106- required = False ,
2107- default = False ,
2108- help_text = "Select if close_old_findings applies to all findings of the same type in the product. "
2109- "By default, it is false meaning that only old findings of the same type in the engagement are in scope." ,
2110- )
21112095 push_to_jira = serializers .BooleanField (default = False )
21122096 environment = serializers .CharField (required = False )
2113- version = serializers .CharField (
2114- required = False , help_text = "Version that was scanned." ,
2115- )
21162097 build_id = serializers .CharField (
21172098 required = False , help_text = "ID of the build that was scanned." ,
21182099 )
@@ -2281,11 +2262,28 @@ def setup_common_context(self, data: dict) -> dict:
22812262
22822263
22832264class ImportScanSerializer (CommonImportScanSerializer ):
2284-
2265+ scan_type = serializers . ChoiceField ( choices = get_choices_sorted ())
22852266 engagement = serializers .PrimaryKeyRelatedField (
22862267 queryset = Engagement .objects .all (), required = False ,
22872268 )
2288-
2269+ tags = TagListSerializerField (
2270+ required = False , allow_empty = True , help_text = "Add tags that help describe this scan." ,
2271+ )
2272+ close_old_findings = serializers .BooleanField (
2273+ required = False ,
2274+ default = False ,
2275+ help_text = "Select if old findings no longer present in the report get closed as mitigated when importing. "
2276+ "If service has been set, only the findings for this service will be closed." ,
2277+ )
2278+ close_old_findings_product_scope = serializers .BooleanField (
2279+ required = False ,
2280+ default = False ,
2281+ help_text = "Select if close_old_findings applies to all findings of the same type in the product. "
2282+ "By default, it is false meaning that only old findings of the same type in the engagement are in scope." ,
2283+ )
2284+ version = serializers .CharField (
2285+ required = False , help_text = "Version that was scanned." ,
2286+ )
22892287 # extra fields populated in response
22902288 # need to use the _id suffix as without the serializer framework gets
22912289 # confused
@@ -2341,9 +2339,36 @@ class ReImportScanSerializer(TaggitSerializer, CommonImportScanSerializer):
23412339 do_not_reactivate = serializers .BooleanField (
23422340 default = False , required = False , help_text = help_do_not_reactivate ,
23432341 )
2342+ scan_type = serializers .ChoiceField (
2343+ choices = get_choices_sorted (), required = True ,
2344+ )
23442345 test = serializers .PrimaryKeyRelatedField (
23452346 required = False , queryset = Test .objects .all (),
23462347 )
2348+ # Close the old findings if the parameter is not provided. This is to
2349+ # maintain the old API behavior after reintroducing the close_old_findings parameter
2350+ # also for ReImport.
2351+ close_old_findings = serializers .BooleanField (
2352+ required = False ,
2353+ default = True ,
2354+ help_text = "Select if old findings no longer present in the report get closed as mitigated when importing." ,
2355+ )
2356+ close_old_findings_product_scope = serializers .BooleanField (
2357+ required = False ,
2358+ default = False ,
2359+ help_text = "Select if close_old_findings applies to all findings of the same type in the product. "
2360+ "By default, it is false meaning that only old findings of the same type in the engagement are in scope. "
2361+ "Note that this only applies on the first call to reimport-scan." ,
2362+ )
2363+ version = serializers .CharField (
2364+ required = False ,
2365+ help_text = "Version that will be set on existing Test object. Leave empty to leave existing value in place." ,
2366+ )
2367+ tags = TagListSerializerField (
2368+ required = False ,
2369+ allow_empty = True ,
2370+ help_text = "Modify existing tags that help describe this scan. (Existing test tags will be overwritten)" ,
2371+ )
23472372
23482373 def set_context (
23492374 self ,
0 commit comments