Skip to content

Commit

Permalink
Update: appknox-go latest
Browse files Browse the repository at this point in the history
  • Loading branch information
yashviagrawal committed Sep 25, 2024
1 parent b21f635 commit 37ee4e2
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/main/java/io/jenkins/plugins/scanner/AppknoxScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class AppknoxScanner extends Builder implements SimpleBuildStep {
private final String riskThreshold;
private final String apiHost;

private static final String binaryVersion = "1.3.1";
private static final String binaryVersion = "1.6.0";
private static final String osName = System.getProperty("os.name").toLowerCase();
private static final String CLI_DOWNLOAD_PATH = System.getProperty("user.home") + File.separator + "appknox";

Expand Down Expand Up @@ -118,9 +118,7 @@ private boolean executeAppknoxCommands(Run<?, ?> run, FilePath workspace, String
env.put("APPKNOX_ACCESS_TOKEN", accessToken);
String appknoxPath = downloadAndInstallAppknox(osName, listener);

String selectedApiHost = resolveApiHost(listener);
// listener.getLogger().println("Using API Host: " + selectedApiHost);
env.put("APPKNOX_API_HOST", selectedApiHost);
listener.getLogger().println("Selected Region: " + apiHost);

// Determine if the file is an APK or IPA based on extension
String appFilePath = findAppFilePath(workspace.getRemote(), filePath, listener);
Expand Down Expand Up @@ -225,23 +223,6 @@ private String findAppFilePathRecursive(File dir, String fileName, TaskListener
return null;
}

private String resolveApiHost(TaskListener listener) {
String resolvedHost;
switch (apiHost) {
case "global":
resolvedHost = "https://api.appknox.com/";
break;
case "saudi":
resolvedHost = "https://sa.secure.appknox.com/";
break;
default:
throw new IllegalArgumentException("Invalid Region selection.");
}
// Log the selected API host and URL
listener.getLogger().println("Using Region: " + apiHost + " with URL: " + resolvedHost);
return resolvedHost;
}


private String extractFileID(String uploadOutput, TaskListener listener) {
String[] lines = uploadOutput.split("\n");
Expand Down Expand Up @@ -332,6 +313,8 @@ private String uploadFile(String appknoxPath, TaskListener listener, Map<String,
command.add(appknoxPath);
command.add("upload");
command.add(appFilePath);
command.add("--region");
command.add(apiHost);

ProcessBuilder pb = new ProcessBuilder(command);
pb.environment().putAll(env);
Expand Down Expand Up @@ -372,6 +355,8 @@ private boolean runCICheck(String appknoxPath, Run<?, ?> run, String fileID, Tas
command.add(fileID);
command.add("--risk-threshold");
command.add(riskThreshold);
command.add("--region");
command.add(apiHost);

ProcessBuilder pb = new ProcessBuilder(command);
pb.environment().putAll(env);
Expand Down Expand Up @@ -421,6 +406,8 @@ private String createReport(String appknoxPath, String fileID, TaskListener list
command.add("reports");
command.add("create");
command.add(fileID);
command.add("--region");
command.add(apiHost);

ProcessBuilder pb = new ProcessBuilder(command);
pb.environment().putAll(env);
Expand Down Expand Up @@ -462,6 +449,8 @@ private void downloadReportSummaryCSV(String appknoxPath, String reportName, Str
command.add(reportID);
command.add("--output");
command.add(workspace.child(reportName).getRemote());
command.add("--region");
command.add(apiHost);

ProcessBuilder pb = new ProcessBuilder(command);
pb.environment().putAll(env);
Expand Down

0 comments on commit 37ee4e2

Please sign in to comment.