DevSecOps Pipeline: ECS integrated Cost Optimized Deployment
Category
DevOps
Author
Stephen Fernandes || Siddha Mehta
Tags
cloud, aws, Development

00:00 / 00:00

In the contemporary landscape of software development, the need in each stage of the development lifecycle of security emerges as an imperative. It necessitates a proactive approach, where the very foundation of software creation is fortified by the seamless integration of robust security measures right from its inception.

The seamless integration of security into the DevOps paradigm, known as DevSecOps, represents a pivotal shift towards proactive safeguarding within the software development lifecycle. Often dubbed as 'shifting left,' this approach advocates for the early adoption of security practices, ensuring that protective measures are woven into the fabric of development from its very outset. This not only fosters a culture of resilience but also empowers teams to fortify their creations against evolving threats, thereby nurturing a landscape where innovation thrives in harmony with security.

To integrate security in the software development lifecycle we have added different tools to perform Software Composition Analysis (SCA), Static Application Security Testing (SAST), and Dynamic Application Security Testing (DAST). For SCA we have utilized the Dependency Check tool which scans all the third-party packages that are being imported and used by the software for known vulnerabilities. For SAST, we have utilized the SonarQube tool which scans the code statically to find any visible secrets, vulnerable code, improper utilization of methods, and quality of the code. For DAST, we have utilized the OWASP ZAP tool to scan the deployed software by trying to assess the software against various inputs for vulnerabilities.

For creating the most important part, the CI-CD pipelines we are using Jenkins. The important part about using Jenkins is its support for different tools directly.

In this architecture, we have tried to uniquely integrate AWS ECS and EFS built with a multi-stage docker image to optimize our costs.

DevSecOps Pipeline Flow:

1. Code Push Trigger: A developer pushes code changes to the version control system (e.g., Git repository). This action triggers the DevSecOps pipeline to begin.

2. Jenkins Pipeline with ECS Plugin:

  • Jenkins, acting as the automation server, orchestrates the pipeline.
  • Upon triggering, Jenkins utilizes the built-in ECS (Elastic Container Service) plugin to manage the deployment of tasks within the ECS cluster. A new task is created inside the cluster every time the pipeline is run and destroyed at the end of the analysis.
  • This plugin allows Jenkins to interact directly with ECS, simplifying the process of task creation and management.

3. Execution of Security Checks:

Within the ECS task, a multi-stage Docker image is deployed. This Docker image contains the necessary tools and configurations to perform security checks, such as Dependency Check and SonarQube analysis.

4. Dependency-Check:

  • Dependency-Check scans the third-party packages used in the software.
  • It compares these packages against a reference database stored in Amazon EFS (Elastic File System), ensuring the detection of any known vulnerabilities.
  • By leveraging EFS, Dependency Check has access to the latest vulnerability data, enhancing the accuracy of the scan.

5. SonarQube Analysis:

SonarQube conducts static code analysis to identify security vulnerabilities, code quality issues, and other potential risks.

6. Post-Analysis Decision:

Quality Gate: Following SonarQube analysis, a quality gate is applied. If the code meets predefined quality criteria, it proceeds to the next stage. If not, appropriate actions are taken, such as halting deployment until issues are addressed.

SonarQube Results:

  • If the code passes the SonarQube checks, indicating that it meets predefined security and quality standards, the pipeline proceeds to the deployment stage.
  • If the code fails the SonarQube checks, indicating the presence of security vulnerabilities or code quality issues, appropriate actions are taken. This may include notifying the development team, halting the deployment process, or triggering remediation tasks to address the identified issues.

7. Deployment Stage:

  • Assuming all security checks have passed satisfactorily, Jenkins proceeds with the deployment of the code to the target environment.
  • By deploying only, the code that has passed rigorous security checks, the deployment stage ensures that only clean and secure code is deployed for further testing.

8. OWASP Scan Post-Deployment:

OWASP ZAP Scan: After deployment, an OWASP ZAP scan is initiated to conduct dynamic application security testing. OWASP ZAP simulates real-world attack scenarios by probing the deployed software for vulnerabilities such as missing http headers, cross-site scripting, SQL injection and many more.

Leveraging Jenkins, ECS, and EFS for Enhanced Security:

  1. Jenkins: As the backbone of our DevSecOps pipeline, Jenkins provides powerful automation capabilities, enabling seamless integration and orchestration of security checks.
  2. Amazon ECS: By utilizing ECS, we leverage the scalability and flexibility of containerized environments, ensuring consistent execution of security checks across different stages of the pipeline.
  3. Amazon EFS: EFS serves as the repository for our reference database used by Dependency Check. With EFS, we ensure that Dependency Check has access to the latest information on known vulnerabilities, enhancing the accuracy of our security scans.

Benefits of DevSecOps Pipeline:

Implementing a DevSecOps pipeline offers numerous benefits

  • Early Detection of Vulnerabilities: By integrating security checks early in the development process, vulnerabilities are identified and addressed sooner, reducing the risk of security breaches in production.
  • Automated Security: Automation streamlines security processes, reducing the burden of manual effort and ensuring consistent application of security practices across the development lifecycle.
  • Enhanced Collaboration: DevSecOps encourages collaboration between development, operations, and security teams, fostering a culture of shared responsibility for security.

Conclusion:

In conclusion, our DevSecOps pipeline, powered by Jenkins and seamlessly integrated with Amazon ECS and EFS, exemplifies a proactive approach to software development. By prioritizing security from the outset and leveraging scalable and efficient infrastructure, we enhance the resilience and integrity of our software while maintaining agility in the development process. As organizations navigate the complex landscape of software development, embracing DevSecOps principles and leveraging modern technologies will be crucial in safeguarding against emerging threats and delivering secure, high-quality software to users.