Skip to content

Commit

Permalink
Configure output dir config for language server
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 600931739
Change-Id: I37884eca12d6f375aa25beddd3f0b38d06f1c77c
  • Loading branch information
nttran8 authored and copybara-github committed Jan 23, 2024
1 parent 4d6e983 commit 4324996
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static LanguageServerCommand create(
String serverCommand,
String port,
String logId,
String outputDir,
boolean trustAllSsl,
Duration timeoutSeconds,
String callbackAddress,
Expand All @@ -34,6 +35,7 @@ public static LanguageServerCommand create(
serverCommand,
port,
logId,
outputDir,
trustAllSsl,
timeoutSeconds,
callbackAddress,
Expand All @@ -47,6 +49,8 @@ public static LanguageServerCommand create(

public abstract String logId();

public abstract String outputDir();

public abstract boolean trustAllSslCert();

public abstract Duration timeoutSeconds();
Expand Down
13 changes: 13 additions & 0 deletions main/src/main/java/com/google/tsunami/main/cli/TsunamiCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;
import java.io.IOException;
import java.nio.file.Path;
import java.security.SecureRandom;
import java.time.Duration;
import java.util.List;
Expand Down Expand Up @@ -198,6 +199,7 @@ private ImmutableList<LanguageServerCommand> extractPluginServerArgs(
LanguageServerCommand.create(
paths.get(i),
ports.get(i),
extractOutputDir(args),
logId,
trustAllSslCertCli != null && trustAllSslCertCli.booleanValue(),
Duration.ZERO,
Expand All @@ -219,6 +221,7 @@ private ImmutableList<LanguageServerCommand> extractPluginServerArgs(
paths.get(i),
ports.get(i),
logId,
extractOutputDir(args),
trustAllSslCertCli == null
? trustAllSslCertConfig
: trustAllSslCertCli.booleanValue(),
Expand All @@ -245,6 +248,16 @@ private Boolean extractCliTrustAllSslCert(String[] args) {
return null;
}

private String extractOutputDir(String[] args) {
for (int i = 0; i < args.length; ++i) {
if (args[i].startsWith("--scan-results-local-output-filename=")) {
String filename = Iterables.get(Splitter.on('=').split(args[i]), 1) + ": ";
return Path.of(filename).getParent().toString();
}
}
return "";
}

private ImmutableList<String> extractCliPluginServerArgs(String[] args, String flag) {
for (int i = 0; i < args.length; ++i) {
if (args[i].startsWith(flag)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void runServerProcess_whenPathExistsAndNormalPort_returnsValidProcessList
"/bin/sh",
"34567",
"34",
"/output-here",
false,
Duration.ofSeconds(10),
"157.34.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void configure_always_loadsAllRemotePlugins() {
generateServerName(),
"34567",
"193",
"/output/here",
false,
Duration.ofSeconds(10),
"157.34.0.2",
Expand All @@ -67,6 +68,7 @@ public void configure_always_loadsAllRemotePlugins() {
generateServerName(),
"34566",
"193",
"/output/now",
false,
Duration.ofSeconds(10),
"157.34.0.2",
Expand Down

0 comments on commit 4324996

Please sign in to comment.