Skip to content

Commit

Permalink
Merge pull request #7 from JordanGS/development-1.1.0-bugfix
Browse files Browse the repository at this point in the history
Development 1.1.0 bugfix
  • Loading branch information
JordanGS committed Apr 13, 2017
2 parents 0a78cc9 + 4573323 commit 1d55f02
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 29 deletions.
12 changes: 4 additions & 8 deletions src/main/java/org/jenkinsci/plugins/zap/ZAPBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down
18 changes: 4 additions & 14 deletions src/main/java/org/jenkinsci/plugins/zap/ZAPDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private void checkParams(AbstractBuild<?, ?> build, BuildListener listener) thro
this.evaluatedInternalSites = envVars.expand(this.evaluatedInternalSites);
if (this.startZAPFirst) {
if (!this.autoLoadSession) {
if (this.evaluatedSessionFilename == null || this.evaluatedSessionFilename.isEmpty()) throw new IllegalArgumentException("SESSION FILENAME IS MISSING, PROVIDED [ " + this.evaluatedZapSettingsDir + " ]");
if (this.evaluatedSessionFilename == null || this.evaluatedSessionFilename.isEmpty()) throw new IllegalArgumentException("SESSION FILENAME IS MISSING, PROVIDED [ " + this.evaluatedSessionFilename + " ]");
else Utils.loggerMessage(listener, 1, "(EXP) SESSION FILENAME = [ {0} ]", this.evaluatedSessionFilename);

if (this.removeExternalSites) {
Expand All @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry help="/descriptor/com.github.jenkinsci.zaproxyplugin.ZAPAuthScriptParam/help/config">
<f:entry help="/descriptor/org.jenkinsci.plugins.zap.ZAPAuthScriptParam/help/config">
<table width="100%">
<tr>
<th>${%Script Parameter Name}</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ZAP will start in a pre-build step (before all other build steps).</br></br><hr/></br>
Please see <b>How to <a href="https://wiki.jenkins-ci.org/display/JENKINS/zaproxy-plugin+How+To#zaproxy-pluginHowTo-%21setting.png%21ConfiguretheJobtoExecuteZAPaspartofaSeleniumBuildJENKINS%3AzaproxypluginExecuteZAPasPreBuild">Configure the Job to Execute ZAP as part of a Selenium Build
Please see <b>How to <a href="https://wiki.jenkins-ci.org/display/JENKINS/zap-plugin+How+To#zap-pluginHowTo-ConfiguretheJobtoExecuteZAPaspartofaSeleniumBuild">Configure the Job to Execute ZAP as part of a Selenium Build
</a></b> for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry help="/descriptor/com.github.jenkinsci.zaproxyplugin.ZAPCmdLine/help/config">
<f:entry help="/descriptor/org.jenkinsci.plugins.zap.ZAPCmdLine/help/config">
<table width="100%">
<tr>
<th>${%Command line option}</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Select a ZAP session to load. The session must be stored in the 'Jenkins Job's Workspace'.</br></br><hr/></br>
Please see <b>How to <a href="https://wiki.jenkins-ci.org/display/JENKINS/zaproxy-plugin+How+To#zaproxy-pluginHowTo-%21setting.png%21ConfiguretheJobtoExecuteZAPJENKINS%3AzaproxypluginExecuteZAP">Configure the Job to Execute ZAP</a></b> for more information.
Please see <b>How to <a href="https://wiki.jenkins-ci.org/display/JENKINS/zap-plugin+How+To#zap-pluginHowTo-ConfiguretheJobtoExecuteZAP">Configure the Job to Execute ZAP</a></b> for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
The file extension is not necessary (".session" extension will be automatically added).</br></br>
The report will be saved into the 'Jenkins Job's Workspace'.</br></br>
e.g. <i>\path\to\filename</i> or simply <i>filename</i></br></br><hr/></br>
Please see <b>How to <a href="https://wiki.jenkins-ci.org/display/JENKINS/zaproxy-plugin+How+To#zaproxy-pluginHowTo-%21setting.png%21ConfiguretheJobtoExecuteZAPaspartofaSeleniumBuildJENKINS%3AzaproxypluginExecuteZAPasPreBuild">Configure the Job to Execute ZAP as part of a Selenium Build
Please see <b>How to <a href="https://wiki.jenkins-ci.org/display/JENKINS/zap-plugin+How+To#zap-pluginHowTo-ConfiguretheJobtoExecuteZAPaspartofaSeleniumBuild">Configure the Job to Execute ZAP as part of a Selenium Build
</a></b> 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).
Original file line number Diff line number Diff line change
@@ -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 1d55f02

Please sign in to comment.