Skip to content

Commit

Permalink
Adjust crypto PoC data model
Browse files Browse the repository at this point in the history
- add `FIPS_FINDING` datatype + respective model class
- add required `name` property to algorithm properties
- fix typo `subject_algorithm_ref` -> `signature_algorithm_ref`
  • Loading branch information
8R0WNI3 committed Dec 12, 2024
1 parent 72cc7c1 commit 0c84de8
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions dso/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def datasource_to_datatypes(datasource: str) -> tuple[str]:
Datasource.CRYPTO: (
Datatype.ARTEFACT_SCAN_INFO,
Datatype.CRYPTO_ASSET,
Datatype.FIPS_FINDING,
),
Datasource.DELIVERY_DASHBOARD: (
Datatype.RESCORING,
Expand Down Expand Up @@ -220,6 +221,7 @@ class Datatype:
COMPLIANCE_SNAPSHOTS = 'compliance/snapshots'
ARTEFACT_SCAN_INFO = 'meta/artefact_scan_info'
CRYPTO_ASSET = 'crypto_asset'
FIPS_FINDING = 'finding/fips'

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


Expand Down Expand Up @@ -406,24 +409,31 @@ class AssetTypes(enum.StrEnum):

@dataclasses.dataclass
class AlgorithmProperties:
name: str
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)
return _as_key(
self.name,
self.primitive,
self.parameter_set_identifier,
self.curve,
self.padding,
)


@dataclasses.dataclass
class CertificateProperties:
subject_algorithm_ref: str | None = None
signature_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)
return _as_key(self.signature_algorithm_ref, self.subject_public_key_ref)


@dataclasses.dataclass
Expand Down Expand Up @@ -476,6 +486,16 @@ def key(self) -> str:
return _as_key(self.asset_type, self.properties.key)


@dataclasses.dataclass(frozen=True)
class FipsFinding(Finding):
asset: CryptoAsset
summary: str | None = None

@property
def key(self) -> str:
return self.asset.key


@dataclasses.dataclass(frozen=True)
class User:
username: str
Expand Down Expand Up @@ -512,6 +532,7 @@ class CustomRescoring:
RescoringVulnerabilityFinding
| RescoringLicenseFinding
| MalwareFindingDetails
| CryptoAsset
)
referenced_type: str
severity: str
Expand Down Expand Up @@ -611,6 +632,7 @@ class ArtefactMetadata:
| CustomRescoring
| ComplianceSnapshot
| CryptoAsset
| FipsFinding
| dict # fallback, there should be a type
)
discovery_date: datetime.date | None = None # required for finding specific SLA tracking
Expand Down

0 comments on commit 0c84de8

Please sign in to comment.