"DevSecOps" Enhance Docker Security: Vulnerability Scanning with Trivy

AtharvaAtharva
2 min read

Introduction

Containerization has revolutionized software development and deployment, offering numerous benefits like portability,scalability, and efficiency. However, the rapid adoption of containers has also introduced new security challenges.

Trivy is a powerful and versatile open-source vulnerability scanner designed to identify security vulnerabilities in various artifacts, including:

Container images

Filesystems

Git repositories

Kubernetes clusters

Cloud environments

Common types of vulnerabilities in Docker images

1. Base Image Vulnerabilities

2. Package Vulnerabilities

3. Configuration Issues

4. Supply Chain Attacks.

5. Runtime Vulnerabilities

6. Secret Management Issues

7. Application Vulnerabilities

Trivy: A Comprehensive Security Scanner

Trivy is an open-source vulnerability scanner designed to identify security vulnerabilities in various artifacts,Key features of Trivy

Installing and Setting Up Trivy

Trivy supports a wide range of operating systems, including:

  • Linux distributions: Debian, Ubuntu, CentOS, RHEL, Fedora, SUSE, Alpine, and many more.

  • macOS

  • Windows (with some limitations)

Here we will be giving Quick Look at installation and use case scenario of trivy scanner on the ubuntu operating system.

1. For installing trivy scanner tool on ubuntu machine

sudo apt-get install wget apt-transport-https gnupg

2. The following command ensures that your system trusts packages from the Trivy repository. Here's why it's important

3. By using following command we are ensuring that it adds trivy repository to the package manager like (apt).

echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee -a /etc/apt/sources.list.d/trivy.list

In essence, this command allows your package manager to find and securely install Trivy packages when you use commands like sudo apt install trivy.

4. After that we need to update our system once

sudo apt-get update

5.Installing trivy from the repository that we have configured earlier .

sudo apt-get install trivy

6. you can use help command to get additional info about trivy and its usecases.

trivy --help

7. the basic vulnerability check of docker images can be done by trivy as follows...

trivy image <image_name>

eg.

trivy image docker.io/httpd

8. Outputs like below explaining the severity of the vulnerabilities in the docker images are displayed by the trivy scanner tool.

Conclusion:

Trivy is your security guard for code. It quickly checks your images for vulnerabilities, helping you plug security holes before problems arise. By making it part of your development process, you can release software with confidence,knowing it's protected.

1
Subscribe to my newsletter

Read articles from Atharva directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Atharva
Atharva