CWE
JSON serialization for CWE::Weakness.
The emitted shape is stable and snake_case. Empty arrays and nil scalars
are omitted so a serialized entry is concise. The catalog identifier
("CWE-79") is emitted as "cweId" alongside the integer "id" for
tooling that wants either form.
JSON.parse(CWE.find!(79).to_json)["cweId"].as_s # => "CWE-79"
Constants
The numeric portion of a CWE id, e.g. "CWE-79", "cwe-79", " 79 ",
or "79". Returns nil if the input does not match.
The prefix is case-insensitive and must be followed by exactly one
separator โ -, _, :, or a single space. Surrounding whitespace is
stripped first; embedded whitespace, repeated separators, and the
separator-less "CWE79" form are all rejected. Numbers too large for an
Int32 return nil rather than overflowing.
Class methods
Default catalog instance. The first call lazily parses the embedded JSON blob; subsequent calls return the same instance.
Look up any entry by id: Weakness, Category, or View.
Resolve a REF-N citation id to its full record. Returns nil if the
id is not in the registry.
All catalog-level citations (the <External_References> block in the
MITRE XML). Empty when the build wasn't given the XML.
Look up a weakness by integer id (e.g. 79) or CWE string
("CWE-79", "cwe-79", "79"). Returns nil if not found.
Raising variants โ NotFoundError if the id is not in the catalog,
ParseError if the string is not a CWE id.
Traversal accepts the same id forms as find โ 79, "79", "CWE-79".
max_depth bounds the transitive walks; the real CWE hierarchy is only
3-4 levels deep, so the default is a guard against pathological catalogs
rather than something callers normally set.
Case-insensitive substring search across name, descriptions, and alternate terms.
Nested types
- CWE::Abstraction
- CWE::AlternateTerm
- CWE::ApplicablePlatform
- CWE::Catalog
- CWE::Category
- CWE::Consequence
- CWE::ContentHistory
- CWE::DemonstrativeExample
- CWE::DetectionMethod
- CWE::Error
- CWE::ExampleCode
- CWE::ExternalReference
- CWE::MappingNotes
- CWE::MappingSuggestion
- CWE::MappingUsage
- CWE::Mitigation
- CWE::ModeOfIntroduction
- CWE::NotFoundError
- CWE::Note
- CWE::ObservedExample
- CWE::Ordinality
- CWE::ParseError
- CWE::ReferenceLink
- CWE::Related
- CWE::Stakeholder
- CWE::Status
- CWE::Structure
- CWE::TaxonomyMapping
- CWE::View
- CWE::Weakness