Question
PLEASE DO NOT SPAM THE QUESTION I WILL AUTOMATICALLY DISLIKE IT (IF YOU SOLVE IT PLEASE POST A PICTURE OF IT WORKING ON YOUR END,
PLEASE DO NOT SPAM THE QUESTION I WILL AUTOMATICALLY DISLIKE IT (IF YOU SOLVE IT PLEASE POST A PICTURE OF IT WORKING ON YOUR END, 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:
import csv
def create_datastore() -> list:
csv_dicts = []
with open('RiskResults.csv', encoding='utf-8-sig') as csvfile:
dreader = csv.DictReader(csvfile)
for row in dreader:
csv_dicts.append(row)
return csv_dicts
data_store = create_datastore()
threat_dict = {
"Emergency": {"Frequent": 16, "Probable": 14, "Likely": 12, "Unlikely": 10, "Rare": 8},
"Major": {"Frequent": 14, "Probable": 12, "Likely": 10, "Unlikely": 8, "Rare": 6},
"Moderate": {"Frequent": 12, "Probable": 10, "Likely": 8, "Unlikely": 6, "Rare": 4},
"Minor": {"Frequent": 10, "Probable": 8, "Likely": 6, "Unlikely": 4, "Rare": 2},
"Negatable": {"Frequent": 8, "Probable": 6, "Likely": 4, "Unlikely": 2, "Rare": 0}
}
def get_recommendation(val):
if (val > 15):
print("Major bug or issue - sending email to sysadmin, infosec chief, and IT manager")
elif (val > 4):
print("Issue will require increase in security and access controls. Adding to Backlog for further planning.")
elif (val >= 0):
print(" Minor issue likely, increasing security is not recommended due to costs involved")
else:
print("Logging Error - check the data provided as this threat value is invalid.")
if __name__ == "__main__":
risk_id = int(input("Please enter risk ID: "))
print(data_store[risk_id - 1]["Description of the Risk"])
get_recommendation(threat_dict[data_store[risk_id - 1]['Severity']][data_store[risk_id - 1]['Probability Category']])
Error message:
print(data_store[risk_id - 1] ["Description of the Risk"]) KeyError: 'Description of the Risk
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started