diff --git a/dashBoard.py b/dashBoard.py index 91e47c2ce375ba29742fe4479982a7005460f561..7b0d647087a77af891db3afb20cd8da8a824a3da 100644 --- a/dashBoard.py +++ b/dashBoard.py @@ -22,45 +22,59 @@ def openFile(): - top = Toplevel() + top = Toplevel(guiRoot) top.title("Parsed diagram") - top.geometry("1500x1500") - - h = Scrollbar(top, orient="vertical") - h.pack() + top.geometry("500x500") lab = Label(top, text="Threat components in the diagrams") - lab.config(font= ("Comic Sans MS", 25, "bold")) - lab.pack(pady=20) + lab.config(font= ("Helvetica", 20, "bold")) + lab.grid() createThreats(diagram, top) return diagram def createThreats(diagram: Diagram, top): + + rowIndex = 0 + for threat in diagram.threats.values(): metrics, components = findMetrics(diagram, threat.componentID, "bowtie") threatFrame = Frame(top) - threatFrame.pack() + threatFrame.grid(row=rowIndex) + rowIndex +=1 - - l1 = Label(threatFrame, text= f"ID: {threat.id} Description: {threat.threatSource}") + l1 = Label(threatFrame, text= f"Threat ID: {threat.id} \n Threat description: {threat.threatSource}") l2 = Label(threatFrame, text= f"Associated vulnerability: {threat.vulnerability}") - l3 = Label(threatFrame, text= f"Observable metrics: {metrics}") + + listofIndicators = Listbox(threatFrame, font="Helvetica") + index = 1 + for metric in metrics: + listofIndicators.insert(index,metric) + index +=1 + + linkedComponents = Listbox(threatFrame, font="Helvetica") + index = 1 + for component in components: + linkedComponents.insert(index, component) + index +=1 + + l3 = Label(threatFrame, text= f"Observable indicators: {metrics}") + + l4 = Label(threatFrame, text = f"Linked Components: {components}") - l1.config(font=("Comic Sans MS", 20)) - l2.config(font=("Comic Sans MS", 15)) - l3.config(font=("Comic Sans MS", 15)) - l4.config(font=("Comic Sans MS", 15)) - - l1.pack() - l2.pack() - l3.pack() - l4.pack() + l1.config(font=("Helvetica", 20, "bold")) + l2.config(font=("Helvetica", 15)) + l3.config(font=("Helvetica", 15)) + l4.config(font=("Helvetica", 15)) + l1.grid(row = 4, column = 0) + l2.grid(row=6, column = 0) + listofIndicators.grid(row=4, column=10) + linkedComponents.grid(row = 4, column = 15) @@ -72,12 +86,12 @@ def findMetrics(diagram, id:int, typeOfObject:str): if typeOfObject == "bowtie": if id in metric.bowtieID: - relevantMetrics.append(metric.ID) + relevantMetrics.append(metric.name) relatedComponents.append(metric.erID) elif typeOfObject == "er": if id in metric.erID: - relevantMetrics.append(metric.ID) + relevantMetrics.append(metric.name) relatedComponents.append(metric.bowtieID) return relevantMetrics, relatedComponents diff --git a/diagramParser.py b/diagramParser.py index 18d4bf44c3c53c6aa1c9494caad1340651a2499e..5ac89648cdcdfc9ba1a2a2109f5f02b07ac725f9 100644 --- a/diagramParser.py +++ b/diagramParser.py @@ -24,7 +24,6 @@ def parseDiagramFile(csvFile) -> component.Diagram: metrics, dynamics = parseDynamic(df, metrics, dynamics) - metricsMatrix, metrics = matrix.parseTable(df, metrics, diagram) #Parse the table return diagram diff --git a/dynamics.py b/dynamics.py index 4c55a4e3faf1e60d38cd5ad570755b36860585a4..82d79f3115d0d9979f4a2d9b123f4e02fe717379 100644 --- a/dynamics.py +++ b/dynamics.py @@ -126,8 +126,8 @@ class BowtieDynamic(DynamicComponent): self.associatedConsequence = destinationComponent self.associatedAttack = sourceComponent - # ! After parsing the different components related to the dynamics component, - # ! the metrics in the component are added to the global metric list and local metric list + # ! After parsing the different components related to the dynamics component, + # ! the metrics in the component are added to the global metric list and local metric list self.linkMetric(df, metricsDict) def linkMetric(self, df, metricsDict: dict): @@ -267,8 +267,7 @@ class ERDynamic(DynamicComponent): continue metric.erID.append(erID) metricsDict[metricID] = metric # ! Adds the metric to the global metric list - - + def checkDuplicateMetrics(metricsDict: dict, metricID: str): """_summary_ Function will check if the diagrams metric dict contains a metric,