Skip to content

Commit

Permalink
Merge pull request #5 from t0x01/bump/service-and-lib-changes
Browse files Browse the repository at this point in the history
ANY.RUN: Refactor/Bump - Adjust to new Sandbox service and client lib changes
  • Loading branch information
anyrun-integrations authored Dec 2, 2024
2 parents 1abf1b2 + 0efb071 commit 39779ea
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 40 deletions.
18 changes: 3 additions & 15 deletions anyrun.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"product_version_regex": ".*",
"publisher": "ANYRUN FZCO",
"license": "Copyright (c) ANYRUN FZCO, 2024",
"app_version": "1.1.0",
"app_version": "1.2.0",
"utctime_updated": "2024-03-01T10:28:44.583548Z",
"package_name": "phantom_any.run",
"main_module": "anyrun_connector.py",
Expand Down Expand Up @@ -1022,9 +1022,6 @@
"Windows7x32_clean",
"Windows7x32_office",
"Windows7x32_complete",
"Windows8.1x32_clean",
"Windows8.1x32_office",
"Windows8.1x32_complete",
"Windows10x32_clean",
"Windows10x32_office",
"Windows10x32_complete",
Expand All @@ -1034,9 +1031,6 @@
"Windows7x64_clean",
"Windows7x64_office",
"Windows7x64_complete",
"Windows8.1x64_clean",
"Windows8.1x64_office",
"Windows8.1x64_complete",
"Windows10x64_clean",
"Windows10x64_office",
"Windows10x64_complete",
Expand Down Expand Up @@ -1604,9 +1598,6 @@
"Windows7x32_clean",
"Windows7x32_office",
"Windows7x32_complete",
"Windows8.1x32_clean",
"Windows8.1x32_office",
"Windows8.1x32_complete",
"Windows10x32_clean",
"Windows10x32_office",
"Windows10x32_complete",
Expand All @@ -1616,9 +1607,6 @@
"Windows7x64_clean",
"Windows7x64_office",
"Windows7x64_complete",
"Windows8.1x64_clean",
"Windows8.1x64_office",
"Windows8.1x64_complete",
"Windows10x64_clean",
"Windows10x64_office",
"Windows10x64_complete",
Expand Down Expand Up @@ -2797,7 +2785,7 @@
},
{
"module": "anyrun",
"input_file": "wheels/anyrun_py-0.1.1-py3-none-any.whl"
"input_file": "wheels/anyrun_py-0.1.2-py3-none-any.whl"
}
]
},
Expand Down Expand Up @@ -2841,7 +2829,7 @@
},
{
"module": "anyrun",
"input_file": "wheels/py3/anyrun_py-0.1.1-py3-none-any.whl"
"input_file": "wheels/py3/anyrun_py-0.1.2-py3-none-any.whl"
}
]
}
Expand Down
60 changes: 36 additions & 24 deletions anyrun_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from __future__ import print_function, unicode_literals

import re
import time

# Phantom App imports
import phantom.app as phantom
Expand Down Expand Up @@ -467,18 +468,23 @@ def _handle_detonate_url(self, param):

# Making an API call
self.save_progress(f"Detonating URL: {obj_url}")
try:
error_message = None
response = self._anyrun_sandbox.submit_url(obj_url, obj_type, data)
except APIError as exc:
error_message = self._get_error_message_from_exception(exc)
except Exception as exc: # pylint: disable=broad-except
error_message = self._get_error_message_from_exception(exc)
error_message = ANYRUN_REST_API_ERROR.format(ACTION_ID_ANYRUN_DETONATE_URL, error_message)
finally:
if error_message:
self.save_progress(error_message)
return action_result.set_status(phantom.APP_ERROR, error_message)
response = None
while response is None:
try:
error_message = None
response = self._anyrun_sandbox.submit_url(obj_url, obj_type, data)
except APIError as exc:
if exc.message == "Parallel task limit":
time.sleep(5)
continue
error_message = self._get_error_message_from_exception(exc)
except Exception as exc: # pylint: disable=broad-except
error_message = self._get_error_message_from_exception(exc)
error_message = ANYRUN_REST_API_ERROR.format(ACTION_ID_ANYRUN_DETONATE_URL, error_message)
finally:
if error_message:
self.save_progress(error_message)
return action_result.set_status(phantom.APP_ERROR, error_message)
self.save_progress(ANYRUN_SUCCESS_DETONATE_URL.format(obj_url))

# Processing server response
Expand Down Expand Up @@ -548,18 +554,24 @@ def _handle_detonate_file(self, param):

# Making an API call
self.save_progress(f"Detonating file with vault ID: {vault_id}")
try:
error_message = None
response = self._anyrun_sandbox.submit_file(file_path, data)
except APIError as exc:
error_message = self._get_error_message_from_exception(exc)
except Exception as exc: # pylint: disable=broad-except
error_message = self._get_error_message_from_exception(exc)
error_message = ANYRUN_REST_API_ERROR.format(ACTION_ID_ANYRUN_DETONATE_FILE, error_message)
finally:
if error_message:
self.save_progress(error_message)
return action_result.set_status(phantom.APP_ERROR, error_message)
response = None
while response is None:
try:
error_message = None
with open(file_path, "rb") as file:
response = self._anyrun_sandbox.submit_file(file, data)
except APIError as exc:
if exc.message == "Parallel task limit":
time.sleep(5)
continue
error_message = self._get_error_message_from_exception(exc)
except Exception as exc: # pylint: disable=broad-except
error_message = self._get_error_message_from_exception(exc)
error_message = ANYRUN_REST_API_ERROR.format(ACTION_ID_ANYRUN_DETONATE_FILE, error_message)
finally:
if error_message:
self.save_progress(error_message)
return action_result.set_status(phantom.APP_ERROR, error_message)
self.save_progress(ANYRUN_SUCCESS_DETONATE_FILE.format(vault_id))

# Processing server response
Expand Down
2 changes: 1 addition & 1 deletion manual_readme_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ This connector comes with some additional python 3 libraries, that it depends on
- yarl-1.9.4 (Apache License 2.0, Copyright 2016-2021, Andrew Svetlov and aio-libs team)
- frozenlist-1.4.1 (Apache License 2.0, Copyright 2013-2019 Nikolay Kim and Andrew Svetlov)
- aiohttp-3.10.2 (Apache License 2.0, Copyright aio-libs contributors)
- anyrun_py-0.1.1
- anyrun_py-0.1.2
3 changes: 3 additions & 0 deletions release_notes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
**Unreleased**
* Removed Windows 8.1 options from `detonate` actions
* Added "Parallel task limit" error handling to `detonate` actions
* Updated anyrun-py lib
Binary file removed wheels/anyrun_py-0.1.1-py3-none-any.whl
Binary file not shown.
Binary file added wheels/anyrun_py-0.1.2-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/anyrun_py-0.1.1-py3-none-any.whl
Binary file not shown.
Binary file added wheels/py3/anyrun_py-0.1.2-py3-none-any.whl
Binary file not shown.

0 comments on commit 39779ea

Please sign in to comment.