Skip to content

Commit

Permalink
Add AuthSecret observable (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
udgover authored Nov 8, 2024
1 parent c8bd5c5 commit 3d3a944
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/schemas/observables/auth_secret.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Literal

from core.schemas import observable


class AuthSecret(observable.Observable):
"""
An authentication secret, such as a private key, public key, or certificate.
"""

type: Literal["auth_secret"] = "auth_secret"
auth_type: str = "" # can be pubkey, privkey, cert, ...
name: str = "" # keypair name as found in aws key pairs
13 changes: 13 additions & 0 deletions tests/schemas/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from core.schemas.observable import Observable
from core.schemas.observables import (
asn,
auth_secret,
bic,
certificate,
cidr,
Expand Down Expand Up @@ -331,6 +332,18 @@ def test_create_asn(self) -> None:
self.assertEqual(observable_obj.value, "AS123")
self.assertIsInstance(observable_obj, asn.ASN)

def test_create_auth_secret(self) -> None:
"""Tests creating an AuthSecret."""
pub_key = """MEgCQQCo9+BpMRYQ/dL3DS2CyJxRF+j6ctbT3/Qp84+KeFhnii7NT7fELilKUSnx
S30WAvQCCo2yU1orfgqr41mM70MBAgMBAAE="""
observable_obj = auth_secret.AuthSecret(
value=pub_key, auth_type="pubkey"
).save()
self.assertIsInstance(observable_obj, auth_secret.AuthSecret)
self.assertIsNotNone(observable_obj.id)
self.assertEqual(observable_obj.value, pub_key)
self.assertEqual(observable_obj.auth_type, "pubkey")

def test_create_wallet(self) -> None:
"""Tests creating a wallet."""
observable_obj = wallet.Wallet(
Expand Down

0 comments on commit 3d3a944

Please sign in to comment.