Registry / serialization / cwe2
library3.0.0pypypi✓ verified 84d ago

cwe2 is a Python library for working with the Common Weakness Enumeration (CWE) dictionary. Version 3.0.0 provides access to CWE data including weaknesses, categories, and views. The library is actively maintained with periodic releases.

pip install cwe2
INSTALL
IMPORT
SIG · CWE2
C
cwe2
serializationpythonv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CWE
✓ import cwe2
✗ from cwe2 import CWE

Initialize CWE object and fetch a weakness by its CWE-ID. The library downloads the CWE data on first use.

from cwe2 import CWE # Load CWE database cwe = CWE() # Get a specific weakness by ID weakness = cwe.get('CWE-79') print(weakness.name) print(weakness.description)
Debug
Known issues
breakingVersion 3.0.0 changed the API: the CWE class is now imported from cwe2 instead of cwe2.cwe. Also the get() method returns a Weakness object instead of a dict.
fix
Update imports to 'from cwe2 import CWE' and access attributes like weakness.name instead of weakness['name'].
affects: <3.0.0 -> >=3.0.0
gotchaCWE data is not bundled; it's downloaded on first instantiation. Requires internet access and write permissions to the cache directory.
fix
Ensure internet connectivity. Set CWE_CACHE_DIR environment variable to a writable path if default (e.g., ~/.cwe) is not accessible.
affects: all
gotchaCWE IDs must include the 'CWE-' prefix. Using just '79' will raise an error.
fix
Always pass full CWE ID string, e.g., 'CWE-79'.
affects: all
Upgrade
Version history
3.0.0latest on PyPI · released Jul 24, 2024
Audit
Dependencies
requestsoptionalUsed for fetching CWE data from the official XML source
lxmloptionalUsed for parsing CWE XML data
Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
cwe2 — pip install cwe2 · libregistry