Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 18 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pip install vulncheck-sdk
## Quickstart

```python
import json
import urllib.request
import vulncheck_sdk
import os
Expand All @@ -57,7 +56,6 @@ TOKEN = os.environ["VULNCHECK_API_TOKEN"] # Remember to store your token secure
# Now let's create a configuration object
configuration = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN
configuration.ignore_operation_servers = True

# Pass that config object to our API client and now...
with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand All @@ -79,13 +77,10 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:
print(cve)

# Download a Backup
backup_client = vulncheck_sdk.BackupApi(api_client)
index = "initial-access"
raw = backup_client.backup_index_get_without_preload_content(index)
response_data = json.loads(raw.read())
download_url = response_data["data"][0]["url"]
api_response = endpoints_client.backup_index_get(index)
file_path = f"{index}.zip"
with urllib.request.urlopen(download_url) as response:
with urllib.request.urlopen(api_response.data[0].url) as response:
with open(file_path, "wb") as file:
file.write(response.read())

Expand All @@ -103,7 +98,6 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:

```python
import asyncio
import json
import os
import aiohttp
import vulncheck_sdk.aio as vcaio
Expand All @@ -113,15 +107,13 @@ TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

configuration = vcaio.Configuration()
configuration.api_key["Bearer"] = TOKEN
configuration.ignore_operation_servers = True


async def run_vulnerability_checks():
# Use 'async with' to manage the ApiClient connection pool
async with vcaio.ApiClient(configuration) as api_client:
endpoints_client = vcaio.EndpointsApi(api_client)
indices_client = vcaio.IndicesApi(api_client)
backup_client = vcaio.BackupApi(api_client)

# --- PURL Search ---
# 'await' the coroutine to get results
Expand All @@ -146,12 +138,11 @@ async def run_vulnerability_checks():

# --- Download Backup (Async) ---
index_name = "initial-access"
# 'await' the coroutine to get raw response bytes
raw = await backup_client.backup_index_get_without_preload_content(index_name)
response_data = json.loads(await raw.read())
# 'await' the coroutine to get results
backup_response = await endpoints_client.backup_index_get(index_name)

if response_data.get("data"):
download_url = response_data["data"][0]["url"]
if backup_response.data:
download_url = backup_response.data[0].url
file_path = f"{index_name}.zip"

print(f"Downloading backup from {download_url}...")
Expand Down Expand Up @@ -323,7 +314,6 @@ if __name__ == "__main__":
Download the backup for an index

```python
import json
import urllib.request
import vulncheck_sdk
import os
Expand All @@ -332,19 +322,16 @@ TOKEN = os.environ["VULNCHECK_API_TOKEN"]

configuration = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN
configuration.ignore_operation_servers = True

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

index = "initial-access"

raw = backup_client.backup_index_get_without_preload_content(index)
response_data = json.loads(raw.read())
download_url = response_data["data"][0]["url"]
api_response = endpoints_client.backup_index_get(index)

file_path = f"{index}.zip"
with urllib.request.urlopen(download_url) as response:
with urllib.request.urlopen(api_response.data[0].url) as response:
with open(file_path, "wb") as file:
file.write(response.read())
```
Expand All @@ -354,7 +341,6 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:

