pygrype


Namepygrype JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryPython wrapper for Grype
upload_time2024-08-02 06:49:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License
keywords anchore grype security
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyGrype

![PyPI](https://img.shields.io/pypi/v/pygrype)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pygrype)
![PyPI - License](https://img.shields.io/pypi/l/pygrype)

A python wrapper for [Anchore Grype](https://github.com/anchore/grype)

## Status
Supported commands

- [ ] ~~completion~~
- [x] db
    - [ ] check
    - [x] delete
    - [ ] diff
    - [ ] import
    - [x] list
    - [ ] status
    - [x] update
- [ ] ~~help~~
- [x] scan
- [x] version

## Getting started
### Prerequisites
PyGrype relies on either an existing grype binary, or a local Docker install.

[Install grype binary following the official instructions](https://github.com/anchore/grype#installation).

[Install Docker following the official instructions](https://docs.docker.com/get-docker/)

### Installation
install using `pip`
```bash
pip install pygrype
```

## Usage

Pygrype is wrapper around the `grype` binary, and can be used in two ways: using a local binary, or using the official Docker container.

### Using Local Binary
Instantiate `Grype` without any arguments. This will use the default binary backend, and will look for the `grype` binary in the system path.

```python3
from pygrype import Grype
grype = Grype()
```
or specify the binary
```python3
from pygrype import Grype, GrypeBinaryBackend
binary_backend = GrypeBinaryBackend(path='/opt/grype')
grype = Grype(backend=binary_backend)
```

### Using Docker
Instantiate `Grype` with the `GrypeDockerBackend` backend. This will use the [official grype Docker container](https://hub.docker.com/r/anchore/grype) to run scans. The backend will use the latest version of the container by default, but you can specify a specific version using the optional `tag` argument.

```python3
from pygrype import Grype, GrypeDockerBackend
docker_backend = GrypeDockerBackend(tag="v0.79.2")
grype = Grype(backend=docker_backend)
```

## Full example
```python3
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)
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pygrype",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "anchore, grype, security",
    "author": null,
    "author_email": "Albert Simon <simon.albert75@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8c/3f/9be0d717c70134ffd899e9c8e48495d9f66f9fa90339cf396bb3df175f20/pygrype-0.4.0.tar.gz",
    "platform": null,
    "description": "# PyGrype\n\n![PyPI](https://img.shields.io/pypi/v/pygrype)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pygrype)\n![PyPI - License](https://img.shields.io/pypi/l/pygrype)\n\nA python wrapper for [Anchore Grype](https://github.com/anchore/grype)\n\n## Status\nSupported commands\n\n- [ ] ~~completion~~\n- [x] db\n    - [ ] check\n    - [x] delete\n    - [ ] diff\n    - [ ] import\n    - [x] list\n    - [ ] status\n    - [x] update\n- [ ] ~~help~~\n- [x] scan\n- [x] version\n\n## Getting started\n### Prerequisites\nPyGrype relies on either an existing grype binary, or a local Docker install.\n\n[Install grype binary following the official instructions](https://github.com/anchore/grype#installation).\n\n[Install Docker following the official instructions](https://docs.docker.com/get-docker/)\n\n### Installation\ninstall using `pip`\n```bash\npip install pygrype\n```\n\n## Usage\n\nPygrype is wrapper around the `grype` binary, and can be used in two ways: using a local binary, or using the official Docker container.\n\n### Using Local Binary\nInstantiate `Grype` without any arguments. This will use the default binary backend, and will look for the `grype` binary in the system path.\n\n```python3\nfrom pygrype import Grype\ngrype = Grype()\n```\nor specify the binary\n```python3\nfrom pygrype import Grype, GrypeBinaryBackend\nbinary_backend = GrypeBinaryBackend(path='/opt/grype')\ngrype = Grype(backend=binary_backend)\n```\n\n### Using Docker\nInstantiate `Grype` with the `GrypeDockerBackend` backend. This will use the [official grype Docker container](https://hub.docker.com/r/anchore/grype) to run scans. The backend will use the latest version of the container by default, but you can specify a specific version using the optional `tag` argument.\n\n```python3\nfrom pygrype import Grype, GrypeDockerBackend\ndocker_backend = GrypeDockerBackend(tag=\"v0.79.2\")\ngrype = Grype(backend=docker_backend)\n```\n\n## Full example\n```python3\nfrom pygrype import Grype\n\ngrype = Grype()\n\nversion_info = grype.version()\n\nprint(f'Using grype {version_info.version}')\n\nimages = [\n    'alpine:3.12',\n    'ubuntu:18.04',\n    'debian:9'\n]\n\nfor image in images:\n    scan = grype.scan(image)\n    criticals = len(list(filter(lambda x: x.vulnerability.severity.lower() == 'critical', scan.matches)))\n    print(f'{image} has {len(scan.matches)} vulnerabilities ({criticals} critical)')\n```\nExample output\n```\nUsing grype 0.62.3\nalpine:3.12 has 23 vulnerabilities (3 critical)\nubuntu:18.04 has 18 vulnerabilities (0 critical)\ndebian:9 has 213 vulnerabilities (23 critical)\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Python wrapper for Grype",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [
        "anchore",
        " grype",
        " security"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23278176d6ad7b1908aa05c997888466aad0ae6567ac457a9c3fc718287fffe6",
                "md5": "31aeaad68a191308f2a6e03ebf03f94a",
                "sha256": "68cc7f9b9c1f13033cfbce64f9ca4f476455fe886bc89c5a5ae9992f31cec2cd"
            },
            "downloads": -1,
            "filename": "pygrype-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "31aeaad68a191308f2a6e03ebf03f94a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15560,
            "upload_time": "2024-08-02T06:49:07",
            "upload_time_iso_8601": "2024-08-02T06:49:07.565558Z",
            "url": "https://files.pythonhosted.org/packages/23/27/8176d6ad7b1908aa05c997888466aad0ae6567ac457a9c3fc718287fffe6/pygrype-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c3f9be0d717c70134ffd899e9c8e48495d9f66f9fa90339cf396bb3df175f20",
                "md5": "b69273d0b82ff2e263bfb95bac331466",
                "sha256": "6a374b5135865fd1c437e128174849c7a7f093e6473b5c16a7a253083cdfd479"
            },
            "downloads": -1,
            "filename": "pygrype-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b69273d0b82ff2e263bfb95bac331466",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12464,
            "upload_time": "2024-08-02T06:49:09",
            "upload_time_iso_8601": "2024-08-02T06:49:09.200907Z",
            "url": "https://files.pythonhosted.org/packages/8c/3f/9be0d717c70134ffd899e9c8e48495d9f66f9fa90339cf396bb3df175f20/pygrype-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-02 06:49:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pygrype"
}
        
Elapsed time: 0.27195s