Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What s the Big Idea? Build on your previous Analyzing Firewall Logs project ( v . 1 - 2 ) to add additional functionality. New
Whats the Big Idea?
Build on your previous Analyzing Firewall Logs project v to add additional functionality.
New Data File
You have been provided with a new CSV that contains a full year of log entry data
BEFORE you continue with this project, download the new CSV into the root directory for your project and execute your Python command.
o Use the following command to execute your program:
python index.py filename firewalllogscsv
o Your program should work precisely as it did before and output only rows of data
Review the New CSV Data
The CSV file provided to you includes simulated data from a firewall program.
Review the structure of the data and familiarize yourself with the fields that are included. You may want to install the Rainbow CSV extension to VS Code to make the CSV easier to read.
Alternatively, you may make a copy of the CSV somewhere NOT in your local root folder and open it with Excel for review. Dont try to save the file from Excel it can corrupt the CSV and make it unreadable by Python.
Refactor Your Existing Program
You will update your program to take TWO required command line arguments:
filename or f
action or a
In your main method, check the value of the action argument. If the value is head run your previous code that writes the first objects from the CSV file to the screen. Your program should run exactly as it did before.
The new command to run your program is:
python index.py filename firewalllogscsv action head
Refactoring Suggestion!
Create a new method named printhead and move your code that writes the first objects to the screen into this new method. Call printhead if the value of the action argument is head
Commit and Branch!
Once your program behaves as described, do the following:
Add and commit your files using Git Remember to add the standard Python gitignore file to your directory if you have not already!
Create a new branch named v that preserves your work at this point in the program
Switch back to the main branch
Optional Push all your branches to GitHub.com with the command git push origin all
Complete instructions can be found in the CIT workbook.
Additional Action: Deny
New Method
Create a method called denycount
In this method, use a list comprehension to filter ONLY the log entries whose action is Deny into a new list.
Print the number of log entries that were denied to the screen.
Implement the New Method
Update your program to allow the user to provide the value deny to the action argument.
If the user chooses this action, call the denycount method.
View the Result
The command
python index.py filename firewalllogscsv action deny
Should result in a print statement that says the following the number will be different based on the data:
log entries were denied.
Additional Action: Count of Country
New Method
Create a method called countrycount It must accept an argument that contains a letter country code.
In this method, use a list comprehension to filter ONLY the log entries whose country matches the country code value of the argument.
Print the number of log entries that match this country code to the screen.
New Argument
To implement this action, you will need to accept a new NONREQUIRED command line argument country, or c
Implement the New Method
Update your program to allow the user to provide the value source to the action argument.
If the user chooses this action, call the countrycount method and pass the value of the country argument.
View the Result
The command
python index.py filename firewalllogscsv action source country US
Should result in a print statement that says the following the number will be different based on the data:
log entries from the US were recorded.
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