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

Finished parsing attacks, consequences and threats.

parent 9de8fa43
Branches
No related tags found
No related merge requests found
......@@ -21,14 +21,16 @@ textArea14 = "Text Area 14"
textArea15 = "Text Area 15"
textArea16 = "Text Area 16"
#Mapped fields for Threat component
Threat = textArea1 # The threat
Threat = "Threat" # The threat
ThreatValue = textArea1 # The threat
ThreatID = textArea2 # The id of the threat
ThreatIDValue = textArea3 # Value
ThreatSource = textArea4 # The threat source
ThreatSource = textArea5 # Value
ThreatSourceValue = textArea5 # Value
Likelihood = textArea6 # The likelihood of the threat
LikelihoodValue = textArea7 # Value
......@@ -40,7 +42,8 @@ Vulnerability = textArea10 # The vulnerability
VulnerabilityValue = textArea11 # Value
#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
ConsequenceIDValue = textArea3 # Value
......@@ -55,7 +58,8 @@ AffectedComponent = textArea8 # The affected component
AffectedComponentValue = textArea9 # Value
#Attack
Attack = textArea1 # The attack
Attack = "Attack" # The attack
AttackValue = textArea1 # The attack
AttackType = textArea2 # The type of attack
AttackTypeValue = textArea3 # Value
......@@ -66,4 +70,13 @@ AttackedComponentValue = textArea5 # Value
AttackDescription = textArea6 # The description of the attack
AttackDescriptionValue = textArea7 # Value
#Dynamics
ThreatDynamic = "Threat Dynamics" # The dynamics
ConsequenceDynamic = "Consequence Dynamics" # The dynamics
AttackDynamic = "Attack Dynamics" # The dynamics
Dynamics = "Dynamics" # The dynamics
......@@ -7,42 +7,69 @@ import dynamics as dynamic
def parseDiagramFile(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
print(df.head)
# List containing all threats and their descriptions
threats = []
threats = {}
threats = parseThreats(df, threats)
print(threats)
print(len(threats))
#List containing all consequences
consequences = []
consequences = {}
consequences = parseConsequences(df, consequences)
print(consequences)
#List containing all metrics
metrics = []
#List containing all attacks
attacks = []
def parseThreats(df):
def parseThreats(df, threatDict):
for i in range(len(df)):
if df[const.textArea1][i] == const.Threat:
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])
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
df[const.ThreatSourceValue][i],
df[const.ThreatDescriptionValue][i],
df[const.LikelihoodValue][i],
df[const.VulnerabilityValue][i]
)
threatDict[df.Id[i]] = threat
return threatDict
#Parses consequences and adds it to dictionary
def parseConsequences(df, consequenceDict):
for i in range(len(df)):
if df[const.ConsequenceValue][i] == const.Consequence:
consequence = component.Consequence(
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
return consequenceDict
def parseConsequences(df):
def parseAttacks(df, attackDict):
for i in range(len(df)):
if df["Shape Type"][i] == "Consequence":
consequences.append(df["Name"][i])
print(consequences)
if df[const.AttackValue][i] == const.Attack:
attack = component.Attack(
df[const.Id][i],
df[const.AttackedComponentValue][i],
df[const.AttackDescriptionValue][i],
)
attackDict[df.Id[i]] = attack
def parseMetrics(df):
return attackDict
#Parses metrics components and adds it to list
def parseDynamic(df, dynamicsDict):
for i in range(len(df)):
if df["Shape Type"][i] == "Metric":
metrics.append(df["Name"][i])
print(metrics)
\ No newline at end of file
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