Skip to main content

Push and Analyse containers with Clair

Project description

Paclair is a Python3 Cli tool to interact with Coreos’s Clair.

Features:

  • Now compatible with Clair V3 (delete is not available)

  • No need to have docker installed since Paclair interacts directly with the registries.

  • Compatible with all registries.

  • Simple to use.

  • Easy integration in a CI job thanks to a lightweight output mode.

Installation

To install Paclair, simply use pip (or pipenv):

$ pip install paclair
✨🍰✨

Voilà!

Configuration

Example

An example configuration file is available in the conf directory

General:
  clair_url: 'https://localhost:6060'
  verify: "/etc/ssl/certs/my_custom_ca.crt"
Plugins:
  Docker:
    class: paclair.plugins.docker_plugin.DockerPlugin
    registries:
      registry.gitlab.domain.com:
        auth:
          - "*****"
          - "*****"
        verify: "/etc/ssl/certs/ca-certificates.crt"

Plugins are dynamically loaded during execution. That’s why you have to specify the class of the plugins you want to use.

We have various plugins to interact with different sources (ex: docker registry, Elasticsearch) because we use a custom variant of Clair which can analyse more than Docker images.

If you want to use Paclair only to analyse docker images, don’t bother with others plugins.

Options

Config Option

Description

General::clair_url

url of the Clair Server.

General::verify

Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use.

General::clair_api_version

Clair Api Version. If different from 3, will be set to default. Default to 1.

General::html_template

Html template. You can use a custom html template when using html output.

Plugins

List of plugins to use. If you only want to analyse docker images, keep the default configuration.

Plugins::Docker::class

Class for the docker plugin

Plugins::Docker::registries

You can specify configuration for registries (authentification, …) if needed.

Plugins::Docker::registries::regi stry1::auth

login/password

Plugins::Docker::registries::regi stry1::verify

Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use.

Plugins::Docker::registries::regi stry1::protocol

Protocol to use (http or https). Default to https.

Plugins::Docker::registries::token

You can specify an authentication token (use with token_type). Default to None.

Plugins::Docker::registries::token _type

Specify the token type. Default to Bearer.

Running the tests

Launch tox.

$ tox

Usage

usage: paclair [-h] [--debug] [--syslog] [--conf CONF]
               plugin hosts [hosts ...] {push,delete,analyse} ...

positional arguments:
  plugin                Plugin to launch
  hosts                 Image/hostname to analyse
  {push,delete,analyse}
                        Command to launch
    push                Push images/hosts to Clair
    delete              Delete images/hosts from Clair
    analyse             Analyse images/hosts already pushed to Clair

optional arguments:
  -h, --help            show this help message and exit
  --debug               Debug mode
  --syslog              Log to syslog
  --conf CONF           Conf file

Analyse command usage

usage: paclair plugin hosts [hosts ...] analyse [-h]
                                            [--output-format {stats,html}]
                                            [--output-report {file,term}]
                                            [--output-dir OUTPUT_DIR]
                                            [--delete]

optional arguments:
  -h, --help            show this help message and exit
  --output-format {stats,html}
                        Change default output format (default: json)
  --output-report {file,term}
                        Change report location (default: logger)
  --output-dir OUTPUT_DIR
                        Change output directory (default: current)
  --delete              Delete after analyse

Examples

Push ubuntu image to Clair

$ paclair --conf conf/conf.yml Docker ubuntu push
Pushed ubuntu to Clair.

Analyse ubuntu image

$ paclair --conf conf/conf.yml Docker ubuntu analyse --output-format stats
Medium: 3

You can have the full json if you don’t specify –output-format stats

Analyse ubuntu image and get a html report in directory /tmp

$ paclair --conf conf/conf.yml Docker ubuntu analyse --output-format html --output-dir /tmp

Delete ubuntu image

$ paclair --conf conf/conf.yml Docker ubuntu delete
ubuntu was deleted from Clair.

Contributing

Feel free to contribute.

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paclair-3.1.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distributions

paclair-3.1.0-py3.7.egg (52.3 kB view details)

Uploaded Source

paclair-3.1.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file paclair-3.1.0.tar.gz.

File metadata

  • Download URL: paclair-3.1.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for paclair-3.1.0.tar.gz
Algorithm Hash digest
SHA256 fa8ae1a09441fa66b76baead67ecf632c3a94708ac0c67e348dbd0d0049033e9
MD5 8b42d52fdea5af54d21f917bef42d94e
BLAKE2b-256 278cf49f45a05c4ca74df4be52f3c9d01b920e7edcaae870df36e88fce4df103

See more details on using hashes here.

File details

Details for the file paclair-3.1.0-py3.7.egg.

File metadata

  • Download URL: paclair-3.1.0-py3.7.egg
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for paclair-3.1.0-py3.7.egg
Algorithm Hash digest
SHA256 0662e340a1d8041391107b474692802bbbbd9ad210dab8048d64b317c650c819
MD5 aee9bbe7f089487cdbf0a650b2e4a3e7
BLAKE2b-256 67890fc5ac63230a9b6e7cd20ee9b6020f1c48d37c932b1da7ed5cb824bc261b

See more details on using hashes here.

File details

Details for the file paclair-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: paclair-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for paclair-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8e582d0b69a477b39e120bea59cad99099db9eaaedca6e2e7898dc61b5b7de
MD5 9c9be272201055c851d336cd6fe2fb93
BLAKE2b-256 8b94a5414af89bafca4fb3110a359d98bc9219f4de2fe5826ca829ab46e49d32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page