Skip to main content

VulnCheck API

Project description

VulnCheck Logo

The VulnCheck SDK For Python

Bring the VulnCheck API to your Python applications.

PyPI - Version PyPI - Python Version Jupyter

Installation

# From PyPi
pip install vulncheck-sdk

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

Resources

Quickstart

import vulncheck_sdk

# First let's setup a few variables to help us
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ["VULNCHECK_API_TOKEN"] # Remember to store your token securely!

# Now let's create a configuration object
configuration = vulncheck_sdk.Configuration(host=DEFAULT_API)
configuration.api_key["Bearer"] = TOKEN

# Pass that config object to our API client and now...
with vulncheck_sdk.ApiClient(configuration) as api_client:
    # We can use two classes to explore the VulnCheck API: EndpointsApi & IndicesApi

    ### EndpointsApi has methods to query every endpoint except `/v3/index`
    # See the full list of endpoints here: https://docs.vulncheck.com/api
    endpoints_client = vulncheck_sdk.EndpointsApi(api_client)

    # PURL
    api_response = endpoints_client.purl_get("pkg:hex/coherence@0.1.2")
    data: V3controllersPurlResponseData = api_response.data
    print(data.cves)

    # CPE
    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)

    # Download a Backup
    api_response = endpoints_client.backup_index_get("initial-access")
    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)

    ### IndicesApi has methods for each index
    indices_client = vulncheck_sdk.IndicesApi(api_client)

    # You can filter your query using parameters as well
    query_params = vulncheck_sdk.ParamsIdxReqParams(cve="CVE-2019-19781")
    api_response = indices_client.index_vulncheck_nvd2_get(query_params)

    print(api_response.data)

    # There are many more indices to explore!
    api_response = indices_client.index_vulncheck_kev_get(vulncheck_sdk.ParamsIdxReqParams())
    api_response = indices_client.index_exploits_get(vulncheck_sdk.ParamsIdxReqParams())
    api_response = indices_client.index_ipintel3d_get(vulncheck_sdk.ParamsIdxReqParams())
    api_response = indices_client. # An editor with a Language Server will show you all the available methods/indices!

Examples

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

Paginate over results for a query to VulnCheck-KEV using cursor

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)
    api_response = indices_client.index_vulncheck_kev_get(
        vulncheck_sdk.ParamsIdxReqParams(),
        start_cursor="true",
        # `limit` increases the size of each page, making it faster
        # to download large datasets
        limit = 300
    )

    print(api_response.data)

    while api_response.meta.next_cursor is not None:
        api_response = indices_client.index_vulncheck_kev_get(
            vulncheck_sdk.ParamsIdxReqParams(), cursor=api_response.meta.next_cursor
        )
        print(api_response.data)

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please create an issue.

Sponsorship

Development of this project is sponsored by VulnCheck learn more about us!

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.4.tar.gz (316.2 kB view details)

Uploaded Source

Built Distribution

vulncheck_sdk-0.0.4-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vulncheck_sdk-0.0.4.tar.gz
  • Upload date:
  • Size: 316.2 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.4.tar.gz
Algorithm Hash digest
SHA256 282a5513abcda32d17c7b79bcb634b34fca8f39339235ba01244ace1a219097c
MD5 f8c76a70ba31c2358ed256660fcbf556
BLAKE2b-256 9605e698da74e9f52557ecccecae0800d55ac404da15ad2458c044999f3c82bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for vulncheck_sdk-0.0.4.tar.gz:

Publisher: release.yml on vulncheck-oss/sdk-python

Attestations:

File details

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

File metadata

File hashes

Hashes for vulncheck_sdk-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8549e76ff6531c964c2f9a1cb3371f5111dcec9d40b7da196bd2acde20cddabb
MD5 7cd04407e4da08ea192ff646d1d43f74
BLAKE2b-256 cc28a5fb6be4e7393f99725a8c67055fd957efb8f3cc80af34357fed15a9f791

See more details on using hashes here.

Provenance

The following attestation bundles were made for vulncheck_sdk-0.0.4-py3-none-any.whl:

Publisher: release.yml on vulncheck-oss/sdk-python

Attestations:

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