Sitemap
Blogs4devs

Blogs4devs

Welcome to our Medium page, where we dive deep into the world of technology! Here, we explore the latest trends, innovations, and best practices.

Management Tool

For the second part of our DevSecOps series, we’ll dive into the crucial role of management tools in streamlining security practices. As teams implement various security measures like DAST, SAST, SCA, and pre-commit hooks, it becomes increasingly important to have a centralized platform to manage and analyze the flood of reports these tools generate and to aggregate all test reports in one place to facilitate result visualization.

Solution 1: Artifacts

A first solution involves generating reports for the tests and storing them as artifacts.

For SAST: SonarCloud generates a report and stores it in the .scannerwork directory.

For SCA: we just need to add — json with the location where we want to store the report.

Press enter or click to view image in full size

Automatically, when Snyk detects vulnerabilities of type “high,” it generates an error, and the pipeline stops. To prevent this, we add “|| true.”

For Container Security: Snyk offers the possibility to generate a report by adding the option — json-file-output with the location where we want to store the report.

Press enter or click to view image in full size

For DAST: OWASP ZAP offers the possibility to generate a report by adding the option -J with the location where we want to store the report.

Press enter or click to view image in full size

Now, we execute the pipeline.

Press enter or click to view image in full size
Press enter or click to view image in full size

The pipeline ran smoothly.

Press enter or click to view image in full size
Press enter or click to view image in full size

In the “Artifacts” section, we notice that all reports are grouped. We can then download them simply by clicking on the artifact and view them.

Reports

For SAST: SonarCloud generates a report that includes a link to the interface.

Press enter or click to view image in full size
Press enter or click to view image in full size

For SCA: Snyk generates a detailed analysis report.

Press enter or click to view image in full size

For Container Security:

Press enter or click to view image in full size

For DAST: OWASP ZAP generates two files: a .json file containing the analysis result in JSON format and another .html file allowing us to visualize the result in an interface for easier reading.

Press enter or click to view image in full size
Press enter or click to view image in full size

Solution 2: DEFECT DOJO

The second solution involves using a tool that automatically retrieves artifacts from the pipeline output and stores them. This eliminates the need for manual downloading.

Get Blogs4devs’s stories in your inbox

Join Medium for free to get updates from this writer.

For this part, we will use DEFECT DOJO.

First, we installe a Docker image of the tool following the instructions provided in the documentation.

Press enter or click to view image in full size

We start the container from the installed image.

Press enter or click to view image in full size

This allows us to access the DEFECT DOJO interface.

Press enter or click to view image in full size

Now, in the pipeline, we add a step at the end of each test job to send the report to this DEFECT DOJO instance. To do this, we need to expose the instance via the Internet. For this purpose, we will use the “Ngrok” tool, which generates a free and secure domain to expose local servers.

First, we need to create an account with Ngrok, then take the generated token. Then, start the tool, giving it the port of DEFECT DOJO, which is 8080.

Press enter or click to view image in full size
Press enter or click to view image in full size

We create a product in DEFECT DOJO via the interface.

Press enter or click to view image in full size

Then we create an engagement.

Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

The engagement ID is 7. We generate a token via the interface and add it to the GitHub repository’s secrets.

Press enter or click to view image in full size

Now, we need to add the step that will take the report and send it to DEFECT DOJO at the end of each test:

We specify the Engagement ID (7), the scan type (SonarQube Scan or Snyk Scan or ZAP Scan), the location of the report, and other properties, as indicated in the documentation.

For SAST:

Press enter or click to view image in full size

For SCA:

Press enter or click to view image in full size

For Container Security:

Press enter or click to view image in full size

For DAST:

Press enter or click to view image in full size

Now, we execute the pipeline.

Press enter or click to view image in full size
Press enter or click to view image in full size

We can see that the reports are added successfully.

Press enter or click to view image in full size

Wrap up

The pipeline starts when a push is made to the main branch and only when changes are made to specified files in the “angular-16-crud-example-master” directory, except for README files.

The pipeline includes several steps, including static security analysis (SAST) with SonarCloud, dependency analysis with Snyk (SCA), building a Docker image, dynamic security analysis (DAST) with OWASP ZAP, and finally deploying changes to a Kubernetes cluster.

Reports generated by SonarCloud, Snyk SCA, OWASP ZAP, as well as information about Docker image building, are downloaded as artifacts and shared with DefectDojo for vulnerability management.

The pipeline ends with updating Kubernetes deployment configuration files with the newly built Docker image version. These changes are then pushed to the remote Git repository.

Press enter or click to view image in full size

After each security analysis, the pipeline can be configured to check the number of detected vulnerabilities. If a fixed threshold is exceeded, rules can be applied to stop the pipeline. This ensures that vulnerabilities are addressed before deploying the application to production.

That concludes this blog. See you in the next one! 👍

--

--