Skip to content

Enums

sereto.enums

Environment

Bases: str, Enum

Enum representing the environment of a Target.

Source code in sereto/enums.py
10
11
12
13
14
15
16
class Environment(str, Enum):
    """Enum representing the environment of a Target."""

    acceptance = "acceptance"
    development = "development"
    production = "production"
    testing = "testing"

FileFormat

Bases: str, Enum

Enum representing the file format.

Source code in sereto/enums.py
19
20
21
22
23
class FileFormat(str, Enum):
    """Enum representing the file format."""

    md = "md"
    tex = "tex"

OutputFormat

Bases: str, Enum

Enum representing the output format.

Source code in sereto/enums.py
26
27
28
29
30
class OutputFormat(str, Enum):
    """Enum representing the output format."""

    table = "table"
    json = "json"

Risk

Bases: str, Enum

Enum representing the risk level of a finding.

Source code in sereto/enums.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@yaml_object(YAML)
class Risk(str, Enum):
    """Enum representing the risk level of a finding."""

    critical = "critical"
    high = "high"
    medium = "medium"
    low = "low"
    informational = "informational"
    closed = "closed"

    @classmethod
    def to_yaml(cls, representer: RoundTripRepresenter, node: "Risk") -> str:
        return representer.represent_str(data=node.value)

    def to_int(self) -> int:
        """Convert risks to a number.

        Usefull for comparison - e.g. `max(risks, key=lambda r: r.to_int())`
        """
        match self:
            case Risk.closed:
                return 0
            case Risk.informational:
                return 1
            case Risk.low:
                return 2
            case Risk.medium:
                return 3
            case Risk.high:
                return 4
            case Risk.critical:
                return 5
            case _:
                raise SeretoValueError("unexpected risk value")

to_int()

Convert risks to a number.

Usefull for comparison - e.g. max(risks, key=lambda r: r.to_int())

Source code in sereto/enums.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def to_int(self) -> int:
    """Convert risks to a number.

    Usefull for comparison - e.g. `max(risks, key=lambda r: r.to_int())`
    """
    match self:
        case Risk.closed:
            return 0
        case Risk.informational:
            return 1
        case Risk.low:
            return 2
        case Risk.medium:
            return 3
        case Risk.high:
            return 4
        case Risk.critical:
            return 5
        case _:
            raise SeretoValueError("unexpected risk value")