Skip to content

Commit d198bed

Browse files
authored
Add support to mitigate log4j vulnerabilities from user imported log4… (#626)
* Add support to mitigate log4j vulnerabilities from user imported log4j libraries Signed-off-by: Frank Gu <[email protected]> * update test case Signed-off-by: Frank Gu <[email protected]> * update java agent syntax Signed-off-by: Frank Gu <[email protected]> * Release TonY v0.4.12 Signed-off-by: Frank Gu <[email protected]>
1 parent 05bc8c9 commit d198bed

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ext.deps = [
9292

9393
allprojects {
9494
group = "com.linkedin.tony"
95-
project.version = "0.4.11"
95+
project.version = "0.4.12"
9696
}
9797

9898
task sourcesJar(type: Jar) {

tony-core/src/main/java/com/linkedin/tony/TonyConfigurationKeys.java

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ private TonyConfigurationKeys() {
155155
public static final String TASK_EXECUTOR_JVM_OPTS = TONY_TASK_PREFIX + "executor.jvm.opts";
156156
public static final String DEFAULT_TASK_EXECUTOR_JVM_OPTS = "-Xmx1536m";
157157

158+
public static final String TASK_EXECUTOR_JAVA_AGENT = TONY_TASK_PREFIX + "executor.java.agent";
159+
158160
public static final String TASK_HEARTBEAT_INTERVAL_MS = TONY_TASK_PREFIX + "heartbeat-interval-ms";
159161
public static final int DEFAULT_TASK_HEARTBEAT_INTERVAL_MS = 1000;
160162

tony-core/src/main/java/com/linkedin/tony/TonySession.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,24 @@ public TonySession build() {
429429
}
430430

431431
public Builder setTaskExecutorJVMArgs(String jvmArgs) {
432-
this.jvmArgs = jvmArgs;
432+
this.jvmArgs = appendDefaultJVMArgs(jvmArgs);
433433
return this;
434434
}
435435

436436
public Builder setTonyConf(Configuration tonyConf) {
437437
this.tonyConf = tonyConf;
438438
return this;
439439
}
440+
441+
// Appends default jvm arguments to task executor job
442+
private String appendDefaultJVMArgs(String jvmArgs) {
443+
jvmArgs += " -Dlog4j2.formatMsgNoLookups=true";
444+
String tonyTaskExecutorJavaAgent = tonyConf.get(TonyConfigurationKeys.TASK_EXECUTOR_JAVA_AGENT, "");
445+
if (!tonyTaskExecutorJavaAgent.isEmpty()) {
446+
jvmArgs += " -javaagent:" + tonyTaskExecutorJavaAgent;
447+
}
448+
return jvmArgs;
449+
}
440450
}
441451

442452
@VisibleForTesting

tony-core/src/test/java/com/linkedin/tony/TestTonyConfigurationFields.java

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void initializeMemberVariables() {
4949
configurationPropsToSkipCompare.add(TonyConfigurationKeys.APPLICATION_TRAINING_STAGE);
5050
configurationPropsToSkipCompare.add(TonyConfigurationKeys.APPLICATION_HADOOP_LOCATION);
5151
configurationPropsToSkipCompare.add(TonyConfigurationKeys.APPLICATION_HADOOP_CLASSPATH);
52+
configurationPropsToSkipCompare.add(TonyConfigurationKeys.TASK_EXECUTOR_JAVA_AGENT);
5253
configurationPropsToSkipCompare.add(TonyConfigurationKeys.TENSORBOARD_LOG_DIR);
5354
configurationPropsToSkipCompare.add(TonyConfigurationKeys.PYTHON_EXEC_PATH);
5455
configurationPropsToSkipCompare.add(TonyConfigurationKeys.TB_VCORE);

0 commit comments

Comments
 (0)