|
112 | 112 | is_finding_groups_enabled, |
113 | 113 | is_scan_file_too_large, |
114 | 114 | ) |
115 | | -from dojo.validators import tag_validator |
| 115 | +from dojo.validators import ImporterFileExtensionValidator, tag_validator |
116 | 116 | from dojo.widgets import TableCheckboxWidget |
117 | 117 |
|
118 | 118 | logger = logging.getLogger(__name__) |
@@ -525,11 +525,15 @@ class ImportScanForm(forms.Form): |
525 | 525 | source_code_management_uri = forms.URLField(max_length=600, required=False, help_text="Resource link to source code") |
526 | 526 | tags = TagField(required=False, help_text="Add tags that help describe this scan. " |
527 | 527 | "Choose from the list or add new tags. Press Enter key to add.") |
528 | | - file = forms.FileField(widget=forms.widgets.FileInput( |
529 | | - attrs={"accept": ".xml, .csv, .nessus, .json, .jsonl, .html, .js, .zip, .xlsx, .txt, .sarif"}), |
| 528 | + file = forms.FileField( |
| 529 | + widget=forms.widgets.FileInput( |
| 530 | + attrs={"accept": ".xml, .csv, .nessus, .json, .jsonl, .html, .js, .zip, .xlsx, .txt, .sarif"}, |
| 531 | + ), |
530 | 532 | label="Choose report file", |
531 | 533 | allow_empty_file=True, |
532 | | - required=False) |
| 534 | + required=False, |
| 535 | + validators=[ImporterFileExtensionValidator()], |
| 536 | + ) |
533 | 537 |
|
534 | 538 | # Close Old Findings has changed. The default is engagement only, and it requires a second flag to expand to the product scope. |
535 | 539 | # Exposing the choice as two different check boxes. |
@@ -646,11 +650,15 @@ class ReImportScanForm(forms.Form): |
646 | 650 | endpoints = forms.ModelMultipleChoiceField(Endpoint.objects, required=False, label="Systems / Endpoints") |
647 | 651 | tags = TagField(required=False, help_text="Modify existing tags that help describe this scan. " |
648 | 652 | "Choose from the list or add new tags. Press Enter key to add.") |
649 | | - file = forms.FileField(widget=forms.widgets.FileInput( |
650 | | - attrs={"accept": ".xml, .csv, .nessus, .json, .jsonl, .html, .js, .zip, .xlsx, .txt, .sarif"}), |
| 653 | + file = forms.FileField( |
| 654 | + widget=forms.widgets.FileInput( |
| 655 | + attrs={"accept": ".xml, .csv, .nessus, .json, .jsonl, .html, .js, .zip, .xlsx, .txt, .sarif"}, |
| 656 | + ), |
651 | 657 | label="Choose report file", |
652 | 658 | allow_empty_file=True, |
653 | | - required=False) |
| 659 | + required=False, |
| 660 | + validators=[ImporterFileExtensionValidator()], |
| 661 | + ) |
654 | 662 | close_old_findings = forms.BooleanField(help_text="Select if old findings in the same test that are no longer present in the report get closed as mitigated when importing.", |
655 | 663 | required=False, initial=True) |
656 | 664 | version = forms.CharField(max_length=100, required=False, help_text="Version that will be set on existing Test object. Leave empty to leave existing value in place.") |
|
0 commit comments