Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
ahouseholder committed Sep 29, 2023
1 parent 95ec303 commit 441536a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion vultron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
from ._version import version_tuple
except ImportError:
__version__ = "unknown version"
version_tuple = (0, 0, "unknown version")
version_tuple = (0, 0, "unknown version")
4 changes: 2 additions & 2 deletions vultron/case_states/enums/explanations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# - see Contributors.md for a full list of Contributors
# - see ContributionInstructions.md for information on how you can Contribute to this project
# Vultron Multiparty Coordinated Vulnerability Disclosure Protocol Prototype is
# licensed under a MIT (SEI)-style license, please see LICENSE.md distributed
# licensed under a MIT (SEI)-style license, please see LICENSE.md distributed
# with this Software or contact [email protected] for full terms.
# Created, in part, with funding and support from the United States Government
# (see Acknowledgments file). This program may include and/or can make use of
# certain third party source code, object code, documentation and other files
# (“Third Party Software”). See LICENSE.md for more details.
# Carnegie Mellon®, CERT® and CERT Coordination Center® are registered in the
# Carnegie Mellon®, CERT® and CERT Coordination Center® are registered in the
# U.S. Patent and Trademark Office by Carnegie Mellon University
"""
Enumerated state explanations
Expand Down
4 changes: 2 additions & 2 deletions vultron/case_states/enums/vep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# - see Contributors.md for a full list of Contributors
# - see ContributionInstructions.md for information on how you can Contribute to this project
# Vultron Multiparty Coordinated Vulnerability Disclosure Protocol Prototype is
# licensed under a MIT (SEI)-style license, please see LICENSE.md distributed
# licensed under a MIT (SEI)-style license, please see LICENSE.md distributed
# with this Software or contact [email protected] for full terms.
# Created, in part, with funding and support from the United States Government
# (see Acknowledgments file). This program may include and/or can make use of
# certain third party source code, object code, documentation and other files
# (“Third Party Software”). See LICENSE.md for more details.
# Carnegie Mellon®, CERT® and CERT Coordination Center® are registered in the
# Carnegie Mellon®, CERT® and CERT Coordination Center® are registered in the
# U.S. Patent and Trademark Office by Carnegie Mellon University
"""
Enumerated VEP states
Expand Down
1 change: 0 additions & 1 deletion vultron/case_states/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class CvdStateModelError(VultronError):


class CVDmodelError(CvdStateModelError):

pass


Expand Down
10 changes: 7 additions & 3 deletions vultron/case_states/hypercube.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def _setup(self):
# now turn the desiderata into state patterns
self.d_to_state_pattern = self._construct_good_patterns()
# invert the lookup too
self.state_pattern_to_d = {v: k for k, v in self.d_to_state_pattern.items()}
self.state_pattern_to_d = {
v: k for k, v in self.d_to_state_pattern.items()
}

self.not_d_to_state_pattern = self._construct_bad_patterns()
# invert the lookup too
Expand Down Expand Up @@ -282,7 +284,9 @@ def next_state(self, state: str, transition=None):
# paths are a list of edges from the graph
# [(u,v),(v,w),(w,x)...]
@ensure_valid_state
def paths_between(self, start: str = "vfdpxa", end: str = "VFDPXA") -> List[tuple]:
def paths_between(
self, start: str = "vfdpxa", end: str = "VFDPXA"
) -> List[tuple]:
"""
Return all paths of transitions between two states
Expand Down Expand Up @@ -397,7 +401,7 @@ def transitions_in_path(self, path: list) -> Tuple[str]:
return seq

@ensure_valid_state
def walk_from(self, start:str=None, end:str="VFDPXA") -> tuple:
def walk_from(self, start: str = None, end: str = "VFDPXA") -> tuple:
"""
Randomly walk from a given state to a given state
Expand Down
4 changes: 3 additions & 1 deletion vultron/case_states/make_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def print_model(model_dir="../../docs/reference/case_states"):
fp.write(_bullet("None"))
else:
for s in info["successors"]:
link = f"[{s}]({_fname(s)}) (score={sg.score_state(s):.2f})"
link = (
f"[{s}]({_fname(s)}) (score={sg.score_state(s):.2f})"
)
fp.write(_bullet(link))
fp.write("|\n")

Expand Down
4 changes: 3 additions & 1 deletion vultron/case_states/patterns/explanations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def explain(state):

def main():
for pat, explanation in EXPLANATIONS.items():
e_str = ", ".join([e.name.replace("_", " ").title() for e in explanation])
e_str = ", ".join(
[e.name.replace("_", " ").title() for e in explanation]
)
print(f"* {pat.pattern} => {e_str}")


Expand Down
5 changes: 4 additions & 1 deletion vultron/case_states/patterns/ssvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"V.....": (SSVC_2_Supplier_Contacted.YES,),
"v.....": (SSVC_2_Supplier_Contacted.NO,),
"VFdp..": (SSVC_2_Public_Value_Added.AMPLIATIVE,),
"..dP..": (SSVC_2_Public_Value_Added.AMPLIATIVE, SSVC_2_Public_Value_Added.LIMITED),
"..dP..": (
SSVC_2_Public_Value_Added.AMPLIATIVE,
SSVC_2_Public_Value_Added.LIMITED,
),
"VF.P..": (SSVC_2_Public_Value_Added.LIMITED,),
"..D...": (SSVC_2_Public_Value_Added.LIMITED,),
}
Expand Down
12 changes: 9 additions & 3 deletions vultron/case_states/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ def is_valid_transition(src: str, dst: str, allow_null: bool = False) -> None:
# if the first pattern matches,
# then the second must as well
if not re.match(b, dst):
raise TransitionValidationError(f"Transition not permitted [{a}->{b}]")
raise TransitionValidationError(
f"Transition not permitted [{a}->{b}]"
)


def is_valid_history(h: str) -> None:
Expand Down Expand Up @@ -328,10 +330,14 @@ def is_valid_history(h: str) -> None:
raise HistoryValidationError("F must precede D")
# P...X or XP
if (h.index("P") - h.index("X")) > 1:
raise HistoryValidationError("P must precede X or immediately follow it")
raise HistoryValidationError(
"P must precede X or immediately follow it"
)
# V...P or PV
if (h.index("V") - h.index("P")) > 1:
raise HistoryValidationError("V must precede V or immediately follow it")
raise HistoryValidationError(
"V must precede V or immediately follow it"
)


def ensure_valid_history(func: Callable) -> Callable:
Expand Down

0 comments on commit 441536a

Please sign in to comment.