```python
import asyncio
import json
import os
import urllib.request
import vulncheck_sdk.aio as vcaio
Expand All @@ -364,7 +350,6 @@ TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

configuration = vcaio.Configuration()
configuration.api_key["Bearer"] = TOKEN
configuration.ignore_operation_servers = True


def download_sync(url, file_path):
Expand All @@ -380,19 +365,23 @@ def download_sync(url, file_path):
async def main():
# Use 'async with' to manage the connection life-cycle
async with vcaio.ApiClient(configuration) as api_client:
backup_client = vcaio.BackupApi(api_client)
endpoints_client = vcaio.EndpointsApi(api_client)
index = "initial-access"

# 'await' the coroutine to get the raw response bytes
raw = await backup_client.backup_index_get_without_preload_content(index)
response_data = json.loads(await raw.read())
download_url = response_data["data"][0]["url"]
# 'await' the coroutine to get the actual response data
api_response = await endpoints_client.backup_index_get(index)

if not api_response.data:
print("No backup URL found.")
return

download_url = api_response.data[0].url
file_path = f"{index}.zip"

print(f"Downloading {index} via urllib (offloaded to thread)...")

# Use asyncio.to_thread to run the blocking call safely
# 'await' the coroutine to get the actual response data
await asyncio.to_thread(download_sync, download_url, file_path)

print(f"Successfully saved to {file_path}")
Expand Down
134 changes: 67 additions & 67 deletions docs/AdvisoryApi.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# vulncheck_sdk.AdvisoryApi

All URIs are relative to *https://api.vulncheck.com/v3*
All URIs are relative to *https://api.vulncheck.com*

Method | HTTP request | Description
------------- | ------------- | -------------
[**advisory_get**](AdvisoryApi.md#advisory_get) | **GET** /advisory | Query advisories
[**advisory_list_get**](AdvisoryApi.md#advisory_list_get) | **GET** /advisory/list | List advisory feeds
[**v4_list_advisory_feeds**](AdvisoryApi.md#v4_list_advisory_feeds) | **GET** /v4/advisory/list | List advisory feeds
[**v4_query_advisories**](AdvisoryApi.md#v4_query_advisories) | **GET** /v4/advisory | Query advisories


# **advisory_get**
> SearchV4AdvisoryReturnValue advisory_get(name=name, cve_id=cve_id, vendor=vendor, product=product, platform=platform, version=version, cpe=cpe, package_name=package_name, purl=purl, reference_url=reference_url, reference_tag=reference_tag, description_lang=description_lang, updated_after=updated_after, updated_before=updated_before, page=page, limit=limit, start_cursor=start_cursor, cursor=cursor)
# **v4_list_advisory_feeds**
> SearchV4ListFeedReturnValue v4_list_advisory_feeds()

Query advisories
List advisory feeds

Query the VulnCheck v4 advisory index
Return a list of available advisory feed names

### Example

* Api Key Authentication (Bearer):

```python
import vulncheck_sdk
from vulncheck_sdk.models.search_v4_advisory_return_value import SearchV4AdvisoryReturnValue
from vulncheck_sdk.models.search_v4_list_feed_return_value import SearchV4ListFeedReturnValue
from vulncheck_sdk.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.vulncheck.com/v3
# Defining the host is optional and defaults to https://api.vulncheck.com
# See configuration.py for a list of all supported configuration parameters.
configuration = vulncheck_sdk.Configuration(
host = "https://api.vulncheck.com/v3"
host = "https://api.vulncheck.com"
)

# The client must configure the authentication and authorization parameters
Expand All @@ -46,63 +46,25 @@ configuration.api_key['Bearer'] = os.environ["API_KEY"]
with vulncheck_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = vulncheck_sdk.AdvisoryApi(api_client)
name = 'name_example' # str | Filter by advisory feed name (e.g. 'vulncheck') (optional)
cve_id = 'cve_id_example' # str | Filter by CVE ID (e.g. 'CVE-2024-1234') (optional)
vendor = 'vendor_example' # str | Filter by vendor name (optional)
product = 'product_example' # str | Filter by product name (optional)
platform = 'platform_example' # str | Filter by OS/platform (optional)
version = 'version_example' # str | Filter by product version (semver-aware) (optional)
cpe = 'cpe_example' # str | Filter by CPE (e.g. 'cpe:2.3:a:vendor:product:*') (optional)
package_name = 'package_name_example' # str | Filter by package name (optional)
purl = 'purl_example' # str | Filter by package URL (PURL) (optional)
reference_url = 'reference_url_example' # str | Filter by reference URL (optional)
reference_tag = 'reference_tag_example' # str | Filter by reference tag (e.g. 'patch', 'advisory') (optional)
description_lang = 'description_lang_example' # str | Filter by description language (e.g. 'en') (optional)
updated_after = 'updated_after_example' # str | Return advisories updated after this date (RFC3339 or date-math e.g. 'now-30d') (optional)
updated_before = 'updated_before_example' # str | Return advisories updated before this date (RFC3339 or date-math) (optional)
page = 56 # int | Page number (default: 1) (optional)
limit = 56 # int | Results per page, max 100 (default: 10) (optional)
start_cursor = 'start_cursor_example' # str | Presence activates cursor mode from the first page (value is ignored; cannot be combined with page) (optional)
cursor = 'cursor_example' # str | Cursor from previous response _meta.next_cursor to fetch the next page (optional)

