DevSecOps pipeline using GitLab CI/CD, integrating security practices and compliance checks at each stage of the pipeline. It builds, tests, and deploys a sample web application, incorporating automated security scanning and compliance checking.
- GitLab
- Docker
- Terraform
- OpenSCAP
- HashiCorp Vault
- OWASP ZAP
- SonarQube
- Safety (Python dependency scanner)
- Prometheus
- Grafana
app/
: Contains the source code and Dockerfile for the sample web applicationterraform/
: Contains Terraform configuration files for provisioning infrastructure resourcesopenscap/
: Contains scripts and configuration files related to OpenSCAP security scanningmonitoring/
: Contains monitoring configurations, such as Prometheus configuration files.gitignore
: A file specifying files and directories that should be ignored by Git.gitlab-ci.yml
: Defines the GitLab CI/CD pipeline configurationREADME.md
: This file, which provides an overview of the project and instructions for getting started
- The GitLab CI/CD pipeline is triggered on code push or merge request.
- The pipeline builds the Docker image for the web application using the Dockerfile in the
app/
directory. - The pipeline runs OpenSCAP security scanning on the Docker image using the
openscap/dockerfile_scan.sh
script. The pipeline will fail if any high-risk vulnerabilities or non-compliant configurations are detected. - The pipeline runs static application security testing (SAST) using SonarQube to scan the source code for vulnerabilities.
- The pipeline performs automated dependency scanning using Safety to identify vulnerabilities in the application's dependencies and libraries.
- The pipeline provisions infrastructure resources using Terraform, based on the configuration files in the
terraform/
directory. - The pipeline deploys the Docker container to the created infrastructure.
- HashiCorp Vault is used to securely store and manage sensitive information, such as API keys, database credentials, and SSL certificates. The pipeline integrates with Vault to access these secrets as needed.
- The pipeline runs dynamic application security testing (DAST) using OWASP ZAP to scan the web application for security vulnerabilities during runtime.
- Monitoring and alerting are set up using Prometheus and Grafana to notify of security events and vulnerabilities detected during the pipeline's execution or in the deployed application.
- A rollback mechanism is implemented in the pipeline to revert the infrastructure state in case of deployment failures or critical security vulnerabilities.
- Clone the repository
- Set up a GitLab project and configure the necessary environment variables for GitLab CI/CD, such as Docker registry credentials, Terraform backend configuration, and HashiCorp Vault access tokens.
- Make changes to the Terraform configuration files in the
terraform/
directory as needed, based on your infrastructure requirements. - Configure the OpenSCAP scanning policy in the
openscap/
directory. - Set up a SonarQube server and configure a project for your application.
- Deploy and configure Prometheus and Grafana for monitoring and alerting.
- Push your changes to the GitLab project, which will trigger the CI/CD pipeline.
- Monitor the pipeline execution in GitLab and review the logs to ensure all stages are successful and that security scans and compliance checks are being performed as expected.
- Fork the project and create a new feature branch.
- Make changes or additions to the project files.
- Ensure that your changes are properly tested and documented.
- Create a merge request to the main repository for review.
This project is licensed under the MIT License. Please see the LICENSE file for more information.