VulnCheck API
Project description
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
Quickstart
[!NOTE] Find more detail in the full OpenAPI docs
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)
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
from vulncheck_sdk.models.params_idx_req_params import ParamsIdxReqParams
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
from vulncheck_sdk.models.params_idx_req_params import ParamsIdxReqParams
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.1.tar.gz
(302.8 kB
view details)
Built Distribution
File details
Details for the file vulncheck_sdk-0.0.1.tar.gz
.
File metadata
- Download URL: vulncheck_sdk-0.0.1.tar.gz
- Upload date:
- Size: 302.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38bed6399f8f3eb07c04e48891470e687e1ad82db1289d6661a2cbeecc3850f9 |
|
MD5 | de20fa3f5bef82ad915afea4d0c82a82 |
|
BLAKE2b-256 | 447ffa781400646e8aa8e3db57e3cf026c343377f486dbdce91fec58b88ad102 |
File details
Details for the file vulncheck_sdk-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: vulncheck_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4de5ab61ad33948507ebd2de2f960c4cf95e4407edb243a7f8848b6f04fa8d0d |
|
MD5 | a9877860eeca119c1bf7e908b3344d9e |
|
BLAKE2b-256 | 50180e0289d6c62e73ec1f7fe3fe98bd5c807ab16aaaae0442971d590731beac |