try:
# Query advisories
api_response = api_instance.advisory_get(name=name, cve_id=cve_id, vendor=vendor, product=product, platform=platform, version=version, cpe=cpe, package_name=package_name, purl=purl, reference_url=reference_url, reference_tag=reference_tag, description_lang=description_lang, updated_after=updated_after, updated_before=updated_before, page=page, limit=limit, start_cursor=start_cursor, cursor=cursor)
print("The response of AdvisoryApi->advisory_get:\n")
# List advisory feeds
api_response = api_instance.v4_list_advisory_feeds()
print("The response of AdvisoryApi->v4_list_advisory_feeds:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AdvisoryApi->advisory_get: %s\n" % e)
print("Exception when calling AdvisoryApi->v4_list_advisory_feeds: %s\n" % e)
```



### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**name** | **str**| Filter by advisory feed name (e.g. 'vulncheck') | [optional]
**cve_id** | **str**| Filter by CVE ID (e.g. 'CVE-2024-1234') | [optional]
**vendor** | **str**| Filter by vendor name | [optional]
**product** | **str**| Filter by product name | [optional]
**platform** | **str**| Filter by OS/platform | [optional]
**version** | **str**| Filter by product version (semver-aware) | [optional]
**cpe** | **str**| Filter by CPE (e.g. 'cpe:2.3:a:vendor:product:*') | [optional]
**package_name** | **str**| Filter by package name | [optional]
**purl** | **str**| Filter by package URL (PURL) | [optional]
**reference_url** | **str**| Filter by reference URL | [optional]
**reference_tag** | **str**| Filter by reference tag (e.g. 'patch', 'advisory') | [optional]
**description_lang** | **str**| Filter by description language (e.g. 'en') | [optional]
**updated_after** | **str**| Return advisories updated after this date (RFC3339 or date-math e.g. 'now-30d') | [optional]
**updated_before** | **str**| Return advisories updated before this date (RFC3339 or date-math) | [optional]
**page** | **int**| Page number (default: 1) | [optional]
**limit** | **int**| Results per page, max 100 (default: 10) | [optional]
**start_cursor** | **str**| Presence activates cursor mode from the first page (value is ignored; cannot be combined with page) | [optional]
**cursor** | **str**| Cursor from previous response _meta.next_cursor to fetch the next page | [optional]
This endpoint does not need any parameter.

### Return type

[**SearchV4AdvisoryReturnValue**](SearchV4AdvisoryReturnValue.md)
[**SearchV4ListFeedReturnValue**](SearchV4ListFeedReturnValue.md)

### Authorization

Expand All @@ -125,27 +87,27 @@ Name | Type | Description | Notes

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **advisory_list_get**
> SearchV4ListFeedReturnValue advisory_list_get()
# **v4_query_advisories**
> SearchV4AdvisoryReturnValue v4_query_advisories(name=name, cve_id=cve_id, vendor=vendor, product=product, platform=platform, version=version, cpe=cpe, package_name=package_name, purl=purl, reference_url=reference_url, reference_tag=reference_tag, description_lang=description_lang, updated_after=updated_after, updated_before=updated_before, page=page, limit=limit, start_cursor=start_cursor, cursor=cursor)

List advisory feeds
Query advisories

Return a list of available advisory feed names
Query the VulnCheck v4 advisory index

### Example

* Api Key Authentication (Bearer):

```python
import vulncheck_sdk
from vulncheck_sdk.models.search_v4_list_feed_return_value import SearchV4ListFeedReturnValue
from vulncheck_sdk.models.search_v4_advisory_return_value import SearchV4AdvisoryReturnValue
from vulncheck_sdk.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.vulncheck.com/v3
# Defining the host is optional and defaults to https://api.vulncheck.com
# See configuration.py for a list of all supported configuration parameters.
configuration = vulncheck_sdk.Configuration(
host = "https://api.vulncheck.com/v3"
host = "https://api.vulncheck.com"
)

