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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Iversen
DynamicRiskManagementforSSC
Commits
e3c89be1
Commit
e3c89be1
authored
1 year ago
by
martiivGylden
Browse files
Options
Downloads
Patches
Plain Diff
Parsing metrics for the dynamics component
parent
45564237
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
ERFormatConstants.py
+1
-1
1 addition, 1 deletion
ERFormatConstants.py
diagramParser.py
+34
-16
34 additions, 16 deletions
diagramParser.py
dynamics.py
+12
-5
12 additions, 5 deletions
dynamics.py
tempCodeRunnerFile.py
+1
-0
1 addition, 0 deletions
tempCodeRunnerFile.py
with
48 additions
and
22 deletions
ERFormatConstants.py
+
1
−
1
View file @
e3c89be1
#File contains constants from the CSV export format of the entity relationship tool
#File contains constants from the CSV export format of the entity relationship tool
#Generic fields for all rows in the CSV file
#Generic fields for all rows in the CSV file
componentID
=
"
Id
"
# LucidChart ID
Id
=
"
Id
"
# The id of the entity
Id
=
"
Id
"
# The id of the entity
textArea1
=
"
Text Area 1
"
textArea1
=
"
Text Area 1
"
...
@@ -76,3 +75,4 @@ ThreatDynamic = "Threat" # The threat dynamics
...
@@ -76,3 +75,4 @@ ThreatDynamic = "Threat" # The threat dynamics
ConsequenceDynamic
=
"
Consequence
"
# The consequence dynamics
ConsequenceDynamic
=
"
Consequence
"
# The consequence dynamics
AttackDynamic
=
"
Attack
"
# The attack dynamics
AttackDynamic
=
"
Attack
"
# The attack dynamics
ERDynamic
=
"
ER
"
# The ER dynamics
ERDynamic
=
"
ER
"
# The ER dynamics
BowtieDynamicType
=
textArea3
# The bowtie dynamics
This diff is collapsed.
Click to expand it.
diagramParser.py
+
34
−
16
View file @
e3c89be1
...
@@ -21,6 +21,7 @@ def parseDiagramFile(csvFile):
...
@@ -21,6 +21,7 @@ def parseDiagramFile(csvFile):
#List containing all attacks
#List containing all attacks
attacks
=
[]
attacks
=
[]
parseDynamic
(
df
)
parseDynamic
(
df
)
...
@@ -68,29 +69,46 @@ def parseAttacks(df, attackDict):
...
@@ -68,29 +69,46 @@ def parseAttacks(df, attackDict):
return
attackDict
return
attackDict
#Parses metrics components and adds it to list
#Parses metrics components and adds it to list
def
parseDynamic
(
df
):
def
parseDynamic
(
df
,
metricList
):
for
i
in
range
(
len
(
df
)):
# Iterates through the dataframe
for
i
in
range
(
len
(
df
)):
# Iterates through the dataframe
if
df
[
const
.
textArea1
][
i
]
==
const
.
Dynamics
:
# If the component is a dynamic component
if
df
[
const
.
textArea1
][
i
]
==
const
.
Dynamics
:
# If the component is a dynamic component
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
print
(
"
Found threat dynamic
"
)
threatDynamic
=
dynamic
.
BowtieDynamic
(
df
[
const
.
Id
][
i
],
# Component ID LucidChart
df
[
const
.
textArea3
][
i
]
)
extractMetrics
(
df
,
i
,
4
)
elif
df
[
const
.
textArea3
][
i
]
==
const
.
ConsequenceDynamic
:
elif
df
[
const
.
textArea3
][
i
]
==
const
.
ConsequenceDynamic
:
print
(
"
Found consequence dynamic
"
)
consequenceDynamic
=
dynamic
.
BowtieDynamic
()
extractMetrics
(
df
,
i
,
4
)
elif
df
[
const
.
textArea3
][
i
]
==
const
.
AttackDynamic
:
elif
df
[
const
.
textArea3
][
i
]
==
const
.
AttackDynamic
:
print
(
"
Found attack dynamic
"
)
attackDynamic
=
dynamic
.
BowtieDynamic
()
extractMetrics
(
df
,
i
,
4
)
elif
df
[
const
.
textArea3
][
i
]
==
const
.
ERDynamic
:
elif
df
[
const
.
textArea3
][
i
]
==
const
.
ERDynamic
:
print
(
"
Found ER dynamic
"
)
erDynamic
=
dynamic
.
ERDynamic
()
extractMetrics
(
df
,
i
,
8
)
for
j
in
range
(
8
,
len
(
df
.
columns
),
2
):
# Parse all text areas to find metrics
metric
=
"
Text Area
"
+
str
(
j
)
def
extractMetrics
(
df
,
index
,
startRange
,
metricList
):
metricDescription
=
"
Text Area
"
+
str
(
j
+
1
)
for
j
in
range
(
startRange
,
len
(
df
.
columns
),
2
):
# Parse all text areas to find metrics
if
pd
.
isnull
(
df
[
metric
][
i
])
==
False
:
# If the text area is not
metricID
=
"
Text Area
"
+
str
(
j
)
print
(
df
[
"
Id
"
][
i
])
metricName
=
"
Text Area
"
+
str
(
j
+
1
)
print
(
f
"
Found Metric with type:
{
df
[
metric
][
i
]
}
"
)
print
(
f
"
Metric description:
{
df
[
metricDescription
][
i
]
}
"
)
if
pd
.
isnull
(
df
[
metric
][
index
])
==
False
:
# If the text area is not empty
print
(
"
Metric: ID
"
,
df
[
metricID
][
index
],
"
Name:
"
,
df
[
metricName
][
index
])
metric
=
dynamic
.
Metric
(
df
[
metricID
][
index
],
df
[
metricName
][
index
])
metricList
.
append
(
metric
)
else
:
else
:
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
This diff is collapsed.
Click to expand it.
dynamics.py
+
12
−
5
View file @
e3c89be1
...
@@ -3,7 +3,7 @@ import logging as log
...
@@ -3,7 +3,7 @@ import logging as log
# Dynamics class parent class for both the bowtie dynamics and the architecture dynamics
# Dynamics class parent class for both the bowtie dynamics and the architecture dynamics
class
DynamicComponent
:
class
DynamicComponent
:
def
__init__
(
self
,
componentID
,
type
)
->
None
:
def
__init__
(
self
,
componentID
)
->
None
:
self
.
componentID
=
componentID
self
.
componentID
=
componentID
self
.
metrics
=
[
Metric
]
# List of metrics for the dynamic
self
.
metrics
=
[
Metric
]
# 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
...
@@ -39,18 +39,25 @@ class DynamicComponent:
...
@@ -39,18 +39,25 @@ class DynamicComponent:
#Metric class, will be used for all dynamics
#Metric class, will be used for all dynamics
class
Metric
:
class
Metric
:
def
__init__
(
self
,
name
,
type
,
description
)
->
None
:
def
__init__
(
self
,
ID
,
name
)
->
None
:
#Metrics found in the dynamics tables
self
.
ID
=
ID
# ID of the metric used to locate in dynamics matrics
self
.
name
=
name
# Name of the metric
self
.
name
=
name
# Name of the metric
self
.
description
=
description
# Description of the metric
self
.
type
=
type
# Four types of dynamic metrics: process, devteam, opensource and vendor
# Metrics found in the metric table
def
__str__
(
self
)
->
str
:
def
__str__
(
self
)
->
str
:
return
f
"
Metric:
{
self
.
name
}
,
{
self
.
description
}
"
return
f
"
Metric:
{
self
.
name
}
,
{
self
.
description
}
"
class
BowtieDynamic
(
DynamicComponent
):
class
BowtieDynamic
(
DynamicComponent
):
def
__init__
(
self
,
componentID
,
type
)
->
None
:
def
__init__
(
self
,
componentID
,
type
)
->
None
:
super
().
__init__
(
componentID
,
type
)
super
().
__init__
(
componentID
)
self
.
type
=
type
# Type of dynamicM
self
.
associatedThreat
=
None
# List of threats associated with the dynamic
self
.
associatedThreat
=
None
# List of threats associated with the dynamic
self
.
associatedAttack
=
None
# List of attacks associated with the dynamic
self
.
associatedAttack
=
None
# List of attacks associated with the dynamic
...
...
This diff is collapsed.
Click to expand it.
tempCodeRunnerFile.py
0 → 100644
+
1
−
0
View file @
e3c89be1
i
\ No newline at end of file
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