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

Finished parsing attacks, consequences and threats.

parent 9de8fa43
No related branches found
No related tags found
No related merge requests found
...@@ -21,14 +21,16 @@ textArea14 = "Text Area 14" ...@@ -21,14 +21,16 @@ textArea14 = "Text Area 14"
textArea15 = "Text Area 15" textArea15 = "Text Area 15"
textArea16 = "Text Area 16" textArea16 = "Text Area 16"
#Mapped fields for Threat component #Mapped fields for Threat component
Threat = textArea1 # The threat Threat = "Threat" # The threat
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 = textArea4 # The threat source
ThreatSource = textArea5 # Value ThreatSourceValue = textArea5 # Value
Likelihood = textArea6 # The likelihood of the threat Likelihood = textArea6 # The likelihood of the threat
LikelihoodValue = textArea7 # Value LikelihoodValue = textArea7 # Value
...@@ -40,7 +42,8 @@ Vulnerability = textArea10 # The vulnerability ...@@ -40,7 +42,8 @@ Vulnerability = textArea10 # The vulnerability
VulnerabilityValue = textArea11 # Value VulnerabilityValue = textArea11 # Value
#Consequence #Consequence
Consequence = textArea1 # The consequence score of the area -> Text area 6 Consequence = "Consequence" # The consequence score of the area -> Text area 6
ConsequenceValue = textArea1 # The consequence
ConsequenceID = textArea2 # The id of the consequence ConsequenceID = textArea2 # The id of the consequence
ConsequenceIDValue = textArea3 # Value ConsequenceIDValue = textArea3 # Value
...@@ -55,7 +58,8 @@ AffectedComponent = textArea8 # The affected component ...@@ -55,7 +58,8 @@ AffectedComponent = textArea8 # The affected component
AffectedComponentValue = textArea9 # Value AffectedComponentValue = textArea9 # Value
#Attack #Attack
Attack = textArea1 # The attack Attack = "Attack" # The attack
AttackValue = textArea1 # The attack
AttackType = textArea2 # The type of attack AttackType = textArea2 # The type of attack
AttackTypeValue = textArea3 # Value AttackTypeValue = textArea3 # Value
...@@ -66,4 +70,13 @@ AttackedComponentValue = textArea5 # Value ...@@ -66,4 +70,13 @@ AttackedComponentValue = textArea5 # Value
AttackDescription = textArea6 # The description of the attack AttackDescription = textArea6 # The description of the attack
AttackDescriptionValue = textArea7 # Value AttackDescriptionValue = textArea7 # Value
#Dynamics
ThreatDynamic = "Threat Dynamics" # The dynamics
ConsequenceDynamic = "Consequence Dynamics" # The dynamics
AttackDynamic = "Attack Dynamics" # The dynamics
Dynamics = "Dynamics" # The dynamics
...@@ -8,41 +8,68 @@ def parseDiagramFile(csvFile): ...@@ -8,41 +8,68 @@ def parseDiagramFile(csvFile):
df = pd.read_csv(csvFile) df = pd.read_csv(csvFile)
df.drop(["Shape Library", "Page ID", "Contained By", "Group", "Comments", "property 1"], axis=1, inplace=True) #Removing unecessary data df.drop(["Shape Library", "Page ID", "Contained By", "Group", "Comments", "property 1"], axis=1, inplace=True) #Removing unecessary data
print(df.head)
# List containing all threats and their descriptions # List containing all threats and their descriptions
threats = [] threats = {}
threats = parseThreats(df, threats)
print(threats)
print(len(threats))
#List containing all consequences #List containing all consequences
consequences = [] consequences = {}
consequences = parseConsequences(df, consequences)
print(consequences)
#List containing all metrics #List containing all metrics
metrics = [] metrics = []
#List containing all attacks #List containing all attacks
attacks = [] attacks = []
def parseThreats(df): def parseThreats(df, threatDict):
for i in range(len(df)): for i in range(len(df)):
if df[const.textArea1][i] == const.Threat: if df[const.ThreatValue][i] == const.Threat: #Creates threat object
threat = component.Threat( threat = component.Threat(
df[const.Id][i], # The id of the entity df[const.ThreatIDValue][i], # ID from ER
df[const.componentID][i], # The component ID field provided by LucidChart df[const.Id][i], # LucidChart ID
df[const.textArea4][i], df[const.ThreatSourceValue][i],
df[const.Description][i], df[const.ThreatDescriptionValue][i],
df[const.textArea6][i], df[const.LikelihoodValue][i],
df[const.textArea7][i]) df[const.VulnerabilityValue][i]
)
threatDict[df.Id[i]] = threat
return threatDict
def parseConsequences(df): #Parses consequences and adds it to dictionary
def parseConsequences(df, consequenceDict):
for i in range(len(df)): for i in range(len(df)):
if df["Shape Type"][i] == "Consequence": if df[const.ConsequenceValue][i] == const.Consequence:
consequences.append(df["Name"][i]) consequence = component.Consequence(
print(consequences) df[const.ConsequenceIDValue][i],
df[const.Id][i],
df[const.ConsequenceDescriptionValue][i],
df[const.ConsequenceScoreValue][i],
df[const.AffectedComponentValue][i]
)
consequenceDict[df.Id[i]] = consequence
def parseMetrics(df): return consequenceDict
def parseAttacks(df, attackDict):
for i in range(len(df)): for i in range(len(df)):
if df["Shape Type"][i] == "Metric": if df[const.AttackValue][i] == const.Attack:
metrics.append(df["Name"][i]) attack = component.Attack(
print(metrics) df[const.Id][i],
\ No newline at end of file df[const.AttackedComponentValue][i],
df[const.AttackDescriptionValue][i],
)
attackDict[df.Id[i]] = attack
return attackDict
#Parses metrics components and adds it to list
def parseDynamic(df, dynamicsDict):
for i in range(len(df)):
pass
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment