Skip to content

Vultron Case State Behaviors

vultron.bt.case_state.conditions

This module defines CVD Case State conditions as Behavior Tree nodes.

cs_in_state_attacks_observed(obj)

True when attacks against the vulnerability have been observed

Source code in vultron/bt/case_state/conditions.py
93
94
95
96
97
98
def cs_in_state_attacks_observed(obj: BtNode) -> bool:
    """True when attacks against the vulnerability have been observed"""
    return (
        obj.bb.q_cs.value.pxa_state.value.attack_observation
        == AttackObservation.A
    )

cs_in_state_exploit_public(obj)

True when an exploit is public for the vulnerability

Source code in vultron/bt/case_state/conditions.py
79
80
81
82
83
84
def cs_in_state_exploit_public(obj: BtNode) -> bool:
    """True when an exploit is public for the vulnerability"""
    return (
        obj.bb.q_cs.value.pxa_state.value.exploit_publication
        == ExploitPublication.X
    )

cs_in_state_fix_deployed(obj)

True when the fix has been deployed

Source code in vultron/bt/case_state/conditions.py
55
56
57
def cs_in_state_fix_deployed(obj: BtNode) -> bool:
    """True when the fix has been deployed"""
    return obj.bb.q_cs.value.vfd_state.value.fix_deployment == FixDeployment.D

cs_in_state_fix_ready(obj)

True when the vendor has a fix ready

Source code in vultron/bt/case_state/conditions.py
44
45
46
def cs_in_state_fix_ready(obj: BtNode) -> bool:
    """True when the vendor has a fix ready"""
    return obj.bb.q_cs.value.vfd_state.value.fix_readiness == FixReadiness.F

cs_in_state_public_aware(obj)

True when the public is aware of the vulnerability

Source code in vultron/bt/case_state/conditions.py
66
67
68
69
70
def cs_in_state_public_aware(obj: BtNode) -> bool:
    """True when the public is aware of the vulnerability"""
    return (
        obj.bb.q_cs.value.pxa_state.value.public_awareness == PublicAwareness.P
    )

cs_in_state_vendor_aware(obj)

True when the vendor is aware of the vulnerability

Source code in vultron/bt/case_state/conditions.py
31
32
33
34
35
def cs_in_state_vendor_aware(obj: BtNode) -> bool:
    """True when the vendor is aware of the vulnerability"""
    return (
        obj.bb.q_cs.value.vfd_state.value.vendor_awareness == VendorAwareness.V
    )

vultron.bt.case_state.transitions

This module defines the CVD Case State Machine as a Behavior Tree.

cs_state_change(name, target_state=None)

Factory function to create a class for transitioning to a new CS state.

Parameters:

Name Type Description Default
name str

the name of the class

required
target_state str

the target state shorthand for the transition (V,F,D,P,X,A)

None

Returns:

Type Description
Type[ActionNode]

A class for transitioning to the given state

Source code in vultron/bt/case_state/transitions.py
27
28
29
30
31
32
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
68
69
70
71
72
73
74
def cs_state_change(
    name: str,
    target_state: str = None,
) -> Type[ActionNode]:
    """
    Factory function to create a class for transitioning to a new CS state.

    Args:
        name: the name of the class
        target_state: the target state shorthand for the transition (V,F,D,P,X,A)

    Returns:
        A class for transitioning to the given state

    """

    def _func(obj: BtNode) -> bool:
        f"""Transition to the target state {target_state}"""
        # get the current state name
        current_state_name = obj.bb.q_cs.name

        # note: we are operating on the node name string because the values
        # are more complex to work with (e.g. "Vendor Aware" vs "V")

        # force the corresponding letter in the state name to upper case
        # if the lower case is not in the state name, this will do nothing
        # which means this is a no-op for the upper-cased states
        new_state_name = current_state_name.replace(
            target_state.lower(), target_state
        )

        # set the state to the one with the new name
        try:
            new_state = CS[new_state_name]
        except KeyError:
            # just don't change the state if the new state name is invalid
            return True

        obj.bb.q_cs = new_state
        obj.bb.q_cs_history.append(new_state)

        # action node functions return True for success
        return True

    node_cls = action_node(name, _func)
    # add the target state as a class attribute (for testing)
    node_cls.target_state = target_state
    return node_cls