diff --git a/examples/create_observable_sshkey.py b/examples/create_observable_sshkey.py new file mode 100644 index 000000000..bcd9dddf9 --- /dev/null +++ b/examples/create_observable_sshkey.py @@ -0,0 +1,17 @@ +# coding: utf-8 +import os + +from pycti import OpenCTIApiClient + +# Variables +api_url = os.getenv("OPENCTI_API_URL", "http://opencti:4000") +api_token = os.getenv("OPENCTI_API_TOKEN", "bfa014e0-e02e-4aa6-a42b-603b19dcf159") + +# OpenCTI initialization +opencti_api_client = OpenCTIApiClient(api_url, api_token) + +observable_sshkey = opencti_api_client.stix_cyber_observable.create( + observableData={"type": "SSH-Key", "fingerprint_sha256": "sha256_test"} +) + +print(observable_sshkey) diff --git a/examples/delete_observable_sshkey.py b/examples/delete_observable_sshkey.py new file mode 100644 index 000000000..e1cf1a337 --- /dev/null +++ b/examples/delete_observable_sshkey.py @@ -0,0 +1,25 @@ +# coding: utf-8 +import os + +from pycti import OpenCTIApiClient + +# Variables +api_url = os.getenv("OPENCTI_API_URL", "http://opencti:4000") +api_token = os.getenv("OPENCTI_API_TOKEN", "bfa014e0-e02e-4aa6-a42b-603b19dcf159") + +# OpenCTI initialization +opencti_api_client = OpenCTIApiClient(api_url, api_token) + +opencti_api_client.stix_cyber_observable.create( + observableData={"type": "SSH-Key", "fingerprint_sha256": "sha256_test"} +) + +observable_sshkey = opencti_api_client.stix_cyber_observable.read( + filters={ + "mode": "and", + "filters": [{"key": "fingerprint_sha256", "values": ["sha256_test"]}], + "filterGroups": [], + } +) + +opencti_api_client.stix_cyber_observable.delete(id=observable_sshkey.get("id")) diff --git a/examples/update_observable_attributes.py b/examples/update_observable_attributes.py index 26f4b8e47..8988b0762 100644 --- a/examples/update_observable_attributes.py +++ b/examples/update_observable_attributes.py @@ -52,3 +52,12 @@ opencti_api_client.stix_cyber_observable.update_created_by( id=observable["id"], identity_id=author["id"] ) + +observable_sshkey = opencti_api_client.stix_cyber_observable.create( + observableData={"type": "SSH-Key", "fingerprint_sha256": "sha256_test"} +) + +opencti_api_client.stix_cyber_observable.update_field( + id=observable_sshkey.get("id"), + input={"key": "fingerprint_sha256", "value": "sha256_test_edit_name"}, +)