Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DynamicRiskManagementforSSC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Iversen
DynamicRiskManagementforSSC
Commits
8e199d81
Commit
8e199d81
authored
1 year ago
by
martiivGylden
Browse files
Options
Downloads
Patches
Plain Diff
Updated structure for matrix parsing FML
parent
3c1c034a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dashBoard.py
+49
-3
49 additions, 3 deletions
dashBoard.py
diagramParser.py
+2
-1
2 additions, 1 deletion
diagramParser.py
matrices.py
+21
-18
21 additions, 18 deletions
matrices.py
with
72 additions
and
22 deletions
dashBoard.py
+
49
−
3
View file @
8e199d81
...
...
@@ -20,19 +20,65 @@ def openFile():
)
diagram
=
parse
.
parseDiagramFile
(
fileName
)
top
=
Toplevel
()
top
.
title
(
"
Parsed diagram
"
)
top
.
geometry
(
"
1500x1500
"
)
lab
=
Label
(
top
,
text
=
"
Dynamic components in the diagrams
"
)
h
=
Scrollbar
(
top
,
orient
=
"
vertical
"
)
h
.
pack
()
lab
=
Label
(
top
,
text
=
"
Threat components in the diagrams
"
)
lab
.
config
(
font
=
(
"
Comic Sans MS
"
,
25
,
"
bold
"
))
lab
.
pack
(
pady
=
20
)
create
Dynamic
(
diagram
,
top
)
create
Threats
(
diagram
,
top
)
return
diagram
def
createThreats
(
diagram
:
Diagram
,
top
):
for
threat
in
diagram
.
threats
.
values
():
metrics
,
components
=
findMetrics
(
diagram
,
threat
.
id
)
threatFrame
=
Frame
(
top
)
threatFrame
.
pack
()
l1
=
Label
(
threatFrame
,
text
=
f
"
ID:
{
threat
.
id
}
Description:
{
threat
.
threatSource
}
"
)
l2
=
Label
(
threatFrame
,
text
=
f
"
Associated vulnerability:
{
threat
.
vulnerability
}
"
)
l3
=
Label
(
threatFrame
,
text
=
f
"
Observable metrics:
{
metrics
}
"
)
l4
=
Label
(
threatFrame
,
text
=
f
"
Linked Components:
{
components
}
"
)
l1
.
config
(
font
=
(
"
Comic Sans MS
"
,
20
))
l2
.
config
(
font
=
(
"
Comic Sans MS
"
,
15
))
l3
.
config
(
font
=
(
"
Comic Sans MS
"
,
15
))
l4
.
config
(
font
=
(
"
Comic Sans MS
"
,
15
))
l1
.
pack
()
l2
.
pack
()
l3
.
pack
()
l4
.
pack
()
def
findMetrics
(
diagram
,
id
):
relevantDynamic
=
[]
relatedComponents
=
[]
for
metric
in
diagram
.
metrics
.
values
():
if
id
in
metric
.
erID
:
relevantDynamic
.
append
(
metric
.
ID
)
relatedComponents
.
append
(
metric
.
erID
)
elif
id
in
metric
.
bowtieID
:
relevantDynamic
.
append
(
metric
.
ID
)
relatedComponents
.
append
(
metric
.
bowtieID
)
return
relevantDynamic
,
relatedComponents
def
createDynamic
(
diagram
:
Diagram
,
top
):
...
...
This diff is collapsed.
Click to expand it.
diagramParser.py
+
2
−
1
View file @
8e199d81
...
...
@@ -23,8 +23,9 @@ def parseDiagramFile(csvFile) -> component.Diagram:
consequences
=
parseConsequences
(
df
,
consequences
)
metrics
,
dynamics
=
parseDynamic
(
df
,
metrics
,
dynamics
)
metricsMatrix
=
matrix
.
parseTable
(
df
,
metrics
)
#Parse the table
metricsMatrix
,
metrics
=
matrix
.
parseTable
(
df
,
metrics
)
#Parse the table
print
(
metricsMatrix
)
return
diagram
...
...
This diff is collapsed.
Click to expand it.
matrices.py
+
21
−
18
View file @
8e199d81
...
...
@@ -15,17 +15,20 @@ def parseTable(df, metricsDict):
matrics
=
pd
.
DataFrame
(
columns
=
cols
)
print
(
len
(
table
))
length
=
len
(
table
.
columns
)
length
=
length
-
7
# Setting the length equal to the amount of text fields
stopLength
=
length
-
15
print
(
stopLength
)
# ! Parsing the first row of the table which has a fucked structure because lucidchart is garbage : )
erID1
=
table
[
const
.
textArea4
].
item
()
# Define the ER ID
BowTieID1
=
table
[
const
.
textArea5
].
item
()
# Define the Bowtie ID
MetricID1
=
table
[
const
.
textArea6
].
item
()
# Define the Metric ID
MetricName1
=
table
[
const
.
t
extArea
15
].
item
()
# Define the Metric Name
Value1
=
table
[
const
.
t
extArea
16
].
item
()
# Define the Value
MeasureDate1
=
table
[
const
.
t
extArea
17
].
item
()
# Define the Measure Date
Frequency1
=
table
[
const
.
t
extArea
18
].
item
()
# Define the Frequency
Guide1
=
table
[
const
.
t
extArea
19
].
item
()
# Define the Measurement guide
MetricName1
=
table
[
f
"
T
ext
Area
{
length
-
9
}
"
].
item
()
# Define the Metric Name
Value1
=
table
[
f
"
T
ext
Area
{
length
-
8
}
"
].
item
()
# Define the Value
MeasureDate1
=
table
[
f
"
T
ext
Area
{
length
-
7
}
"
].
item
()
# Define the Measure Date
Frequency1
=
table
[
f
"
T
ext
Area
{
length
-
6
}
"
].
item
()
# Define the Frequency
Guide1
=
table
[
f
"
T
ext
Area
{
length
-
5
}
"
].
item
()
# Define the Measurement guide
matrics
.
loc
[
0
]
=
erID1
,
BowTieID1
,
MetricID1
,
MetricName1
,
Value1
,
MeasureDate1
,
Frequency1
,
Guide1
# Fill inn dataframe
...
...
@@ -38,11 +41,11 @@ def parseTable(df, metricsDict):
erID2
=
table
[
const
.
textArea7
].
item
()
# Define the ER ID
BowTieID2
=
table
[
const
.
textArea8
].
item
()
# Define the Bowtie ID
MetricID2
=
table
[
const
.
textArea9
].
item
()
# Define the Metric ID
MetricName2
=
table
[
const
.
t
extArea
20
].
item
()
# Define the Metric Name
Value2
=
table
[
const
.
t
extArea
21
].
item
()
# Define the Value
MeasureDate2
=
table
[
const
.
t
extArea
22
].
item
()
# Define the Measure Date
Frequency2
=
table
[
const
.
t
extArea
23
].
item
()
# Define the Frequency
Guide2
=
table
[
const
.
t
extArea
24
].
item
()
# Define the Measurement guide
MetricName2
=
table
[
f
"
T
ext
Area
{
length
-
4
}
"
].
item
()
# Define the Metric Name
Value2
=
table
[
f
"
T
ext
Area
{
length
-
3
}
"
].
item
()
# Define the Value
MeasureDate2
=
table
[
f
"
T
ext
Area
{
length
-
2
}
"
].
item
()
# Define the Measure Date
Frequency2
=
table
[
f
"
T
ext
Area
{
length
-
1
}
"
].
item
()
# Define the Frequency
Guide2
=
table
[
f
"
T
ext
Area
{
length
}
"
].
item
()
# Define the Measurement guide
matrics
.
loc
[
1
]
=
erID2
,
BowTieID2
,
MetricID2
,
MetricName2
,
Value2
,
MeasureDate2
,
Frequency2
,
Guide2
...
...
@@ -52,15 +55,13 @@ def parseTable(df, metricsDict):
if
metric
==
None
:
handleMissingMetric
()
matricsIndex
=
2
# Parsing from the third row and onwards is standard format
for
i
in
range
(
25
,
len
(
table
.
columns
)
,
8
):
if
pd
.
isnull
(
table
[
"
Text Area
"
+
str
(
i
)].
item
())
==
True
or
pd
.
isnull
(
table
[
"
Text Area
"
+
str
(
i
+
1
)].
item
())
==
True
:
for
i
in
range
(
10
,
stopLength
,
8
):
if
i
>=
stopLength
:
break
erID
=
table
[
"
Text Area
"
+
str
(
i
)].
item
()
# Define the ER ID
BowTieID
=
table
[
"
Text Area
"
+
str
(
i
+
1
)].
item
()
# Define the Bowtie ID
MetricID
=
table
[
"
Text Area
"
+
str
(
i
+
2
)].
item
()
# Define the Metric ID
...
...
@@ -73,9 +74,11 @@ def parseTable(df, metricsDict):
series
=
pd
.
Series
([
erID
,
BowTieID
,
MetricID
,
MetricName
,
Value
,
MeasureDate
,
Frequency
,
Guide
])
matrics
.
loc
[
matricsIndex
]
=
erID
,
BowTieID
,
MetricID
,
MetricName
,
Value
,
MeasureDate
,
Frequency
,
Guide
matricsIndex
+=
1
matricsIndex
+=
1
print
(
matrics
)
return
matrics
return
matrics
,
metricsDict
def
handleMissingMetric
():
"""
Function will communicate to end user that a metric is in the matrics but is not used in the diagram
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment