fix roll view log null exception (#8914)

slim
Kerwin 2022-03-16 10:09:29 +08:00 committed by GitHub
parent e53ac4e304
commit 5ad73f8352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -32,6 +32,8 @@ import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseCommand;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.Constants; import org.apache.dolphinscheduler.remote.utils.Constants;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -146,6 +148,9 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
*/ */
private boolean checkPathSecurity(String path) { private boolean checkPathSecurity(String path) {
String dsHome = System.getProperty("DOLPHINSCHEDULER_WORKER_HOME"); String dsHome = System.getProperty("DOLPHINSCHEDULER_WORKER_HOME");
if (StringUtils.isBlank(dsHome)) {
dsHome = System.getProperty("user.dir");
}
if (path.startsWith(dsHome) && !path.contains("../") && path.endsWith(".log")) { if (path.startsWith(dsHome) && !path.contains("../") && path.endsWith(".log")) {
return true; return true;
} }