diff --git a/ERFormatConstants.py b/ERFormatConstants.py index 697f7b063cfc48b1b56593e6169d529e6c37c65c..cbbe74971c4fd91f07020a26cb57b4d6741e962f 100644 --- a/ERFormatConstants.py +++ b/ERFormatConstants.py @@ -1,10 +1,8 @@ #File contains constants from the CSV export format of the entity relationship tool -#Generic fields for all entities +#Generic fields for all rows in the CSV file componentID = "Id" # LucidChart ID Id = "Id" # The id of the entity -Description = "Description" # The description of the entity - textArea1 = "Text Area 1" textArea2 = "Text Area 2" @@ -23,17 +21,49 @@ textArea14 = "Text Area 14" textArea15 = "Text Area 15" textArea16 = "Text Area 16" -#Threats -Threat = "Threat" # The threat -> Text area 1 -ThreatSource = "Threat source" # The threat source -> Text area 4 -Likelihood = "Likelihood" # The likelihood of the threat -> Text area 6 -Vulnerability = "Vulnerability" # The vulnerability -> Text area 7 +#Mapped fields for Threat component +Threat = textArea1 # The threat -#Attack -Type = "Type" # The type of the consequence -> Text area 2 -Component = "Component" # The component related to the attack -> Text area 4 +ThreatID = textArea2 # The id of the threat +ThreatIDValue = textArea3 # Value + +ThreatSource = textArea4 # The threat source +ThreatSource = textArea5 # Value + +Likelihood = textArea6 # The likelihood of the threat +LikelihoodValue = textArea7 # Value + +ThreatDescription = textArea8 # The description of the threat +ThreatDescriptionValue = textArea9 # Value + +Vulnerability = textArea10 # The vulnerability +VulnerabilityValue = textArea11 # Value #Consequence -Consequence = "Consequence" # The consequence score of the area -> Text area 6 -AffectedComponents = "Affected components" # The affected components -> Text area 7 +Consequence = textArea1 # The consequence score of the area -> Text area 6 + +ConsequenceID = textArea2 # The id of the consequence +ConsequenceIDValue = textArea3 # Value + +ConsequenceDescription = textArea4 # The description of the consequence +ConsequenceDescriptionValue = textArea5 # Value + +ConsequenceScore = textArea6 # The consequence score of the area +ConsequenceScoreValue = textArea7 # Value + +AffectedComponent = textArea8 # The affected component +AffectedComponentValue = textArea9 # Value + +#Attack +Attack = textArea1 # The attack + +AttackType = textArea2 # The type of attack +AttackTypeValue = textArea3 # Value + +AttackedComponent = textArea4 # The attacked component +AttackedComponentValue = textArea5 # Value + +AttackDescription = textArea6 # The description of the attack +AttackDescriptionValue = textArea7 # Value + diff --git a/diagramParser.py b/diagramParser.py index 3610a72310072415031b68e780cc453b7e7e6071..af009618fa300baa27be4dd5ca39f447c3304da3 100644 --- a/diagramParser.py +++ b/diagramParser.py @@ -1,5 +1,7 @@ import pandas as pd import ERFormatConstants as const +import components as component +import dynamics as dynamic # Function will parse a csv file and extract the necessary information, this is step 1 of the parse def parseDiagramFile(csvFile): @@ -24,9 +26,14 @@ def parseDiagramFile(csvFile): def parseThreats(df): for i in range(len(df)): if df[const.textArea1][i] == const.Threat: - - threats.append(df["Name"][i]) - print(threats) + threat = component.Threat( + df[const.Id][i], # The id of the entity + df[const.componentID][i], # The component ID field provided by LucidChart + df[const.textArea4][i], + df[const.Description][i], + df[const.textArea6][i], + df[const.textArea7][i]) + def parseConsequences(df): for i in range(len(df)): diff --git a/dynamics.py b/dynamics.py index 3ee1ad938f0bd5cc9e8ee19d1769d1a112cd1e15..c176358fe574a2a33e68ee6b2b8e8c02dc36f67d 100644 --- a/dynamics.py +++ b/dynamics.py @@ -4,8 +4,8 @@ from enum import Enum #Dynamics class parent class for all dynamic components in the diagram class Dynamics: - def __init__(self, id) -> None: - self.id = id + def __init__(self, componentID) -> None: + self.componentID = componentID self.metrics = [Metric] #List of metrics for the dynamic