Vulnerability Static Analysis for Containers
Go to file
Jimmy Zelinskie 2f08cf52f6 Merge pull request #442 from arminc/add-integration-clari-scanner
Adding 'clair-scanner' cli tool as one of integration tools
2017-08-07 18:52:16 -04:00
api Merge pull request #408 from KeyboardNerd/grpc 2017-06-30 17:33:57 -04:00
cmd/clair api: v2 api with gRPC and gRPC-gateway 2017-06-13 15:58:10 -04:00
contrib/k8s Updated Kubernetes config with new db connection string config 2017-06-01 23:51:46 +01:00
database Add Debian Buster (10) and update "*stable" aliases 2017-06-19 07:54:51 -07:00
Documentation Fix the confusing text 2017-08-07 17:24:42 +02:00
ext Merge pull request #418 from KeyboardNerd/multiplens 2017-06-28 13:53:21 -04:00
pkg converted to structured logging by using logrus 2017-05-04 13:59:57 -04:00
testdata/DistUpgrade clair: move worker to top level package 2017-01-26 18:24:04 -05:00
vendor vendor: updated vendor dir for grpc v2 api 2017-06-13 15:58:11 -04:00
.dockerignore Initial commit 2015-11-13 14:11:28 -05:00
.travis.yml api: v2 api with gRPC and gRPC-gateway 2017-06-13 15:58:10 -04:00
bill-of-materials.json *: added bill-of-materials 2017-05-01 17:15:40 -04:00
config.example.yaml api: v2 api with gRPC and gRPC-gateway 2017-06-13 15:58:10 -04:00
CONTRIBUTING.md Initial commit 2015-11-13 14:11:28 -05:00
DCO Initial commit 2015-11-13 14:11:28 -05:00
docker-compose.yml *: move all references in README to HEAD 2017-03-15 16:05:31 -04:00
Dockerfile remove MAINTAINER from Dockerfile 2017-02-28 13:41:09 +08:00
glide.lock api: v2 api with gRPC and gRPC-gateway 2017-06-13 15:58:10 -04:00
glide.yaml api: v2 api with gRPC and gRPC-gateway 2017-06-13 15:58:10 -04:00
grafana.json prometheus: fix grafana's updater notes graph 2016-02-24 16:36:45 -05:00
LICENSE Initial commit 2015-11-13 14:11:28 -05:00
NOTICE Initial commit 2015-11-13 14:11:28 -05:00
notifier.go converted to structured logging by using logrus 2017-05-04 13:59:57 -04:00
README.md README: clean up after README refactor 2017-04-11 15:01:29 -04:00
ROADMAP.md ROADMAP: refresh with current priorities 2017-04-12 12:57:13 -04:00
updater_test.go clair: mv updater clair and mv severity to db 2017-01-22 23:20:56 -05:00
updater.go updater: sleep before continuing the lock loop 2017-06-28 17:13:27 -04:00
worker_test.go featurefmt: use namespace's versionfmt to specify listers 2017-06-22 15:36:07 -04:00
worker.go featurefmt: use namespace's versionfmt to specify listers 2017-06-22 15:36:07 -04:00

Clair

Build Status Docker Repository on Quay Go Report Card GoDoc IRC Channel

Note: The master branch may be in an unstable or even broken state during development. Please use releases instead of the master branch in order to get stable binaries.

Clair Logo

Clair is an open source project for the static analysis of vulnerabilities in application containers (currently including appc and docker).

  1. In regular intervals, Clair ingests vulnerability metadata from a configured set of sources and stores it in the database.
  2. Clients use the Clair API to index their container images; this parses a list of installed source packages and stores them in the database.
  3. Clients use the Clair API to query the database; correlating data is done in real time, rather than a cached result that needs re-scanning.
  4. When updates to vulnerability metadata occur, a webhook containg the affected images can be configured to page or block deployments.

Our goal is to enable a more transparent view of the security of container-based infrastructure. Thus, the project was named Clair after the French term which translates to clear, bright, transparent.

When would I use Clair?

  • You've found an image by searching the internet and want to determine if it's safe enough for you to use in production.
  • You're regularly deploying into a containerized production environment and want operations to alert or block deployments on insecure software.

Documentation

Deploying Clair

Container Repositories

Clair is officially packaged and released as a container.

Commercially Supported

Clair is professionally supported as a data source for the Quay Security Scanning feature. The setup documentation for using Clair for this environment can be found on the Quay documentation on the CoreOS website. Be sure to adjust the version of the documentation to the version of Quay being used in your deployment.

Community Supported

NOTE: These instructions demonstrate running HEAD and not stable versions.

The following are community supported instructions to run Clair in a variety of ways. A database instance is required for all instructions.

Clair currently supports and tests against:

