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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,12 @@ v2.5.1 (2024-04-02)
-------------------

#### Improvements
- Added more unit tests for all currently available modules.
- Added more unit tests for all currently available modules.


2.6.3 (2024-07-17)
-------------------

#### Bugfixes
- **a1000** module:
- Changed the `upload_sample_from_url` method's name to `submit_url_for_analysis`.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ If username and password are used instead, a token fetching request will be done
- Accepts a file path string and returns a response containing the analysis task ID
- `upload_sample_from_file`
- Accepts a file open in 'rb' mode and returns a response containing the analysis task ID
- `upload_sample_from_url`
- Accepts a url and returns a response containing the analysis task ID
- `submit_url_for_analysis`
- Sends a URL for analysis on A1000.
- `check_submitted_url_status`
- Accepts a task id returned by upload_sample_from_url and returns a response containing processing status and
report if the report is ready
Expand All @@ -57,8 +57,8 @@ If username and password are used instead, a token fetching request will be done
- Accepts a task ID returned by upload_sample_from_url and returns a response
- This method utilizes the set number of retries and wait time in seconds to time
out if the analysis results are not ready
- `upload_sample_from_url_and_get_report`
- Accepts a url and returns a response containing the analysis report
- `submit_url_for_analysis_and_get_report`
- Sends a URL for analysis on A1000.
- The result fetching action of this method utilizes the set number of retries and wait time in seconds to time
out if the analysis results are not ready
- `get_summary_report_v2`
Expand Down
2 changes: 1 addition & 1 deletion ReversingLabs/SDK/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
A Python SDK for communicating with ReversingLabs services.
"""

__version__ = "2.6.2"
__version__ = "2.6.3"
48 changes: 24 additions & 24 deletions ReversingLabs/SDK/a1000.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ def upload_sample_from_file(self, file_source, custom_filename=None, archive_pas

return response

def upload_sample_from_url(self, file_url, crawler=None, archive_password=None, rl_cloud_sandbox_platform=None):
"""Accepts a file url and returns a response.
def submit_url_for_analysis(self, url_string, crawler=None, archive_password=None, rl_cloud_sandbox_platform=None):
"""Sends a URL for analysis on A1000.
Additional parameters can be provided.
:param file_url: URL from which the appliance should download the data
:type file_url: str
:param url_string: URL to analyze
:type url_string: str
:param crawler: crawler method (local or cloud)
:type crawler: str
:param archive_password: password, if file is a password-protected archive
:param archive_password: password, if it is a password-protected archive
:type archive_password: str
:param rl_cloud_sandbox_platform: Cloud Sandbox platform (windows7, windows10 or macos_11)
:type rl_cloud_sandbox_platform: str
Expand All @@ -283,7 +283,7 @@ def upload_sample_from_url(self, file_url, crawler=None, archive_password=None,
crawler=crawler,
archive_password=archive_password,
rl_cloud_sandbox_platform=rl_cloud_sandbox_platform,
file_url=file_url
url_string=url_string
)

url = self._url.format(endpoint=self.__UPLOAD_ENDPOINT)
Expand Down Expand Up @@ -381,30 +381,30 @@ def get_submitted_url_report(self, task_id, retry):
raise RequestTimeoutError("Report fetching attempts finished - The analysis report is still not ready "
"or the sample does not exist on the appliance.")

def upload_sample_from_url_and_get_report(self, file_url, retry=True, crawler="local", archive_password=None,
rl_cloud_sandbox_platform=None):
"""Accepts a file url for file upload and returns a report response.
This method combines uploading a sample from url and obtaining the summary analysis report.
def submit_url_for_analysis_and_get_report(self, url_string, retry=True, crawler="local", archive_password=None,
rl_cloud_sandbox_platform=None):
"""Sends a URL for analysis on A1000.
This method combines submitting a URL for analysis and obtaining the summary analysis report.
Additional fields can be provided.
The result fetching action of this method utilizes the set number of retries and wait time in seconds to time
out if the analysis results are not ready.
:param file_url: URL from which the appliance should download the data
:type file_url: str
:param url_string: URL to analyze
:type url_string: str
:param retry: if set to False there will only be one try at obtaining the analysis report
:type retry: bool
:param crawler: crawler method (local or cloud)
:type crawler: string
:param archive_password: password, if file is a password-protected archive
:param archive_password: password, if it is a password-protected archive
:type archive_password: str
:param rl_cloud_sandbox_platform: Cloud Sandbox platform (windows7, windows10 or macos_11)
:type rl_cloud_sandbox_platform: str
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""

upload_response = self.upload_sample_from_url(file_url=file_url, crawler=crawler,
archive_password=archive_password,
rl_cloud_sandbox_platform=rl_cloud_sandbox_platform)
upload_response = self.submit_url_for_analysis(url_string=url_string, crawler=crawler,
archive_password=archive_password,
rl_cloud_sandbox_platform=rl_cloud_sandbox_platform)

response_detail = upload_response.json().get("detail")
task_id = response_detail.get("id")
Expand Down Expand Up @@ -2287,15 +2287,15 @@ def __get_token(self, username, password):
return token

@staticmethod
def __create_post_payload(custom_filename=None, file_url=None, crawler=None, archive_password=None,
def __create_post_payload(custom_filename=None, url_string=None, crawler=None, archive_password=None,
rl_cloud_sandbox_platform=None, tags=None, comment=None, cloud_analysis=True,
classification=None, risk_score=None, threat_platform=None, threat_type=None,
threat_name=None, name=None, content=None, publish=None, ticloud=None):
"""Accepts optional fields and returns a formed dictionary of those fields.
:param custom_filename: custom file name for upload
:type custom_filename: str
:param file_url: URL from which the appliance should download the data
:type file_url: str
:param url_string: URL to analyze
:type url_string: str
:param crawler: crawler method (local or cloud)
:type crawler: str
:param archive_password: password, if file is a password-protected archive
Expand Down Expand Up @@ -2340,10 +2340,10 @@ def __create_post_payload(custom_filename=None, file_url=None, crawler=None, ar
if tags and not isinstance(tags, str):
raise WrongInputError("tags parameter must be string.")

if file_url:
if not isinstance(file_url, str):
if url_string:
if not isinstance(url_string, str):
raise WrongInputError("file_url parameter must be string.")
if not file_url.startswith(("http://", "https://")):
if not url_string.startswith(("http://", "https://")):
raise WrongInputError("Supported file_url protocols are HTTP and HTTPS.")

if crawler and crawler not in ("cloud", "local"):
Expand Down Expand Up @@ -2417,8 +2417,8 @@ def __create_post_payload(custom_filename=None, file_url=None, crawler=None, ar
if cloud_analysis:
data["analysis"] = "cloud"

if file_url:
data["url"] = file_url
if url_string:
data["url"] = url_string

if classification:
data['classification'] = classification
Expand Down
4 changes: 2 additions & 2 deletions tests/test_a1000.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class TestA1000:
def setup_class(cls):
cls.a1000 = A1000(cls.host, token=cls.token)

def test_sample_from_url(self, requests_mock):
self.a1000.upload_sample_from_url(file_url="https://some.url")
def test_submit_url(self, requests_mock):
self.a1000.submit_url_for_analysis(url_string="https://some.url")

expected_url = f"{self.host}/api/uploads/"

Expand Down