Skip to content

Commit

Permalink
[client] Added crypto-wallet back
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonsai8863 committed Jul 9, 2024
1 parent db04b51 commit 18e0066
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 41 deletions.
10 changes: 10 additions & 0 deletions docs/pycti/pycti.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ Classes
- :py:class:`CustomObservableFinancialTransaction`:
Financial Transaction observable.

- :py:class:`CustomObservableCryptocurrencyWallet`:
Cryptocurrency wallet observable.

- :py:class:`CustomObservableText`:
Text observable.

Expand Down Expand Up @@ -617,6 +620,13 @@ Classes
.. inheritance-diagram:: CustomObservableFinancialTransaction
:parts: 1

.. autoclass:: CustomObservableCryptocurrencyWallet
:members:

.. rubric:: Inheritance
.. inheritance-diagram:: CustomObservableCryptocurrencyWallet
:parts: 1

.. autoclass:: CustomObservableText
:members:

Expand Down
4 changes: 2 additions & 2 deletions examples/create_observable_financial_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"account_status": "active",
"account_type": "credit_credit_card",
"x_opencti_score": 90,
"iban_number": "55667",
"bic_number": "009998877",
"iban": "55667",
"bic": "009998877",
"currency_code": "bahraini_dinar_(bhd)",
}
)
Expand Down
2 changes: 2 additions & 0 deletions pycti/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
CustomObjectChannel,
CustomObjectTask,
CustomObservableCredential,
CustomObservableCryptocurrencyWallet,
CustomObservableFinancialAccount,
CustomObservableFinancialAsset,
CustomObservableFinancialTransaction,
Expand Down Expand Up @@ -140,6 +141,7 @@
"CustomObservableFinancialAccount",
"CustomObservableFinancialAsset",
"CustomObservableFinancialTransaction",
"CustomObservableCryptocurrencyWallet",
"CustomObservableHostname",
"CustomObservablePaymentCard",
"CustomObservablePhoneNumber",
Expand Down
14 changes: 10 additions & 4 deletions pycti/entities/opencti_stix_core_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ def __init__(self, opencti, file):
... on CryptographicKey {
value
}
... on CryptocurrencyWallet {
value
}
... on Hostname {
value
}
Expand Down Expand Up @@ -639,8 +642,8 @@ def __init__(self, opencti, file):
account_number
account_status
account_type
iban_number
bic_number
iban
bic
currency_code
}
... on FinancialAsset {
Expand Down Expand Up @@ -1279,6 +1282,9 @@ def __init__(self, opencti, file):
... on CryptographicKey {
value
}
... on CryptocurrencyWallet {
value
}
... on Hostname {
value
}
Expand Down Expand Up @@ -1308,8 +1314,8 @@ def __init__(self, opencti, file):
account_number
account_status
account_type
iban_number
bic_number
iban
bic
currency_code
}
... on FinancialAsset {
Expand Down
24 changes: 13 additions & 11 deletions pycti/entities/opencti_stix_cyber_observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def create(self, **kwargs):
$WindowsRegistryKey: WindowsRegistryKeyAddInput,
$WindowsRegistryValueType: WindowsRegistryValueTypeAddInput,
$CryptographicKey: CryptographicKeyAddInput,
$CryptocurrencyWallet: CryptocurrencyWalletAddInput,
$Hostname: HostnameAddInput
$Text: TextAddInput,
$UserAgent: UserAgentAddInput
Expand Down Expand Up @@ -439,6 +440,7 @@ def create(self, **kwargs):
WindowsRegistryKey: $WindowsRegistryKey,
WindowsRegistryValueType: $WindowsRegistryValueType,
CryptographicKey: $CryptographicKey,
CryptocurrencyWallet: $CryptocurrencyWallet,
Hostname: $Hostname,
Text: $Text,
UserAgent: $UserAgent
Expand Down Expand Up @@ -999,15 +1001,15 @@ def create(self, **kwargs):
else None
),
}
# elif (
# type == "Cryptocurrency-Wallet"
# or type.lower() == "x-opencti-cryptocurrency-wallet"
# ):
# input_variables["CryptocurrencyWallet"] = {
# "value": (
# observable_data["value"] if "value" in observable_data else None
# ),
# }
elif (
type == "Cryptocurrency-Wallet"
or type.lower() == "x-opencti-cryptocurrency-wallet"
):
input_variables["CryptocurrencyWallet"] = {
"value": (
observable_data["value"] if "value" in observable_data else None
),
}
elif type == "Credential" or type.lower() == "x-opencti-credential":
input_variables["Credential"] = {
"value": (
Expand All @@ -1027,8 +1029,8 @@ def create(self, **kwargs):
or type.lower() == "x-opencti-financial-account"
):
input_variables["FinancialAccount"] = {
"iban_number": observable_data.get("iban_number"),
"bic_number": observable_data.get("bic_number"),
"iban": observable_data.get("iban"),
"bic": observable_data.get("bic"),
"account_number": observable_data.get("account_number"),
"account_status": observable_data.get("account_status"),
"account_type": observable_data.get("account_type"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@
... on CryptographicKey {
value
}
... on CryptocurrencyWallet {
value
}
... on Hostname {
value
}
Expand Down Expand Up @@ -284,8 +287,8 @@
account_number
account_status
account_type
iban_number
bic_number
iban
bic
currency_code
}
... on FinancialAsset {
Expand Down Expand Up @@ -560,6 +563,9 @@
... on CryptographicKey {
value
}
... on CryptocurrencyWallet {
value
}
... on Hostname {
value
}
Expand Down Expand Up @@ -608,8 +614,8 @@
account_number
account_status
account_type
iban_number
bic_number
iban
bic
currency_code
}
... on FinancialAsset {
Expand Down
38 changes: 19 additions & 19 deletions pycti/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class StixCyberObservableTypes(Enum):
WINDOWS_REGISTRY_VALUE_TYPE = "Windows-Registry-Value-Type"
HOSTNAME = "Hostname"
CRYPTOGRAPHIC_KEY = "Cryptographic-Key"
# CRYPTOCURRENCY_WALLET = "Cryptocurrency-Wallet"
CRYPTOCURRENCY_WALLET = "Cryptocurrency-Wallet"
FINANCIAL_ACCOUNT = "Financial-Account"
FINANCIAL_ASSET = "Financial-Asset"
FINANCIAL_TRANSACTION = "Financial-Transaction"
Expand Down Expand Up @@ -354,22 +354,22 @@ class CustomObservableCredential:
pass


# @CustomObservable(
# "cryptocurrency-wallet",
# [
# ("value", StringProperty(required=True)),
# ("spec_version", StringProperty(fixed="2.1")),
# (
# "object_marking_refs",
# ListProperty(
# ReferenceProperty(valid_types="marking-definition", spec_version="2.1")
# ),
# ),
# ],
# ["value"],
# )
# class CustomObservableCryptocurrencyWallet:
# """Cryptocurrency wallet observable."""
@CustomObservable(
"cryptocurrency-wallet",
[
("value", StringProperty(required=True)),
("spec_version", StringProperty(fixed="2.1")),
(
"object_marking_refs",
ListProperty(
ReferenceProperty(valid_types="marking-definition", spec_version="2.1")
),
),
],
["value"],
)
class CustomObservableCryptocurrencyWallet:
"""Cryptocurrency wallet observable."""


@CustomObservable(
Expand Down Expand Up @@ -463,8 +463,8 @@ class CustomObservableMediaContent:
("account_number", StringProperty()),
("account_status", StringProperty()),
("account_type", StringProperty()),
("iban_number", StringProperty()),
("bic_number", StringProperty()),
("iban", StringProperty()),
("bic", StringProperty()),
("currency_code", StringProperty()),
("spec_version", StringProperty(fixed="2.1")),
(
Expand Down
2 changes: 1 addition & 1 deletion pycti/utils/opencti_stix2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"windows-registry-value-type": "Windows-Registry-Value-Type",
"hostname": "Hostname",
"cryptographic-key": "Cryptographic-Key",
# "cryptocurrency-wallet": "Cryptocurrency-Wallet",
"cryptocurrency-wallet": "Cryptocurrency-Wallet",
"text": "Text",
"user-agent": "User-Agent",
# "bank-account": "Bank-Account",
Expand Down

0 comments on commit 18e0066

Please sign in to comment.