Skip to content

Commit 2ed7443

Browse files
authored
Merge pull request #2 from wallarm/feature/desciption_fixes
Feature/desciption fixes
2 parents 124f0ab + e16db8c commit 2ed7443

File tree

3 files changed

+97
-71
lines changed

3 files changed

+97
-71
lines changed

src/main/java/io/jenkins/plugins/WallarmFastBuilder.java

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class WallarmFastBuilder extends Builder implements SimpleBuildStep {
4747
private String localDockerNetwork;
4848
private String localDockerIp;
4949
private String wallarmVersion;
50+
private String fileExtensionsToExclude;
5051
private int inactivityTimeout;
5152
private int testRunRps;
5253

@@ -69,6 +70,7 @@ public WallarmFastBuilder(
6970
String localDockerNetwork,
7071
String localDockerIp,
7172
String wallarmVersion,
73+
String fileExtensionsToExclude,
7274
int inactivityTimeout,
7375
int testRunRps) {
7476

@@ -89,6 +91,7 @@ public WallarmFastBuilder(
8991
this.localDockerNetwork = localDockerNetwork;
9092
this.localDockerIp = localDockerIp;
9193
this.wallarmVersion = not_empty(wallarmVersion) ? wallarmVersion : "latest";
94+
this.fileExtensionsToExclude = fileExtensionsToExclude;
9295
this.inactivityTimeout = inactivityTimeout;
9396
this.testRunRps = testRunRps;
9497

@@ -167,6 +170,10 @@ public String getWallarmVersion() {
167170
return wallarmVersion;
168171
}
169172

173+
public String getFileExtensionsToExclude() {
174+
return fileExtensionsToExclude;
175+
}
176+
170177
public int getInactivityTimeout() {
171178
return inactivityTimeout;
172179
}
@@ -228,6 +235,9 @@ public void setLocalDockerIp (String localDockerIp) {
228235
public void setWallarmVersion (String wallarmVersion) {
229236
this.wallarmVersion = wallarmVersion;
230237
}
238+
public void setFileExtensionsToExclude (String fileExtensionsToExclude) {
239+
this.fileExtensionsToExclude = fileExtensionsToExclude;
240+
}
231241
public void setInactivityTimeout (int inactivityTimeout) {
232242
this.inactivityTimeout = inactivityTimeout;
233243
}
@@ -247,11 +257,14 @@ public void perform(
247257

248258
add_required_params(cmd);
249259
add_optional_params(cmd);
250-
add_params_with_default_values(cmd);
251260

252261
if (record) {
262+
add_record_params(cmd);
263+
cmd.add("wallarm/fast:" + wallarmVersion ); // this must be the last parameter!
253264
record_baselines(cmd, run, launcher, listener);
254265
} else {
266+
add_testing_params(cmd);
267+
cmd.add("wallarm/fast:" + wallarmVersion ); // this must be the last parameter!
255268
run_tests(cmd, run, launcher, listener);
256269
}
257270
}
@@ -271,36 +284,33 @@ public boolean not_empty(boolean param) {
271284

272285
public void add_required_params(List<String> cmd) {
273286
cmd.add("docker run --rm");
274-
cmd.add("--name " + fastName);
275-
276-
if (record) {
277-
cmd.add("-d");
278-
cmd.add("-e CI_MODE=recording");
279-
cmd.add("-p " + fastPort + ":8080");
280-
} else {
281-
cmd.add("-e CI_MODE=testing");
282-
}
283-
284287
cmd.add("-e WALLARM_API_TOKEN=$WALLARM_API_TOKEN");
288+
cmd.add("-e WALLARM_API_HOST=" + wallarmApiHost );
289+
if (not_empty(appHost)) {cmd.add("-e TEST_RUN_URI=http://" + appHost + ":" + appPort);}
285290
}
286291

292+
public void add_record_params(List<String> cmd) {
293+
cmd.add("-d");
294+
cmd.add("-e CI_MODE=recording");
295+
cmd.add("-p " + fastPort + ":8080");
296+
cmd.add("-e INACTIVITY_TIMEOUT=" + inactivityTimeout );
297+
}
298+
299+
public void add_testing_params(List<String> cmd) {
300+
cmd.add("-e CI_MODE=testing");
301+
if (not_empty(policyId)) {cmd.add("-e POLICY_ID=" + policyId);}
302+
if (not_empty(testRecordId)) {cmd.add("-e TEST_RECORD_ID=" + testRecordId);}
303+
if (not_empty(testRunRps)) {cmd.add("-e TEST_RUN_RPS=" + testRunRps);}
304+
if (not_empty(testRunName)) {cmd.add("-e TEST_RUN_NAME=" + testRunName.replace(" ", "_"));}
305+
if (not_empty(testRunDesc)) {cmd.add("-e TEST_RUN_DESC=" + testRunDesc.replace(" ", "_"));}
306+
if (not_empty(stopOnFirstFail)) {cmd.add("-e TEST_RUN_STOP_ON_FIRST_FAIL=" + stopOnFirstFail);}
307+
if (not_empty(fileExtensionsToExclude)) {cmd.add("-e FILE_EXTENSIONS_TO_EXCLUDE=" + fileExtensionsToExclude);}
308+
}
287309

288310
public void add_optional_params(List<String> cmd) {
289-
if ( not_empty(policyId) ) { cmd.add("-e POLICY_ID=" + policyId ); }
290-
if ( not_empty(testRecordId) ) { cmd.add("-e TEST_RECORD_ID=" + testRecordId ); }
291-
if ( not_empty(localDockerNetwork) ){ cmd.add("--net " + localDockerNetwork ); }
292-
if ( not_empty(localDockerIp) ) { cmd.add("--ip " + localDockerIp ); }
293-
if ( not_empty(testRunName) ) { cmd.add("-e TEST_RUN_NAME=" + testRunName.replace(" ", "_")); }
294-
if ( not_empty(testRunDesc) ) { cmd.add("-e TEST_RUN_DESC=" + testRunDesc.replace(" ", "_")); }
295-
if ( not_empty(stopOnFirstFail) ) { cmd.add("-e TEST_RUN_STOP_ON_FIRST_FAIL=" + stopOnFirstFail ); }
296-
if ( not_empty(testRunRps) ) { cmd.add("-e TEST_RUN_RPS=" + testRunRps ); }
297-
if ( not_empty(appHost) ) { cmd.add("-e TEST_RUN_URI=http://" + appHost + ":" + appPort); }
298-
}
299-
300-
public void add_params_with_default_values(List<String> cmd) {
301-
cmd.add("-e WALLARM_API_HOST=" + wallarmApiHost );
302-
cmd.add("-e INACTIVITY_TIMEOUT=" + inactivityTimeout );
303-
cmd.add("wallarm/fast:" + wallarmVersion ); // this must be the last parameter
311+
cmd.add("--name " + fastName);
312+
if (not_empty(localDockerNetwork)) {cmd.add("--net " + localDockerNetwork);}
313+
if (not_empty(localDockerIp)) {cmd.add("--ip " + localDockerIp);}
304314
}
305315

306316
// this one is used when we need to parse the output of the command we're launching
@@ -487,6 +497,7 @@ public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
487497
private String localDockerNetwork;
488498
private String localDockerIp;
489499
private String wallarmVersion;
500+
private String fileExtensionsToExclude;
490501
private int inactivityTimeout;
491502
private int testRunRps;
492503

@@ -571,6 +582,10 @@ public String getWallarmVersion() {
571582
return wallarmVersion;
572583
}
573584

585+
public String getFileExtensionsToExclude() {
586+
return fileExtensionsToExclude;
587+
}
588+
574589
public int getInactivityTimeout() {
575590
return inactivityTimeout;
576591
}

src/main/resources/io/jenkins/plugins/WallarmFastBuilder/config.jelly

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,81 @@
11
<?jelly escape-by-default='true'?>
22
<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">
3-
<f:section>
3+
<f:block>
44
<img src="https://wallarm.com/assets/images/logo-short.svg" alt="Wallarm FAST"></img>
5-
</f:section>
5+
</f:block>
66

77
<f:section title="General">
8-
<f:entry title="${%WallarmApiToken}" field="wallarmApiToken" description='Your Wallarm node token. Can be found at "https://us1.my.wallarm.com/nodes"'>
8+
<f:entry title="${%Wallarm API token}" field="wallarmApiToken" description='Your Wallarm node token.'>
99
<f:textbox />
1010
</f:entry>
11-
<f:entry title="${%WallarmApiHost}" field="wallarmApiHost" description='Wallarm API. use "us1.api.wallarm.com" for North America (default) and "api.wallarm.com" for Europe'>
11+
<f:entry title="${%Wallarm API host}" field="wallarmApiHost" description='Wallarm API. Use "us1.api.wallarm.com" for North America (default) and "api.wallarm.com" for Europe'>
1212
<f:textbox />
1313
</f:entry>
1414

15-
<f:entry title="${%AppHost}" field="appHost" description='Address of your application (ip or name will do)'>
15+
<f:entry title="${%Application host}" field="appHost" description='Address of your application (ip or name will do)'>
1616
<f:textbox />
1717
</f:entry>
18-
<f:entry title="${%AppPort}" field="appPort" description='Port of your application (defaults to 8080)'>
18+
<f:entry title="${%Application port}" field="appPort" description='Port of your application (defaults to 8080)'>
1919
<f:textbox />
2020
</f:entry>
2121

22-
<f:entry title="${%Record}" field="record" description='Record baselines for later use or run tests with recorded baselines'>
23-
<f:checkbox />
24-
</f:entry>
2522
</f:section>
2623

27-
<f:section title="Recording only">
28-
<f:entry title="${%FastPort}" field="fastPort" description="Port for FAST docker (used in recording mode)">
29-
<f:textbox />
30-
</f:entry>
24+
<f:radioBlock name="record" value="true" title="Record baselines" checked="false" inline="true">
25+
<f:nested>
26+
<f:entry title="${%Fast port}" field="fastPort" description="Port for FAST docker">
27+
<f:textbox />
28+
</f:entry>
3129

32-
<f:entry title="${%InactivityTimeout}" field="inactivityTimeout" description='Autoshutdown timer in seconds. Can be from 0 to 691200 (1 week). Defaults to 600 seconds (10 minutes). Used in recording mode'>
33-
<f:textbox default="600"/>
34-
</f:entry>
35-
</f:section>
30+
<f:entry title="${%Inactivity timeout}" field="inactivityTimeout" description='Autoshutdown timer in seconds. Can be from 0 to 691200 (1 week). Defaults to 600 seconds (10 minutes).'>
31+
<f:textbox default="600"/>
32+
</f:entry>
33+
</f:nested>
34+
</f:radioBlock>
3635

37-
<f:section title="Playback only">
38-
<f:entry title="${%PolicyId}" field="policyId" description='Policy Id to use. Use 0 for default policy'>
39-
<f:textbox />
40-
</f:entry>
41-
<f:entry title="${%TestRecordId}" field="testRecordId" description='Test record you wish to use. Use 0 to use the latest one available'>
42-
<f:textbox />
43-
</f:entry>
44-
<f:entry title="${%TestRunRps}" field="testRunRps" description='Request per second limit for your test run (optional)'>
45-
<f:textbox />
46-
</f:entry>
47-
<f:entry title="${%TestRunName}" field="testRunName" description='Name of your TestRun (optional)'>
48-
<f:textbox />
49-
</f:entry>
50-
<f:entry title="${%TestRunDesc}" field="testRunDesc" description='TestRun description (optional)'>
51-
<f:textbox />
52-
</f:entry>
53-
<f:entry title="${%StopOnFirstFail}" field="stopOnFirstFail" description='Stop running tests as soon as a vulnerability is found'>
54-
<f:checkbox />
55-
</f:entry>
56-
<f:entry title="${%FailBuild}" field="failBuild" description='Fail build on completion if vulnerabilities are found'>
57-
<f:checkbox />
58-
</f:entry>
59-
</f:section>
36+
<f:radioBlock name="record" value="false" title="Playback baselines" checked="true" inline="true" >
37+
<f:nested>
38+
<f:entry title="${%Policy id}" field="policyId" description='Policy Id to use. Use 0 for default policy'>
39+
<f:textbox />
40+
</f:entry>
41+
<f:entry title="${%TestRecord id}" field="testRecordId" description='Test record you wish to use. Use 0 to use the latest one available'>
42+
<f:textbox />
43+
</f:entry>
44+
<f:entry title="${%TestRun RPS}" field="testRunRps" description='Request per second limit for your test run (optional)'>
45+
<f:textbox />
46+
</f:entry>
47+
<f:entry title="${%TestRun name}" field="testRunName" description='Name of your TestRun (optional)'>
48+
<f:textbox />
49+
</f:entry>
50+
<f:entry title="${%TestRun description}" field="testRunDesc" description='TestRun description (optional)'>
51+
<f:textbox />
52+
</f:entry>
53+
<f:entry title="${%Stop on first fail}" field="stopOnFirstFail" description='Stop running tests as soon as a vulnerability is found'>
54+
<f:checkbox />
55+
</f:entry>
56+
<f:entry title="${%Fail build}" field="failBuild" description='Fail build on completion if vulnerabilities are found'>
57+
<f:checkbox />
58+
</f:entry>
59+
<f:entry title="${%Exclude}" field="fileExtensionsToExclude" description="FAST will skip any requests to files with the extensions specified here. Use the following format: 'js|jpeg|jpg|gif|png|css'">
60+
<f:textbox default="js|jpeg|jpg|gif|png|css"/>
61+
</f:entry>
62+
</f:nested>
63+
</f:radioBlock>
6064

6165
<f:section title="Optional">
62-
<f:entry title="${%FastName}" field="fastName" description="Name for FAST docker. Has default values for both recording and testing">
66+
<f:entry title="${%Fast name}" field="fastName" description="Name for FAST docker. Has default values for both recording and testing">
6367
<f:textbox />
6468
</f:entry>
65-
<f:entry title="${%WallarmVersion}" field="wallarmVersion" description='Wallarm/fast version. Leave blank for "latest"'>
69+
<f:entry title="${%Wallarm version}" field="wallarmVersion" description='Wallarm/fast version. Leave blank for "latest"'>
6670
<f:textbox />
6771
</f:entry>
68-
<f:entry title="${%LocalDockerNetwork}" field="localDockerNetwork" description='Adds the `--net your_network` parameter to FAST. Useful when your application runs inside of a docker container'>
72+
<f:entry title="${%Local docker network}" field="localDockerNetwork" description='Adds the `--net your_network` parameter to FAST. Useful when your application runs inside of a docker container'>
6973
<f:textbox />
7074
</f:entry>
71-
<f:entry title="${%LocalDockerIp}" field="localDockerIp" description="Adds the `--ip your_ip` parameter to FAST. Used when you need to address FAST while inside a docker network">
75+
<f:entry title="${%Local docker ip}" field="localDockerIp" description="Adds the `--ip your_ip` parameter to FAST. Used when you need to address FAST while inside a docker network">
7276
<f:textbox />
7377
</f:entry>
74-
<f:entry title="${%WithoutSudo}" field="withoutSudo" description='If checked, calls docker without sudo'>
78+
<f:entry title="${%Without sudo}" field="withoutSudo" description='If checked, calls docker without sudo'>
7579
<f:checkbox />
7680
</f:entry>
7781
</f:section>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
Static files found by FAST often do not contain vulnerabilities and to not react to payloads, however it is impossible to dynamically determine if the page is invulnerable to the used payloads or just doesn't proccess payloads at all. Excluding payloads from the scanning will speed up the testing proccess significantly.
3+
4+
Leave this field blank to scan all files found.
5+
6+
Default: 'js|jpeg|jpg|gif|png|css'
7+
</div>

0 commit comments

Comments
 (0)