Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.27.5
-------
- Add PasswordProtectedArchiveError raised when a submitted archive is password protected

1.27.4
-------
- Add alert_update_time field to alert and remove case_association_time
Expand Down
2 changes: 1 addition & 1 deletion intezer_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.27.4'
__version__ = '1.27.5'
3 changes: 3 additions & 0 deletions intezer_sdk/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,9 @@ def _assert_analysis_response_status_code(response: Response):
if error == 'Invalid url':
raise errors.InvalidUrlError(response)

if error == 'Archive is password protected':
raise errors.PasswordProtectedArchiveError(response)

raise errors.ServerError(f'Server returned bad request error: {error}, details: {details}', response)
case HTTPStatus.CREATED:
pass
Expand Down
7 changes: 7 additions & 0 deletions intezer_sdk/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ def __init__(self, response: requests.Response):
super().__init__('Invalid url', response)


class PasswordProtectedArchiveError(ServerError):
"""Raised when the submitted archive is password protected and cannot be extracted."""

def __init__(self, response: requests.Response):
super().__init__('Archive is password protected', response)


class AnalysisSkippedByRuleError(ServerError):
def __init__(self, response: requests.Response):
super().__init__('Analysis skipped by rule', response)
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/test_file_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,34 @@ def test_send_analysis_by_sha256_that_is_too_large_raise_error(self):
with self.assertRaises(errors.FileTooLargeError):
analysis.send()

def test_send_analysis_of_password_protected_archive_raise_error(self):
# Arrange
with responses.RequestsMock() as mock:
mock.add('POST',
url=f'{self.full_url}/analyze',
status=HTTPStatus.BAD_REQUEST,
json={'error': 'Archive is password protected'})
analysis = FileAnalysis(file_path='a')

with patch(self.patch_prop, mock_open_bytes()):
# Act + Assert
with self.assertRaises(errors.PasswordProtectedArchiveError):
analysis.send()

def test_password_protected_archive_error_is_a_server_error(self):
# Arrange
with responses.RequestsMock() as mock:
mock.add('POST',
url=f'{self.full_url}/analyze',
status=HTTPStatus.BAD_REQUEST,
json={'error': 'Archive is password protected'})
analysis = FileAnalysis(file_path='a')

with patch(self.patch_prop, mock_open_bytes()):
# Act + Assert
with self.assertRaises(errors.ServerError):
analysis.send()

def test_send_analysis_by_sha256_with_expired_jwt_token_gets_new_token(self):
# Arrange
analysis = FileAnalysis(file_hash='a' * 64)
Expand Down
Loading