Skip to main content

Python wrapper for Grype

Project description

PyGrype

PyPI PyPI - Python Version PyPI - License

A python wrapper for Anchore Grype

Status

Supported commands

  • completion
  • db
    • check
    • delete
    • diff
    • import
    • list
    • status
    • update
  • help
  • scan
  • version

Getting started

Prerequisites

PyGrype relies on an existing grype binary. Install grype following the official instructions.

Installation

install using pip

pip install pygrype

Usage

Instantiate Grype using the default path

from pygrype import Grype
grype = Grype()

or specify the binary

from pygrype import Grype
grype = Grype(path='/opt/grype')

Full example

from pygrype import Grype

grype = Grype()

version_info = grype.version()

print(f'Using grype {version_info.version}')

images = [
    'alpine:3.12',
    'ubuntu:18.04',
    'debian:9'
]

for image in images:
    scan = grype.scan(image)
    criticals = len(list(filter(lambda x: x.vulnerability.severity.lower() == 'critical', scan.matches)))
    print(f'{image} has {len(scan.matches)} vulnerabilities ({criticals} critical)')

Example output

Using grype 0.62.3
alpine:3.12 has 23 vulnerabilities (3 critical)
ubuntu:18.04 has 18 vulnerabilities (0 critical)
debian:9 has 213 vulnerabilities (23 critical)

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

pygrype-0.3.2.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

pygrype-0.3.2-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

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