Complete the code to write a log entry using Python's logging module.
import logging logging.basicConfig(filename='app.log', level=logging.[1]) logging.info('User logged in')
The level parameter sets the minimum severity of messages to log. INFO logs informational messages like user actions.
Complete the command to view the last 50 lines of the audit log file.
tail -n [1] /var/log/audit/audit.logThe -n 50 option tells tail to show the last 50 lines of the file.
Fix the error in the audit rule to log all executions of the 'passwd' command.
-w /usr/bin/passwd -p [1] -k passwd_changesr or w which monitor reads or writes, not executions.The -p x flag tells auditd to watch for executions (x) of the file.
Fill both blanks to create a dictionary comprehension that filters audit events with severity higher than 4.
filtered_events = {event['id']: event for event in events if event['severity'] [1] [2]The condition event['severity'] > 4 filters events with severity greater than 4.
Fill all three blanks to create a filtered audit log dictionary with uppercase event IDs and severity above 3.
filtered_logs = [1]: [2] for [3], v in audit_logs.items() if v['severity'] > 3
This comprehension uses k.upper() as keys, v as values, and iterates over k, v pairs.