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

Decided on csv, working on schema

parent 5a721ea3
No related branches found
No related tags found
No related merge requests found
Necessary info from each component:
Threat:
ID -> Necesary for links and identification
Text area 1 -> Name (Threat)
Text area 2 -> ID For matrix linkage
Text area 3 -> Actual ID
Text area 4 -> Threat source
Text area 5 -> Description threat source
Text area 6 -> Likelihood
Text area 7 -> Description Likelihood
Text area 8 -> Description
Text area 9 -> Description of description
Text area 10 -> Vulnerability
Text area 11 -> Description of vulnerability
Consequence:
ID -> Necesary for links and identification
Text area 1 -> Name (Consequence)
Text area 2 -> ID
Text area 3 -> ID for linkage
Text area 4 -> Description
Text area 5 -> Description of consequence
Text area 6 -> Qonsequence
Text area 7 -> Consequence score
Text area 8 -> Affected components
Text area 9 -> The components in the architecture which are affected by consequence
Attack:
Text area 1 -> Name (Attack)
Text area 2 -> Type
Text area 3 -> Type description, what kind of attack is it
Text area 4 -> Component
Text area 5 -> Component description, what component is the attack related to
Text area 6 -> Description
Text area 7 -> Description of the attack
Risk
Text area 1 -> Name (Risk)
Text area 2 -> ID
Text area 3 -> ID for linkage
Threat dynamic:
Text area 1 -> Name (Threat dynamic)
Text area 2 -> Metric
Text area 3 -> Metric description
Text area 4 -> Metric
Text area 5 -> Metric description
...
Consequence dynamic:
Text area 1 -> Name (Consequence dynamic)
Text area 2 -> Metric
Text area 3 -> Metric description
Text area 4 -> Metric
Text area 5 -> Metric description
...
Attack dynamic:
Text area 1 -> Name (Attack dynamic)
Text area 2 -> Metric
Text area 3 -> Metric description
Text area 4 -> Metric
Text area 5 -> Metric description
...
ID -> Necesary for links and identification
Text area 1 -> Main description of the component Basically ID
Text area 2 -> Secondary description of the component
import csv import pandas as pd
import requests
import xml.etree.ElementTree as ET
def parseDiagramFile(xmlFile): # Function will parse a csv file and extract the necessary information, this is step 1 of the parse
xmlTree = ET.parse(xmlFile) def parseDiagramFile(csvFile):
root = xmlTree.getroot() 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 # List containing all threats and their descriptions
threats = [] threats = []
#List containing all consequences #List containing all consequences
\ No newline at end of file consequences = []
#List containing all metrics
metrics = []
#List containing all attacks
attacks = []
def parseThreats(df):
for i in range(len(df)):
if df["Shape Type"][i] == "Threat":
threats.append(df["Name"][i])
print(threats)
def parseConsequences(df):
for i in range(len(df)):
if df["Shape Type"][i] == "Consequence":
consequences.append(df["Name"][i])
print(consequences)
def parseMetrics(df):
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
This diff is collapsed.
import dynamics as dyn import dynamics as dyn
import diagramParser as parse
def main(): def main():
dynamicMetrics = [] dynamicMetricsBowtie = [] # List of metrics for the bowtie model
dynamicMetricsArchitecture = [] # List of metrics for the architecture
threat = dyn.ThreatDynamics(1, "Threat1") parse.parseDiagramFile('diagrams/Thesis Bow-Tie and architecture - Bowtie.csv') # Parse the diagram
print(threat)
threat.addMetrics(dynamicMetrics, "Metric1", "Description1", "opensource")
threat.addMetrics(dynamicMetrics, "Metric2", "Description2","opensource")
threat.addMetrics(dynamicMetrics, "Metric3", "Description3", "opensource")
print("Threat object:", threat)
print("Metrics:", dynamicMetrics)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment