Skip to main content

CLI tool to check requirements.txt for vulnerabilities using NVD API

Project description

secure-req-check

PyPI version Python versions License: MIT Code style: black

A command‑line tool to scan Python requirements.txt files for known security vulnerabilities using the NVD (National Vulnerability Database) API.

Features

  • Fast scanning of requirements.txt with exact version matching (package==version).
  • Direct integration with NVD REST API – no local vulnerability database required.
  • Flexible output formats: table, JSON, CSV.
  • Severity filtering – show only LOW, MEDIUM, HIGH, or CRITICAL findings.
  • Caching – reduces API calls and speeds up repeated scans.
  • CI/CD ready – returns non‑zero exit code when vulnerabilities are found.
  • Optional NVD API key support for higher rate limits.

Installation

From PyPI (recommended)

pip install secure-req-check

From source

git clone https://github.com/yourusername/secure-req-check.git
cd secure-req-check
pip install .

Quick Start

  1. Navigate to a directory containing a requirements.txt file (or create one).

  2. Run the scanner:

    secure-req-check scan
    
  3. Review the table of discovered vulnerabilities.

Usage

Scan Command

secure-req-check scan [OPTIONS] [REQUIREMENTS_FILE]
Option Description
-f, --file PATH Path to requirements.txt (default: ./requirements.txt)
-o, --output [table|json|csv|quiet] Output format (default: table)
--output-file PATH Write report to a file instead of stdout
--severity [LOW|MEDIUM|HIGH|CRITICAL] Minimum severity level to display
--ignore-cve TEXT Ignore a specific CVE (repeatable)
--ignore-package TEXT Ignore a package entirely (repeatable)
--no-cache Disable local cache – always query the NVD API
--timeout INTEGER Request timeout in seconds (default: 30)
--verbose Print detailed progress information

Configuration Commands

secure-req-check config set-api-key YOUR_NVD_API_KEY   # Store API key
secure-req-check config show                           # Display current settings
secure-req-check config clear-cache                    # Remove all cached responses

The API key can also be provided via the environment variable NVD_API_KEY.

Obtaining an NVD API Key

Public API requests are limited to 5 calls per 30 seconds.
To increase this limit to 50 calls per 30 seconds, request a free API key at:
https://nvd.nist.gov/developers/request-an-api-key

Example Output

Table Format (default)

$ secure-req-check scan -f requirements.txt
+-----------+---------+----------------+------------+---------------------------------------------+
| Package   | Version | CVE ID         | Severity   | Description                                 |
+===========+=========+================+============+=============================================+
| django    | 3.2.12  | CVE-2022-28346 | CRITICAL   | SQL injection vulnerability in QuerySet...  |
| pillow    | 8.4.0   | CVE-2022-22817 | HIGH       | Buffer overflow in path handling...         |
+-----------+---------+----------------+------------+---------------------------------------------+

⚠️  Found 2 vulnerabilities (CRITICAL: 1, HIGH: 1)
💡 Consider upgrading affected packages.

JSON Output

secure-req-check scan -o json --output-file report.json

Quiet Mode for CI

secure-req-check scan --severity HIGH --output quiet
# Returns exit code 1 if any HIGH or CRITICAL vulnerabilities are present.

Caching

By default, API responses are cached in ~/.cache/secure-req-check/ for 24 hours.
Use --no-cache to force a fresh lookup, or secure-req-check config clear-cache to remove all cached data.

CI/CD Integration

The tool exits with code 1 when at least one vulnerability is found. This behaviour makes it easy to block pipelines:

# GitLab CI example
security_scan:
  script:
    - pip install secure-req-check
    - secure-req-check scan --severity HIGH --output quiet

Limitations

  • Currently supports only package==version syntax. Ranges (e.g., >=) are partially supported – the tool extracts a minimum version.
  • Vendor mapping for CPE generation is based on a small built‑in list. If a package cannot be matched, you may see N/A in the output.

Development

git clone https://github.com/yourusername/secure-req-check.git
cd secure-req-check
python -m venv venv
source venv/bin/activate
pip install -e .[dev]
pytest

License

This project is licensed under the MIT License – see the LICENSE file for details.

Changelog

The сhangelog is available in this file - CHANGELOG.md

Disclaimer

This tool relies on the accuracy and completeness of the NVD database. It does not guarantee detection of all vulnerabilities and should be used as part of a comprehensive security strategy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secure_req_check-0.1.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file secure_req_check-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for secure_req_check-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df141df7a01a0db031cdbdb459ec1d65331138a555cc2d089355194c50a6908f
MD5 524e3c6d620f80326d8e4e83765c2958
BLAKE2b-256 cc16637db21ce3f14ae531207d4d856f94cad4dc1dd07871f0a2e8fa0e49ccde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page