Answered step by step
Verified Expert Solution
Link Copied!

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.1-2) 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 firewall_logs_2022.csv
o Your program should work precisely as it did before (and output only 5 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:
1.--filename (or -f)
2.--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 5 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 firewall_logs_2022.csv --action head
Refactoring Suggestion!
Create a new method named print_head() and move your code that writes the first 5 objects to the screen into this new method. Call print_head() if the value of the --action argument is head.
Commit and Branch!
Once your program behaves as described, do the following:
1. Add and commit your files using Git 2. Remember to add the standard Python .gitignore file to your directory if you have not already!
3. Create a new branch (named v3) that preserves your work at this point in the program
4. Switch back to the main branch
5.(Optional) Push all your branches to GitHub.com with the command git push origin all
Complete instructions can be found in the CIT 30900 workbook.
Additional Action: Deny
New Method
Create a method called deny_count().
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 deny_count() method.
View the Result
The command
python index.py --filename firewall_logs_2022.csv --action deny
Should result in a print() statement that says the following (the number will be different based on the data):
12,345 log entries were denied.
Additional Action: Count of Country
New Method
Create a method called country_count(). It must accept an argument that contains a 2-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 NON-REQUIRED 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 country_count() method and pass the value of the --country argument.
View the Result
The command
python index.py --filename firewall_logs_2022.csv --action source --country US
Should result in a print() statement that says the following (the number will be different based on the data):
12,345 log entries from the US were recorded.

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

Logidata+ Deductive Databases With Complex Objects Lncs 701

Authors: Paolo Atzeni

1st Edition

354056974X, 978-3540569749

More Books

Students also viewed these Databases questions

Question

=+2. What level of impact will this tactic make on the key public?

Answered: 1 week ago

Question

library erd

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago