Skip to content

Commit

Permalink
Resolve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
johanah29 committed Oct 11, 2024
1 parent 9780cfd commit 86f3414
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.openbas.config.OpenBASConfig;
import io.openbas.database.model.Endpoint;
import io.openbas.database.raw.RawAsset;
import io.openbas.database.repository.EndpointRepository;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
Expand Down Expand Up @@ -37,7 +36,8 @@ public class EndpointService {
@Value("${openbas.admin.token:#{null}}")
private String adminToken;

@Value("${info.app.version:unknown}") String version;
@Value("${info.app.version:unknown}")
String version;

private final EndpointRepository endpointRepository;

Expand Down Expand Up @@ -99,20 +99,20 @@ public String getFileOrDownloadFromJfrog(String platform, String file, String ad
String extension = switch (platform.toLowerCase()) {
case "windows" -> "ps1";
case "linux", "macos" -> "sh";
default -> throw new UnsupportedOperationException("");
default -> throw new UnsupportedOperationException("");
};
String filename = file + "-" + version + "." + extension;
String filename = file + "-" + version + "." + extension;
String resourcePath = "/openbas-agent/" + platform.toLowerCase() + "/";
InputStream in = getClass().getResourceAsStream("/agents" + resourcePath + filename);
if (in == null) { // Dev mode, get from artifactory
filename = file + "-latest." + extension;
in = new BufferedInputStream(new URL(JFROG_BASE + resourcePath + filename).openStream());
}
return IOUtils.toString(in, StandardCharsets.UTF_8)
.replace("${OPENBAS_URL}", openBASConfig.getBaseUrlForAgent())
.replace("${OPENBAS_TOKEN}", adminToken)
.replace("${OPENBAS_UNSECURED_CERTIFICATE}", String.valueOf(openBASConfig.isUnsecuredCertificate()))
.replace("${OPENBAS_WITH_PROXY}", String.valueOf(openBASConfig.isWithProxy()));
.replace("${OPENBAS_URL}", openBASConfig.getBaseUrlForAgent())
.replace("${OPENBAS_TOKEN}", adminToken)
.replace("${OPENBAS_UNSECURED_CERTIFICATE}", String.valueOf(openBASConfig.isUnsecuredCertificate()))
.replace("${OPENBAS_WITH_PROXY}", String.valueOf(openBASConfig.isWithProxy()));
}

public String generateInstallCommand(String platform, String token) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package io.openbas.database.repository;

import io.openbas.database.model.Endpoint;
import io.openbas.database.model.Scenario;
import io.openbas.database.raw.RawAsset;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
Expand Down

0 comments on commit 86f3414

Please sign in to comment.