diff --git a/ERFormatConstants.py b/ERFormatConstants.py index 7340013d897b68f6de6d4bc55ea95a7aeda276e0..83c37d1d1db41bcf4b8dee1db935fe7db8e42929 100644 --- a/ERFormatConstants.py +++ b/ERFormatConstants.py @@ -38,14 +38,14 @@ ThreatValue = textArea1 # The threat ThreatID = textArea2 # The id of the threat ThreatIDValue = textArea3 # Value -ThreatSource = textArea4 # The threat source -ThreatSourceValue = textArea5 # Value +ThreatSource = textArea6 # The threat source +ThreatSourceValue = textArea7 # Value Likelihood = textArea6 # The likelihood of the threat LikelihoodValue = textArea7 # Value -ThreatDescription = textArea8 # The description of the threat -ThreatDescriptionValue = textArea9 # Value +ThreatDescription = textArea4 # The description of the threat +ThreatDescriptionValue = textArea5 # Value Vulnerability = textArea10 # The vulnerability VulnerabilityValue = textArea11 # Value diff --git a/dashBoard.py b/dashBoard.py index d2549d7daf47541f547f93d05aabf1683acd7dc2..e8e3db8ab0850a6234d623812cea54183364331f 100644 --- a/dashBoard.py +++ b/dashBoard.py @@ -108,7 +108,7 @@ def createMetrics(diagram: Diagram, frame, canvasWidth): 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('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() rowIndex = 0 @@ -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") bowTieList = utils.createBowtieLabel(bowTieFrame, diagram.metrics[metricID], diagram) + for i in range(len(bowTieList)): bowTieList[i].grid(row=i+1, column=0, sticky="nw") diff --git a/dashboardUtils.py b/dashboardUtils.py index 2ac386b8b7eecba57f05dbc5a59049529ef15ce5..8ade295cfa3cca0f938fbb01cd756dc49ee06480 100644 --- a/dashboardUtils.py +++ b/dashboardUtils.py @@ -9,6 +9,9 @@ import diagramParser as parse def createERLabel(top, metric: Metric, diagram: Diagram): + s = ttk.Style() + s.configure('ListFrame.TLabel', background='white', foreground="#1A323B", font=('Helvetica', 15, 'bold')) + nameList = [] labelList = [] for i in metric.erID: @@ -22,27 +25,38 @@ def createERLabel(top, metric: Metric, diagram: Diagram): else: pass for k in nameList: - label = ttk.Label(top, text= f"{k}") + label = ttk.Label(top, text= f"{k}", style="ListFrame.TLabel") labelList.append(label) return labelList def createBowtieLabel(top, metric: Metric, diagram: Diagram): - nameList = [] + s = ttk.Style() + s.configure('ListFrame.TLabel', background='white', foreground="#1A323B", font=('Helvetica', 15, 'bold')) + labelList = [] + nameList = [] + + for i in metric.bowtieID: - try: - nameList.append(diagram.threats[i].description) - except KeyError: - try: - nameList.append(diagram.consequences[i].description) - except KeyError: - try: - nameList.append(diagram.attacks[i].description) - except KeyError: - continue - - for k in nameList: - label = ttk.Label(top, text= f"{k}") + if i in diagram.threats.keys(): + label = ttk.Label(top, text= f"Threat component: {diagram.threats[i].description}", style="ListFrame.TLabel") + + nameList.append(diagram.threats[i].description) + + labelList.append(label) + + elif i in diagram.consequences.keys(): + label = ttk.Label(top, text= f"Consequence component: {diagram.consequences[i].description}", style="ListFrame.TLabel") + + nameList.append(diagram.consequences[i].description) + + 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) return labelList diff --git a/diagramParser.py b/diagramParser.py index 9e8e180aebd5a7e2ddcfa43017f36fb9fe3b8813..969e203f13cd9703230178ca4ce4ed408da156b1 100644 --- a/diagramParser.py +++ b/diagramParser.py @@ -33,7 +33,7 @@ def parseDiagramFile(csvFile) -> component.Diagram: def parseThreats(df, threatDict): for i in range(len(df)): if df[const.ThreatValue][i] == const.Threat: #Creates threat object - + threat = component.Threat( df[const.ThreatIDValue][i], # ID from ER df[const.Id][i], # LucidChart ID @@ -50,6 +50,9 @@ def parseThreats(df, threatDict): def parseConsequences(df, consequenceDict): for i in range(len(df)): if df[const.ConsequenceValue][i] == const.Consequence: + + print(df[const.ConsequenceDescriptionValue][i]) + consequence = component.Consequence( df[const.ConsequenceIDValue][i], df[const.Id][i], @@ -64,6 +67,7 @@ def parseConsequences(df, consequenceDict): def parseAttacks(df, attackDict): for i in range(len(df)): if df[const.AttackValue][i] == const.Attack: + attack = component.Attack( df[const.Id][i], df[const.AttackedComponentValue][i],