Complete the code to enable audit logging in Jenkins.
auditLogger = Jenkins.instance.getExtensionList('hudson.security.AuditLogger')[[1]]
The audit logger is accessed by index 0 in the extension list.
Complete the code to enable audit logging for all authentication events.
auditLogger.setEnabled(true)
auditLogger.setLogAuthentication([1])Setting logAuthentication to true enables logging of all authentication events.
Fix the error in the code to correctly log audit events to a file.
auditLogger.setLogFile(new File([1]))The file path must be a string with quotes. Double quotes are correct here.
Fill both blanks to configure audit logging to include user and timestamp.
auditLogger.setFormat("User: [1], Time: [2]")
%u inserts the username, and %t inserts the timestamp in the log format.
Fill all three blanks to create a filter that logs only failed login attempts.
auditLogger.setFilter({ event -> event.getType() == [1] && event.getResult() == [2] && event.getUser() != [3] })This filter logs events where the type is AUTHENTICATION, the result is FAILURE, and the user is not anonymous.
