Giter VIP home page Giter VIP logo

trivitall's Introduction

Trivitall

This is a simple python script which gets a list of all docker swarm services and runs every container image found through Aquasecurity's excellent Trivy security scanner. Note: The script needs access to the docker socket, so make sure to scan through the code to make sure you trust it.

Usage

First off, build the image that will run the script :

docker build -t trivitall:some-tag .

And on a swarm master run the image :

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock trivitall:some-tag

That should produce output like this for any images found to have critial security warnings :

Image nginx:latest has CRITICAL vulnarabilities. Used in service(s) {'my-web-app'}

Options

You can control the verbosity of the output and what security level you want to report on using environment variables :

docker run -e TRIV_VERBOSE=1 -e TRIV_LEVEL=MEDIUM,HIGH,CRITICAL --rm -v /var/run/docker.sock:/var/run/docker.sock trivitall:some-tag

The TRIV_LEVEL option can be any of UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL with the default being CRITICAL. The TRIV_VERBOSE option will give you a lot more output :

Scanning the following images : {'minio/minio:RELEASE.2019-08-21T19-40-07Z', 'nginx:latest'}
Image minio/minio:RELEASE.2019-08-21T19-40-07Z has no vulnarabilties
Image nginx:latest has CRITICAL vulnarabilities. Used in service(s) {'freddy'}
###### Output from trivy scan of nginx:latest ######
b"2020-03-14T15:22:24.109Z\t\x1b[33mWARN\x1b[0m\tYou should avoid using the :latest tag as it is cached. You need to specify '--clear-cache' option when :latest image is changed"
b'2020-03-14T15:22:30.957Z\t\x1b[34mINFO\x1b[0m\tDetecting Debian vulnerabilities...'
b''
b'nginx:latest (debian 10.1)'
b'=========================='
b'Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 2)'
b''
b'+-----------------+------------------+----------+-------------------+---------------+--------------------------------+'
b'|     LIBRARY     | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION |             TITLE              |'
b'+-----------------+------------------+----------+-------------------+---------------+--------------------------------+'
b'| libjpeg62-turbo | CVE-2019-2201    | CRITICAL | 1:1.5.2-2         |               | libjpeg-turbo: several integer |'
b'|                 |                  |          |                   |               | overflows and subsequent       |'
b'|                 |                  |          |                   |               | segfaults when attempting      |'
b'|                 |                  |          |                   |               | to compress/decompress         |'
b'|                 |                  |          |                   |               | gigapixel...                   |'
b'+-----------------+------------------+          +-------------------+---------------+--------------------------------+'
b'| tar             | CVE-2005-2541    |          | 1.30+dfsg-6       |               | Tar 1.15.1 does not properly   |'
b'|                 |                  |          |                   |               | warn the user when extracting  |'
b'|                 |                  |          |                   |               | setuid or...                   |'
b'+-----------------+------------------+----------+-------------------+---------------+--------------------------------+'
###### End of output from trivy scan of nginx:latest ######

Exit codes

The script will exit with 0 if there were no issues found, 1 if there were any and 2 if something unexpected happened.

trivitall's People

Contributors

ohnotnow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.