Skip to content

Commit

Permalink
break out threat event
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbailey committed Feb 4, 2019
1 parent 9996179 commit 0f94839
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
3 changes: 2 additions & 1 deletion rail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

from .tree import Tree
from .threat_source import ThreatSource, ThreatSources
from .rail import ThreatSource, ThreatSources, ThreatEvent, ThreatEvents, Control, Controls, Vulnerability, Vulnerabilities, Likelihood, Impact, Risk, Risks
from .threat_event import ThreatEvent, ThreatEvents
from .rail import Control, Controls, Vulnerability, Vulnerabilities, Likelihood, Impact, Risk, Risks

14 changes: 1 addition & 13 deletions rail/rail.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,13 @@

from .tree import Tree
from .threat_source import ThreatSource, ThreatSources
from .threat_event import ThreatEvent, ThreatEvents

pd.set_option('display.float_format', lambda x: '%.2f' % x)
pd.set_option('display.max_colwidth', -1)
plt.style.use('seaborn-poster')


class ThreatEvent(UserDict):
def __init__(self, name: str, threat_source: ThreatSource) -> None:
self.data = {}
self.data['name'] = name
self.data['threat_source'] = threat_source


class ThreatEvents(UserDict):
def new(self, name: str, threat_source: ThreatSource) -> ThreatEvent:
self.data[name] = ThreatEvent(name, threat_source)
return self.data[name]


class Control(UserDict):
def __init__(self, name: str, cost: float, reduction: float, implemented: bool=True) -> None:
self.data = {}
Expand Down
28 changes: 28 additions & 0 deletions rail/threat_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
A class to represent Threat Events
"""
from collections import UserDict

from .threat_source import ThreatSource

class ThreatEvent(UserDict): # pylint: disable=too-many-ancestors
"""
A class to represent Threat Events
"""
def __init__(self, name: str, threat_source: ThreatSource) -> None:
UserDict.__init__(self)
self.data = {}
self.data['name'] = name
self.data['threat_source'] = threat_source


class ThreatEvents(UserDict): # pylint: disable=too-many-ancestors
"""
A class to hold multiple Threat Events
"""
def new(self, name: str, threat_source: ThreatSource) -> ThreatEvent:
"""
A method to add a new threat event to the Threat Events class
"""
self.data[name] = ThreatEvent(name, threat_source)
return self.data[name]
4 changes: 2 additions & 2 deletions rail/threat_source.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
A class to implement Threat Sources
A class to represent Threat Sources
"""
from collections import UserDict

class ThreatSource(UserDict): # pylint: disable=too-many-ancestors
"""
A class to implement Threat Sources
A class to represent Threat Sources
"""
def __init__(self, name: str) -> None:
UserDict.__init__(self)
Expand Down

0 comments on commit 0f94839

Please sign in to comment.