Skip to main content

VulnCheck API

Project description

VulnCheck Logo

The VulnCheck SDK

Bring the VulnCheck API to your Python applications.

Installation

# Directly from github
pip install git+https://github.com/vulncheck-oss/sdk-python.git

# From PyPi
pip install vulncheck-sdk

[!IMPORTANT] Windows users may need to enable Long Path Support

Quickstart

Connecting to the API

import vulncheck_sdk

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    # For purl, cpe, backup, tags, pdns, etc.
    endpoints_client = vulncheck_sdk.EndpointsApi(api_client)
    # For querying an individual index
    indices_client = vulncheck_sdk.IndicesApi(api_client)

[!NOTE] Find more detail in the full OpenAPI docs

PURL

Get the CVE's for a given PURL

import vulncheck_sdk
from vulncheck_sdk.models.v3controllers_purl_response_data import (
    V3controllersPurlResponseData,
)

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    endpoints_client = vulncheck_sdk.EndpointsApi(api_client)

    purl = "pkg:hex/coherence@0.1.2"

    api_response = endpoints_client.purl_get(purl)
    data: V3controllersPurlResponseData = api_response.data

    print(data.cves)

CPE

Get all CPE's related to a CVE

import vulncheck_sdk

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    endpoints_client = vulncheck_sdk.EndpointsApi(api_client)

    cpe = "cpe:/a:microsoft:internet_explorer:8.0.6001:beta"

    api_response = endpoints_client.cpe_get(cpe)

    for cve in api_response.data:
        print(cve)

Backup

Download the backup for an index

import requests
import vulncheck_sdk

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    endpoints_client = vulncheck_sdk.EndpointsApi(api_client)

    index = "initial-access"

    api_response = endpoints_client.backup_index_get(index)

    backup_url = requests.get(api_response.data[0].url)

    file_path = f"{index}.zip"
    with open(file_path, "wb") as file:
      file.write(backup_url.content)

Indices

Get all available indices

import vulncheck_sdk

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    endpoints_client = vulncheck_sdk.EndpointsApi(api_client)

    api_response = endpoints_client.index_get()

    for index in api_response.data:
        print(index.name)

Index

Query VulnCheck-NVD2 for CVE-2019-19781

import vulncheck_sdk

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    indices_client = vulncheck_sdk.IndicesApi(api_client)

    query_params = vulncheck_sdk.ParamsIdxReqParams(cve="CVE-2019-19781")
    api_response = indices_client.index_vulncheck_nvd2_get(query_params)

    print(api_response.data)

Pagination

With a limit of 10 findings, get the first 5 pages of results from ipintel-3d

import vulncheck_sdk
from vulncheck_sdk.models.paginate_pagination import PaginatePagination

DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
    indices_client = vulncheck_sdk.IndicesApi(api_client)
    query_params = vulncheck_sdk.ParamsIdxReqParams()

    limit = 10
    page = 1

    while page <= 5:
        api_response = indices_client.index_ipintel3d_get(
            query_params, limit=limit, page=page
        )
        print(f"Page {page}:")
        print(api_response.data)

        meta: PaginatePagination = api_response.meta
        if meta.page >= meta.total_pages:
            break
        page += 1

License

Apache License 2.0. Please see License File for more information.

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

vulncheck_sdk-0.0.2.tar.gz (309.9 kB view details)

Uploaded Source

Built Distribution

vulncheck_sdk-0.0.2-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file vulncheck_sdk-0.0.2.tar.gz.

File metadata

  • Download URL: vulncheck_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 309.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for vulncheck_sdk-0.0.2.tar.gz
Algorithm Hash digest
SHA256 29ae4788fbc22d79c3e1ce6ef96cb04e83fbeab5df8486d8976f7d96bbac840c
MD5 4c7aa40f961e83182b9cd2c01ed5fa25
BLAKE2b-256 964dd71ead0d281d57f63b50ddbf1f58ff5be1eec7be99b8a4ddc812e8551f00

See more details on using hashes here.

File details

Details for the file vulncheck_sdk-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for vulncheck_sdk-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 875cbe6b3ebfc50d7d8d3ea883d6b9384bfb02c1929181e950d8ba2fbfe5ac5a
MD5 4cf07da55899069a5ab15b039a5cc829
BLAKE2b-256 af805dcec5075e96f9d6c615bb9ea75baf2d6583ec968a72a42c6865977872a2

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