Metadata-Version: 2.4
Name: pydantic-cwe
Version: 0.0.4
Summary: A Pythonic representation of CWE records using Pydantic models.
Author-email: Eduard Pinconschi <eduard.pinconschi@tecnico.ulisboa.pt>
License-Expression: MIT
Project-URL: repository, https://github.com/epicosy/pydantic-cwe
Project-URL: homepage, https://github.com/epicosy/pydantic-cwe
Keywords: package,cwe,pydantic
Classifier: Topic :: Software Development
Classifier: Programming Language :: Python
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lxml>=5.4.0
Requires-Dist: pydantic>=2.11.6
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: coverage; extra == "test"
Requires-Dist: twine>=1.11.0; extra == "test"
Requires-Dist: setuptools>=38.6.0; extra == "test"
Requires-Dist: wheel>=0.31.0; extra == "test"
Dynamic: license-file

# 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

```bash
pip install pydantic-cwe
```

## Usage

### Loading a CWE catalog

```python
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

```python
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 scripts
- `pydantic_cwe/`: Main package directory
  - `models`: Pydantic models for CWE data
  - `__init__.py`: Package initialization and exports
  - `loader.py`: XML loading and parsing functionality
- `tests/`: Unit tests

## Development

### Setting up the development environment

```bash
# 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

```bash
pytest
```
