-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime-v2: mask workDir value in logs by default
Add workDirMasking option to concord-agent.conf to enable masking of workDir values in logs. The actual path is replaced with a `$WORK_DIR` literal.
- Loading branch information
Showing
11 changed files
with
91 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/logging/CustomLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.walmartlabs.concord.runtime.v2.runner.logging; | ||
|
||
/*- | ||
* ***** | ||
* Concord | ||
* ----- | ||
* Copyright (C) 2017 - 2023 Walmart Inc. | ||
* ----- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ===== | ||
*/ | ||
|
||
import ch.qos.logback.classic.PatternLayout; | ||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import com.walmartlabs.concord.runtime.v2.runner.SensitiveDataHolder; | ||
import com.walmartlabs.concord.runtime.v2.sdk.WorkingDirectory; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class CustomLayout extends PatternLayout { | ||
|
||
private static volatile String workDirToReplace; | ||
|
||
/** | ||
* Enables masking of ${workDir} values in logs. Such values often add noise to logs. | ||
*/ | ||
public static void enableWorkingDirectoryMasking(WorkingDirectory workDir) { | ||
requireNonNull(workDir); | ||
|
||
var workDirToReplace = workDir.getValue().toString(); | ||
if (CustomLayout.workDirToReplace != null && !CustomLayout.workDirToReplace.equals(workDirToReplace)) { | ||
System.err.printf("CustomLayout: an attempt to override existing workDir value by thread %s%n", Thread.currentThread()); | ||
return; | ||
} | ||
|
||
CustomLayout.workDirToReplace = workDirToReplace; | ||
} | ||
|
||
@Override | ||
public String doLayout(ILoggingEvent event) { | ||
var sensitiveData = SensitiveDataHolder.getInstance().get(); | ||
var msg = super.doLayout(event); | ||
for (var sensitiveString : sensitiveData) { | ||
msg = msg.replace(sensitiveString, "******"); | ||
} | ||
if (CustomLayout.workDirToReplace != null) { | ||
msg = msg.replace(workDirToReplace, "$WORK_DIR"); | ||
} | ||
return msg; | ||
} | ||
} |
40 changes: 0 additions & 40 deletions
40
...in/java/com/walmartlabs/concord/runtime/v2/runner/logging/MaskingSensitiveDataLayout.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters