Skip to content
Snippets Groups Projects
Commit a2920baf authored by martiivGylden's avatar martiivGylden
Browse files

Printer fixed for dynamic components

parent 92bdca3e
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,7 @@ def parseDynamic(df, metricList): ...@@ -86,6 +86,7 @@ def parseDynamic(df, metricList):
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
threatDynamic.associateBowtie(df, threatDynamic.type) # Associate the dynamic with the correct components threatDynamic.associateBowtie(df, threatDynamic.type) # Associate the dynamic with the correct components
print(threatDynamic, "\n")
elif df[const.textArea3][i] == const.ConsequenceDynamic: elif df[const.textArea3][i] == const.ConsequenceDynamic:
consequenceDynamic = dynamic.BowtieDynamic( consequenceDynamic = dynamic.BowtieDynamic(
...@@ -94,7 +95,8 @@ def parseDynamic(df, metricList): ...@@ -94,7 +95,8 @@ def parseDynamic(df, metricList):
) )
consequenceDynamic.metrics = extractMetrics(df, i, 4) # Extracts metrics from the dynamic component consequenceDynamic.metrics = extractMetrics(df, i, 4) # Extracts metrics from the dynamic component
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
consequenceDynamic.associateBowtie(df, consequenceDynamic.type) # Associate the dynamic with the correct components consequenceDynamic.associateBowtie(df, consequenceDynamic.type)
print(consequenceDynamic, "\n")# Associate the dynamic with the correct components
elif df[const.textArea3][i] == const.AttackDynamic: elif df[const.textArea3][i] == const.AttackDynamic:
...@@ -105,7 +107,7 @@ def parseDynamic(df, metricList): ...@@ -105,7 +107,7 @@ def parseDynamic(df, metricList):
attackDynamic.metrics = extractMetrics(df, i, 4) attackDynamic.metrics = extractMetrics(df, i, 4)
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
attackDynamic.associateBowtie(df,attackDynamic.type) # Associate the dynamic with the correct components attackDynamic.associateBowtie(df,attackDynamic.type) # Associate the dynamic with the correct components
print(attackDynamic, "\n")
elif df[const.textArea3][i] == const.ERDynamic: elif df[const.textArea3][i] == const.ERDynamic:
erDynamic = dynamic.ERDynamic( erDynamic = dynamic.ERDynamic(
...@@ -115,7 +117,8 @@ def parseDynamic(df, metricList): ...@@ -115,7 +117,8 @@ def parseDynamic(df, metricList):
) )
erDynamic.metrics = extractMetrics(df, i, 8) erDynamic.metrics = extractMetrics(df, i, 8)
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
#erDynamic.associatedERComponents(df) erDynamic.associatER(df)
print(erDynamic , "\n")
def extractMetrics(df, index, startRange): def extractMetrics(df, index, startRange):
......
...@@ -39,6 +39,16 @@ class BowtieDynamic(DynamicComponent): ...@@ -39,6 +39,16 @@ class BowtieDynamic(DynamicComponent):
self.associatedAttack = None # Attack associated with the dynamic self.associatedAttack = None # Attack associated with the dynamic
self.associatedConsequence = None # Consequence associated with the dynamic self.associatedConsequence = None # Consequence associated with the dynamic
def __str__(self) -> str:
if self.type == const.ThreatDynamic:
return super().__str__() + f"Associated threat ID: {self.associatedThreat[const.Id].item()} Associated attack ID {(self.associatedAttack[const.Id].item())}"
elif self.type == const.ConsequenceDynamic:
return super().__str__() + f"Associated consequence ID: {self.associatedConsequence[const.Id].item()} Assocaited attack ID:{(self.associatedAttack[const.Id].item())}"
elif self.type == const.AttackDynamic:
return super().__str__() + f"Associated attack ID: {self.associatedAttack[const.Id].item()}"
"""_summary_ """_summary_
Handles the associated dynamics for the bowtie model as they are different from the ER model Handles the associated dynamics for the bowtie model as they are different from the ER model
ER model has one type of dynamic component with metrics however, the bowtie model has three dynamic types and needs more parsing ER model has one type of dynamic component with metrics however, the bowtie model has three dynamic types and needs more parsing
...@@ -93,14 +103,6 @@ class BowtieDynamic(DynamicComponent): ...@@ -93,14 +103,6 @@ class BowtieDynamic(DynamicComponent):
self.associatedAttack = sourceComponent self.associatedAttack = sourceComponent
class ERDynamic(DynamicComponent): class ERDynamic(DynamicComponent):
def __init__(self, componentID, type, description) -> None: def __init__(self, componentID, type, description) -> None:
super().__init__(componentID) super().__init__(componentID)
...@@ -109,6 +111,8 @@ class ERDynamic(DynamicComponent): ...@@ -109,6 +111,8 @@ class ERDynamic(DynamicComponent):
self.associatedERComponents = [] # Associated ER component self.associatedERComponents = [] # Associated ER component
self.type = type self.type = type
def __str__(self) -> str:
return super().__str__() + f"ER Dynamic: {self.type}, {self.description}, Amount of associated components {len(self.associatedERComponents)}"
"""_summary_ """_summary_
Function will use the dynamic component ID to find linked threats, ER components, attacks and consequences Function will use the dynamic component ID to find linked threats, ER components, attacks and consequences
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment