Giter VIP home page Giter VIP logo

trivy-offline's Introduction

Trivy Offline

Build Status

This project aims to solve an issue while using trivy at scale. In an environment where you need to scan hundreds or even thousands of container images with trivy, you can hit a GitHub limit while downloading the vulnerability database.

Inspiration

This project was inspired by the arminc/clair-db container image, and github.com/arminc/clair-local-scan project witch speeds up clair vulnerability scans.

What we do

We build and publish a new container image every day following trivy documentation to download and use the vulnerability database just once. The process was designed to be used in the air-gapped environment. Still, it fits perfectly while running this software on CI systems like drone, gitlab, github-actions, circle-ci, or travis.

We publish two different tags every day:

Quick Start

# Don't forget to pull before running
$ docker pull quay.io/sighup/trivy-offline
$ docker run --rm quay.io/sighup/trivy-offline [YOUR_IMAGE_NAME]
# or
$ docker run --rm quay.io/sighup/trivy-offline:$(date +%Y-%m-%d) [YOUR_IMAGE_NAME]

If you would like to scan the image on your host machine, you need to mount docker.sock.

# Don't forget to pull before run
$ docker pull quay.io/sighup/trivy-offline
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
    quay.io/sighup/trivy-offline python:3.4-alpine
# or
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
    quay.io/sighup/trivy-offline:$(date +%Y-%m-%d) python:3.4-alpine

Please re-pull latest quay.io/sighup/trivy-offline if an error occurred.

CI Example - drone ci

You can scan your container images (or anyone public available) on drone ci. See an example below:

---
kind: pipeline
name: example

steps:
  - name: scan
    image: quay.io/sighup/trivy-offline:latest
    pull: always
    commands:
      - trivy image --skip-update python:3.4-alpine

CI Example - gitlab ci

You can include gitlab.yml in your .gitlab-ci.yml.

Here trivy is defined as a hidden job so it can be extended in any job in any stage any number of times in the same pipeline.

You can scan your own public/private container images (or anyone public available) on gitlab ci.

By default CI_REGISTRY, CI_REGISTRY_USER & CI_REGISTRY_PASSWORD are used to fetch private docker image if TRIVY_AUTH_URL, TRIVY_USERNAME & TRIVY_PASSWORD variables are not defined.

In this example, by default trivy will scan the docker image (${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}) in the container registry of the repo for the branch pipeline is running for,

include:
  - remote: 'https://raw.githubusercontent.com/sighupio/trivy-offline/main/gitlab.yml'

trivy:
  extends: .trivy
  stage: scan

And, in this example we are passing the docker image manually.

trivy:
  extends: .trivy
  stage: scan
  script:
    - |
      # node:alpine...
      trivy image --skip-update node:alpine

CI Example - circle ci

You can scan your container images (or anyone public available) on circle ci. See an example below:

  test:
    docker:
      - image: quay.io/sighup/trivy-offline:latest
    steps:
      - run:
          name: Run Aquasec trivy scanner
          command: trivy image --exit-code 0 --format json --output trivy-container-scanning-report.json --no-progress --skip-update python:3.4-alpine
      - store_artifacts:
          path: trivy-container-scanning-report.json
          destination: trivy-container-scanning-report

trivy-offline's People

Contributors

angelbarrera92 avatar omissis avatar opencloudengineer avatar ralgozino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trivy-offline's Issues

Add more usage example: Azure Pipelines, Google Build...

Description

We want to see how you use this project in your CI pipelines. The scope of this issue is to have a clear example, (as it is already available for drone ci) that demonstrate how easy is to use this image in your CI system.

We already know some CI systems, but maybe yours is not listed in the repository.
If you are using Azure Pipelines, Google Build or any other CI system, please continue here!

Checklist

  • Add a new markdown section in the README.md file: CI Example - my-ci-system
  • Add a relative link from what-we-do section to the new CI Example - my-ci-system section.

Replace my-ci-system to your CI System name. Example: CI Example - Google Build

Final note

If you like this project, don't forget to Star ⭐ it!
Enjoy #Hacktoberfest2020!

Add gitlab-ci usage example

Description

We want to see how you use this project in your CI pipelines. The scope of this issue is to have a clear example, (as it is already available for drone ci) that demonstrate how easy is to use this image in this CI system.

Checklist

The CI target system here is Gitlab CI.

  • Add a new markdown section in the README.md file: CI Example - gitlab ci
  • Add a relative link from what-we-do section to the new CI Example - gitlab ci section.

Final note

If you like this project, don't forget to Star ⭐ it!
Enjoy #Hacktoberfest2020!

Add circle-ci usage example

Description

We want to see how you use this project in your CI pipelines. The scope of this issue is to have a clear example, (as it is already available for drone ci) that demonstrate how easy is to use this image in this CI system.

Checklist

The CI target system here is Circle CI.

  • Add a new markdown section in the README.md file: CI Example - circle ci
  • Add a relative link from what-we-do section to the new CI Example - circle ci section.

Final note

If you like this project, don't forget to Star ⭐ it!
Enjoy #Hacktoberfest2020!

upgrade to trivy 0.37 and include the Java Index Database

trivy 0.37 is out with a new feature (the Java Index Database) that should solve all problems related to JAR scanning and search.maven.org timeouts, cf aquasecurity/trivy#3518

It would be extremely useful (at least for me) to:

  • upgrade trivy to 0.37
  • include the Java Index Database (using --download-java-db-only and --skip-java-db-update) in the offline dbs.

I can do a PR if needed...

Add travis-ci usage example

Description

We want to see how you use this project in your CI pipelines. The scope of this issue is to have a clear example, (as it is already available for drone ci) that demonstrate how easy is to use this image in this CI system.

Checklist

The CI target system here is Travis CI.

  • Add a new markdown section in the README.md file: CI Example - travis ci
  • Add a relative link from what-we-do section to the new CI Example - travis ci section.

Final note

If you like this project, don't forget to Star ⭐ it!
Enjoy #Hacktoberfest2020!

cannot disable downloading the vunerabulity database in a disconnected environment

i am running our CI/CD system in a disconnected environment.

I used the trivy-offline image, where i run this command :

+ trivy image --exit-code 1 --input nexus-nexus-jd-snapshots-nodejs-sample-1-0-0-b5d0446

However, i got this error :

2021-01-19T12:13:38.148Z	INFO	Need to update DB

2021-01-19T12:13:38.148Z	INFO	Downloading DB...

2021-01-19T12:14:08.151Z	FATAL	failed to download vulnerability DB: failed to download vulnerability DB: failed to list releases: Get "https://api.github.com/repos/aquasecurity/trivy-db/releases": dial tcp 140.x.y.z:443: i/o timeout

script returned exit code 1

How can i disable downloading the DB

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.