Skip to content

Commit ffcaccf

Browse files
committed
added a guide and screenshot of owasp-zap tool and added sonarqube service in docker-compose
1 parent 24519e2 commit ffcaccf

7 files changed

+47
-26
lines changed

README.md

+15-22
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,42 @@ This is a "Vulnerable" Web Application developed by Cyber Security and Privacy F
44

55
## Prerequisites:
66

7-
- git
8-
- docker docker-compose
9-
- vagrant
7+
- [git](https://git-scm.com/downloads)
8+
- with [Docker](https://docs.docker.com/install/), [docker-compose](https://docs.docker.com/compose/install/) and [Vagrant](https://www.vagrantup.com/docs/installation/)
9+
- or [JDK8+](https://openjdk.java.net/install/), [Maven](http://maven.apache.org/install.html) and [tomcat 8](https://tomcat.apache.org/tomcat-8.5-doc/setup.html)
1010

1111
## Deploy it
1212

13-
1. Using Docker to run on a machine :
13+
There are many easy way to deploy this application.
14+
15+
1. Using Vagrant to run this application in a VM (containers are launched inside it, as describe in option #2) :
1416

1517
```sh
1618
git clone https://github.com/softwaresecured/JavaVulnerableLab.git
1719
cd JavaVulnerableLab
18-
docker-compose up
20+
vagrant up
1921
```
2022

21-
2. Using Vagrant to run this application in a VM (containers are launched inside it) :
23+
2. Using Docker to run on a machine :
2224

2325
```sh
2426
git clone https://github.com/softwaresecured/JavaVulnerableLab.git
2527
cd JavaVulnerableLab
26-
vagrant up
28+
docker-compose up -d javavulnlab mysql
2729
```
2830

2931
3. If not using Docker at all, you'll need to the JDBC URL in `config.properties` and `install.jsp` from :
3032

3133
```
32-
dburl=jdbc:mysql://mysql:3306/
33-
```
34-
35-
to this :
36-
37-
```
38-
jdbc:mysql://localhost:3306
34+
dburl=jdbc:mysql://mysql:3306/ => jdbc:mysql://localhost:3306
3935
```
4036

4137
4. If you want to play with it on a VPS, you'll need to the JDBC URL in `config.properties` and `install.jsp` from :
4238

4339
```
44-
dburl=jdbc:mysql://mysql:3306/
40+
dburl=jdbc:mysql://mysql:3306/ => jdbc:mysql://SERVER_HOSTNAME_OR_IP_ADDRESS:3306
4541
```
4642

47-
to this :
48-
49-
```
50-
jdbc:mysql://IP_ADDRESS:3306
51-
```
5243
And the link at next step will require the server hostname or IP address.
5344

5445
5. You already have a tomcat, and want to deploy the application with a war.
@@ -65,9 +56,11 @@ And the link at next step will require the server hostname or IP address.
6556

6657
2. And click on `Install` button, by leaving default values as-is.
6758

68-
## Vulnerabilties Metrics
59+
## Vulnerabilities Scan
6960

70-
OWASP comes with a Zed Attack Proxy (ZAP) tool to scan the vulnerabilities. We can use a ZAP Plugin for SonarQube 7.x to do just that. If you are interested in doing so, please refer to [this](./sonarqube/sonarqube.md)
61+
The Open Web Application Security Project (OWASP) team recommends many [tools](https://www.owasp.org/index.php/Appendix_A:_Testing_Tools) to address security matters.
62+
One of the most popular is the OWASP `Zed Attack Proxy` (**ZAP**) tool to scan the vulnerabilities. please refer to [this guideline](docs/owasp-zap.md).
63+
Also, if you need to automate everything in your Continuous Integration and Continuous Delivery (**CI/CD**) toolchain, you can go through this [this guideline](docs/sonarqube.md).
7164

7265
## Notes
7366

Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
3131
cd /vagrant
3232
/usr/local/bin/docker-compose down
3333
/usr/local/bin/docker-compose build
34-
/usr/local/bin/docker-compose up -d
34+
/usr/local/bin/docker-compose up -d javavulnlab mysql
3535
SHELL
3636

3737
end

docker-compose.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ mysql:
1111
- 3306:3306
1212
environment:
1313
- MYSQL_ROOT_PASSWORD=root
14+
15+
sonarqube:
16+
build: ./sonarqube
17+
ports:
18+
- 9000:9000
19+
- 9092:9092
400 KB
Loading

docs/owasp-zap.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# OWASP Zap Tool
2+
3+
The Open Web Application Security Project (OWASP) provides a security tool, called `Zed Attack Proxy` (**ZAP**) to scan the vulnerabilities.
4+
OWASP ZAP is one of the most popular security tools and is actively maintained. It comes with a UI and it allows to launch an automated scan against a URL of a web application - for example [http://localhost:8080](http://localhost:8080).
5+
6+
![Alt Text](assets/owasp-zap-2.8.0-screenshot.png)
7+
8+
You may download it [here](https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project).
9+
10+
But in the software industry, we may want to automate to this inside the Continuous Integration and Continuous Delivery (**CI/CD**) toolchain. Generally, SonarQube is used to gather metrics related to the software quality and vulnerabilities.
11+
12+
13+
Here, we can use a[ ZAP Plugin](https://github.com/Coveros/zap-sonar-plugin) for SonarQube 7.x to do just that. If you are interested in doing so, please refer to [this guideline](sonarqube.md).
14+

sonarqube/sonarqube.md renamed to docs/sonarqube.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ We can use a plugin that has been developed by Gene Gotimer ([zap-sonar-plugin](
3434

3535
## SonarQube instance
3636

37-
In order to be able to scan the code for vulnerabilities as well as for code qualimetry (coverage, duplication...), we need a running instance of SonarQube. Here we are using Docker to provide that instance, and by the way we do have to create a Dockerfile adding the Zap-Proxy plugin jar on top of SonarQube docker image `sonarqube:lts`. The Current LTS version is 7.9.
37+
In order to be able to scan the code for vulnerabilities as well as for code qualimetry (coverage, duplication...), we need a running instance of SonarQube.
38+
Here we can use Docker to provide that instance. It's the simpliest way. The sonarqube/Dockerfile is doing the job for you. Within the Dockerfile, the Zap-Proxy plugin jar is added. As per the time this is written, that plugin requires the current LTS version is 7.9 of SonarQube.
39+
40+
You may run the below commands on the machine (Vagrant VM, or VPS, local machine) :
41+
42+
```
43+
docker-compose build sonarqube
44+
docker-compose up -d sonarqube
45+
```
3846

3947
## Run a scan
4048

@@ -44,10 +52,10 @@ Run this command to analyse the codebase :
4452
mvn sonar:sonar
4553
```
4654

47-
It connected to the SonarQube server to retrieve informations, such as rules and plugins to apply while scanning the code.
55+
It connects to the SonarQube server to retrieve information, such as rules and plugins to apply while scanning the code.
4856

4957
## Quality Metrics
5058

5159
Once this is done, we can see the metrics on SonarQube [Dashboard](http://127.0.0.1:9000/project/issues?id=org.cysecurity%3AJavaVulnerableLab&resolved=false&sonarsourceSecurity=sql-injection&types=SECURITY_HOTSPOT)
5260

53-
![Alt Text](./Java-SonarQube-OWASP-Vulnerabilities.png)
61+
![Alt Text](assets/Java-SonarQube-OWASP-Vulnerabilities.png)

0 commit comments

Comments
 (0)