id_list = new ArrayList<>();
434 | id_list.add(sourceId);
435 | jsoChild.put("id_list", id_list);
436 | jso.put("source", jsoChild);
437 | String reportId = doPostLoc(apiUrl + "/reports", jso.toString()).respStr;
438 | waitReportStatus(reportId);
439 | String[] downloadLinkList = doGet(apiUrl + "/reports/" + reportId).jso.getString("download").split(",");
440 | String downloadLink = null;
441 | for (String item : downloadLinkList) {
442 | if (item.contains(".html")) {
443 | downloadLink = item.replaceAll("\"", "").replaceAll("\\[", "".replaceAll("]", ""));
444 | break;
445 | }
446 | }
447 | // download report
448 | return downloadLink;
449 | }
450 |
451 | public Boolean checkThreat(String checkThreat, String scanThreat) {
452 | //return true if the threat detected is equal or greater than threat set
453 | //checkthreat is the level set in plugin config and scanThreat from the scan result
454 | if (checkThreat.equals("DoNotFail")) {
455 | return false;
456 | }
457 | return Arrays.asList(threatCategory.get(checkThreat)).contains(scanThreat);
458 | }
459 |
460 | public Integer getVersion() throws IOException {
461 | if (apiUrl.matches(":\\d+")) {
462 | JSONObject jso = doGet(apiUrl + "/info").jso;
463 | return jso.getInt("major_version");
464 | }
465 | else {
466 | return 13;
467 | }
468 | }
469 |
470 | public String getReportFileName(String urlSource) throws IOException {
471 | URLConnection connection = new URL(urlSource).openConnection();
472 | connection.addRequestProperty("User-Agent", "Mozilla");
473 | String cd = connection.getHeaderField("Content-Disposition");
474 | String fileName = null;
475 | if (cd != null && cd.contains("=")) {
476 | fileName = "Acunetix_" + cd.split("=")[1].trim().replaceAll("\"", "");
477 | }
478 | return fileName;
479 | }
480 |
481 | public void doDownload(String urlSource, FilePath savePath) throws IOException, InterruptedException {
482 | URL url = new URL(urlSource);
483 | savePath.copyFrom(url);
484 | }
485 |
486 |
487 | }
488 |
489 | class ConnectionException extends RuntimeException {
490 | public ConnectionException() {
491 | super(SR.getString("cannot.connect.to.application"));
492 | }
493 | public ConnectionException(String message) {
494 | super(message);
495 | }
496 | }
497 |
--------------------------------------------------------------------------------
/src/main/java/com/acunetix/SR.java:
--------------------------------------------------------------------------------
1 | package com.acunetix;
2 |
3 | import java.text.MessageFormat;
4 |
5 | import static java.util.ResourceBundle.getBundle;
6 |
7 | /**
8 | * Expose message resources
9 | */
10 | class SR {
11 | private static java.util.ResourceBundle acunetixBundle = getBundle("Messages");
12 |
13 | private SR() {
14 | }
15 |
16 | static String getString(String key, Object... args) {
17 | String message = acunetixBundle.getString(key);
18 |
19 | if (args != null && args.length > 0) {
20 | return MessageFormat.format(message, args);
21 | }
22 | return message;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/resources/Messages.properties:
--------------------------------------------------------------------------------
1 | cannot.connect.to.application=Cannot connect to Acunetix API engine
2 | connected.successfully=Connected successfully
3 | please.set.the.api.url=Please set the API URL
4 | please.set.the.api.key=Please set the API Key
5 | invalid.api.url=Invalid API URL
6 | api.key.not.set=API Key is not set
7 | starting.scan.on.target.0=Starting scan on target: {0}
8 | bad.response.0=Bad response received: {0}
9 | scan.threat.0=At least one \"{0}\" vulnerability was found
10 | scan.aborted.outside=The scan was aborted outside of this instance
11 | scan.aborted=The scan was aborted
12 | scan.completed=The scan was completed
13 | scan.scheduled=The scan was scheduled. Please ensure the configured scan can run immediately
14 | abort.scan.scheduled=The build was aborted because the scan is scheduled
15 | aborting.the.build=Aborting the build
16 | build.aborted=The build was aborted
17 | scan.threat=The scan threat level is greater or equal than the configured level
18 | the.scan.was.stopped=The scan was stopped
19 | certificate.to.the.java.ca.store=Please add the Acunetix scanner certificate to Java CA store
20 | scan.started=Scan started
21 | the.scan.is.in.scheduled.state=The scan is in scheduled state! Waiting to start ...
22 | the.scan.was.deleted=The scan was deleted
23 | could.not.connect.to.application.connection.refused=Could not connect to application. Connection refused
24 | could.not.find.scan.with.scanid.0=Could not find the scan with scanId: {0}
25 | could.not.connect=The connection could not be established. Check if the server is responsive and API key is valid
26 | invalid.target=The target is invalid
27 | invalid.scan_type=The scan type is invalid
28 | could.not.find.scan.with.scanid.0.create.new=Could not find the scan with scanId: {0}\n Please create a new one by saving the project configuration
29 | view.scan.status=View scan on Acunetix:
30 | check.vulnerabilities.found=Check vulnerabilities found by this scan:
31 | generating.0.report=Generating \"{0}\" report
32 | report.saved.in.workspace.0=Report saved in workspace: \"{0}\"
33 | scan.report.download.link.0=Scan report download link: \"{0}\"
34 | invalid.report.file.path.0=Invalid report file path: \"{0}\"
35 |
36 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ${%Incremental scan}
23 |
24 |
25 |
26 |
27 | ${%Stop scans on the Target before starting a new scan}
28 |
29 |
30 |
31 |
32 |
33 |
34 | ${%Stop the scan when build fails}
35 |
36 |
37 |
38 |
39 |
40 |
41 | ${%Save report in workspace}
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/global.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-gApiKey.html:
--------------------------------------------------------------------------------
1 |
2 | Acunetix API Key. The API Key may be obtained from the Acunetix User Interface under the Administrator's Profile section
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-gApiKeyID.html:
--------------------------------------------------------------------------------
1 |
2 | The URL of the Acunetix API. Example: https://localhost:3443/api/v1.
3 | Note: When change the API key make sure it is saved, using "Apply" button, before trying "Test Connection"
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-incScan.html:
--------------------------------------------------------------------------------
1 |
2 | This will create an Incremental scan. The first scan will scan all the site. Subsequent scans will only scan the changes in the site, resulting in smaller scans.
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-profile.html:
--------------------------------------------------------------------------------
1 |
2 | The Scan Type used to scan the target
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-repTemp.html:
--------------------------------------------------------------------------------
1 |
2 | Generate a Report after the scan completes.
3 | The report is available for download from Acunetix backend within a time frame of one hour
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-stopScan.html:
--------------------------------------------------------------------------------
1 |
2 | If selected, the scan will be stopped if the build fails (Threat Level is reached)
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-stopTargetScans.html:
--------------------------------------------------------------------------------
1 |
2 | This is useful when older versions of the web application are discarded by the CI/CD when an updated version is created.
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-svRep.html:
--------------------------------------------------------------------------------
1 |
2 | Option to download the report in the project workspace from where it can be used for other operations like attaching
3 | to an email or archiving.
4 | Note: Archiving can be done with "Archive the artifacts" post-build action
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-target.html:
--------------------------------------------------------------------------------
1 |
2 | The Scan Target on which to run a scan (excludes Targets requiring Manual Intervention)
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help-threat.html:
--------------------------------------------------------------------------------
1 |
2 | The Threat Level (High, Medium, Low) to fail the build on
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/acunetix/BuildScanner/help.html:
--------------------------------------------------------------------------------
1 |
2 | Trigger automated Acunetix scans as part of your web application's build process
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/index.jelly:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | Plugin for starting Acunetix Premium scans
7 |
8 |
--------------------------------------------------------------------------------