Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
fix(schema): Resolve circular imports in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
maringuu committed Jun 3, 2024
1 parent 25c4c57 commit 91e516b
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 188 deletions.
218 changes: 34 additions & 184 deletions fkie_cve_make_release/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,185 +12,40 @@

from . import cvss_v2, cvss_v3


class Type(Enum):
primary = 'Primary'
secondary = 'Secondary'


class AccessVectorType(Enum):
network = 'NETWORK'
adjacent_network = 'ADJACENT_NETWORK'
local = 'LOCAL'


class AccessComplexityType(Enum):
high = 'HIGH'
medium = 'MEDIUM'
low = 'LOW'


class AuthenticationType(Enum):
multiple = 'MULTIPLE'
single = 'SINGLE'
none = 'NONE'


class CiaType(Enum):
none = 'NONE'
partial = 'PARTIAL'
complete = 'COMPLETE'


class ExploitabilityType(Enum):
unproven = 'UNPROVEN'
proof_of_concept = 'PROOF_OF_CONCEPT'
functional = 'FUNCTIONAL'
high = 'HIGH'
not_defined = 'NOT_DEFINED'


class RemediationLevelType(Enum):
official_fix = 'OFFICIAL_FIX'
temporary_fix = 'TEMPORARY_FIX'
workaround = 'WORKAROUND'
unavailable = 'UNAVAILABLE'
not_defined = 'NOT_DEFINED'


class ReportConfidenceType(Enum):
unconfirmed = 'UNCONFIRMED'
uncorroborated = 'UNCORROBORATED'
confirmed = 'CONFIRMED'
not_defined = 'NOT_DEFINED'


class CollateralDamagePotentialType(Enum):
none = 'NONE'
low = 'LOW'
low_medium = 'LOW_MEDIUM'
medium_high = 'MEDIUM_HIGH'
high = 'HIGH'
not_defined = 'NOT_DEFINED'


class TargetDistributionType(Enum):
none = 'NONE'
low = 'LOW'
medium = 'MEDIUM'
high = 'HIGH'
not_defined = 'NOT_DEFINED'


class CiaRequirementType(Enum):
low = 'LOW'
medium = 'MEDIUM'
high = 'HIGH'
not_defined = 'NOT_DEFINED'


ScoreType = Annotated[float, Meta(ge=0.0, le=10.0)]


class AttackVectorType(Enum):
network = 'NETWORK'
adjacent_network = 'ADJACENT_NETWORK'
local = 'LOCAL'
physical = 'PHYSICAL'


class ModifiedAttackVectorType(Enum):
network = 'NETWORK'
adjacent_network = 'ADJACENT_NETWORK'
local = 'LOCAL'
physical = 'PHYSICAL'
not_defined = 'NOT_DEFINED'


class AttackComplexityType(Enum):
high = 'HIGH'
low = 'LOW'


class ModifiedAttackComplexityType(Enum):
high = 'HIGH'
low = 'LOW'
not_defined = 'NOT_DEFINED'


class PrivilegesRequiredType(Enum):
high = 'HIGH'
low = 'LOW'
none = 'NONE'


class ModifiedPrivilegesRequiredType(Enum):
high = 'HIGH'
low = 'LOW'
none = 'NONE'
not_defined = 'NOT_DEFINED'


class UserInteractionType(Enum):
none = 'NONE'
required = 'REQUIRED'


class ModifiedUserInteractionType(Enum):
none = 'NONE'
required = 'REQUIRED'
not_defined = 'NOT_DEFINED'


class ScopeType(Enum):
unchanged = 'UNCHANGED'
changed = 'CHANGED'


class ModifiedScopeType(Enum):
unchanged = 'UNCHANGED'
changed = 'CHANGED'
not_defined = 'NOT_DEFINED'


class CiaTypeModel(Enum):
none = 'NONE'
low = 'LOW'
high = 'HIGH'


class ModifiedCiaType(Enum):
none = 'NONE'
low = 'LOW'
high = 'HIGH'
not_defined = 'NOT_DEFINED'


class ExploitCodeMaturityType(Enum):
unproven = 'UNPROVEN'
proof_of_concept = 'PROOF_OF_CONCEPT'
functional = 'FUNCTIONAL'
high = 'HIGH'
not_defined = 'NOT_DEFINED'


class ConfidenceType(Enum):
unknown = 'UNKNOWN'
reasonable = 'REASONABLE'
confirmed = 'CONFIRMED'
not_defined = 'NOT_DEFINED'


class SeverityType(Enum):
none = 'NONE'
low = 'LOW'
medium = 'MEDIUM'
high = 'HIGH'
critical = 'CRITICAL'


CveId = Annotated[str, Meta(pattern='^CVE-[0-9]{4}-[0-9]{4,}$')]

from .enums import (
AccessComplexityType,
AccessVectorType,
AttackComplexityType,
AttackVectorType,
AuthenticationType,
CiaRequirementType,
CiaType,
CiaTypeModel,
CollateralDamagePotentialType,
ConfidenceType,
ExploitabilityType,
ExploitCodeMaturityType,
ModifiedAttackComplexityType,
ModifiedAttackVectorType,
ModifiedCiaType,
ModifiedPrivilegesRequiredType,
ModifiedScopeType,
ModifiedUserInteractionType,
Operator,
PrivilegesRequiredType,
RemediationLevelType,
ReportConfidenceType,
ScopeType,
SeverityType,
TargetDistributionType,
Type,
UserInteractionType,
)

from .types import (
CveId,
ScoreType,
)

class LangString(Struct):
lang: str
Expand All @@ -215,11 +70,6 @@ class Weakness(Struct):
description: List[LangString]


class Operator(Enum):
and_ = 'AND'
or_ = 'OR'


class CpeMatch(Struct):
vulnerable: bool
criteria: str
Expand Down
7 changes: 5 additions & 2 deletions fkie_cve_make_release/schema/cvss_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from msgspec import Meta, Struct, field
from typing_extensions import Annotated

from . import (
from .enums import (
AccessComplexityType,
AccessVectorType,
AuthenticationType,
Expand All @@ -20,10 +20,13 @@
ExploitabilityType,
RemediationLevelType,
ReportConfidenceType,
ScoreType,
TargetDistributionType,
)

from .types import (
ScoreType,
)


class Version(Enum):
field_2_0 = '2.0'
Expand Down
7 changes: 5 additions & 2 deletions fkie_cve_make_release/schema/cvss_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from msgspec import Meta, Struct, field
from typing_extensions import Annotated

from . import (
from .enums import (
AttackComplexityType,
AttackVectorType,
CiaRequirementType,
Expand All @@ -26,11 +26,14 @@
PrivilegesRequiredType,
RemediationLevelType,
ScopeType,
ScoreType,
SeverityType,
UserInteractionType,
)

from .types import (
ScoreType,
)


class Version(Enum):
field_3_0 = '3.0'
Expand Down
Loading

0 comments on commit 91e516b

Please sign in to comment.