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

Finished parsing etc, attack needs to be configured though...

parent 5bc918d9
No related branches found
No related tags found
No related merge requests found
...@@ -38,14 +38,14 @@ ThreatValue = textArea1 # The threat ...@@ -38,14 +38,14 @@ ThreatValue = textArea1 # The threat
ThreatID = textArea2 # The id of the threat ThreatID = textArea2 # The id of the threat
ThreatIDValue = textArea3 # Value ThreatIDValue = textArea3 # Value
ThreatSource = textArea4 # The threat source ThreatSource = textArea6 # The threat source
ThreatSourceValue = textArea5 # Value ThreatSourceValue = textArea7 # Value
Likelihood = textArea6 # The likelihood of the threat Likelihood = textArea6 # The likelihood of the threat
LikelihoodValue = textArea7 # Value LikelihoodValue = textArea7 # Value
ThreatDescription = textArea8 # The description of the threat ThreatDescription = textArea4 # The description of the threat
ThreatDescriptionValue = textArea9 # Value ThreatDescriptionValue = textArea5 # Value
Vulnerability = textArea10 # The vulnerability Vulnerability = textArea10 # The vulnerability
VulnerabilityValue = textArea11 # Value VulnerabilityValue = textArea11 # Value
......
...@@ -108,7 +108,7 @@ def createMetrics(diagram: Diagram, frame, canvasWidth): ...@@ -108,7 +108,7 @@ def createMetrics(diagram: Diagram, frame, canvasWidth):
s.configure('Head.TLabel', background='#51D88F', foreground="#1A323B" ,font=('Helvetica', 20, 'bold')) s.configure('Head.TLabel', background='#51D88F', foreground="#1A323B" ,font=('Helvetica', 20, 'bold'))
s.configure('Test.TLabel', background='#51D88F', foreground="#1A323B" ,font=('Helvetica', 20)) s.configure('Test.TLabel', background='#51D88F', foreground="#1A323B" ,font=('Helvetica', 20))
s.configure('ListFrame.TFrame', background='white', foreground="#155E53") s.configure('ListFrame.TFrame', background='white', foreground="#155E53")
s.configure('ListFrame.TLabel', background='white', foreground="#155E53", font=('Helvetica', 20, 'bold')) s.configure('ListFrame.TLabel', background='white', foreground="#1A323B", font=('Helvetica', 20, 'bold'))
metrics = diagram.metrics.values() metrics = diagram.metrics.values()
rowIndex = 0 rowIndex = 0
...@@ -177,6 +177,7 @@ def createMetrics(diagram: Diagram, frame, canvasWidth): ...@@ -177,6 +177,7 @@ def createMetrics(diagram: Diagram, frame, canvasWidth):
ttk.Label(bowTieFrame, text="BowTie components", style="ListFrame.TLabel").grid(row=0, column=0, sticky="nw") ttk.Label(bowTieFrame, text="BowTie components", style="ListFrame.TLabel").grid(row=0, column=0, sticky="nw")
bowTieList = utils.createBowtieLabel(bowTieFrame, diagram.metrics[metricID], diagram) bowTieList = utils.createBowtieLabel(bowTieFrame, diagram.metrics[metricID], diagram)
for i in range(len(bowTieList)): for i in range(len(bowTieList)):
bowTieList[i].grid(row=i+1, column=0, sticky="nw") bowTieList[i].grid(row=i+1, column=0, sticky="nw")
......
...@@ -9,6 +9,9 @@ import diagramParser as parse ...@@ -9,6 +9,9 @@ import diagramParser as parse
def createERLabel(top, metric: Metric, diagram: Diagram): def createERLabel(top, metric: Metric, diagram: Diagram):
s = ttk.Style()
s.configure('ListFrame.TLabel', background='white', foreground="#1A323B", font=('Helvetica', 15, 'bold'))
nameList = [] nameList = []
labelList = [] labelList = []
for i in metric.erID: for i in metric.erID:
...@@ -22,27 +25,38 @@ def createERLabel(top, metric: Metric, diagram: Diagram): ...@@ -22,27 +25,38 @@ def createERLabel(top, metric: Metric, diagram: Diagram):
else: else:
pass pass
for k in nameList: for k in nameList:
label = ttk.Label(top, text= f"{k}") label = ttk.Label(top, text= f"{k}", style="ListFrame.TLabel")
labelList.append(label) labelList.append(label)
return labelList return labelList
def createBowtieLabel(top, metric: Metric, diagram: Diagram): def createBowtieLabel(top, metric: Metric, diagram: Diagram):
nameList = [] s = ttk.Style()
s.configure('ListFrame.TLabel', background='white', foreground="#1A323B", font=('Helvetica', 15, 'bold'))
labelList = [] labelList = []
nameList = []
for i in metric.bowtieID: for i in metric.bowtieID:
try: if i in diagram.threats.keys():
nameList.append(diagram.threats[i].description) label = ttk.Label(top, text= f"Threat component: {diagram.threats[i].description}", style="ListFrame.TLabel")
except KeyError:
try: nameList.append(diagram.threats[i].description)
nameList.append(diagram.consequences[i].description)
except KeyError: labelList.append(label)
try:
nameList.append(diagram.attacks[i].description) elif i in diagram.consequences.keys():
except KeyError: label = ttk.Label(top, text= f"Consequence component: {diagram.consequences[i].description}", style="ListFrame.TLabel")
continue
nameList.append(diagram.consequences[i].description)
for k in nameList:
label = ttk.Label(top, text= f"{k}") labelList.append(label)
elif i in diagram.attacks.keys():
label = ttk.Label(top, text= f"Attack component: {diagram.attacks[i].description}", style="ListFrame.TLabel")
nameList.append(diagram.attacks[i].description)
labelList.append(label) labelList.append(label)
return labelList return labelList
......
...@@ -33,7 +33,7 @@ def parseDiagramFile(csvFile) -> component.Diagram: ...@@ -33,7 +33,7 @@ def parseDiagramFile(csvFile) -> component.Diagram:
def parseThreats(df, threatDict): def parseThreats(df, threatDict):
for i in range(len(df)): for i in range(len(df)):
if df[const.ThreatValue][i] == const.Threat: #Creates threat object if df[const.ThreatValue][i] == const.Threat: #Creates threat object
threat = component.Threat( threat = component.Threat(
df[const.ThreatIDValue][i], # ID from ER df[const.ThreatIDValue][i], # ID from ER
df[const.Id][i], # LucidChart ID df[const.Id][i], # LucidChart ID
...@@ -50,6 +50,9 @@ def parseThreats(df, threatDict): ...@@ -50,6 +50,9 @@ def parseThreats(df, threatDict):
def parseConsequences(df, consequenceDict): def parseConsequences(df, consequenceDict):
for i in range(len(df)): for i in range(len(df)):
if df[const.ConsequenceValue][i] == const.Consequence: if df[const.ConsequenceValue][i] == const.Consequence:
print(df[const.ConsequenceDescriptionValue][i])
consequence = component.Consequence( consequence = component.Consequence(
df[const.ConsequenceIDValue][i], df[const.ConsequenceIDValue][i],
df[const.Id][i], df[const.Id][i],
...@@ -64,6 +67,7 @@ def parseConsequences(df, consequenceDict): ...@@ -64,6 +67,7 @@ def parseConsequences(df, consequenceDict):
def parseAttacks(df, attackDict): def parseAttacks(df, attackDict):
for i in range(len(df)): for i in range(len(df)):
if df[const.AttackValue][i] == const.Attack: if df[const.AttackValue][i] == const.Attack:
attack = component.Attack( attack = component.Attack(
df[const.Id][i], df[const.Id][i],
df[const.AttackedComponentValue][i], df[const.AttackedComponentValue][i],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment