Skip to content

Commit 69c503c

Browse files
author
Samuel Hassine
committedDec 6, 2019
[client] Better management of empty in list
1 parent 640837d commit 69c503c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎examples/export_intrusion_set_stix2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
intrusion_set = opencti_api_client.intrusion_set.read(filters=[{'key': 'name', 'values': ['APT28']}])
1515

1616
# Create the bundle
17-
bundle = opencti_api_client.stix2.export_entity('intrusion-set', intrusion_set['id'], 'full')
17+
bundle = opencti_api_client.stix2.export_entity('campaign', '0d31f298-da86-4330-8c0a-4fcfa44f6ae0', 'full')
1818
json_bundle = json.dumps(bundle, indent=4)
1919

2020
# Write the bundle

‎pycti/api/opencti_api_client.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,17 @@ def health_check(self):
199199

200200
def not_empty(self, value):
201201
if value is not None:
202-
if isinstance(value, str) or isinstance(value, list):
202+
if isinstance(value, str):
203203
if len(value) > 0:
204204
return True
205205
else:
206206
return False
207+
if isinstance(value, list):
208+
is_empty = True
209+
for v in value:
210+
if len(v) > 0:
211+
is_empty = False
212+
return is_empty
207213
if isinstance(value, int):
208214
return True
209215
else:

0 commit comments

Comments
 (0)
Please sign in to comment.