Understanding the target architecture of the DevSecOps pipeline – Implementing DevSecOps with AWS
- Blog
- Understanding the target architecture of the DevSecOps pipeline – Implementing DevSecOps with AWS
A pipeline definition in AWS CodePipeline consists of at least two stages, and corresponding actions within each stage. We covered the constructs of AWS CodePipeline in detail in Chapter 5, Rolling Out a CI/CD Pipeline. Typical stages that come to our mind when we think of the entire life cycle of software delivery are source, build, test, and deploy. In the exercise that follows, we will mainly focus on the first two stages and understand how DevSecOps practices could be introduced in a Docker image delivery workflow, as an example.
We developed and deployed a Python-based To-Do list manager application in the previous chapters. We will reuse the application code and respective Docker manifest file. Our main focus will be on introducing security assessments that can be integrated into the build phase of this application, leading to the creation of a secure Docker image. Figure 9.2 highlights the different types of security scans we will run:
Figure 9.2 – Different stages of the DevSecOps pipeline
Let’s begin by outlining the steps that are executed in each stage of the pipeline:
I. Software Composition Analysis (SCA): This is a CodePipeline action withinthe application validation stage. We leverage CodeBuild to provide a temporary compute environment that can be used to install the Dependency-Check utility from OWASP. Post installation, we validate the Python code dependencies defined in the requirements.txt file. If you have not worked with Python before, the requirements.txt file lists all the dependencies – that is, the libraries and packages used by a Python project.
Dependency-check is an SCA tool that works with various programming languages and detects publicly disclosed vulnerabilities of the project dependencies. This is achieved by assessing the presence of a Common Platform Enumeration (CPE) identifier for a specified dependency. In the event of discovery, a comprehensive report will be generated, containing links to the corresponding CVE entries.
II. Static Application Security Testing (SAST): In this CodePipeline action, we use the Bandit utility, which scans Python code to bring security issues to the surface. Bandit creates an abstract syntax tree (AST) from all the Python code files it scans and then runs security validation plugins against this AST. The output is a report that highlights security issues, along with the suggested actions for the developers.
For Dockerfile linting and security analysis, we make use of hadolint. In addition to providing basic linting capabilities, hadolint also allows security professionals to enforce certain things. For example, you can define the trusted registries these Dockerfiles can be based on or suppress false positives. All validations from hadolint can be accessed at https://github.com/ hadolint/hadolint#rules.
The workflow we are deploying can be easily extended with specific deployment actions for any other software. In the ideal scenario, you would have additional stages that consume the artifacts (Docker images) from this pipeline and deploy them onto an environment that supports running Docker containers, such as Elastic Container Service (ECS) or Elastic Kubernetes Service (EKS).
Having understood the overall flow and what we are trying to achieve with the DevSecOps pipeline, let’s outline the two components of the code base that we will be working with.
© Copyright 2024 morningfun.org