Skip to content

Commit

Permalink
financial observable creation examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonsai8863 authored and ParamConstructor committed May 30, 2024
1 parent 093f0f4 commit 017cc03
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
25 changes: 25 additions & 0 deletions examples/create_observable_financial_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding: utf-8

from pycti import OpenCTIApiClient

# Variables
api_url = "http://localhost:4000"
api_token = "6C2C9EAE-6FF5-4421-B118-74A3CA5AAC20"

# OpenCTI initialization
opencti_api_client = OpenCTIApiClient(api_url, api_token)

process = opencti_api_client.stix_cyber_observable.create(
observableData={
"type": "Financial-Account",
"account_number": "123-45-9988",
"account_status": "active",
"account_type": "credit_credit_card",
"x_opencti_score": 90,
"iban_number": "55667",
"bic_number": "009998877",
"currency_code": "bahraini_dinar_(bhd)",
}
)

print(process)
22 changes: 22 additions & 0 deletions examples/create_observable_financial_asset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# coding: utf-8

from pycti import OpenCTIApiClient

# Variables
api_url = "http://localhost:4000"
api_token = "6C2C9EAE-6FF5-4421-B118-74A3CA5AAC20"

# OpenCTI initialization
opencti_api_client = OpenCTIApiClient(api_url, api_token)

process = opencti_api_client.stix_cyber_observable.create(
observableData={
"type": "Financial-Asset",
"name": "Joe's Big Boat",
"asset_type": "boat",
"asset_value": 12000000,
"currency_code": "belarusian_ruble_(byr)",
}
)

print(process)
25 changes: 25 additions & 0 deletions examples/create_observable_financial_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding: utf-8
from dateutil.parser import parse

from pycti import OpenCTIApiClient

# Variables
api_url = "http://localhost:4000"
api_token = "6C2C9EAE-6FF5-4421-B118-74A3CA5AAC20"

# OpenCTI initialization
opencti_api_client = OpenCTIApiClient(api_url, api_token)

# Define the date
date = parse("2019-02-06").strftime("%Y-%m-%dT%H:%M:%SZ")

process = opencti_api_client.stix_cyber_observable.create(
observableData={
"type": "Financial-Transaction",
"transaction_date": date,
"transaction_value": 62000000,
"currency_code": "belarusian_ruble_(byr)",
}
)

print(process)
14 changes: 11 additions & 3 deletions pycti/entities/opencti_stix_cyber_observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,10 @@ def create(self, **kwargs):
observable_data["value"] if "value" in observable_data else None
),
}
elif type == "Financial-Account" or type.lower() == "x-opencti-financial-account":
elif (
type == "Financial-Account"
or type.lower() == "x-opencti-financial-account"
):
input_variables["FinancialAccount"] = {
"iban_number": observable_data.get("iban_number"),
"bic_number": observable_data.get("bic_number"),
Expand All @@ -1645,14 +1648,19 @@ def create(self, **kwargs):
"account_type": observable_data.get("account_type"),
"currency_code": observable_data.get("currency_code"),
}
elif type == "Financial-Asset" or type.lower() == "x-opencti-financial-asset":
elif (
type == "Financial-Asset" or type.lower() == "x-opencti-financial-asset"
):
input_variables["FinancialAsset"] = {
"name": observable_data.get("name"),
"asset_type": observable_data.get("asset_type"),
"asset_value": observable_data.get("asset_value"),
"currency_code": observable_data.get("currency_code"),
}
elif type == "Financial-Transaction" or type.lower() == "x-opencti-transaction":
elif (
type == "Financial-Transaction"
or type.lower() == "x-opencti-transaction"
):
input_variables["FinancialTransaction"] = {
"transaction_date": observable_data.get("transaction_date"),
"transaction_value": observable_data.get("transaction_value"),
Expand Down
1 change: 1 addition & 0 deletions pycti/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ class CustomObservableCredential:
# class CustomObservableCryptocurrencyWallet:
# """Cryptocurrency wallet observable."""


@CustomObservable(
"phone-number",
[
Expand Down

0 comments on commit 017cc03

Please sign in to comment.