Highly Recommend using repo here -Day12 to practise this project instead of code snippets, In case of confusion, Please do watch video that is explained in English, the code here in the blog is not changed to keep screenshots intact
SonarQube
SonarQube is a code coverage tool, that ensures code is easily readable, avoided duplicate lines of code, code coverage, Bugs, Quality gates and lot more.
Since SonarQube is more for Developers as checks are based on completely code level. But as a DevOps it becomes our part to configure SonarQube
SonarQube uses Sonar-Scanner tool to fetch the data from the code and update the data in database, in case there is no database, sonar uses local H2 database(not recommended)
If we need to install SonarQube manually, we need to install Java, SonarQube , and for Database postgres or any DB
But as an alternative, we can use DockerImage of SonarQUbe which makes our job lot easier
Since i have found a blog where SonarQube is configured inside Jenkins and its easy to understand, and not to infringe the data, please do navigate from link below and follow the steps
Though the blog was done for localhost, we have configured by taking sonarqube in different sever and docker was installed before following the Blog
Trivy
sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
trivy image sagarkakkala385/react-nginx
trivy image --severity HIGH,CRITICAL <image_name>
To get output in json format
trivy image --format json --output report.json sagarkakkala385/react-nginx
To Scan repo
trivy repo https://github.com/Hari0o/Gold_Site_Ecommerce.git
Post Configuring SonarQube and Trivy you can see the pattern followed will be this way
Code > Scan Using SonarQube (if passed , next stage ; if failed, developers need to fix code ) > Build code and create image > Image Scanned by Trivy (if no vulnerabilities, next stage'; if there are vulnerabilities, DevOps need to fix) > Deployment stage steps
Now our architecture looks somewhat this way
Comments
Post a Comment