Skip to content

Commit 9d6721c

Browse files
Merge branch '2.9.0-branch' into 'develop'
2.9.0 branch See merge request integrations/sdk/reversinglabs-sdk-py3!13
2 parents 6fd665f + ebfe901 commit 9d6721c

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

ReversingLabs/SDK/ticloud.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -6032,10 +6032,9 @@ def feed_query(self, family_name, time_format, time_value, count=100):
60326032

60336033
self._raise_on_error(response)
60346034

6035-
return response
6036-
6035+
return response
60376036

6038-
class TAXIIRansomwareFeed(TiCloudAPI):
6037+
class TAXIIFeed(TiCloudAPI):
60396038
"""TCTF-0001"""
60406039

60416040
__DISCOVERY_ENDPOINT = "/api/taxii/taxii2/"
@@ -6044,7 +6043,7 @@ class TAXIIRansomwareFeed(TiCloudAPI):
60446043

60456044
def __init__(self, host, username, password, verify=True, proxies=None, user_agent=DEFAULT_USER_AGENT,
60466045
allow_none_return=False):
6047-
super(TAXIIRansomwareFeed, self).__init__(host, username, password, verify, proxies,
6046+
super(TAXIIFeed, self).__init__(host, username, password, verify, proxies,
60486047
user_agent=user_agent, allow_none_return=allow_none_return)
60496048

60506049
self._url = "{host}{{endpoint}}".format(host=self._host)
@@ -6194,7 +6193,7 @@ def get_objects_aggregated(self, api_root, collection_id, result_limit=500, adde
61946193

61956194
response_json = response.json()
61966195

6197-
objects = response_json.get("objects")
6196+
objects = response_json.get("objects", [])
61986197
results.extend(objects)
61996198

62006199
next_page = response_json.get("next")
@@ -6208,6 +6207,11 @@ def get_objects_aggregated(self, api_root, collection_id, result_limit=500, adde
62086207
if not more_pages or len(results) >= max_results:
62096208
return results[:max_results]
62106209

6210+
class TAXIIRansomwareFeed(TAXIIFeed):
6211+
def __init__(self, host, username, password, verify=True, proxies=None, user_agent=DEFAULT_USER_AGENT,
6212+
allow_none_return=False):
6213+
super(TAXIIRansomwareFeed, self).__init__(host, username, password, verify, proxies,
6214+
user_agent=user_agent, allow_none_return=allow_none_return)
62116215

62126216
class AdvancedActions(object):
62136217
"""A class containing advanced and combined actions

tests/test_ticloud.py

+53-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
AdvancedSearch, ExpressionSearch, RHA1FunctionalSimilarity, RHA1Analytics, URIStatistics, URIIndex, FileDownload, \
66
URLThreatIntelligence, AnalyzeURL, DomainThreatIntelligence, IPThreatIntelligence, FileUpload, DeleteFile, \
77
ReanalyzeFile, DataChangeSubscription, DynamicAnalysis, CertificateIndex, RansomwareIndicators, NewMalwareFilesFeed, \
8-
NewMalwareURIFeed, ImpHashSimilarity, YARAHunting, YARARetroHunting, TAXIIRansomwareFeed, CustomerUsage, \
8+
NewMalwareURIFeed, ImpHashSimilarity, YARAHunting, YARARetroHunting, TAXIIRansomwareFeed, TAXIIFeed, CustomerUsage, \
99
NetworkReputation, FileReputationUserOverride, NetworkReputationUserOverride, MalwareFamilyDetection, \
1010
VerticalFeedsStatistics, VerticalFeedsSearch, CertificateAnalytics, CertificateThumbprintSearch, \
1111
NewMalwarePlatformFiltered, NewFilesFirstScan, NewFilesFirstAndRescan, FilesWithDetectionChanges, \
@@ -1120,6 +1120,58 @@ def test_get_objects_regular(self, requests_mock):
11201120
params=query_params
11211121
)
11221122

1123+
class TestTAXIIFeed:
1124+
@classmethod
1125+
def setup_class(cls):
1126+
cls.taxii = TAXIIFeed(HOST, USERNAME, PASSWORD)
1127+
1128+
def test_get_objects_lite(self, requests_mock):
1129+
self.taxii.get_objects(
1130+
api_root="lite-root",
1131+
collection_id="123456"
1132+
)
1133+
1134+
query_params = {
1135+
"limit": 500,
1136+
"added_after": None,
1137+
"match[id]": None,
1138+
"next": None
1139+
}
1140+
1141+
expected_url = f"{HOST}/api/taxii/lite-root/collections/123456/objects/"
1142+
1143+
requests_mock.get.assert_called_with(
1144+
url=expected_url,
1145+
auth=(USERNAME, PASSWORD),
1146+
verify=True,
1147+
proxies=None,
1148+
headers={"User-Agent": DEFAULT_USER_AGENT, 'Accept': 'application/taxii+json;version=2.1'},
1149+
params=query_params
1150+
)
1151+
1152+
def test_get_objects_regular(self, requests_mock):
1153+
self.taxii.get_objects(
1154+
api_root="regular-root",
1155+
collection_id="654321"
1156+
)
1157+
1158+
query_params = {
1159+
"limit": 500,
1160+
"added_after": None,
1161+
"match[id]": None,
1162+
"next": None
1163+
}
1164+
1165+
expected_url = f"{HOST}/api/taxii/regular-root/collections/654321/objects/"
1166+
1167+
requests_mock.get.assert_called_with(
1168+
url=expected_url,
1169+
auth=(USERNAME, PASSWORD),
1170+
verify=True,
1171+
proxies=None,
1172+
headers={"User-Agent": DEFAULT_USER_AGENT, 'Accept': 'application/taxii+json;version=2.1'},
1173+
params=query_params
1174+
)
11231175

11241176
class TestCustomerUsage:
11251177
@classmethod

0 commit comments

Comments
 (0)