Skip to content
Permalink
Browse files

FIX JENKINS-43384

-removed support from the ZAP Settings Variable for System Environment Variables, Build Variables as well as Environment Inject Plugin Variables since the Job Configuration page is ONLY run on the master and has no access to the slave
-updated help file to refelect the changes made
  • Loading branch information
JordanGS committed Apr 12, 2017
1 parent 00890eb commit 45733233e9ccd48f8f76350c8433059f345fe827
@@ -133,7 +133,6 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
if (zapHost == null || zapHost.isEmpty()) throw new IllegalArgumentException("ZAP HOST IS MISSING");
String zapPort = zaproxy.getZapPort();
if (zapPort == null || zapPort.isEmpty()) throw new IllegalArgumentException("ZAP PORT IS MISSING");
String zapSettingsDir = zaproxy.getZapSettingsDir();
String sessionFilename = zaproxy.getSessionFilename();
String internalSites = zaproxy.getInternalSites();
String contextName = zaproxy.getContextName();
@@ -147,7 +146,6 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
try {
zapHost = applyMacro(build, listener, zapHost);
zapPort = applyMacro(build, listener, zapPort);
zapSettingsDir = applyMacro(build, listener, zapSettingsDir);
sessionFilename = applyMacro(build, listener, sessionFilename);
internalSites = applyMacro(build, listener, internalSites);
contextName = applyMacro(build, listener, contextName);
@@ -165,7 +163,6 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {

zaproxy.setEvaluatedZapHost(zapHost);
zaproxy.setEvaluatedZapPort(Integer.valueOf(zapPort));
zaproxy.setEvaluatedZapSettingsDir(zapSettingsDir);
zaproxy.setEvaluatedSessionFilename(sessionFilename);
zaproxy.setEvaluatedInternalSites(internalSites);
zaproxy.setEvaluatedContextName(contextName);
@@ -179,7 +176,6 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
Utils.loggerMessage(listener, 1, "HOST = [ {0} ]", zapHost);
Utils.loggerMessage(listener, 1, "PORT = [ {0} ]", zapPort);
Utils.lineBreak(listener);
Utils.loggerMessage(listener, 1, "ZAP SETTINGS DIRECTORY = [ {0} ]", zapSettingsDir);
Utils.loggerMessage(listener, 1, "SESSION FILENAME = [ {0} ]", sessionFilename);
Utils.loggerMessage(listener, 1, "INTERNAL SITES = [ {0} ]", internalSites.trim().replace("\n", ", "));
Utils.lineBreak(listener);
@@ -201,15 +197,15 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {

/* Clear the ZAP Settings folder of all previous zap logs. */
Utils.loggerMessage(listener, 0, "[{0}] CLEAR LOGS IN SETTINGS...", Utils.ZAP);
Utils.loggerMessage(listener, 1, "SETTINGS DIR [ {0} ]", this.zaproxy.getEvaluatedZapSettingsDir());
Utils.loggerMessage(listener, 1, "SETTINGS DIR [ {0} ]", this.zaproxy.getZapSettingsDir());
Utils.loggerMessage(listener, 1, "WORKSPACE [ {0} ]", build.getWorkspace().getRemote());

/* No workspace before the first build, so workspace is null. */
FilePath ws = build.getWorkspace();
if (ws != null) {
File[] listFiles = {};
try {
listFiles = ws.act(new LogCallable(this.zaproxy.getEvaluatedZapSettingsDir()));
listFiles = ws.act(new LogCallable(this.zaproxy.getZapSettingsDir()));
}
catch (IOException e) {
e.printStackTrace(); /* No listener because it's not during a build but it's on the job config page. */
@@ -302,15 +298,15 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

/* Upon ZAP successfully shutting down, copy the files from the ZAP settings directory into the workspace folder. */
Utils.loggerMessage(listener, 0, "[{0}] LOG SEARCH...", Utils.ZAP);
Utils.loggerMessage(listener, 1, "SETTINGS DIR [ {0} ]", this.zaproxy.getEvaluatedZapSettingsDir());
Utils.loggerMessage(listener, 1, "SETTINGS DIR [ {0} ]", this.zaproxy.getZapSettingsDir());
Utils.loggerMessage(listener, 1, "WORKSPACE [ {0} ]", build.getWorkspace().getRemote());

/* No workspace before the first build, so workspace is null. */
FilePath ws = build.getWorkspace();
if (ws != null) {
File[] listFiles = {};
try {
listFiles = ws.act(new LogCallable(this.zaproxy.getEvaluatedZapSettingsDir()));
listFiles = ws.act(new LogCallable(this.zaproxy.getZapSettingsDir()));
}
catch (IOException e) {
e.printStackTrace(); /* No listener because it's not during a build but it's on the job config page. */
@@ -540,10 +540,6 @@ private void checkParams(AbstractBuild<?, ?> build, BuildListener listener) thro
}
}

this.evaluatedZapSettingsDir = envVars.expand(this.evaluatedZapSettingsDir);
if (this.evaluatedZapSettingsDir == null || this.evaluatedZapSettingsDir.isEmpty()) throw new IllegalArgumentException("ZAP SETTINGS DIRECTORY IS MISSING, PROVIDED [ " + this.evaluatedZapSettingsDir + " ]");
else Utils.loggerMessage(listener, 1, "(EXP) ZAP SETTINGS DIRECTORY = [ {0} ]", this.evaluatedZapSettingsDir);

this.evaluatedContextName = envVars.expand(this.evaluatedContextName);
if (this.evaluatedContextName == null || this.evaluatedContextName.isEmpty()) this.evaluatedContextName = "Jenkins Default Context";
else Utils.loggerMessage(listener, 1, "(EXP) CONTEXT NAME = [ {0} ]", this.evaluatedContextName);
@@ -634,9 +630,9 @@ public Proc startZAP(AbstractBuild<?, ?> build, BuildListener listener, Launcher
cmd.add(CMD_LINE_API_KEY + "=" + API_KEY);

/* Set the default directory used by ZAP if it's defined and if a scan is provided */
if (this.activeScanURL && this.evaluatedZapSettingsDir != null && !this.evaluatedZapSettingsDir.isEmpty()) {
if (this.activeScanURL && this.zapSettingsDir != null && !this.zapSettingsDir.isEmpty()) {
cmd.add(CMD_LINE_DIR);
cmd.add(this.evaluatedZapSettingsDir);
cmd.add(this.zapSettingsDir);
}

/* Adds command line arguments if it's provided */
@@ -1097,7 +1093,7 @@ public boolean executeZAP(BuildListener listener, FilePath workspace) {
if (workspace != null) {
File[] listFiles = {};
try {
listFiles = workspace.act(new PluginCallable(this.evaluatedZapSettingsDir));
listFiles = workspace.act(new PluginCallable(this.zapSettingsDir));
}
catch (IOException e) {
e.printStackTrace(); /* No listener because it's not during a build but it's on the job config page. */
@@ -2825,12 +2821,6 @@ private void getAvailableFormats(ZAPDriverDescriptorImpl zapDriver) {

public String getZapSettingsDir() { return zapSettingsDir; }

private String evaluatedZapSettingsDir; /* Todo */

public String getEvaluatedZapSettingsDir() { return evaluatedZapSettingsDir; }

public void setEvaluatedZapSettingsDir(String evaluatedZapSettingsDir) { this.evaluatedZapSettingsDir = evaluatedZapSettingsDir; }

/* Session Management */
private final boolean autoLoadSession; /* Todo */

@@ -1,3 +1,2 @@
Path to the 'default directory' that ZAP uses (on the build's machine).</br></br>
Please see <a href="https://github.com/zaproxy/zaproxy/wiki/FAQconfig">FAQconfig</a> for more information.</br></br><hr/></br>
Accepts <b>System Environment Variables</b>, <b>Build Variables</b> as well as <b>Environment Inject Plugin Variables</b>(cannot be used during pre-build).
Please see <a href="https://github.com/zaproxy/zaproxy/wiki/FAQconfig">FAQconfig</a> for more information.

0 comments on commit 4573323

Please sign in to comment.
You can’t perform that action at this time.