Skip to content

Commit

Permalink
fix(scan): Added pull of latest scan-action image on scan
Browse files Browse the repository at this point in the history
The plugin was not pulling the latest scanner image, so it would not pick
up fixes and enhancements.
  • Loading branch information
glb committed May 14, 2019
1 parent fa5fffe commit afe442c
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,38 @@ private boolean addUsernamePasswordArgs(
return true;
}

private void pullScanImage(PrintStream logger, Launcher launcher) throws IOException, InterruptedException {
ArgumentListBuilder dockerPullCommandArgs = new ArgumentListBuilder();
dockerPullCommandArgs.add("docker", "pull", DSSC_SCAN_IMAGE);

if (step.isDebug()) {
logger.println("command = " + dockerPullCommandArgs.toString());
}

logger.println("Pulling Deep Security Smart Check scan image...");

ByteArrayOutputStream baos = new ByteArrayOutputStream();
int status = launcher
.launch()
.cmds(dockerPullCommandArgs)
.stderr(logger)
.stdout(baos)
.quiet(!step.isDebug())
.join();
String output = new String(baos.toByteArray(), "UTF-8");

if (step.isDebug()) {
logger.println("Status code was: " + status);
}

if (status != EXIT_OK) {
String errorMessage = "Could not retrieve Deep Security Smart Check scan image.";
logger.println(errorMessage);
logger.println(output);
throw new AbortException(errorMessage);
}
}

@Override
protected Void run() throws IOException, InterruptedException {
LOGGER.fine("Starting scan step");
Expand All @@ -400,6 +432,9 @@ protected Void run() throws IOException, InterruptedException {
);
return null;
}

pullScanImage(logger, launcher);

String workspacePath = workspaceFilePath.getRemote();

ArgumentListBuilder dockerCommandArgs = new ArgumentListBuilder();
Expand Down

0 comments on commit afe442c

Please sign in to comment.