Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable audit logging in Jenkins.
Jenkins
auditLogger = Jenkins.instance.getExtensionList('hudson.security.AuditLogger')[[1]]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 1 or 2 causes an error because those indexes don't exist.
✗ Incorrect
The audit logger is accessed by index 0 in the extension list.
2fill in blank
mediumComplete the code to enable audit logging for all authentication events.
Jenkins
auditLogger.setEnabled(true)
auditLogger.setLogAuthentication([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using false disables logging, so no audit logs are created.
✗ Incorrect
Setting logAuthentication to true enables logging of all authentication events.
3fill in blank
hardFix the error in the code to correctly log audit events to a file.
Jenkins
auditLogger.setLogFile(new File([1])) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes causes syntax errors.
Using single quotes is valid but here double quotes are preferred.
✗ Incorrect
The file path must be a string with quotes. Double quotes are correct here.
4fill in blank
hardFill both blanks to configure audit logging to include user and timestamp.
Jenkins
auditLogger.setFormat("User: [1], Time: [2]")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using %T or %U are incorrect format specifiers for user or time.
✗ Incorrect
%u inserts the username, and %t inserts the timestamp in the log format.
5fill in blank
hardFill all three blanks to create a filter that logs only failed login attempts.
Jenkins
auditLogger.setFilter({ event -> event.getType() == [1] && event.getResult() == [2] && event.getUser() != [3] }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using "SUCCESS" instead of "FAILURE" logs successful logins, not failures.
✗ Incorrect
This filter logs events where the type is AUTHENTICATION, the result is FAILURE, and the user is not anonymous.