Git Product home page Git Product logo

nvd-api's Introduction

NVD API Client

NVD API client is a community driven NVD API 2.0 client. This client support Vulnerabilities API and Products API.

https://img.shields.io/pypi/dw/nvd-api?style=flat https://codecov.io/gh/kannkyo/nvd-api/branch/main/graph/badge.svg?token=ASYLVG3X9O https://bestpractices.coreinfrastructure.org/projects/6889/badge

Getting Start

Products / CPE API

This API's simple example is bellow.

from client import NvdApiClient
from pprint import pprint

client = NvdApiClient()

response = client.get_cpes(
    cpe_name_id="87316812-5F2C-4286-94FE-CC98B9EAEF53",
    results_per_page=1,
    start_index=0
)
pprint(response)

get_cpes method check API's all constraints and limitations.

  • cpeNameId and matchCriteriaId must be uuid format.
  • cpeMatchString must be CPEv2.3 format.
  • If filtering by keywordExactMatch, keywordSearch is REQUIRED.
  • If filtering by the last modified date, both lastModStartDate and lastModEndDate are REQUIRED.
  • resultsPerPage's maximum allowable limit is 10,000.
  • The maximum allowable range when using any date range parameters is 120 consecutive days.

Products / Match Criteria API

This API's simple example is bellow.

from nvd_api import NvdApiClient
from pprint import pprint

client = NvdApiClient()

response = client.get_cpe_match(
    cve_id="CVE-2022-32223",
    results_per_page=1,
    start_index=0
)
pprint(response)

get_cpe_match method check API's all constraints and limitations.

  • cveId is must be CVE ID format.
  • If filtering by the last modified date, both lastModStartDate and lastModEndDate are REQUIRED.
  • matchCriteriaId must be uuid format.
  • resultsPerPage's maximum allowable limit is 5,000.
  • The maximum allowable range when using any date range parameters is 120 consecutive days.
  • cpeName must be CPEv2.3 format.

Vulnerabilities / CVE API

This API's simple example is bellow.

from nvd_api import NvdApiClient
from pprint import pprint

client = NvdApiClient()

response = client.get_cves(
    cpe_name="cpe:2.3:o:debian:debian_linux:3.0:*:*:*:*:*:*:*",
    cvss_v2_metrics="AV:L/AC:L/Au:N/C:C/I:C/A:C",
    cvss_v2_severity="HIGH",
    results_per_page=1,
    start_index=1
)
pprint(response)
  • cpeName must be CPEv2.3 format.
  • cveId is must be CVE ID format.
  • cvssV2Severity, cvssV2Metrics is must be CVSS v2 format.
  • cvssV3Severity, cvssV3Metrics is must be CVSS v3 format.
  • cweId is must be CWE ID format.
  • resultsPerPage's maximum allowable limit is 2,000.
  • If filtering by keywordExactMatch, keywordSearch is REQUIRED.
  • If filtering by the last modified date, both lastModStartDate and lastModEndDate are REQUIRED.
  • If filtering by the last modified date, both pubStartDate and pubEndDate are REQUIRED.
  • The maximum allowable range when using any date range parameters is 120 consecutive days.
  • cvssV2Metrics cannot be used in requests that include cvssV3Metrics.
  • cvssV3Metrics cannot be used in requests that include cvssV2Metrics.
  • cvssV2Severity cannot be used in requests that include cvssV3Severity.
  • cvssV3Severity cannot be used in requests that include cvssV2Severity.

Vulnerabilities / CVE Change History API

This API's simple example is bellow.

from nvd_api import NvdApiClient
from pprint import pprint

client = NvdApiClient()

response = client.get_cve_history(
    change_start_date="2021-08-04T00:00:00.000",
    change_end_date="2021-10-23T00:00:00.000",
    event_name="CVE Rejected",
    results_per_page=1,
    start_index=1
)
pprint(response)

get_cve_history method check API's all constraints and limitations.

  • If filtering by the change date, both changeStartDate and changeEndDate are REQUIRED.
  • cveId is must be CVE ID format.
  • resultsPerPage's maximum allowable limit is 5,000.
  • The maximum allowable range when using any date range parameters is 120 consecutive days.

With API Key

If you have the nvd api key, you can set key to client.

from nvd_api import NvdApiClient
from pprint import pprint

client = NvdApiClient(wait_time=1 * 1000, api_key='THIS IS API KEY')

response = client.get_cves(
    cpe_name="cpe:2.3:o:debian:debian_linux:3.0:*:*:*:*:*:*:*",
    cvss_v2_metrics="AV:L/AC:L/Au:N/C:C/I:C/A:C",
    cvss_v2_severity="HIGH",
    results_per_page=1,
    start_index=1
)
pprint(response)
  • api_key : api key published by nvd.
  • wait_time : interval time to execute api (with api key is 50 requests in a rolling 30s window, without api key is 5 requests in a rolling 30s window)

nvd-api's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar kannkyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

slapdrone

nvd-api's Issues

Proxy Parameter Request

Nice python lib for NVD api2.0 !

Is there a way to add a proxy parameter to Class NvdApiClient?
I've try to add a proxy parameter in class NvdApiClient and Configuration manually, but still get the following error:
'Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.