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
784f6409
Commit
784f6409
authored
1 year ago
by
martiivGylden
Browse files
Options
Downloads
Patches
Plain Diff
Finished parsing attacks, consequences and threats.
parent
9de8fa43
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ERFormatConstants.py
+17
-4
17 additions, 4 deletions
ERFormatConstants.py
diagramParser.py
+52
-25
52 additions, 25 deletions
diagramParser.py
with
69 additions
and
29 deletions
ERFormatConstants.py
+
17
−
4
View file @
784f6409
...
...
@@ -21,14 +21,16 @@ textArea14 = "Text Area 14"
textArea15
=
"
Text Area 15
"
textArea16
=
"
Text Area 16
"
#Mapped fields for Threat component
Threat
=
textArea1
# The threat
Threat
=
"
Threat
"
# The threat
ThreatValue
=
textArea1
# The threat
ThreatID
=
textArea2
# The id of the threat
ThreatIDValue
=
textArea3
# Value
ThreatSource
=
textArea4
# The threat source
ThreatSource
=
textArea5
# Value
ThreatSource
Value
=
textArea5
# Value
Likelihood
=
textArea6
# The likelihood of the threat
LikelihoodValue
=
textArea7
# Value
...
...
@@ -40,7 +42,8 @@ Vulnerability = textArea10 # The vulnerability
VulnerabilityValue
=
textArea11
# Value
#Consequence
Consequence
=
textArea1
# The consequence score of the area -> Text area 6
Consequence
=
"
Consequence
"
# The consequence score of the area -> Text area 6
ConsequenceValue
=
textArea1
# The consequence
ConsequenceID
=
textArea2
# The id of the consequence
ConsequenceIDValue
=
textArea3
# Value
...
...
@@ -55,7 +58,8 @@ AffectedComponent = textArea8 # The affected component
AffectedComponentValue
=
textArea9
# Value
#Attack
Attack
=
textArea1
# The attack
Attack
=
"
Attack
"
# The attack
AttackValue
=
textArea1
# The attack
AttackType
=
textArea2
# The type of attack
AttackTypeValue
=
textArea3
# Value
...
...
@@ -66,4 +70,13 @@ AttackedComponentValue = textArea5 # Value
AttackDescription
=
textArea6
# The description of the attack
AttackDescriptionValue
=
textArea7
# Value
#Dynamics
ThreatDynamic
=
"
Threat Dynamics
"
# The dynamics
ConsequenceDynamic
=
"
Consequence Dynamics
"
# The dynamics
AttackDynamic
=
"
Attack Dynamics
"
# The dynamics
Dynamics
=
"
Dynamics
"
# The dynamics
This diff is collapsed.
Click to expand it.
diagramParser.py
+
52
−
25
View file @
784f6409
...
...
@@ -7,42 +7,69 @@ import dynamics as dynamic
def
parseDiagramFile
(
csvFile
):
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
threats
=
[]
threats
=
{}
threats
=
parseThreats
(
df
,
threats
)
print
(
threats
)
print
(
len
(
threats
))
#List containing all consequences
consequences
=
[]
consequences
=
{}
consequences
=
parseConsequences
(
df
,
consequences
)
print
(
consequences
)
#List containing all metrics
metrics
=
[]
#List containing all attacks
attacks
=
[]
def
parseThreats
(
df
):
def
parseThreats
(
df
,
threatDict
):
for
i
in
range
(
len
(
df
)):
if
df
[
const
.
textArea1
][
i
]
==
const
.
Threat
:
threat
=
component
.
Threat
(
df
[
const
.
Id
][
i
],
# The id of the entity
df
[
const
.
componentID
][
i
],
# The component ID field provided by LucidChart
df
[
const
.
textArea4
][
i
],
df
[
const
.
Description
][
i
],
df
[
const
.
textArea6
][
i
],
df
[
const
.
textArea7
][
i
])
if
df
[
const
.
ThreatValue
][
i
]
==
const
.
Threat
:
#Creates threat object
threat
=
component
.
Threat
(
df
[
const
.
ThreatIDValue
][
i
],
# ID from ER
df
[
const
.
Id
][
i
],
# LucidChart ID
df
[
const
.
ThreatSourceValue
][
i
],
df
[
const
.
ThreatDescriptionValue
][
i
],
df
[
const
.
LikelihoodValue
][
i
],
df
[
const
.
VulnerabilityValue
][
i
]
)
threatDict
[
df
.
Id
[
i
]]
=
threat
return
threatDict
#Parses consequences and adds it to dictionary
def
parseConsequences
(
df
,
consequenceDict
):
for
i
in
range
(
len
(
df
)):
if
df
[
const
.
ConsequenceValue
][
i
]
==
const
.
Consequence
:
consequence
=
component
.
Consequence
(
df
[
const
.
ConsequenceIDValue
][
i
],
df
[
const
.
Id
][
i
],
df
[
const
.
ConsequenceDescriptionValue
][
i
],
df
[
const
.
ConsequenceScoreValue
][
i
],
df
[
const
.
AffectedComponentValue
][
i
]
)
consequenceDict
[
df
.
Id
[
i
]]
=
consequence
return
consequenceDict
def
parse
Consequences
(
df
):
def
parse
Attacks
(
df
,
attackDict
):
for
i
in
range
(
len
(
df
)):
if
df
[
"
Shape Type
"
][
i
]
==
"
Consequence
"
:
consequences
.
append
(
df
[
"
Name
"
][
i
])
print
(
consequences
)
if
df
[
const
.
AttackValue
][
i
]
==
const
.
Attack
:
attack
=
component
.
Attack
(
df
[
const
.
Id
][
i
],
df
[
const
.
AttackedComponentValue
][
i
],
df
[
const
.
AttackDescriptionValue
][
i
],
)
attackDict
[
df
.
Id
[
i
]]
=
attack
def
parseMetrics
(
df
):
return
attackDict
#Parses metrics components and adds it to list
def
parseDynamic
(
df
,
dynamicsDict
):
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
pass
\ 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