Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 38953f9

Browse files
[client] delete example
1 parent 805f133 commit 38953f9

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

examples/create_observable_sshkey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
opencti_api_client = OpenCTIApiClient(api_url, api_token)
1111

1212
observable_sshkey = opencti_api_client.stix_cyber_observable.create(
13-
observableData={"type": "SSH-Key", "SSHKey": {"fingerprint_sha256": "sha256_test"}}
13+
observableData={"type": "SSH-Key", "fingerprint_sha256": "sha256_test"}
1414
)
1515

1616
print(observable_sshkey)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# coding: utf-8
2+
3+
from pycti import OpenCTIApiClient
4+
5+
# Variables
6+
api_url = "http://opencti:4000"
7+
api_token = "bfa014e0-e02e-4aa6-a42b-603b19dcf159"
8+
9+
# OpenCTI initialization
10+
opencti_api_client = OpenCTIApiClient(api_url, api_token)
11+
12+
opencti_api_client.stix_cyber_observable.create(
13+
observableData={"type": "SSH-Key", "fingerprint_sha256": "sha256_test"}
14+
)
15+
16+
observable_sshkey = opencti_api_client.stix_cyber_observable.read(
17+
filters={
18+
"mode": "and",
19+
"filters": [{"key": "fingerprint_sha256", "values": ["sha256_test"]}],
20+
"filterGroups": [],
21+
}
22+
)
23+
24+
opencti_api_client.stix_cyber_observable.delete(id=observable_sshkey.get("id"))

pycti/entities/opencti_stix_cyber_observable.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,10 @@ def create(self, **kwargs):
578578
)
579579
is not None
580580
):
581-
observable_data["x_opencti_additional_names"] = (
582-
self.opencti.get_attribute_in_extension(
583-
"additional_names", observable_data
584-
)
581+
observable_data[
582+
"x_opencti_additional_names"
583+
] = self.opencti.get_attribute_in_extension(
584+
"additional_names", observable_data
585585
)
586586
input_variables["Artifact"] = {
587587
"hashes": hashes if len(hashes) > 0 else None,
@@ -615,10 +615,10 @@ def create(self, **kwargs):
615615
)
616616
is not None
617617
):
618-
observable_data["x_opencti_additional_names"] = (
619-
self.opencti.get_attribute_in_extension(
620-
"additional_names", observable_data
621-
)
618+
observable_data[
619+
"x_opencti_additional_names"
620+
] = self.opencti.get_attribute_in_extension(
621+
"additional_names", observable_data
622622
)
623623
input_variables["StixFile"] = {
624624
"hashes": hashes if len(hashes) > 0 else None,
@@ -722,7 +722,7 @@ def create(self, **kwargs):
722722
"key_type": (
723723
observable_data["key_type"]
724724
if "key_type" in observable_data
725-
else False
725+
else None
726726
),
727727
"public_key": (
728728
observable_data["public_key"]
@@ -874,10 +874,10 @@ def create(self, **kwargs):
874874
)
875875
is not None
876876
):
877-
observable_data["x_opencti_product"] = (
878-
self.opencti.get_attribute_in_extension(
879-
"x_opencti_product", observable_data
880-
)
877+
observable_data[
878+
"x_opencti_product"
879+
] = self.opencti.get_attribute_in_extension(
880+
"x_opencti_product", observable_data
881881
)
882882
input_variables["Software"] = {
883883
"name": (

0 commit comments

Comments
 (0)