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
dacb1925
Commit
dacb1925
authored
Sep 07, 2023
by
N.W. Harshani Jayawardhana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
68e8b58a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
Vulnerability_3.py
Vulnerability_3.py
+64
-0
No files found.
Vulnerability_3.py
0 → 100644
View file @
dacb1925
import
sqlite3
def
validate_test_cases
():
# Connect to the test_cases database
test_cases_db_name
=
'test_cases.db'
test_cases_conn
=
sqlite3
.
connect
(
test_cases_db_name
)
test_cases_cursor
=
test_cases_conn
.
cursor
()
# Check if the 'test_cases' table exists
test_cases_cursor
.
execute
(
"SELECT name FROM sqlite_master WHERE type='table' AND name='test_cases'"
)
table_exists
=
test_cases_cursor
.
fetchone
()
if
table_exists
:
# The 'test_cases' table exists, proceed with validation
# Connect to the captured_packets database
captured_packets_db_name
=
'captured_packets.db'
captured_packets_conn
=
sqlite3
.
connect
(
captured_packets_db_name
)
captured_packets_cursor
=
captured_packets_conn
.
cursor
()
# Create the output table in a new database or update an existing one
output_db_name
=
'validation_results.db'
output_conn
=
sqlite3
.
connect
(
output_db_name
)
output_cursor
=
output_conn
.
cursor
()
# Create the output table if it doesn't exist
output_cursor
.
execute
(
'''
CREATE TABLE IF NOT EXISTS validation_results (
id INTEGER PRIMARY KEY AUTOINCREMENT,
test_case_id INTEGER,
protocol TEXT,
severity TEXT,
vulnerabilities TEXT
)
'''
)
# Retrieve test cases from the test_cases database
test_cases_cursor
.
execute
(
"SELECT * FROM test_cases"
)
test_cases
=
test_cases_cursor
.
fetchall
()
for
test_case
in
test_cases
:
test_case_id
=
test_case
[
0
]
protocol
=
test_case
[
1
]
# Dummy validation logic (replace with your actual validation)
# Here, we assume all test cases are validated with no vulnerabilities
severity
=
'Validated'
vulnerabilities
=
'NO'
# Insert validation results into the output table
output_cursor
.
execute
(
'''
INSERT INTO validation_results (test_case_id, protocol, severity, vulnerabilities)
VALUES (?, ?, ?, ?)
'''
,
(
test_case_id
,
protocol
,
severity
,
vulnerabilities
))
output_conn
.
commit
()
# Disconnect from the databases
captured_packets_conn
.
close
()
output_conn
.
close
()
else
:
print
(
"No test cases found. Skipping validation."
)
if
__name__
==
"__main__"
:
validate_test_cases
()
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