Skip to content

Commit 0749bd3

Browse files
Merge branch '2.7.0-branch' into 'develop'
v2.7.0 See merge request integrations/reversinglabs-sdk-py3!3
2 parents 05bd483 + 8d553fc commit 0749bd3

File tree

7 files changed

+284
-98
lines changed

7 files changed

+284
-98
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,24 @@ v2.5.1 (2024-04-02)
332332
- Implemented the default user agent string in embedded `FileAnalysis` calls.
333333

334334

335+
2.7.0 (2024-07-24)
336+
-------------------
337+
338+
#### Improvements
339+
- **ticloud** module:
340+
- `rha1_type` is now an optional parameter in the `RHA1FunctionalSimilarity` and `RHA1Analitics` class methods. The user can decide if it should be passed in manually or calculated automatically.
341+
- `detonate_url` and `detonate_sample` methods of the `DynamicAnalysis` class now accept optional parameters through `**optional_parameters`. Optional parameters should be passed in as key-value pairs (kwargs). Named parameters `internet_simulation` and `sample_name` are now deprecated and should be used through `**optional_parameters`.
342+
- Added the `AdvancedActions` class containing the `enriched_file_analysis` method which returns a File Analysis report enriched with Dynamic Analysis.
343+
344+
#### Deprecations
345+
- **ticloud** module:
346+
- Parameters `internet_simulation` and `sample_name` of the `DynamicAnalysis.detonate_sample` method are now deprecated. Use `**optional_parameters` instead.
347+
348+
349+
350+
335351
### Scheduled removals
336352
- **December 2024.**:
337-
- In the `ticloud.DynamicAnalysis.detonate_sample` method the `sample_sha1` parameter will be removed.
353+
- Parameter `sample_sha1` from the `ticloud.DynamicAnalysis.detonate_sample` method will be removed. Parameter `sample_hash` should be used instead.
354+
- **March 2025.**:
355+
- Parameters `internet_simulation` and `sample_name` from the `ticloud.DynamicAnalysis.detonate_sample` method will be removed and should be further used through `**optional_parameters`.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,13 @@ class TAXIIRansomwareFeed(TiCloudAPI)
879879
- Returns objects from a TAXII collection.
880880
- This method does the paging automatically and returns a defined number of objects as a list in the end.
881881

882+
#### Class:
883+
```python
884+
class AdvancedActions(object)
885+
````
886+
#### Methods:
887+
- `enriched_file_analysis`
888+
- Accepts a sample hash and returns a TCA-0104 File Analysis report enriched with a TCA-0106 Dynamic Analysis report.
882889

883890
***
884891

ReversingLabs/SDK/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
A Python SDK for communicating with ReversingLabs services.
66
"""
77

8-
__version__ = "2.6.4"
8+
__version__ = "2.7.0"

ReversingLabs/SDK/a1000.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class A1000(object):
7474
"identification_name", "identification_version", "file_size", "extracted_file_count",
7575
"local_first_seen", "local_last_seen", "classification_origin", "classification_reason",
7676
"classification_source", "classification", "riskscore", "classification_result", "ticore", "tags",
77-
"summary", "ticloud", "aliases", "networkthreatintelligence", "domainthreatintelligence"
77+
"summary", "ticloud", "aliases", "networkthreatintelligence", "domainthreatintelligence", "imphash",
78+
"discussion", "proposed_filename", "av_scanners", "av_scanners_summary"
7879
)
7980

8081
__TITANIUM_CORE_FIELDS = "sha1, sha256, sha512, md5, imphash, info, application, protection, security, behaviour," \
@@ -555,7 +556,8 @@ def upload_sample_and_get_summary_report_v2(self, file_path=None, file_source=No
555556

556557
return response
557558

558-
def get_detailed_report_v2(self, sample_hashes, retry=False, fields=None, skip_reanalysis=False):
559+
def get_detailed_report_v2(self, sample_hashes, retry=False, fields=None, skip_reanalysis=False,
560+
include_networkthreatintelligence=True):
559561
"""Accepts a single hash or a list of hashes and returns a detailed analysis report for the selected samples.
560562
This method utilizes the set number of retries and wait time in seconds and times out if the
561563
analysis results are not ready.
@@ -567,6 +569,8 @@ def get_detailed_report_v2(self, sample_hashes, retry=False, fields=None, skip_r
567569
:type fields: list[str]
568570
:param skip_reanalysis: skip sample reanalysis when fetching the summary report
569571
:type skip_reanalysis: bool
572+
:param include_networkthreatintelligence: include network threat intelligence in the detailed report
573+
:type include_networkthreatintelligence: bool
570574
:return: :class:`Response <Response>` object
571575
:rtype: requests.Response
572576
"""
@@ -617,16 +621,22 @@ def get_detailed_report_v2(self, sample_hashes, retry=False, fields=None, skip_r
617621
"skip_reanalysis": str(skip_reanalysis).lower()
618622
}
619623

620-
response = self.__post_request(url=url, data=data)
624+
if include_networkthreatintelligence:
625+
if "networkthreatintelligence" not in fields or "domainthreatintelligence" not in fields:
626+
raise WrongInputError("If include_networkthreatintelligence is set to True, the fields list must "
627+
"include both 'networkthreatintelligence' and 'domainthreatintelligence'.")
628+
629+
data["include_networkthreatintelligence"] = str(include_networkthreatintelligence).lower()
621630

631+
response = self.__post_request(url=url, data=data)
622632
self.__raise_on_error(response)
623633

624634
return response
625635

626636
def upload_sample_and_get_detailed_report_v2(self, file_path=None, file_source=None, retry=True, fields=None,
627637
custom_filename=None, tags=None, comment=None, cloud_analysis=True,
628638
archive_password=None, rl_cloud_sandbox_platform=None,
629-
skip_reanalysis=False):
639+
skip_reanalysis=False, include_networkthreatintelligence=True):
630640
"""Accepts either a file path string or an open file in 'rb' mode for file upload and returns a detailed
631641
analysis report response. This method combines uploading a sample and obtaining the detailed analysis report.
632642
Additional fields can be provided.
@@ -654,6 +664,8 @@ def upload_sample_and_get_detailed_report_v2(self, file_path=None, file_source=N
654664
:type archive_password: str
655665
:param rl_cloud_sandbox_platform: Cloud Sandbox platform (windows7, windows10 or macos_11)
656666
:type rl_cloud_sandbox_platform: str
667+
:param include_networkthreatintelligence: include network threat intelligence in the detailed report
668+
:type include_networkthreatintelligence: bool
657669
:return: response
658670
:rtype: requests.Response
659671
"""
@@ -676,7 +688,8 @@ def upload_sample_and_get_detailed_report_v2(self, file_path=None, file_source=N
676688
sample_hashes=sha1,
677689
retry=retry,
678690
fields=fields,
679-
skip_reanalysis=skip_reanalysis
691+
skip_reanalysis=skip_reanalysis,
692+
include_networkthreatintelligence=include_networkthreatintelligence
680693
)
681694

682695
return response

ReversingLabs/SDK/helper.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
import codecs
99
import binascii
10+
from functools import wraps
1011
from http import HTTPStatus
12+
import inspect
13+
from warnings import warn
14+
1115
from ReversingLabs.SDK import __version__
1216

1317

@@ -170,3 +174,31 @@ def validate_hashes(hash_input, allowed_hash_types):
170174
"Only hash strings of the following types are allowed as input values: {allowed}".format(
171175
allowed=allowed_hash_types
172176
))
177+
178+
179+
def deprecated_args(dpr_args: list):
180+
def decorator(func):
181+
@wraps(func)
182+
def wrapper(*args, **kwargs):
183+
arg_names = list(inspect.getfullargspec(func).args)
184+
arg_names.extend(dpr_args)
185+
args_kv = dict(zip(arg_names, args))
186+
new_args = list(args)
187+
for k in dpr_args:
188+
if k not in kwargs and k in args_kv:
189+
if k == "sample_sha1":
190+
warn(f"DEPRECATION WARNING - Parameter sample_sha1 is deprecated. "
191+
f"Start using sample_hash instead.", Warning)
192+
193+
else:
194+
warn(f"DEPRECATION WARNING - Parameter {k} is deprecated. "
195+
f"Start using it through optional_parameters.", Warning)
196+
arg_idx = arg_names.index(k)
197+
del new_args[arg_idx]
198+
del arg_names[arg_idx]
199+
kwargs[k] = args_kv[k]
200+
return func(*new_args, **kwargs)
201+
202+
return wrapper
203+
204+
return decorator

0 commit comments

Comments
 (0)