Skip to content

Commit

Permalink
Revert "Add crypto asset dataclasses PoC"
Browse files Browse the repository at this point in the history
This reverts commit 9563e6f.
  • Loading branch information
8R0WNI3 committed Dec 11, 2024
1 parent 72cc7c1 commit f3a9eb2
Showing 1 changed file with 0 additions and 90 deletions.
90 changes: 0 additions & 90 deletions dso/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class Datasource:
CHECKMARX = 'checkmarx'
CLAMAV = 'clamav'
CC_UTILS = 'cc-utils'
CRYPTO = 'crypto'
DELIVERY_DASHBOARD = 'delivery-dashboard'
DIKI = 'diki'

Expand All @@ -63,10 +62,6 @@ def datasource_to_datatypes(datasource: str) -> tuple[str]:
Datasource.CC_UTILS: (
Datatype.OS_IDS,
),
Datasource.CRYPTO: (
Datatype.ARTEFACT_SCAN_INFO,
Datatype.CRYPTO_ASSET,
),
Datasource.DELIVERY_DASHBOARD: (
Datatype.RESCORING,
),
Expand Down Expand Up @@ -219,7 +214,6 @@ class Datatype:
RESCORING = 'rescorings'
COMPLIANCE_SNAPSHOTS = 'compliance/snapshots'
ARTEFACT_SCAN_INFO = 'meta/artefact_scan_info'
CRYPTO_ASSET = 'crypto_asset'

@staticmethod
def datatype_to_datasource(datatype: str) -> str:
Expand All @@ -230,7 +224,6 @@ def datatype_to_datasource(datatype: str) -> str:
Datatype.CODECHECKS_AGGREGATED: Datasource.CHECKMARX,
Datatype.MALWARE_FINDING: Datasource.CLAMAV,
Datatype.DIKI_FINDING: Datasource.DIKI,
Datatype.CRYPTO_ASSET: Datasource.CRYPTO,
}[datatype]


Expand Down Expand Up @@ -396,86 +389,6 @@ def key(self) -> str:
return _as_key(self.provider_id, f'{self.ruleset_id}:{self.ruleset_version}', self.rule_id)


class AssetTypes(enum.StrEnum):
ALGORITHM = 'algorithm'
CERTIFICATE = 'certificate'
LIBRARY = 'library'
PROTOCOL = 'protocol'
RELATED_CRYPTO_MATERIAL = 'related-crypto-material'


@dataclasses.dataclass
class AlgorithmProperties:
primitive: str | None = None
parameter_set_identifier: str | None = None
curve: str | None = None
padding: str | None = None

@property
def key(self) -> str:
return _as_key(self.primitive, self.parameter_set_identifier, self.curve, self.padding)


@dataclasses.dataclass
class CertificateProperties:
subject_algorithm_ref: str | None = None
subject_public_key_ref: str | None = None

@property
def key(self) -> str:
return _as_key(self.subject_algorithm_ref, self.subject_public_key_ref)


@dataclasses.dataclass
class LibraryProperties:
name: str
version: str | None = None

@property
def key(self) -> str:
return _as_key(self.name, self.version)


@dataclasses.dataclass
class ProtocolProperties:
type: str | None = None
version: str | None = None

@property
def key(self) -> str:
return _as_key(self.type, self.version)


@dataclasses.dataclass
class RelatedCryptoMaterialProperties:
type: str | None = None
algorithm_ref: str | None = None
size: int | None = None

@property
def key(self) -> str:
return _as_key(self.type, self.algorithm_ref, str(self.size))


@dataclasses.dataclass
class CryptoAsset:
names: list[str]
locations: list[str]
asset_type: AssetTypes
properties: (
AlgorithmProperties
| CertificateProperties
| LibraryProperties
| RelatedCryptoMaterialProperties
| ProtocolProperties
)
count: int = 1

@property
def key(self) -> str:
return _as_key(self.asset_type, self.properties.key)


@dataclasses.dataclass(frozen=True)
class User:
username: str
Expand Down Expand Up @@ -610,7 +523,6 @@ class ArtefactMetadata:
| OsID
| CustomRescoring
| ComplianceSnapshot
| CryptoAsset
| dict # fallback, there should be a type
)
discovery_date: datetime.date | None = None # required for finding specific SLA tracking
Expand All @@ -629,9 +541,7 @@ def from_dict(raw: dict):
ArtefactKind,
ComplianceSnapshotStatuses,
MetaRescoringRules,
AssetTypes,
],
strict=True,
),
)

Expand Down

0 comments on commit f3a9eb2

Please sign in to comment.