Report templatesFunctions

justCWEId

Extract only the CWE ID from a full CWE string

Usage

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

Syntax

{cweString | justCWEId}

Parameters

  • input (string): A CWE string, potentially in format "CWE-XX: Description"

Returns

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

Examples

Basic CWE extraction

{"CWE-79: Cross-site Scripting" | justCWEId}
// Returns: "CWE-79"

Already clean CWE ID

{"CWE-89" | justCWEId}
// Returns: "CWE-89"

With vulnerability data

{vulnerability.cwe | justCWEId}
// Extracts just the CWE ID from vulnerability's CWE field

Multiple colons

{"CWE-20: Improper Input Validation: Additional Info" | justCWEId}
// Returns: "CWE-20"

With extra whitespace

{"CWE-287 : Improper Authentication" | justCWEId}
// Returns: "CWE-287"

Use Cases

  • 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