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

Created join metrics function, dynamics now store all metrics in global list

parent e3c89be1
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ import pandas as pd ...@@ -2,6 +2,7 @@ import pandas as pd
import ERFormatConstants as const import ERFormatConstants as const
import components as component import components as component
import dynamics as dynamic import dynamics as dynamic
import logging as log
# Function will parse a csv file and extract the necessary information, this is step 1 of the parse # Function will parse a csv file and extract the necessary information, this is step 1 of the parse
def parseDiagramFile(csvFile): def parseDiagramFile(csvFile):
...@@ -22,7 +23,7 @@ def parseDiagramFile(csvFile): ...@@ -22,7 +23,7 @@ def parseDiagramFile(csvFile):
attacks = [] attacks = []
parseDynamic(df) parseDynamic(df, metrics)
def parseThreats(df, threatDict): def parseThreats(df, threatDict):
...@@ -76,39 +77,68 @@ def parseDynamic(df, metricList): ...@@ -76,39 +77,68 @@ def parseDynamic(df, metricList):
if df[const.textArea3][i] == const.ThreatDynamic: # If the dynamic component is a threat if df[const.textArea3][i] == const.ThreatDynamic: # If the dynamic component is a threat
threatDynamic = dynamic.BowtieDynamic( threatDynamic = dynamic.BowtieDynamic(
df[const.Id][i], # Component ID LucidChart df[const.Id][i], # Component ID LucidChart
df[const.textArea3][i] df[const.textArea3][i] # Name of dynamic
) )
extractMetrics(df, i, 4) threatDynamic.metrics = extractMetrics(df, i, 4) # Extracts metrics from the dynamic component
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
elif df[const.textArea3][i] == const.ConsequenceDynamic: elif df[const.textArea3][i] == const.ConsequenceDynamic:
consequenceDynamic = dynamic.BowtieDynamic() consequenceDynamic = dynamic.BowtieDynamic(
extractMetrics(df, i, 4) 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
elif df[const.textArea3][i] == const.AttackDynamic: elif df[const.textArea3][i] == const.AttackDynamic:
attackDynamic = dynamic.BowtieDynamic() attackDynamic = dynamic.BowtieDynamic(
extractMetrics(df, i, 4) df[const.Id][i], # Component ID LucidChart
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
elif df[const.textArea3][i] == const.ERDynamic: elif df[const.textArea3][i] == const.ERDynamic:
erDynamic = dynamic.ERDynamic() erDynamic = dynamic.ERDynamic(
extractMetrics(df, i, 8) df[const.id][i], # Component ID LucidChart
df.textArea3[i], # Name of dynamic
)
erDynamic.metrics = extractMetrics(df, i, 8)
joinMetrcs(threatDynamic.metrics, metricList) # Adds the metrics to the global metric list
def extractMetrics(df, index, startRange, metricList): def extractMetrics(df, index, startRange):
for j in range(startRange, len(df.columns),2): # Parse all text areas to find metrics for j in range(startRange, len(df.columns),2): # Parse all text areas to find metrics
listOfMetrics = []
metricID = "Text Area "+str(j) metricID = "Text Area "+str(j)
metricName = "Text Area "+str(j+1) metricName = "Text Area "+str(j+1)
if pd.isnull(df[metric][index]) == False: # If the text area is not empty if pd.isnull(df[metric][index]) == False: # If the text area is not empty
print("Metric: ID", df[metricID][index], "Name: ", df[metricName][index]) print("Metric: ID", df[metricID][index], "Name: ", df[metricName][index])
metric = dynamic.Metric(df[metricID][index], df[metricName][index]) metric = dynamic.Metric(df[metricID][index], df[metricName][index])
metricList.append(metric) listOfMetrics.append(metric)
else: else:
j=0 j=0
break # First empty field indicates no more metrics break # First empty field indicates no more metrics
return metricList # Returns metric found in the dynamic component return listOfMetrics # Returns metric found in the dynamic component
"""_summary_
Function will use a local metric list and insert the local metrics into a global metric list
containing all the metrics in the threat landscape
"""
def joinMetrcs(localMetrics, globalMetrics):
duplicateMetrics = 0 # Counter for duplicate metrics per function run
for i in range(globalMetrics):
for j in range(localMetrics):
if globalMetrics[i].name == localMetrics[j].name: # Local metric already exists in the global metric list
duplicateMetrics += 1
break # Check next entry
else:
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)
Har komponenter
Lagt til lokale metrics i hver komponent
1. Må nå lage en global metric liste
2. Må lage ER dynamikk liste
3. Må koble dynamic komponenter til trusselkomponent
# Thesis problem description
Problem description:
The thesis aims to innovate in risk modeling through the use of bowtie diagrams and the identification and documentation of dynamic indicators of software supply chain risk.
The goal of the thesis is to research the possibilities of graphical linkage between bow tie risk models and entity relationship diagrams and to develop a method for this linkage.
This is all in an effort to facilitate dynamic risk management for software supply chains.
The thesis proposes a method for linking bow tie risk diagrams and entity relationship diagrams through dynamic indicators.
The method will use new annotations on bow tie risk models and matrices containing indicators which can be observed for both ER architecture diagrams and bow tie risk models.
To analyze the modeled diagrams and matrices, a analysis tool will be developed to facilitate the analysis and scoring of the modeled risk image.
The scoring will be based on amount of indicators observed for critical components and their status.
Method formulation and scorecard developement is being done using Technology research. This methodology splits the research into problem definition where a literature mapping was leveraged to understand state of the art.
The next step is innovation where the method and prototype is developed.
For evaluation the method and tool will be tested on two cases provided by partners.
Preceeding the evaluation a new iteration of technology research will be started to improve the method and tool according to the evaluation.
The focus of the annotation will be on risks and aspects related to software supply chains.
The method will use specialized Entity relationship components to annotate the bow tie risk models and architecture diagram, this annotation will facilitate linkage between an entity relationship diagram of a software supply chain and the bow tie risk models associated with it.
All resulting in a method which can help in determine which metrics one should observe to pick up on changes in the risk landscape of the software supply chain facilitating dynamic risk management.
...@@ -5,7 +5,7 @@ class DynamicComponent: ...@@ -5,7 +5,7 @@ class DynamicComponent:
def __init__(self, componentID) -> None: def __init__(self, componentID) -> None:
self.componentID = componentID self.componentID = componentID
self.metrics = [Metric] # List of metrics for the dynamic self.metrics = [] # List of metrics for the dynamic
self.DynamicsRow = None # The row in the dynamics table the dynamic is associated with self.DynamicsRow = None # The row in the dynamics table the dynamic is associated with
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment