pygitguardian


Namepygitguardian JSON
Version 1.14.0 PyPI version JSON
download
home_pagehttps://github.com/GitGuardian/py-gitguardian
SummaryPython Wrapper for GitGuardian's API -- Scan security policy breaks everywhere
upload_time2024-02-26 12:52:46
maintainerGitGuardian
docs_urlNone
authorGitGuardian
requires_python>=3.8
licenseMIT
keywords api-client devsecops secrets-detection security-tools library gitguardian
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a href="https://gitguardian.com/"><img src="https://cdn.jsdelivr.net/gh/gitguardian/py-gitguardian/doc/logo.svg"></a>

# [py-gitguardian](https://github.com/GitGuardian/py-gitguardian) - GitGuardian API Client

[![PyPI](https://img.shields.io/pypi/v/pygitguardian?color=%231B2D55&style=for-the-badge)](https://pypi.org/project/pygitguardian/)
[![License](https://img.shields.io/github/license/GitGuardian/py-gitguardian?color=%231B2D55&style=for-the-badge)](LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/gitguardian/py-gitguardian?color=%231B2D55&style=for-the-badge)](https://github.com/GitGuardian/py-gitguardian/stargazers)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/GitGuardian/py-gitguardian/test-lint.yml?branch=master&style=for-the-badge)
[![Codecov](https://img.shields.io/codecov/c/github/GitGuardian/py-gitguardian?style=for-the-badge)](https://codecov.io/gh/GitGuardian/py-gitguardian/)

API client library for the [GitGuardian API](https://api.gitguardian.com/).

The GitGuardian API puts at your fingertips the power to detect more than 200 types of secrets in any text content, as well as other potential security vulnerabilities.

**py-gitguardian** can be used to create integrations to scan various data sources, from your workstation's filesystem to your favorite chat application.

You can check API details [here](https://api.gitguardian.com/docs)
with all the response codes and expected structures on each method.

## Requirements

Python 3.8+

## Projects using `py-gitguardian`

- [**GitGuardian Shield**](https://github.com/GitGuardian/gg-shield) - Scan for secrets in your CI and pre-commit.

## Getting started

You can obtain API keys for API usage on your [dashboard](https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=github&utm_medium=py_gitguardian&utm_campaign=py1).

**pip**

```bash
pip3 install --upgrade pygitguardian
```

**pipenv**

```bash
pipenv install pygitguardian
```

**poetry**

```bash
poetry add pygitguardian
```

## Examples

Check [examples/](examples/) for full examples on how to use py-gitguardian.

### Scanning text content

```py
# please don't hardcode your gg_api_key in source code :)
API_KEY = os.getenv("GITGUARDIAN_API_KEY")
DOCUMENT = """
    import urllib.request
    url = 'http://jen_barber:correcthorsebatterystaple@cake.gitguardian.com/isreal.json'
    response = urllib.request.urlopen(url)
    consume(response.read())"
"""

client = GGClient(api_key=API_KEY)

# Check the health of the API and the API key used.
if client.health_check().success:
    try:
        scan_result = client.content_scan(DOCUMENT)
    except Exception as exc:
        # Handle exceptions such as schema validation
        traceback.print_exc(2, file=sys.stderr)
        print(str(exc))
        print(scan_result)
else:
    print("Invalid API Key")
```

### Scanning multiple files

```py
API_KEY = os.getenv("GITGUARDIAN_API_KEY")
client = GGClient(api_key=API_KEY)

# Create a list of dictionaries for scanning
file_paths = (pathlib.Path(name) for name in glob.iglob("**/*", recursive=True))
to_scan = [
    {"filename": path.name, "document": path.read_text(errors="replace")}
    for path in file_paths
]

scan = client.multi_content_scan(to_scan)
```

### Transform results to dict or JSON

Any model in `py-gitguardian` can be turned to a JSON string or a dictionary using
the `to_dict` and `to_json` methods.

```py
from pygitguardian.models import Detail

detail = Detail("Invalid API Key.")
print(detail.to_dict())
print(detail.to_json())
```

### Dependencies

Py-gitguardian depends on these excellent libraries:

- `requests` - HTTP client
- `marshmallow` - Request (de)serialization and input validation

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/GitGuardian/py-gitguardian",
    "name": "pygitguardian",
    "maintainer": "GitGuardian",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "api-client devsecops secrets-detection security-tools library gitguardian",
    "author": "GitGuardian",
    "author_email": "support@gitguardian.com",
    "download_url": "https://files.pythonhosted.org/packages/9e/8b/409389c1c43ef019b0b65e9a239ef4065a5ae29902a2cd7006d69ebe5b49/pygitguardian-1.14.0.tar.gz",
    "platform": null,
    "description": "<a href=\"https://gitguardian.com/\"><img src=\"https://cdn.jsdelivr.net/gh/gitguardian/py-gitguardian/doc/logo.svg\"></a>\n\n# [py-gitguardian](https://github.com/GitGuardian/py-gitguardian) - GitGuardian API Client\n\n[![PyPI](https://img.shields.io/pypi/v/pygitguardian?color=%231B2D55&style=for-the-badge)](https://pypi.org/project/pygitguardian/)\n[![License](https://img.shields.io/github/license/GitGuardian/py-gitguardian?color=%231B2D55&style=for-the-badge)](LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/gitguardian/py-gitguardian?color=%231B2D55&style=for-the-badge)](https://github.com/GitGuardian/py-gitguardian/stargazers)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/GitGuardian/py-gitguardian/test-lint.yml?branch=master&style=for-the-badge)\n[![Codecov](https://img.shields.io/codecov/c/github/GitGuardian/py-gitguardian?style=for-the-badge)](https://codecov.io/gh/GitGuardian/py-gitguardian/)\n\nAPI client library for the [GitGuardian API](https://api.gitguardian.com/).\n\nThe GitGuardian API puts at your fingertips the power to detect more than 200 types of secrets in any text content, as well as other potential security vulnerabilities.\n\n**py-gitguardian** can be used to create integrations to scan various data sources, from your workstation's filesystem to your favorite chat application.\n\nYou can check API details [here](https://api.gitguardian.com/docs)\nwith all the response codes and expected structures on each method.\n\n## Requirements\n\nPython 3.8+\n\n## Projects using `py-gitguardian`\n\n- [**GitGuardian Shield**](https://github.com/GitGuardian/gg-shield) - Scan for secrets in your CI and pre-commit.\n\n## Getting started\n\nYou can obtain API keys for API usage on your [dashboard](https://dashboard.gitguardian.com/api/v1/auth/user/github_login/authorize?utm_source=github&utm_medium=py_gitguardian&utm_campaign=py1).\n\n**pip**\n\n```bash\npip3 install --upgrade pygitguardian\n```\n\n**pipenv**\n\n```bash\npipenv install pygitguardian\n```\n\n**poetry**\n\n```bash\npoetry add pygitguardian\n```\n\n## Examples\n\nCheck [examples/](examples/) for full examples on how to use py-gitguardian.\n\n### Scanning text content\n\n```py\n# please don't hardcode your gg_api_key in source code :)\nAPI_KEY = os.getenv(\"GITGUARDIAN_API_KEY\")\nDOCUMENT = \"\"\"\n    import urllib.request\n    url = 'http://jen_barber:correcthorsebatterystaple@cake.gitguardian.com/isreal.json'\n    response = urllib.request.urlopen(url)\n    consume(response.read())\"\n\"\"\"\n\nclient = GGClient(api_key=API_KEY)\n\n# Check the health of the API and the API key used.\nif client.health_check().success:\n    try:\n        scan_result = client.content_scan(DOCUMENT)\n    except Exception as exc:\n        # Handle exceptions such as schema validation\n        traceback.print_exc(2, file=sys.stderr)\n        print(str(exc))\n        print(scan_result)\nelse:\n    print(\"Invalid API Key\")\n```\n\n### Scanning multiple files\n\n```py\nAPI_KEY = os.getenv(\"GITGUARDIAN_API_KEY\")\nclient = GGClient(api_key=API_KEY)\n\n# Create a list of dictionaries for scanning\nfile_paths = (pathlib.Path(name) for name in glob.iglob(\"**/*\", recursive=True))\nto_scan = [\n    {\"filename\": path.name, \"document\": path.read_text(errors=\"replace\")}\n    for path in file_paths\n]\n\nscan = client.multi_content_scan(to_scan)\n```\n\n### Transform results to dict or JSON\n\nAny model in `py-gitguardian` can be turned to a JSON string or a dictionary using\nthe `to_dict` and `to_json` methods.\n\n```py\nfrom pygitguardian.models import Detail\n\ndetail = Detail(\"Invalid API Key.\")\nprint(detail.to_dict())\nprint(detail.to_json())\n```\n\n### Dependencies\n\nPy-gitguardian depends on these excellent libraries:\n\n- `requests` - HTTP client\n- `marshmallow` - Request (de)serialization and input validation\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Wrapper for GitGuardian's API -- Scan security policy breaks everywhere",
    "version": "1.14.0",
    "project_urls": {
        "Homepage": "https://github.com/GitGuardian/py-gitguardian"
    },
    "split_keywords": [
        "api-client",
        "devsecops",
        "secrets-detection",
        "security-tools",
        "library",
        "gitguardian"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "58f2e8794763909cca8331ced6a0b9b799bbb715663b957b8997122e6b87d587",
                "md5": "721b79533dbd18d030d8bb8aecde48af",
                "sha256": "47ebbb0b0baa7540c3e79f635c9b2c4e6860318e41dad073f7187035b9333f41"
            },
            "downloads": -1,
            "filename": "pygitguardian-1.14.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "721b79533dbd18d030d8bb8aecde48af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17831,
            "upload_time": "2024-02-26T12:52:43",
            "upload_time_iso_8601": "2024-02-26T12:52:43.792679Z",
            "url": "https://files.pythonhosted.org/packages/58/f2/e8794763909cca8331ced6a0b9b799bbb715663b957b8997122e6b87d587/pygitguardian-1.14.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e8b409389c1c43ef019b0b65e9a239ef4065a5ae29902a2cd7006d69ebe5b49",
                "md5": "2fa7f7ecca4999d5b7911093c00025c3",
                "sha256": "52f3a2820dd0eb448bf235993669bcd814233daaa52f0a133a2d83303bb5284a"
            },
            "downloads": -1,
            "filename": "pygitguardian-1.14.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2fa7f7ecca4999d5b7911093c00025c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27043,
            "upload_time": "2024-02-26T12:52:46",
            "upload_time_iso_8601": "2024-02-26T12:52:46.767574Z",
            "url": "https://files.pythonhosted.org/packages/9e/8b/409389c1c43ef019b0b65e9a239ef4065a5ae29902a2cd7006d69ebe5b49/pygitguardian-1.14.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 12:52:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "GitGuardian",
    "github_project": "py-gitguardian",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pygitguardian"
}
        
Elapsed time: 0.19335s