Purpose of this repository to implement a simple example pipeline to demonstrate DevSecOps in practice.
Infrasructure made with Terraform and Amazon Web Services. The project will contains the following instances:
- Jenkins (with docker engine)
- Sonarqube
- ZAP
- Source Composition Analysis
- A sample application (Tomcat 'hello world' app)
- Terraform (https://learn.hashicorp.com/tutorials/terraform/install-cli)
- Amazon Web Services account (https://aws.amazon.com/resources/create-account/)
You can skip these steps if you have already configured Terraform with your AWS account on your machine.
- Setup Terraform on your machine: https://learn.hashicorp.com/tutorials/terraform/install-cli
- Add you AWS account following: https://learn.hashicorp.com/tutorials/terraform/aws-build
- Create AWS ssh key and add its name to the terraform/variables.tf "keyname" variable.
Starting infrastructure described in Terraform template will cost $0.05 per hour. SonarQube not able to run on t2.micro free tier eligible instance due to low resources. Every other components of the project is free tier eligible.
- After Terraform template applied, you can access created instances with the Terraform output information from the CLI:
- You can access SonarQube server with the DNS provided by Terraform output with the addition of port 9000 e.g. http://sonar-dns:9000. The default login and password is admin:admin.
- To generate a token, to go User > My Account > Security. Your existing tokens are listed here, each with a Revoke button.
The form at the bottom of the page allows you to generate new tokens. Once you click the Generate button, you will see the token value. Copy it immediately; once you dismiss the notification you will not be able to retrieve it. This token will be used in Jenkins.
- You can access Jenkins server server with the DNS provided by Terraform output with the addition of port 8080 e.g. http://jenkins-dns:8080
- When you accessed the Web UI, follow the instructions and chose "Install suggested plugins" option.
- At the home page of Jenkins go to "Manage Jenkins"-> "Manage Plugins". On the Available tab, search for "SSH Agent" and "SonarQube Scanner" plugins and install them without restart.
- In the credential store, add new credentials ("Manage Jenkins" -> "Manage Credentials").
- Add the ssh key into the credentials shown the picture below.
- Add the SonarQube access token key (created in SonarQube section) into the credentials shown the picture below.
- At the home page click on New item type your pipeline name e.g. "first-pipeline" and select Pipeline type for your item.
- In the Pipeline section select "Pipeline from SCM" from the Definition drop-down list and add your repository address, where your Jenkinsfile located. Click on save.
- At the "Manage Jenkins" -> "Configure System" scroll to the SonarQube servers section. Make sure, you checked "Environment variables". At the Server authentication token choose the previously added credentials.
- Jenkins setup guide with plugins and credentials (SSH Agent, SonarQube).
- Add SonarQube as Static Application Security Testing (SAST).
- SonarQube setup guide.
- SonarQube Quality Gate setups to break build if the code is vulnerable.
- Terraform modification for complete infrastructure (SG, Subnets etc.).
- Add Source Compositon Analysis (SCA) solution to the project.
- Add ZAP to the project as Dynamic Application Security Testing (DAST).
- Deployment to any container environment instead of a single Tomcat host.
- Container security solution integration in the pipeline.



