Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE DO NOT SPAM THE QUESTION I WILL AUTOMATICALLY DISLIKE IT (THANKS) The following Python script needs to be FIXED. It Reads a CSV file(down

PLEASE DO NOT SPAM THE QUESTION I WILL AUTOMATICALLY DISLIKE IT (THANKS)

The following Python script needs to be FIXED. It Reads a CSV file(down below) into a list of dictionaries to map the severity and probability to the threat value, and stores the threat value, threat description, severity, and probability in a dictionary. It calculates a threat value based on the severity and probability of each threat, stores the threat information in a dictionary, and outputs a recommendation for each threat based on its threat value. The recommended actions range from minor security increases to emailing the sysadmin, infosec chief, and IT manager.

code:

threat_map = {

"Emergency": {"Frequent": 16, "Probable": 14, "Unlikely": 11, "Rare": 8},

"Major": {"Frequent": 14, "Probable": 11, "Unlikely": 8, "Rare": 5},

"Moderate": {"Frequent": 11, "Probable": 8, "Unlikely": 5, "Rare": 2},

"Minor": {"Frequent": 5, "Probable": 2, "Unlikely": 1, "Rare": 0}

}

threats = []

with open("RiskResults.cvs") as file:

for line in file:

parts = line.strip().split(",")

ID, start_time, end_time, description, severity = parts

prob = "Frequent"

threat_value = threat_map[severity][prob]

threat = {

"ID": ID,

"start_time": start_time,

"end_time": end_time,

"description": description,

"severity": severity,

"probability": prob,

"threat_value": threat_value

}

threats.append(threat)

for threat in threats:

threat_value = threat["threat_value"]

if threat_value

print("Logging Error - check the data provided as this threat value is invalid.")

elif threat_value

print("Minor issue likely, increasing security is not recommended due to costs involved")

elif threat_value

print("Issue will require increase in security and access controls. Adding to Backlog for further planning.")

else:

print("Major bug or issue - sending email to sysadmin, infosec chief, and IT manager.")

RiskResults.cvs:

ID Start time Completion time Provide a "Description of the Risk" Select its severity Select its Probability Category

1 1/7/2023 12:03 1/7/2023 12:11 Internal employee sabotaging or leaking confidential data Major Unlikely People

2 1/12/2023 9:51 1/12/2023 9:54 Sensitive data over home network (potentially unsecured) Major Frequent Network

3 1/12/2023 10:16 1/12/2023 10:16 There is no security system protecting the house. Moderate Unlikely Physical

4 1/12/2023 10:13 1/12/2023 10:16 Natural disaster in florida Emergency Frequent Disaster

5 1/12/2023 10:16 1/12/2023 10:16 Hurricane Emergency Likely Disaster

6 1/12/2023 10:16 1/12/2023 10:16 Natural disaster Moderate Unlikely Disaster

7 1/12/2023 10:16 1/12/2023 10:16 Hurricane Emergency Unlikely Disaster

8 1/12/2023 10:16 1/12/2023 10:16 Baseball smashing through a window Minor Unlikely Physical

9 1/12/2023 9:51 1/12/2023 10:17 The homeowners face a risk of flood or hurricane damage Emergency Frequent Disaster

10 1/12/2023 10:16 1/12/2023 10:26 Building Maintenance Major Unlikely Maintenance

Error message:

image text in transcribed

ID, start_time, end_time, description, severity = parts ValueError: not enough values to unpack (expected 5, got 1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions