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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
89 changes: 29 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@ pip install vulncheck-sdk
## Quickstart

```python
import urllib.request
import vulncheck_sdk
import os
import requests

# 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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

# Pass that config object to our API client and now...
Expand All @@ -81,11 +79,10 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:
# Download a Backup
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)
with urllib.request.urlopen(api_response.data[0].url) as response:
with open(file_path, "wb") as file:
file.write(response.read())

### IndicesApi has methods for each index
indices_client = vulncheck_sdk.IndicesApi(api_client)
Expand All @@ -106,11 +103,9 @@ import aiohttp
import vulncheck_sdk.aio as vcaio

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


Expand Down Expand Up @@ -183,11 +178,9 @@ from vulncheck_sdk.models.v3controllers_purl_response_data import (
)
import os

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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand All @@ -213,11 +206,9 @@ from vulncheck_sdk.aio.models.v3controllers_purl_response_data import (
)

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


Expand Down Expand Up @@ -261,11 +252,9 @@ Get all CPE's related to a CVE
import vulncheck_sdk
import os

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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand All @@ -288,11 +277,9 @@ import os
import vulncheck_sdk.aio as vcaio

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


Expand Down Expand Up @@ -327,15 +314,13 @@ if __name__ == "__main__":
Download the backup for an index

```python
import requests
import urllib.request
import vulncheck_sdk
import os

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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand All @@ -345,11 +330,10 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:

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)
with urllib.request.urlopen(api_response.data[0].url) as response:
with open(file_path, "wb") as file:
file.write(response.read())
```


Expand All @@ -358,27 +342,24 @@ with vulncheck_sdk.ApiClient(configuration) as api_client:
```python
import asyncio
import os
import requests
import urllib.request
import vulncheck_sdk.aio as vcaio

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


def download_sync(url, file_path):
"""
Standard synchronous download using requests.
Standard synchronous download using urllib.request.
This runs in a separate thread to avoid blocking the event loop.
"""
response = requests.get(url)
response.raise_for_status()
with open(file_path, "wb") as file:
file.write(response.content)
with urllib.request.urlopen(url) as response:
with open(file_path, "wb") as file:
file.write(response.read())


async def main():
Expand All @@ -397,9 +378,9 @@ async def main():
download_url = api_response.data[0].url
file_path = f"{index}.zip"

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

# Use asyncio.to_thread to run the blocking requests call safely
# 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)

Expand All @@ -421,11 +402,9 @@ Get all available indices
import vulncheck_sdk
import os

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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand All @@ -446,11 +425,9 @@ import os
import vulncheck_sdk.aio as vcaio

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


Expand Down Expand Up @@ -488,11 +465,9 @@ Query VulnCheck-NVD2 for `CVE-2019-19781`
import vulncheck_sdk
import os

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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand All @@ -512,11 +487,9 @@ import os
import vulncheck_sdk.aio as vcaio

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


Expand Down Expand Up @@ -553,11 +526,9 @@ Paginate over results for a query to VulnCheck-KEV using `cursor`
import vulncheck_sdk
import os

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 = vulncheck_sdk.Configuration()
configuration.api_key["Bearer"] = TOKEN

with vulncheck_sdk.ApiClient(configuration) as api_client:
Expand Down Expand Up @@ -587,11 +558,9 @@ import os
import vulncheck_sdk.aio as vcaio

# Configuration
DEFAULT_HOST = "https://api.vulncheck.com"
DEFAULT_API = DEFAULT_HOST + "/v3"
TOKEN = os.environ.get("VULNCHECK_API_TOKEN")

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


Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryA10.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryA10

advisory.A10

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryABBAdvisory.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryABBAdvisory

advisory.ABBAdvisory

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryADP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryADP

advisory.ADP

## Properties

Expand Down
3 changes: 2 additions & 1 deletion docs/AdvisoryADPContainer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryADPContainer

advisory.ADPContainer

## Properties

Expand All @@ -11,7 +12,7 @@ Name | Type | Description | Notes
**impacts** | [**List[AdvisoryImpact]**](AdvisoryImpact.md) | OK | [optional]
**metrics** | [**List[AdvisoryMetric]**](AdvisoryMetric.md) | OK | [optional]
**problem_types** | [**List[AdvisoryMProblemTypes]**](AdvisoryMProblemTypes.md) | OK | [optional]
**provider_metadata** | [**AdvisoryMProviderMetadata**](AdvisoryMProviderMetadata.md) | OK | [optional]
**provider_metadata** | [**AdvisoryMProviderMetadata**](AdvisoryMProviderMetadata.md) | | [optional]
**references** | [**List[AdvisoryMReference]**](AdvisoryMReference.md) | | [optional]
**tags** | **List[str]** | OK | [optional]
**title** | **str** | OK | [optional]
Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAIX.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAIX

advisory.AIX

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAMD.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAMD

advisory.AMD

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAMI.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAMI

advisory.AMI

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryASRG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryASRG

advisory.ASRG

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAVEVAAdvisory.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAVEVAAdvisory

advisory.AVEVAAdvisory

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAVIDMLAdvs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAVIDMLAdvs

advisory.AVIDMLAdvs

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAWS

advisory.AWS

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAbbott.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAbbott

advisory.Abbott

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAbsolute.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAbsolute

advisory.Absolute

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAcknowledgement.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAcknowledgement

advisory.Acknowledgement

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAcronis.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAcronis

advisory.Acronis

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAdobeAdvisory.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAdobeAdvisory

advisory.AdobeAdvisory

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAdobeAffected.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAdobeAffected

advisory.AdobeAffected

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAdobeCVE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAdobeCVE

advisory.AdobeCVE

## Properties

Expand Down
1 change: 1 addition & 0 deletions docs/AdvisoryAdobeSolution.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdvisoryAdobeSolution

advisory.AdobeSolution

## Properties

Expand Down
Loading
Loading