Kubernetes

If you don't have a local Kubernetes cluster already, check out minikube.

git clone https://github.com/coreos/clair
cd clair/contrib/k8s
kubectl create secret generic clairsecret --from-file=./config.yaml
kubectl create -f clair-kubernetes.yaml

Docker Compose

$ curl -L https://raw.githubusercontent.com/coreos/clair/master/docker-compose.yml -o $HOME/docker-compose.yml
$ mkdir $HOME/clair_config
$ curl -L https://raw.githubusercontent.com/coreos/clair/master/config.example.yaml -o $HOME/clair_config/config.yaml
$ $EDITOR $HOME/clair_config/config.yaml # Edit database source to be postgresql://postgres:password@postgres:5432?sslmode=disable
$ docker-compose -f $HOME/docker-compose.yml up -d

Docker Compose may start Clair before Postgres which will raise an error. If this error is raised, manually execute docker-compose start clair.

Docker

$ mkdir $PWD/clair_config
$ curl -L https://raw.githubusercontent.com/coreos/clair/master/config.example.yaml -o $PWD/clair_config/config.yaml
$ docker run -d -e POSTGRES_PASSWORD="" -p 5432:5432 postgres:9.6
$ docker run -d -p 6060-6061:6060-6061 -v $PWD/clair_config:/config quay.io/coreos/clair-git:latest -config=/config/config.yaml

Source

To build Clair, you need to latest stable version of Go and a working Go environment. In addition, Clair requires some additional binaries be installed on the system $PATH as runtime dependencies:

$ go get github.com/coreos/clair
$ go install github.com/coreos/clair/cmd/clair
$ $EDITOR config.yaml # Add the URI for your postgres database
$ ./$GOPATH/bin/clair -config=config.yaml

Frequently Asked Questions

Who's using Clair?

You can find production users and third party integrations documented in their respective pages of the local documentation.

What do you mean by static analysis?

There are two major ways to perform analysis of programs: Static Analysis and Dynamic Analysis. Clair has been designed to perform static analysis; containers never need to be executed. Rather, the filesystem of the container image is inspected and features are indexed into a database. By indexing the features of an image into the database, images only need to be rescanned when new detectors are added.

What data sources does Clair currently support?

Data Source Data Collected Format License
Debian Security Bug Tracker Debian 6, 7, 8, unstable namespaces dpkg Debian
Ubuntu CVE Tracker Ubuntu 12.04, 12.10, 13.04, 14.04, 14.10, 15.04, 15.10, 16.04 namespaces dpkg GPLv2
Red Hat Security Data CentOS 5, 6, 7 namespaces rpm CVRF
Oracle Linux Security Data Oracle Linux 5, 6, 7 namespaces rpm CVRF
Alpine SecDB Alpine 3.3, Alpine 3.4, Alpine 3.5 namespaces apk MIT
NIST NVD Generic Vulnerability Metadata N/A Public Domain

What do most deployments look like?

From a high-level, most deployments integrate with the registry workflow rather than manual API usage by a human. They typically take up a form similar to the following diagram:

Simple Clair Diagram

I just started up Clair and nothing appears to be working, what's the deal?

During the first run, Clair will bootstrap its database with vulnerability data from the configured data sources. It can take several minutes before the database has been fully populated, but once this data is stored in the database, subsequent updates will take far less time.

What terminology do I need to understand to work with Clair internals?

  • Image - a tarball of the contents of a container
  • Layer - an appc or Docker image that may or may not be dependent on another image
  • Feature - anything that when present could be an indication of a vulnerability (e.g. the presence of a file or an installed software package)
  • Feature Namespace - a context around features and vulnerabilities (e.g. an operating system)
  • Vulnerability Updater - a Go package that tracks upstream vulnerability data and imports them into Clair
  • Vulnerability Metadata Appender - a Go package that tracks upstream vulnerability metadata and appends them into vulnerabilities managed by Clair

How can I customize Clair?

The major components of Clair are all programmatically extensible in the same way Go's standard database/sql package is extensible. Everything extensible is located in the ext directory.

Custom behavior can be accomplished by creating a package that contains a type that implements an interface declared in Clair and registering that interface in init(). To expose the new behavior, unqualified imports to the package must be added in your own custom main.go, which should then start Clair using Boot(*config.Config).

Are there any public presentations on Clair?

  • Clair: The Container Image Security Analyzer @ ContainerDays Boston 2016 - Event Video Slides
  • Identifying Common Vulnerabilities and Exposures in Containers with Clair @ CoreOS Fest 2016 - Event Video Slides
  • Clair: A Container Image Security Analyzer @ Microservices NYC - Event Video Slides
  • Clair: A Container Image Security Analyzer @ Container Orchestration NYC - Event Video Slides