skillfed

cwe2

cwe2 is a CWE common weakness enumeration library for Python

cwe2 v3.0.0 78.9K downloads/30d#14,400 on PyPI15
Permissive license MIT and LicenseRef-scancode-cwe-tou DORMANT released

What it is and what it does

cwe2 is a Python wrapper around the Common Weakness Enumeration (CWE) database maintained by MITRE. It bundles a vendored copy of the CWE data and exposes it through a simple query interface, letting you fetch weakness records by ID and access their structured attributes—name, description, related weaknesses, mitigation strategies, and more. The package is useful for security tools, vulnerability scanners, and code analysis systems that need to resolve CWE IDs to human-readable weakness information.

The library requires Python 3.7 or later and has minimal dependencies. It provides convenience methods to retrieve curated subsets like the top 25 CWEs, OWASP top ten 2021 weaknesses, and those used by the National Vulnerability Database (NVD). Maintenance is dormant but the package is stable and carries no known security vulnerabilities.

Use it for:

  • Resolve CWE IDs in vulnerability reports to fetch full weakness descriptions and mitigation guidance.
  • Build security dashboards or scanners that need to display MITRE CWE metadata alongside CVE findings.
  • Analyze code or dependencies and map detected weakness categories to their MITRE definitions for compliance reporting.
  • Query curated CWE lists like top 25 or OWASP top ten 2021 for security training or policy enforcement.
  • Enrich vulnerability data pipelines with standardized CWE weakness context and related attack patterns.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

cwe2 provides programmatic access to the Common Weakness Enumeration (CWE) database, allowing you to look up vulnerability weakness categories by ID and retrieve their detailed attributes.

Yes, if you need to programmatically look up CWE weakness data in a Python application. The package is stable, has no known vulnerabilities, and low install friction. The main caveat is dormant maintenance—the vendored CWE data may lag behind MITRE's official updates, so verify the data freshness suits your use case before relying on it for critical security decisions.

Install

cwe2 on PyPI

pip

pip install cwe2

uv

uv add cwe2

poetry

poetry add cwe2

Installing cwe2

Before you install

Low install friction with a single lightweight dependency (importlib-resources). Maintenance is dormant—last commit was 2024-08-29 and no releases in over a year, though the repository remains active and the package is marked Production/Stable.

License in practice

Dual-licensed under MIT and LicenseRef-scancode-cwe-tou. The CWE data itself carries MITRE's terms of use; permissive for code but you must respect MITRE's CWE usage terms when distributing or relying on the weakness data.

Quickstart

pip install cwe2

from cwe2.database import Database
db = Database()
weakness = db.get(15)
print(weakness.description)

Verify before relying

  • Whether the vendored CWE data is kept current with MITRE's official CWE updates, given the dormant maintenance status.
  • Performance characteristics when querying large numbers of weaknesses or iterating the full database.

Package facts

License MIT and LicenseRef-scancode-cwe-tou (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 1 — importlib-resources
Maintenance dormant — 751 days since the last release
Last repo commit
First released
Downloads 78,876/month — #14,400 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cwe2-3.0.0-py3-none-any.whl

Keywords: utilities, CWE, weakness, CVE, vulnerabilities

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: Software DevelopmentTopic :: Utilities

Tags

CWE lookup librarycommon weakness enumeration databasevulnerability weakness categoriesCWE ID resolversecurity weakness referenceMITRE CWE data accessCVE weakness mapping
vulnerability-referencesecurity-metadata

More Software Development packages