Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public static void main(String[] args) throws Exception {
var file = Path.of(Environment.getenv("SCAN_PATH"));
var verdict = vaas.forFile(file);

System.out.printf("File %s was sync detected as %s", verdict.getSha256(), verdict.getVerdict());
System.out.printf("File %s was sync detected as %s and is encrypted: %s", verdict.getSha256(), verdict.getVerdict(), verdict.getIsEncrypted());

vaas.forFileAsync(file).thenAccept(vaasResult -> {
System.out.printf("\nFile %s was async detected as %s", vaasResult.getSha256(), vaasResult.getVerdict());
System.out.printf("\nFile %s was async detected as %s and is encrypted: %s", vaasResult.getSha256(), vaasResult.getVerdict(), vaasResult.getIsEncrypted());
}).get();
}
}
4 changes: 3 additions & 1 deletion java/src/main/java/de/gdata/vaas/messages/FileReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ public class FileReport {
String detection;
String fileType;
String mimeType;
Boolean isEncrypted;

public FileReport(@NonNull String sha256, @NonNull Verdict verdict, String detection, String fileType,
String mimeType) {
String mimeType, Boolean isEncrypted) {
this.sha256 = sha256;
this.verdict = verdict;
this.detection = detection;
this.fileType = fileType;
this.mimeType = mimeType;
this.isEncrypted = isEncrypted;
}

public static FileReport fromJson(String json) {
Expand Down
4 changes: 3 additions & 1 deletion java/src/main/java/de/gdata/vaas/messages/UrlReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ public class UrlReport {
String detection;
String fileType;
String mimeType;
Boolean isEncrypted;

public UrlReport(@NonNull String sha256, @NonNull Verdict verdict, @NonNull String url, String detection, String fileType,
String mimeType) {
String mimeType, Boolean isEncrypted) {
this.sha256 = sha256;
this.verdict = verdict;
this.url = url;
this.detection = detection;
this.fileType = fileType;
this.mimeType = mimeType;
this.isEncrypted = isEncrypted;
}

public static UrlReport fromJson(String json) {
Expand Down
3 changes: 3 additions & 0 deletions java/src/main/java/de/gdata/vaas/messages/VaasVerdict.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class VaasVerdict {
String detection;
String fileType;
String mimeType;
Boolean isEncrypted;

public VaasVerdict(UrlReport urlReport) {
this.sha256 = urlReport.sha256;
this.verdict = urlReport.verdict;
this.detection = urlReport.detection;
this.fileType = urlReport.fileType;
this.mimeType = urlReport.mimeType;
this.isEncrypted = urlReport.isEncrypted;
}

public VaasVerdict(FileReport fileReport) {
Expand All @@ -27,6 +29,7 @@ public VaasVerdict(FileReport fileReport) {
this.detection = fileReport.detection;
this.fileType = fileReport.fileType;
this.mimeType = fileReport.mimeType;
this.isEncrypted = fileReport.isEncrypted;
}

public static VaasVerdict From(UrlReport urlReport) {
Expand Down
42 changes: 42 additions & 0 deletions java/src/test/java/de/gdata/test/TestDotenv.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.gdata.test;

import io.github.cdimascio.dotenv.Dotenv;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

public final class TestDotenv {
private static final String ENV_FILENAME = ".env";

private TestDotenv() {
}

public static Dotenv load() {
return load(Paths.get("").toAbsolutePath());
}

public static Dotenv load(Path startDirectory) {
var envDirectory = findEnvDirectory(startDirectory);
var dotenv = Dotenv.configure()
.ignoreIfMissing();

envDirectory.ifPresent(path -> dotenv.directory(path.toString()).filename(ENV_FILENAME));

return dotenv.load();
}

public static Optional<Path> findEnvDirectory(Path startDirectory) {
var currentDirectory = startDirectory.toAbsolutePath().normalize();

while (currentDirectory != null) {
if (Files.isRegularFile(currentDirectory.resolve(ENV_FILENAME))) {
return Optional.of(currentDirectory);
}
currentDirectory = currentDirectory.getParent();
}

return Optional.empty();
}
}
Loading
Loading