{"id":27675,"library":"cwe2","title":"cwe2: CWE common weakness enumeration library","description":"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.","status":"active","version":"3.0.0","language":"python","source_language":"en","source_url":"https://github.com/nexB/cwe2","tags":["cwe","common-weakness-enumeration","security","vulnerability","weakness"],"install":[{"cmd":"pip install cwe2","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Used for fetching CWE data from the official XML source","package":"requests","optional":true},{"reason":"Used for parsing CWE XML data","package":"lxml","optional":true}],"imports":[{"wrong":"from cwe2 import CWE","symbol":"CWE","correct":"import cwe2"}],"quickstart":{"code":"from cwe2 import CWE\n\n# Load CWE database\ncwe = CWE()\n# Get a specific weakness by ID\nweakness = cwe.get('CWE-79')\nprint(weakness.name)\nprint(weakness.description)","lang":"python","description":"Initialize CWE object and fetch a weakness by its CWE-ID. The library downloads the CWE data on first use."},"warnings":[{"fix":"Update imports to 'from cwe2 import CWE' and access attributes like weakness.name instead of weakness['name'].","message":"Version 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.","severity":"breaking","affected_versions":"<3.0.0 -> >=3.0.0"},{"fix":"Ensure internet connectivity. Set CWE_CACHE_DIR environment variable to a writable path if default (e.g., ~/.cwe) is not accessible.","message":"CWE data is not bundled; it's downloaded on first instantiation. Requires internet access and write permissions to the cache directory.","severity":"gotcha","affected_versions":"all"},{"fix":"Always pass full CWE ID string, e.g., 'CWE-79'.","message":"CWE IDs must include the 'CWE-' prefix. Using just '79' will raise an error.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.0.0':22 'access':24 'activ':36 'categori':30 'common':3,16,43 'common-weakness-enumer':42 'cwe':2,19,26,41 'cwe2':1,7 'data':27 'dictionari':20 'enumer':5,18,45 'includ':28 'librari':6,11,34 'maintain':37 'period':39 'provid':23 'python':10 'releas':40 'secur':46 'version':21 'view':32 'vulner':47 'weak':4,17,29,44,48 'work':13","created_at":"2026-05-09T05:51:29.922591+00:00","updated_at":"2026-05-09T05:51:29.922591+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/nexB/cwe2","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cwe2/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}