pydantic-cwe
pydantic-cwe provides a structured, object-oriented way to work with the Common Weakness Enumeration (CWE) database.
By modeling CWE entries as Pydantic objects, this library enables developers and security researchers to
programmatically access, validate, and manipulate CWE data with ease. Ideal for static analysis tools, vulnerability
scanners, or custom security pipelines.
Installation
pip install pydantic-cwe
Usage
Loading a CWE catalog
from pydantic_cwe import Loader
# Create a loader instance
loader = Loader()
# Load the catalog
catalog = loader.load()
# Print some basic information about the catalog
print(f"Catalog Name: {catalog.name}")
print(f"Catalog Version: {catalog.version}")
print(f"Catalog Date: {catalog.date}")
print(f"Number of weaknesses: {len(catalog.weaknesses.weaknesses)}")
Working with weaknesses
from pydantic_cwe import Loader
loader = Loader()
catalog = loader.load()
# Get weaknesses ordered by ID
for weakness in catalog.get_ordered_weaknesses():
if weakness.status == 'Deprecated':
continue
print(f"ID: {weakness.id}")
print(f"Name: {weakness.name}")
print(f"Abstraction: {weakness.abstraction}")
print(f"Structure: {weakness.structure}")
print(f"Status: {weakness.status}")
print(f"Description: {weakness.description}")
Project Structure
The project follows a standard Python library structure:
examples/: Example scriptspydantic_cwe/: Main package directorymodels: Pydantic models for CWE data__init__.py: Package initialization and exportsloader.py: XML loading and parsing functionality
tests/: Unit tests
Development
Setting up the development environment
# Clone the repository
git clone https://github.com/epicosy/pydantic-cwe.git
cd pydantic-cwe
# Create a virtual environment
python -m venv env
source env/bin/activate # On Windows: env\Scripts\activate
# Install development dependencies
pip install -e ".[test]"
Running tests
pytest
Metadata
Release files for pydantic-cwe 0.1.2
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 | Actions |
|---|---|---|---|---|
| pydantic_cwe-0.1.2.tar.gz | 14.8 kB | Without provenance | Details for pydantic_cwe-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_cwe-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pydantic_cwe-0.1.2-py3-none-any.whl |
Total release size: 25.0 kB
Release files / pydantic_cwe-0.1.2.tar.gz
| Download URL | pydantic_cwe-0.1.2.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f0da8850f56af23ab495782df6ba49e2fcb10f1a1f751567a727fbb94d77064
|
|
BLAKE2b-256 checksum How to use checksums |
4369ad18620d98858d0a975eec75887cba1b789cf26af6c82041b5fc12e839c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.7
|
Release files / pydantic_cwe-0.1.2-py3-none-any.whl
| Download URL | pydantic_cwe-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8f14141d1b69cd8b6a2e43bb47685a04d50ba9bca61db098dd6fd3bd6e04398
|
|
BLAKE2b-256 checksum How to use checksums |
521a50a2a4bc760576073fba9494f2d160da2e4e3e747f6b0d657ccbe3770f24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.7
|
Security for pydantic-cwe 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.