Skip to content

Commit

Permalink
fix: Make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jun 14, 2024
1 parent 64b2622 commit 57a7bc4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pandora/workers/blocklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ def analyse(self, task: Task, report: Report, manual_trigger: bool=False) -> Non
report.add_details('Info', f'The result for files with extension {ext} is overwritten by the admin. It generally means we cannot decide on the status of the file. Contact your admin for more details.')

if ext in self.malicious_extensions:
report.status = 'malicious_extension'
report.status = 'malicious_extension' # type: ignore[assignment]
report.add_details('Warning', f'The extension {ext} is considered as malicious by default.')

if self.enable_mimetypes:
if not task.file.mime_type:
report.status = 'no_mimetype'
report.status = 'no_mimetype' # type: ignore[assignment]
report.add_details('Warning', 'Unable to find a mime type.')
elif task.file.mime_type in self.malicious_mimetypes:
report.status = 'malicious_mimetype'
report.status = 'malicious_mimetype' # type: ignore[assignment]
report.add_details('Warning', f'The mimetype {task.file.mime_type} is considered as malicious by default.')
else:
guessed_type, encoding = mimetypes.guess_type(task.file.original_filename)
if not guessed_type:
report.status = 'cannot_guess_mimetype'
report.status = 'cannot_guess_mimetype' # type: ignore[assignment]
report.add_details('Warning', 'Unable to guess the mimetype based on the filename. This is a known technique used to bypass detection. If you are unsure what do to, talk to your administrator.')
else:
list_valid_mimetypes = [guessed_type]
if guessed_type in self.synonyms:
list_valid_mimetypes += self.synonyms[guessed_type]
if task.file.mime_type not in list_valid_mimetypes:
report.status = 'missmatch_mimetype'
report.status = 'missmatch_mimetype' # type: ignore[assignment]
report.add_details('Warning', f'The mimetype guessed from the filename ({guessed_type}) differs from the one guessed by magic ({task.file.mime_type}). It is a known technique used to bypass detections.')

0 comments on commit 57a7bc4

Please sign in to comment.