Report templatesFunctions

arrayContains

Return input value if array contains a specific element, otherwise return null

Usage

The arrayContains function checks if an array contains a specific value. If found, it returns the original input value; otherwise, it returns null.

Syntax

{input | arrayContains:haystack:needle}

Parameters

  • input (any): The value to return if the needle is found in the haystack
  • haystack (array): The array to search in
  • needle (any): The value to search for

Returns

  • Returns the input value if needle is found in haystack
  • Returns null if needle is not found or if any parameter is null/undefined

Examples

{"Found!" | arrayContains:["apple","banana","orange"]:"banana"}
// Returns: "Found!"

Search not found

{"Found!" | arrayContains:["apple","banana","orange"]:"grape"}
// Returns: null

Conditional rendering

{vulnerability.name | arrayContains:criticalVulns:vulnerability.id}
// Returns vulnerability name only if its ID is in the criticalVulns array

Filtering scope items

{endpoint.url | arrayContains:allowedDomains:endpoint.domain}
// Returns URL only if domain is in allowed list

Using with numbers

{port.service | arrayContains:[80,443,8080]:port.number}
// Returns service name if port number is in the list

Use Cases

  • Conditional display of data based on array membership
  • Filtering items based on whitelist/blacklist
  • Scope validation in security assessments
  • Permission-based content rendering
  • Tag-based filtering in reports