Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-261
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gamage G.G.I.V.M
2023-261
Commits
c6f5d30c
Commit
c6f5d30c
authored
Nov 02, 2023
by
Gamage G.G.I.V.M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
cb19c7e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
IT20036102/Severity.py
IT20036102/Severity.py
+62
-0
No files found.
IT20036102/Severity.py
0 → 100644
View file @
c6f5d30c
import
sqlite3
# Function to create the 'validation_severity' database
def
create_validation_severity_database
():
connection
=
sqlite3
.
connect
(
'validation_severity.db'
)
cursor
=
connection
.
cursor
()
# Create the 'validation_severity' table with columns for details and the 'severity' column
cursor
.
execute
(
'''
CREATE TABLE IF NOT EXISTS validation_severity (
id INTEGER PRIMARY KEY AUTOINCREMENT,
protocol TEXT,
source TEXT,
destination TEXT,
length INTEGER,
vulnerability_info TEXT,
severity TEXT
)
'''
)
connection
.
commit
()
connection
.
close
()
# Function to calculate and set severity in 'validation_severity' based on 'length'
def
calculate_and_set_severity
():
# Connect to the 'vulnerabilities' database
connection
=
sqlite3
.
connect
(
'vulnerabilities.db'
)
cursor
=
connection
.
cursor
()
# Connect to the 'validation_severity' database
severity_connection
=
sqlite3
.
connect
(
'validation_severity.db'
)
severity_cursor
=
severity_connection
.
cursor
()
# Query to retrieve vulnerabilities from 'vulnerabilities' database
cursor
.
execute
(
"SELECT protocol, source, destination, length, vulnerability_info FROM vulnerabilities"
)
vulnerabilities
=
cursor
.
fetchall
()
for
vulnerability
in
vulnerabilities
:
protocol
,
source
,
destination
,
length
,
vulnerability_info
=
vulnerability
# Calculate severity based on 'length'
if
length
<
500
:
severity
=
'Informational'
elif
500
<=
length
<
1000
:
severity
=
'Low'
elif
1000
<=
length
<
2000
:
severity
=
'Medium'
elif
2000
<=
length
<
3000
:
severity
=
'High'
else
:
severity
=
'Critical'
# Insert data into 'validation_severity' database with the calculated severity
severity_cursor
.
execute
(
"INSERT INTO validation_severity (protocol, source, destination, length, vulnerability_info, severity) VALUES (?, ?, ?, ?, ?, ?)"
,
(
protocol
,
source
,
destination
,
length
,
vulnerability_info
,
severity
))
severity_connection
.
commit
()
connection
.
close
()
severity_connection
.
close
()
# Create the 'validation_severity' database and calculate severity
create_validation_severity_database
()
calculate_and_set_severity
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment