Merge branch 'stable-2.15' into master
* stable-2.15: Document that NoteDb migration requires a large heap Move downloaded artifact cache from buck-cache to bazel-cache Move downloaded artifact cache from buck-cache to bazel-cache Revert "Hide sensitive data from audit and gerrit logs" dev-plugins: Improve formatting of reviewer suggestion documentation ReviewerSuggestion: Reword Javadoc ReviewerRecommender: Add debug log of plugin provided weight Handle deleted project in ReindexIfStaleTask Disallow tabbing on paper-button Handle the ReindexIfStale event when a change is deleted PolyGerrit: Fix gr-diff-view arrows to use html code Migrate metrics-core to 4.0.2 version CreateChange: Fix appending Signed-off-by line after Change-Id CreateChange: Only insert Change-Id if there isn't already one CreateChangeIT: Disable "Insert Signed-off-by" after test Fix gr-group-members to add and delete using group id rather than name Fix group member URL Change-Id: I5ccbc4265266236b55b3c864347e7016cc7a2bd0
This commit is contained in:
@@ -48,12 +48,9 @@ class SshLog implements LifecycleListener {
|
||||
private static final String P_STATUS = "status";
|
||||
private static final String P_AGENT = "agent";
|
||||
|
||||
private static final String MASK = "***";
|
||||
|
||||
private final Provider<SshSession> session;
|
||||
private final Provider<Context> context;
|
||||
private final AsyncAppender async;
|
||||
private final boolean auditMask;
|
||||
private final AuditService auditService;
|
||||
|
||||
@Inject
|
||||
@@ -67,7 +64,6 @@ class SshLog implements LifecycleListener {
|
||||
this.context = context;
|
||||
this.auditService = auditService;
|
||||
|
||||
auditMask = config.getBoolean("audit", "maskSensitiveData", false);
|
||||
if (!config.getBoolean("sshd", "requestLog", true)) {
|
||||
async = null;
|
||||
return;
|
||||
@@ -125,7 +121,8 @@ class SshLog implements LifecycleListener {
|
||||
final Context ctx = context.get();
|
||||
ctx.finished = TimeUtil.nowMs();
|
||||
|
||||
String cmd = extractWhat(dcmd, true);
|
||||
String cmd = extractWhat(dcmd);
|
||||
|
||||
final LoggingEvent event = log(cmd);
|
||||
event.setProperty(P_WAIT, (ctx.started - ctx.created) + "ms");
|
||||
event.setProperty(P_EXEC, (ctx.finished - ctx.started) + "ms");
|
||||
@@ -157,11 +154,7 @@ class SshLog implements LifecycleListener {
|
||||
if (async != null) {
|
||||
async.append(event);
|
||||
}
|
||||
|
||||
if (!auditMask) {
|
||||
cmd = extractWhat(dcmd, false);
|
||||
}
|
||||
audit(ctx, status, cmd, extractParameters(dcmd));
|
||||
audit(context.get(), status, dcmd);
|
||||
}
|
||||
|
||||
private ListMultimap<String, ?> extractParameters(DispatchCommand dcmd) {
|
||||
@@ -184,10 +177,7 @@ class SshLog implements LifecycleListener {
|
||||
// --param=value
|
||||
int eqPos = arg.indexOf('=');
|
||||
if (arg.startsWith("--") && eqPos > 0) {
|
||||
String param = arg.substring(0, eqPos);
|
||||
String value =
|
||||
auditMask && dcmd.isSensitiveParameter(param) ? MASK : arg.substring(eqPos + 1);
|
||||
parms.put(param, value);
|
||||
parms.put(arg.substring(0, eqPos), arg.substring(eqPos + 1));
|
||||
continue;
|
||||
}
|
||||
// -p value or --param value
|
||||
@@ -202,7 +192,7 @@ class SshLog implements LifecycleListener {
|
||||
if (paramName == null) {
|
||||
parms.put("$" + argPos++, arg);
|
||||
} else {
|
||||
parms.put(paramName, auditMask && dcmd.isSensitiveParameter(paramName) ? MASK : arg);
|
||||
parms.put(paramName, arg);
|
||||
paramName = null;
|
||||
}
|
||||
}
|
||||
@@ -266,6 +256,10 @@ class SshLog implements LifecycleListener {
|
||||
audit(ctx, result, cmd, null);
|
||||
}
|
||||
|
||||
void audit(Context ctx, Object result, DispatchCommand cmd) {
|
||||
audit(ctx, result, extractWhat(cmd), extractParameters(cmd));
|
||||
}
|
||||
|
||||
private void audit(Context ctx, Object result, String cmd, ListMultimap<String, ?> params) {
|
||||
String sessionId;
|
||||
CurrentUser currentUser;
|
||||
@@ -283,16 +277,11 @@ class SshLog implements LifecycleListener {
|
||||
auditService.dispatch(new SshAuditEvent(sessionId, currentUser, cmd, created, params, result));
|
||||
}
|
||||
|
||||
private String extractWhat(DispatchCommand dcmd, boolean hideSensitive) {
|
||||
private String extractWhat(DispatchCommand dcmd) {
|
||||
if (dcmd == null) {
|
||||
return "Command was already destroyed";
|
||||
}
|
||||
return hideSensitive ? dcmd.getFormattedMaskedArguments(".") : extractWhat(dcmd);
|
||||
}
|
||||
|
||||
private String extractWhat(DispatchCommand dcmd) {
|
||||
String name = dcmd.getCommandName();
|
||||
StringBuilder commandName = new StringBuilder(name == null ? "" : name);
|
||||
StringBuilder commandName = new StringBuilder(dcmd.getCommandName());
|
||||
String[] args = dcmd.getArguments();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
commandName.append(".").append(args[i]);
|
||||
|
Reference in New Issue
Block a user