Skip to main content

The cli tool for checking the security of the packages.

Project description

SafePackages

SafePackages is a powerful Python CLI tool designed to scan your project's dependencies for known vulnerabilities. It leverages the OSV (Open Source Vulnerabilities) database to provide accurate and up-to-date security information for a wide range of ecosystems.

Features

  • Multi-Mode Scanning:
    • Single Package: Scan a specific package version.
    • Manifest File: Parse and scan dependency files (e.g., requirements.txt, package.json).
    • Batch Mode: Scan a list of packages from a JSON input.
  • Broad Ecosystem Support: Supports npm, PyPI, Maven, NuGet, Go, Rust, PHP (Composer), Ruby (Gems), and more.
  • Flexible Output: Generate reports in Table, JSON, or CSV formats.
  • CI/CD Ready:
    • Set failure thresholds (e.g., fail only on CRITICAL or HIGH severity).
    • Exit codes for pipeline integration.
  • Dev Dependency Control: Option to include or exclude development dependencies.

Installation

You can install SafePackages using pip:

pip install safe-packages

Or using uv:

uv pip install safe-packages

Usage

After installation, the safepackages command will be available. You can see the help message by running:

safepackages --help

Commands

SafePackages provides three main commands:

1. scan - Scan a Single Package

Scan a specific package version for vulnerabilities.

Usage:

safepackages scan [OPTIONS] NAME

Arguments:

  • NAME: The name of the package to scan (Required).

Options:

  • -e, --ecosystem TEXT: Package ecosystem (e.g., npm, PyPI, Maven, NuGet) (Required).
  • -v, --version TEXT: Package version to check.
  • -f, --format [table|json|csv]: Output format (Default: table).
  • -o, --output TEXT: Write output to a file.
  • --fail-on [low|medium|high|critical]: Exit with error code 1 if vulnerabilities of this severity or higher are found (Default: high).

Example:

safepackages scan requests --version 2.20.0 --ecosystem PyPI

2. file - Scan a Manifest File

Scan a dependency manifest file. The file type is automatically detected.

Usage:

safepackages file [OPTIONS] FILE_PATH

Arguments:

  • FILE_PATH: Path to the manifest file (Required).

Options:

  • --include-dev: Include development dependencies in the scan.
  • -f, --format [table|json|csv]: Output format (Default: table).
  • -o, --output TEXT: Write output to a file.
  • --fail-on [low|medium|high|critical]: Exit with error code 1 if vulnerabilities of this severity or higher are found (Default: high).

Supported Manifests:

  • requirements.txt, poetry.lock, Pipfile.lock (Python)
  • package.json, package-lock.json (npm)
  • yarn.lock (yarn)
  • pom.xml (Maven)
  • go.mod (Go)
  • Cargo.lock (Rust)
  • Gemfile.lock (Ruby)
  • composer.lock (PHP)
  • packages.config, *.csproj (NuGet)

Example:

safepackages file requirements.txt --include-dev --format json

3. batch - Batch Scan

Scan a list of packages from a JSON input string or file.

Usage:

safepackages batch [OPTIONS] JSON_INPUT

Arguments:

  • JSON_INPUT: A JSON string array of packages or a path to a JSON file (Required).
    • Format: [{"name": "pkg_name", "version": "1.0.0", "ecosystem": "PyPI"}, ...]

Options:

  • -f, --format [table|json|csv]: Output format (Default: table).
  • -o, --output TEXT: Write output to a file.
  • --fail-on [low|medium|high|critical]: Exit with error code 1 if vulnerabilities of this severity or higher are found (Default: high).

Example:

# From JSON string
safepackages batch '[{"name":"django","version":"3.0.0","ecosystem":"PyPI"}]'

# From JSON file
safepackages batch packages.json

Development

We use uv and poethepoet for development.

  1. Install uv: https://github.com/astral-sh/uv
  2. Run tasks:
    • uv run poe check - Run full verification (lint, test, build).
    • uv run poe list - List all available tasks.

License

Apache 2.0 License

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

safe_packages-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

safe_packages-0.1.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file safe_packages-0.1.0.tar.gz.

File metadata

  • Download URL: safe_packages-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for safe_packages-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8408a443d3b36dd4a07b6bc0950162ed442e5ebcdee2b1f0977beab4763eb676
MD5 81c7bbbd178cbde80451809205cdfc60
BLAKE2b-256 33f01e462897c4b7a338772e9b3597eb66650919f82ae19af63aae653213aefa

See more details on using hashes here.

Provenance

The following attestation bundles were made for safe_packages-0.1.0.tar.gz:

Publisher: release.yml on thedevappsecguy/safe-packages

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file safe_packages-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: safe_packages-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for safe_packages-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d0ea48775b749dcb349a598e38d5e34cf91de3d662485e5f64c05905787757d
MD5 06492c732fadfaa1440968fb28206f03
BLAKE2b-256 adf0add001223ee9029cf5ec3ef5c41f85f03f0ba9bff2bb9fab568d51dfe656

See more details on using hashes here.

Provenance

The following attestation bundles were made for safe_packages-0.1.0-py3-none-any.whl:

Publisher: release.yml on thedevappsecguy/safe-packages

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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