Skip to content

Commit 29fec30

Browse files
author
Samuel Hassine
committed
[all] Release the new Python client
1 parent 3445ae8 commit 29fec30

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

examples/stix2/import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
config = yaml.load(open(os.path.dirname(__file__) + '/../config.yml'))
1010

1111
# File to import
12-
file_to_import = './enterprise-attack.json'
12+
file_to_import = '/home/oxid/Dropbox/Developpement/Associations/Luatix/Produits/OpenCTI/cti/enterprise-attack/enterprise-attack.json'
1313

1414
# OpenCTI initialization
1515
opencti_api_client = OpenCTIApiClient(config['opencti']['url'], config['opencti']['token'])

pycti/opencti_api_client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ class OpenCTIApiClient:
2020
"""
2121

2222
def __init__(self, url, token, log_level='info'):
23+
self.log_level = log_level
2324
# Configure logger
24-
numeric_level = getattr(logging, log_level.upper(), None)
25+
numeric_level = getattr(logging, self.log_level.upper(), None)
2526
if not isinstance(numeric_level, int):
26-
raise ValueError('Invalid log level: ' + log_level)
27+
raise ValueError('Invalid log level: ' + self.log_level)
2728
logging.basicConfig(level=numeric_level)
2829

2930
self.api_url = url + '/graphql'
@@ -3565,16 +3566,16 @@ def stix2_import_bundle_from_file(self, file_path, update=False, types=[]):
35653566
with open(os.path.join(file_path)) as file:
35663567
data = json.load(file)
35673568

3568-
stix2 = OpenCTIStix2(self, log_level)
3569+
stix2 = OpenCTIStix2(self, self.log_level)
35693570
stix2.import_bundle(data, update, types)
35703571

35713572
def stix2_import_bundle(self, json_data, update=False, types=[]):
35723573
data = json.loads(json_data)
3573-
stix2 = OpenCTIStix2(self, log_level)
3574+
stix2 = OpenCTIStix2(self, self.log_level)
35743575
stix2.import_bundle(data, update, types)
35753576

35763577
def stix2_export_entity(self, entity_type, entity_id, mode='simple'):
3577-
stix2 = OpenCTIStix2(self, log_level)
3578+
stix2 = OpenCTIStix2(self, self.log_level)
35783579
bundle = {
35793580
'type': 'bundle',
35803581
'id': 'bundle--' + str(uuid.uuid4()),
@@ -3589,7 +3590,7 @@ def stix2_export_entity(self, entity_type, entity_id, mode='simple'):
35893590
return bundle
35903591

35913592
def stix2_export_bundle(self, types=[]):
3592-
stix2 = OpenCTIStix2(self, log_level)
3593+
stix2 = OpenCTIStix2(self, self.log_level)
35933594
uuids = []
35943595
bundle = {
35953596
'type': 'bundle',

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
print("warning: pypandoc module not found, could not convert Markdown to RST")
1414
read_md = lambda f: open(f, 'r').read()
1515

16-
VERSION = "1.2.8"
16+
VERSION = "1.2.9"
1717

1818

1919
class VerifyVersionCommand(install):

0 commit comments

Comments
 (0)