Skip to content
Snippets Groups Projects
Commit 4a0ccced authored by martiivGylden's avatar martiivGylden
Browse files

Function adds all dynamics into list

parent a2920baf
Branches
No related tags found
No related merge requests found
......@@ -20,13 +20,15 @@ def parseDiagramFile(csvFile):
# ER components
erComponents = {}
# Dynamic components
dynamics = {}
#List containing all metrics
metrics = []
#List containing all attacks
attacks = []
parseDynamic(df, metrics)
parseDynamic(df, metrics, dynamics)
def parseThreats(df, threatDict):
......@@ -73,7 +75,7 @@ def parseAttacks(df, attackDict):
return attackDict
#Parses metrics components and adds it to list
def parseDynamic(df, metricList):
def parseDynamic(df, metricList, dynamicsDict):
for i in range(len(df)): # Iterates through the dataframe
if df[const.textArea1][i] == const.Dynamics: # If the component is a dynamic component
......@@ -83,21 +85,21 @@ def parseDynamic(df, metricList):
df[const.textArea3][i] # Name of dynamic
)
threatDynamic.metrics = extractMetrics(df, i, 4) # Extracts metrics from the dynamic component
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
metricList = joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
threatDynamic.associateBowtie(df, threatDynamic.type) # Associate the dynamic with the correct components
print(threatDynamic, "\n")
dynamicsDict[df.Id[i]] = threatDynamic
elif df[const.textArea3][i] == const.ConsequenceDynamic:
consequenceDynamic = dynamic.BowtieDynamic(
df[const.Id][i], # Component ID LucidChart
df[const.textArea3][i] # Name of dynamic
)
consequenceDynamic.metrics = extractMetrics(df, i, 4) # Extracts metrics from the dynamic component
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
metricList = joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list@
consequenceDynamic.associateBowtie(df, consequenceDynamic.type)
print(consequenceDynamic, "\n")# Associate the dynamic with the correct components
dynamicsDict[df.Id[i]] = consequenceDynamic
elif df[const.textArea3][i] == const.AttackDynamic:
attackDynamic = dynamic.BowtieDynamic(
......@@ -105,10 +107,11 @@ def parseDynamic(df, metricList):
df[const.textArea3][i] # Name of dynamic
)
attackDynamic.metrics = extractMetrics(df, i, 4)
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
metricList = joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
attackDynamic.associateBowtie(df,attackDynamic.type) # Associate the dynamic with the correct components
print(attackDynamic, "\n")
dynamicsDict[df.Id[i]] = attackDynamic
elif df[const.textArea3][i] == const.ERDynamic:
erDynamic = dynamic.ERDynamic(
df[const.Id][i], # Component ID LucidChart
......@@ -116,9 +119,11 @@ def parseDynamic(df, metricList):
df[const.textArea5][i] # Description
)
erDynamic.metrics = extractMetrics(df, i, 8)
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
metricList = joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
erDynamic.associatER(df)
print(erDynamic , "\n")
dynamicsDict[df.Id[i]] = erDynamic
print("Number of dynamics: ", len(dynamicsDict))
def extractMetrics(df, index, startRange):
......@@ -152,3 +157,5 @@ def joinMetrcs(localMetrics, globalMetrics):
globalMetrics.append(localMetrics[j]) # Add the local metric to the global metric list
log.info("New local metric added to global metric list, metric: ", localMetrics[j].name)
log.info("Added all metrics in local list \n, number of duplicate metrics: ", duplicateMetrics, "\n Number of new metrics: ", len(localMetrics)-duplicateMetrics)
return globalMetrics
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment