Skip to content

justCWEId

The justCWEId function extracts the CWE identifier from a full CWE string that may include a description after a colon.

{cweString | justCWEId}
  • input (string): A CWE string, potentially in format “CWE-XX: Description”

The CWE ID portion only (text before the colon), trimmed of whitespace

{"CWE-79: Cross-site Scripting" | justCWEId}
// Returns: "CWE-79"
{"CWE-89" | justCWEId}
// Returns: "CWE-89"
{vulnerability.cwe | justCWEId}
// Extracts just the CWE ID from vulnerability's CWE field
{"CWE-20: Improper Input Validation: Additional Info" | justCWEId}
// Returns: "CWE-20"
{"CWE-287 : Improper Authentication" | justCWEId}
// Returns: "CWE-287"
  • Creating CWE reference links
  • Standardizing CWE format in reports
  • Building CWE statistics without descriptions
  • Filtering or grouping by CWE ID
  • Integration with CWE databases requiring ID-only format