GHSA Client
A Python client library for the GitHub Security Advisory (GHSA) API, providing structured access to security advisory data.
Features
- Sync and async clients:
GHSAClientfor synchronous code,AsyncGHSAClientfor async/await - Type-safe models: Full Pydantic models for GHSA data structures
- Rate limiting: Built-in rate limit handling and retry logic
- Flexible queries: Search advisories with various filters
- Comprehensive data: Access to all GHSA fields including CVSS scores, CWE mappings, and package information
Installation
pip install ghsa-client
Quick Start
import logging
from ghsa_client import GHSAClient, GHSA_ID
# Set up logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# Create client
client = GHSAClient(logger)
# Get a specific advisory
ghsa_id = GHSA_ID("GHSA-gq96-8w38-hhj2")
advisory = client.get_advisory(ghsa_id)
print(f"Advisory: {advisory.summary}")
print(f"Severity: {advisory.severity}")
print(f"CVSS Score: {advisory.cvss.score if advisory.cvss else 'N/A'}")
Usage
Authentication
The client automatically uses the GITHUB_TOKEN environment variable if available:
export GITHUB_TOKEN=your_github_token_here
Getting an Advisory
from ghsa_client import GHSAClient, GHSA_ID
client = GHSAClient(logger)
advisory = client.get_advisory(GHSA_ID("GHSA-gq96-8w38-hhj2"))
# Access advisory properties
print(advisory.summary)
print(advisory.severity)
print(advisory.published_at)
print(advisory.vulnerabilities)
Async Client
AsyncGHSAClient provides the same API using httpx.AsyncClient:
from ghsa_client import AsyncGHSAClient, GHSA_ID
async with AsyncGHSAClient() as client:
advisory = await client.get_advisory(GHSA_ID("GHSA-gq96-8w38-hhj2"))
async for adv in client.search_advisories(ecosystem="npm"):
print(adv.summary)
Searching Advisories
# Search by ecosystem
advisories = client.search_advisories(ecosystem="npm")
# Search by severity
advisories = client.search_advisories(severity="high")
# Search by date range
advisories = client.search_advisories(published="2024-01-01..2024-12-31")
# Get all advisories for a year
advisories = client.get_all_advisories_for_year(2024)
Rate Limiting
The client automatically handles GitHub's rate limits:
# Check remaining rate limit
rate_limit = client.get_ratelimit_remaining()
print(f"Remaining requests: {rate_limit['resources']['core']['remaining']}")
# The client will automatically wait for rate limit reset when needed
Models
Advisory
The main model representing a GitHub Security Advisory:
from ghsa_client import Advisory
advisory: Advisory = client.get_advisory(ghsa_id)
# Core properties
advisory.ghsa_id # GHSA_ID object
advisory.cve_id # Optional CVE_ID object
advisory.summary # str
advisory.severity # str
advisory.published_at # str (ISO date)
advisory.description # Optional[str]
# Vulnerability data
advisory.vulnerabilities # List[Vulnerability]
advisory.affected_packages # List[Package] (computed property)
# CVSS data
advisory.cvss # Optional[CVSS]
advisory.cwes # Optional[List[str]]
# Repository information
advisory.source_code_location # Optional[str]
advisory.repository_url # str (property, raises if not found)
# References
advisory.references # List[str]
GHSA_ID
Type-safe GHSA identifier with validation:
from ghsa_client import GHSA_ID, InvalidGHSAIDError
try:
ghsa_id = GHSA_ID("GHSA-gq96-8w38-hhj2")
print(ghsa_id.id) # "GHSA-gq96-8w38-hhj2"
except InvalidGHSAIDError as e:
print(f"Invalid GHSA ID: {e}")
CVE_ID
Type-safe CVE identifier with validation:
from ghsa_client import CVE_ID
cve_id = CVE_ID("CVE-2024-12345")
print(cve_id.id) # "CVE-2024-12345"
Development
Setup
git clone https://github.com/valmarelox/ghsa-client.git
cd ghsa-client
pip install -e ".[dev]"
Running Tests
pytest
Code Formatting
black .
isort .
Type Checking
mypy src/ghsa_client
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
Changelog
See the releases page for a history of changes.
Metadata
Release files for ghsa-client 1.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ghsa_client-1.14.0.tar.gz | 20.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ghsa_client-1.14.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.8 kB
Release files / ghsa_client-1.14.0.tar.gz
| Download URL | ghsa_client-1.14.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5797262cfc6c301807f4d94f79c883ea47f19fecc9058cc2ee82d91d262f90f1
|
|
BLAKE2b-256 checksum How to use checksums |
dbf3d45381cd188d1d24d33c16139720d401d81778da43cd5d64a7132549db0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logRelease files / ghsa_client-1.14.0-py3-none-any.whl
| Download URL | ghsa_client-1.14.0-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a047d27a011cb447a10545669ef302b02d5e624a9b0d42362b94317976c335d
|
|
BLAKE2b-256 checksum How to use checksums |
e050ec69df79f02b36a504d90544bd13e7e4a752ab72194ba9473e971d44079e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logSecurity for ghsa-client 1.14.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ghsa_client-1.14.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.