Sign inSign up

crashbar/trivy-exporter

By crashbar

•Updated 11 months ago

Trivy exporter for Prometheus

Image
Networking
Security
API management
0

367

crashbar/trivy-exporter repository overview

⁠🐳 Trivy Exporter

This exporter is built on Python and uses Trivy as an entry point for Prometheus metrics.
It is suitable for scanning local Docker images (used in compose files or a Swarm cluster) as well as the host's local file system.

P.S. Please don't judge harshly — this is my first published image!


⁠⚠️ Warning:

The first scan will start only after you access the entry point.


⁠Features

  • Scans local Docker images for vulnerabilities.
  • Outputs results as Prometheus metrics.
  • Provides an overall summary of vulnerabilities by package.
  • Provides detailed descriptions of vulnerabilities by package.
  • Ideal for building Grafana dashboards to monitor image security.

⁠⚙️ Endpoints

  1. Overall vulnerabilities summary:
    http://<your_ip_or_localhost>:7175/metrics

  2. Detailed vulnerabilities by package:
    http://<your_ip_or_localhost>:7175/details


⁠How to run

⁠Using docker run:
docker run --rm \
  --name trivy-exporter \
  -p 7175:7175 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  crashbar/trivy-exporter:latest
⁠Using docker-compose.yml:
services:
  trivy-exporter:
    image: crashbar/trivy-exporter:latest
    container_name: trivy-exporter
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "7175:7175"
⁠Example output metrics (curl 127.0.0.1:7175/metrics)
# HELP trivy_vulnerabilities Detailed vulnerabilities by image, package and severity
# TYPE trivy_vulnerabilities gauge
trivy_vulnerabilities{image="trivy-trivy:latest",package="apt",installed="3.0.3",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="apt-transport-https",installed="3.0.3",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="bash",installed="5.2.37-2+b5",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="bash-completion",installed="1:2.16.0-7",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="bsdutils",installed="1:2.41-5",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="coreutils",installed="9.7-3",fixed="",severity="LOW"} 2
trivy_vulnerabilities{image="trivy-trivy:latest",package="curl",installed="8.14.1-2",fixed="",severity="MEDIUM"} 2
trivy_vulnerabilities{image="trivy-trivy:latest",package="dirmngr",installed="2.4.7-21+b3",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="docker-cli",installed="26.1.5+dfsg1-9+b9",fixed="",severity="MEDIUM"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="docker.io",installed="26.1.5+dfsg1-9+b9",fixed="",severity="MEDIUM"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="git",installed="1:2.47.3-0+deb13u1",fixed="",severity="LOW"} 3
trivy_vulnerabilities{image="trivy-trivy:latest",package="git-man",installed="1:2.47.3-0+deb13u1",fixed="",severity="LOW"} 3
trivy_vulnerabilities{image="trivy-trivy:latest",package="gnupg",installed="2.4.7-21",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="gnupg-l10n",installed="2.4.7-21",fixed="",severity="LOW"} 1
trivy_vulnerabilities{image="trivy-trivy:latest",package="gnupg-utils",installed="2.4.7-21+b3",fixed="",severity="LOW"} 1
⁠Example output details (curl -H "Accept: application/json" 127.0.0.1:7175/details | jq .)
"trivy-trivy:latest": {
    "timestamp": "",
    "vulnerabilities": [
      {
        "fixed": "",
        "id": "CVE-2011-3374",
        "installed": "3.0.3",
        "pkg": "apt",
        "severity": "LOW",
        "title": "It was found that apt-key in apt, all versions, do not correctly valid ...",
        "url": "https://avd.aquasec.com/nvd/cve-2011-3374"
      },
      {
        "fixed": "",
        "id": "CVE-2011-3374",
        "installed": "3.0.3",
        "pkg": "apt-transport-https",
        "severity": "LOW",
        "title": "It was found that apt-key in apt, all versions, do not correctly valid ...",
        "url": "https://avd.aquasec.com/nvd/cve-2011-3374"
      },
      {
        "fixed": "",
        "id": "TEMP-0841856-B18BAF",
        "installed": "5.2.37-2+b5",
        "pkg": "bash",
        "severity": "LOW",
        "title": "[Privilege escalation possible to other user than root]",
        "url": "https://security-tracker.debian.org/tracker/TEMP-0841856-B18BAF"
      },

Tag summary

Content type

Image

Digest

sha256:c84373f18…

Size

327.3 MB

Last updated

11 months ago

docker pull crashbar/trivy-exporter