| Name | pydantic-cwe JSON |
| Version |
0.1.0
JSON |
| download |
| home_page | None |
| Summary | A Pythonic representation of CWE records using Pydantic models. |
| upload_time | 2025-10-14 13:23:13 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.9 |
| license | None |
| keywords |
package
cwe
pydantic
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# 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
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pydantic-cwe",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "package, cwe, pydantic",
"author": null,
"author_email": "Eduard Pinconschi <eduard.pinconschi@tecnico.ulisboa.pt>",
"download_url": "https://files.pythonhosted.org/packages/94/ae/b4565b28d10dfb05e7916793184b55c9fdd3e61d7f7bf1e7c7c1422559f0/pydantic_cwe-0.1.0.tar.gz",
"platform": null,
"description": "# pydantic-cwe\n\n`pydantic-cwe` provides a structured, object-oriented way to work with the Common Weakness Enumeration (CWE) database. \nBy modeling CWE entries as Pydantic objects, this library enables developers and security researchers to \nprogrammatically access, validate, and manipulate CWE data with ease. Ideal for static analysis tools, vulnerability \nscanners, or custom security pipelines.\n\n## Installation\n\n```bash\npip install pydantic-cwe\n```\n\n## Usage\n\n### Loading a CWE catalog\n\n```python\nfrom pydantic_cwe import Loader\n\n# Create a loader instance\nloader = Loader()\n\n# Load the catalog\ncatalog = loader.load()\n\n# Print some basic information about the catalog\nprint(f\"Catalog Name: {catalog.name}\")\nprint(f\"Catalog Version: {catalog.version}\")\nprint(f\"Catalog Date: {catalog.date}\")\nprint(f\"Number of weaknesses: {len(catalog.weaknesses.weaknesses)}\")\n```\n\n### Working with weaknesses\n\n```python\nfrom pydantic_cwe import Loader\n\nloader = Loader()\ncatalog = loader.load()\n\n# Get weaknesses ordered by ID\nfor weakness in catalog.get_ordered_weaknesses():\n if weakness.status == 'Deprecated':\n continue\n\n print(f\"ID: {weakness.id}\")\n print(f\"Name: {weakness.name}\")\n print(f\"Abstraction: {weakness.abstraction}\")\n print(f\"Structure: {weakness.structure}\")\n print(f\"Status: {weakness.status}\")\n print(f\"Description: {weakness.description}\")\n```\n\n## Project Structure\n\nThe project follows a standard Python library structure:\n\n- `examples/`: Example scripts\n- `pydantic_cwe/`: Main package directory\n - `models`: Pydantic models for CWE data\n - `__init__.py`: Package initialization and exports\n - `loader.py`: XML loading and parsing functionality\n- `tests/`: Unit tests\n\n## Development\n\n### Setting up the development environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/epicosy/pydantic-cwe.git\ncd pydantic-cwe\n\n# Create a virtual environment\npython -m venv env\nsource env/bin/activate # On Windows: env\\Scripts\\activate\n\n# Install development dependencies\npip install -e \".[test]\"\n```\n\n### Running tests\n\n```bash\npytest\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A Pythonic representation of CWE records using Pydantic models.",
"version": "0.1.0",
"project_urls": {
"homepage": "https://github.com/epicosy/pydantic-cwe",
"repository": "https://github.com/epicosy/pydantic-cwe"
},
"split_keywords": [
"package",
" cwe",
" pydantic"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "09903a78f9211fb2891aee2d43f228e18e6ecc4c719d41b91484e9feed7be439",
"md5": "71392e1e02fca72007b0245205cbcc64",
"sha256": "04e2ed56a4de7792167ada624dbee3ef62b4bf554605059c846946095e390663"
},
"downloads": -1,
"filename": "pydantic_cwe-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "71392e1e02fca72007b0245205cbcc64",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9992,
"upload_time": "2025-10-14T13:23:12",
"upload_time_iso_8601": "2025-10-14T13:23:12.042036Z",
"url": "https://files.pythonhosted.org/packages/09/90/3a78f9211fb2891aee2d43f228e18e6ecc4c719d41b91484e9feed7be439/pydantic_cwe-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "94aeb4565b28d10dfb05e7916793184b55c9fdd3e61d7f7bf1e7c7c1422559f0",
"md5": "0c324c3fd2dadb0fda28a90225316d39",
"sha256": "db42d97b0009c0860779b0a9a59815f746cf7a94d614d619e417159eb8fe6768"
},
"downloads": -1,
"filename": "pydantic_cwe-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "0c324c3fd2dadb0fda28a90225316d39",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 14533,
"upload_time": "2025-10-14T13:23:13",
"upload_time_iso_8601": "2025-10-14T13:23:13.170736Z",
"url": "https://files.pythonhosted.org/packages/94/ae/b4565b28d10dfb05e7916793184b55c9fdd3e61d7f7bf1e7c7c1422559f0/pydantic_cwe-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-14 13:23:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "epicosy",
"github_project": "pydantic-cwe",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pydantic-cwe"
}