# The client must configure the authentication and authorization parameters
Expand All @@ -163,25 +125,63 @@ configuration.api_key['Bearer'] = os.environ["API_KEY"]
with vulncheck_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = vulncheck_sdk.AdvisoryApi(api_client)
name = 'name_example' # str | Filter by advisory feed name (e.g. 'vulncheck') (optional)
cve_id = 'cve_id_example' # str | Filter by CVE ID (e.g. 'CVE-2024-1234') (optional)
vendor = 'vendor_example' # str | Filter by vendor name (optional)
product = 'product_example' # str | Filter by product name (optional)
platform = 'platform_example' # str | Filter by OS/platform (optional)
version = 'version_example' # str | Filter by product version (semver-aware) (optional)
cpe = 'cpe_example' # str | Filter by CPE (e.g. 'cpe:2.3:a:vendor:product:*') (optional)
package_name = 'package_name_example' # str | Filter by package name (optional)
purl = 'purl_example' # str | Filter by package URL (PURL) (optional)
reference_url = 'reference_url_example' # str | Filter by reference URL (optional)
reference_tag = 'reference_tag_example' # str | Filter by reference tag (e.g. 'patch', 'advisory') (optional)
description_lang = 'description_lang_example' # str | Filter by description language (e.g. 'en') (optional)
updated_after = 'updated_after_example' # str | Return advisories updated after this date (RFC3339 or date-math e.g. 'now-30d') (optional)
updated_before = 'updated_before_example' # str | Return advisories updated before this date (RFC3339 or date-math) (optional)
page = 56 # int | Page number (default: 1) (optional)
limit = 56 # int | Results per page, max 100 (default: 10) (optional)
start_cursor = 'start_cursor_example' # str | Presence activates cursor mode from the first page (value is ignored; cannot be combined with page) (optional)
cursor = 'cursor_example' # str | Cursor from previous response _meta.next_cursor to fetch the next page (optional)

try:
# List advisory feeds
api_response = api_instance.advisory_list_get()
print("The response of AdvisoryApi->advisory_list_get:\n")
# Query advisories
api_response = api_instance.v4_query_advisories(name=name, cve_id=cve_id, vendor=vendor, product=product, platform=platform, version=version, cpe=cpe, package_name=package_name, purl=purl, reference_url=reference_url, reference_tag=reference_tag, description_lang=description_lang, updated_after=updated_after, updated_before=updated_before, page=page, limit=limit, start_cursor=start_cursor, cursor=cursor)
print("The response of AdvisoryApi->v4_query_advisories:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AdvisoryApi->advisory_list_get: %s\n" % e)
print("Exception when calling AdvisoryApi->v4_query_advisories: %s\n" % e)
```



### Parameters

This endpoint does not need any parameter.

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**name** | **str**| Filter by advisory feed name (e.g. 'vulncheck') | [optional]
**cve_id** | **str**| Filter by CVE ID (e.g. 'CVE-2024-1234') | [optional]
**vendor** | **str**| Filter by vendor name | [optional]
**product** | **str**| Filter by product name | [optional]
**platform** | **str**| Filter by OS/platform | [optional]
**version** | **str**| Filter by product version (semver-aware) | [optional]
**cpe** | **str**| Filter by CPE (e.g. 'cpe:2.3:a:vendor:product:*') | [optional]
**package_name** | **str**| Filter by package name | [optional]
**purl** | **str**| Filter by package URL (PURL) | [optional]
**reference_url** | **str**| Filter by reference URL | [optional]
**reference_tag** | **str**| Filter by reference tag (e.g. 'patch', 'advisory') | [optional]
**description_lang** | **str**| Filter by description language (e.g. 'en') | [optional]
**updated_after** | **str**| Return advisories updated after this date (RFC3339 or date-math e.g. 'now-30d') | [optional]
**updated_before** | **str**| Return advisories updated before this date (RFC3339 or date-math) | [optional]
**page** | **int**| Page number (default: 1) | [optional]
**limit** | **int**| Results per page, max 100 (default: 10) | [optional]
**start_cursor** | **str**| Presence activates cursor mode from the first page (value is ignored; cannot be combined with page) | [optional]
**cursor** | **str**| Cursor from previous response _meta.next_cursor to fetch the next page | [optional]

### Return type

[**SearchV4ListFeedReturnValue**](SearchV4ListFeedReturnValue.md)
[**SearchV4AdvisoryReturnValue**](SearchV4AdvisoryReturnValue.md)

### Authorization

Expand Down
Loading
Loading