Skip to content

Commit 04a773e

Browse files
committed
(code review) Improve audit logged messages
Log the value obtained from the property, rather than whatever was provided by the end-user. In 99% of the times, this should be equal, but the property itself should always be right.
1 parent 01a4e5a commit 04a773e

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

xmppserver/src/main/webapp/system-admin-console-access.jsp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
final Set<String> blocklist = new HashSet<>(AuthCheckFilter.IP_ACCESS_BLOCKLIST.getValue());
7272
if (blocklist.remove(deleteBlockedIP) ) {
7373
AuthCheckFilter.IP_ACCESS_BLOCKLIST.setValue(blocklist);
74-
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Removed from Blocklist: '" + deleteBlockedIP + "', Blocklist now is {" + String.join(", ", blocklist) + "}");
74+
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Removed from Blocklist: '" + deleteBlockedIP + "', Blocklist now is {" + String.join(", ", AuthCheckFilter.IP_ACCESS_BLOCKLIST.getValue()) + "}");
7575
}
7676
}
7777
if (blockValue != null && errors.isEmpty()) {
@@ -82,7 +82,7 @@
8282
final Set<String> blocklist = new HashSet<>(AuthCheckFilter.IP_ACCESS_BLOCKLIST.getValue());
8383
if (blocklist.add(blockValue)) {
8484
AuthCheckFilter.IP_ACCESS_BLOCKLIST.setValue(blocklist);
85-
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Added to Blocklist: '" + blockValue + "', Blocklist now is {" + String.join(", ", blocklist) + "}");
85+
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Added to Blocklist: '" + blockValue + "', Blocklist now is {" + String.join(", ", AuthCheckFilter.IP_ACCESS_BLOCKLIST.getValue()) + "}");
8686
blockValue = null;
8787
}
8888
}
@@ -92,7 +92,7 @@
9292
final Set<String> allowlist = new HashSet<>(AuthCheckFilter.IP_ACCESS_ALLOWLIST.getValue());
9393
if (allowlist.remove(deleteAllowedIP) ) {
9494
AuthCheckFilter.IP_ACCESS_ALLOWLIST.setValue(allowlist);
95-
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Removed from Allowlist: '" + deleteAllowedIP + "', Allowlist now is {" + String.join(", ", allowlist) + "}");
95+
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Removed from Allowlist: '" + deleteAllowedIP + "', Allowlist now is {" + String.join(", ", AuthCheckFilter.IP_ACCESS_ALLOWLIST.getValue()) + "}");
9696
}
9797
}
9898
if (allowValue != null && errors.isEmpty()) {
@@ -103,7 +103,7 @@
103103
final Set<String> allowlist = new HashSet<>(AuthCheckFilter.IP_ACCESS_ALLOWLIST.getValue());
104104
if (allowlist.add(allowValue)) {
105105
AuthCheckFilter.IP_ACCESS_ALLOWLIST.setValue(allowlist);
106-
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Added from Allowlist: '" + allowValue + "', Allowlist now is {" + String.join(", ", allowlist) + "}");
106+
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Added to Allowlist: '" + allowValue + "', Allowlist now is {" + String.join(", ", AuthCheckFilter.IP_ACCESS_ALLOWLIST.getValue()) + "}");
107107
allowValue = null;
108108
}
109109
}
@@ -116,7 +116,7 @@
116116
AuthCheckFilter.IP_ACCESS_IGNORE_EXCLUDES.setValue(ignoreExcludes);
117117
118118
// Log the event
119-
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Ignore excludes = " + ignoreExcludes);
119+
webManager.logEvent("Updated Admin Console access configuration (Access Lists).", "Ignore excludes = " + AuthCheckFilter.IP_ACCESS_IGNORE_EXCLUDES.getValue());
120120
response.sendRedirect("system-admin-console-access.jsp?success=true");
121121
return;
122122
}
@@ -182,7 +182,16 @@
182182
AdminConsolePlugin.ADMIN_CONSOLE_FORWARDED_TRUSTED_PROXIES.setValue(newTrustedProxies);
183183
184184
// Log the event
185-
webManager.logEvent("Updated Admin Console access configuration (Forwarded).", "X-Forwarded-For enabled: " + isXFFEnabled + "\nRFC-Header: " + fHeader + "\nLegacy Header: " + xffHeader + "\nServer Header: " + xffServerHeader + "\nHost Name: " + name + "\nTrusted proxies: " + (newTrustedProxies == null || newTrustedProxies.isEmpty() ? "(none)" : String.join(", ", newTrustedProxies)));
185+
webManager.logEvent(
186+
"Updated Admin Console access configuration (Forwarded).",
187+
"Forwarded enabled: " + isXFFEnabled
188+
+ "\nRFC Header: " + AdminConsolePlugin.ADMIN_CONSOLE_FORWARDED_HEADER.getValue()
189+
+ "\nLegacy Header: " + AdminConsolePlugin.ADMIN_CONSOLE_FORWARDED_FOR.getValue()
190+
+ "\nServer Header: " + AdminConsolePlugin.ADMIN_CONSOLE_FORWARDED_SERVER.getValue()
191+
+ "\nHost Header: " + AdminConsolePlugin.ADMIN_CONSOLE_FORWARDED_HOST.getValue()
192+
+ "\nHost Name: " + AdminConsolePlugin.ADMIN_CONSOLE_FORWARDED_HOST_NAME.getValue()
193+
+ "\nTrusted proxies: " + (newTrustedProxies == null || newTrustedProxies.isEmpty() ? "(none)" : String.join(", ", newTrustedProxies))
194+
);
186195
response.sendRedirect("system-admin-console-access.jsp?success=true");
187196
return;
188197
}
@@ -200,7 +209,7 @@
200209
}
201210
202211
// Log the event
203-
webManager.logEvent("Updated Admin Console access configuration (Content-Security-Policy).", "Content-Security-Policy enabled: " + isCSPEnabled + "\nHeader Value: " + cspValue);
212+
webManager.logEvent("Updated Admin Console access configuration (Content-Security-Policy).", "Content-Security-Policy enabled: " + isCSPEnabled + "\nHeader Value: " + AdminConsolePlugin.ADMIN_CONSOLE_CONTENT_SECURITY_POLICY_RESPONSEVALUE.getValue());
204213
response.sendRedirect("system-admin-console-access.jsp?success=true");
205214
return;
206215
}

0 commit comments

Comments
 (0)