Expression Logic
Most Handlebars expressions can be used. Some basic examples are given here, but much more information is available in the Handlebars documentation. Specific sections of interest are Expressions, Block Helpers, and Built-in Helpers.
Boolean Expressions
if
, ifeq
, and ifneq
. Note
that ifeq
and ifneq
are custom helpers provided by
Software Risk Manager.- If
{{#if finding.detection.isDast}} This finding is a DAST finding. {{else}} This finding is not a DAST finding. {{/if}}
will result
This finding is a DAST finding.
whenThis finding is not a DAST finding.
- ifeq
The
ifeq
helper allows you to test the equality between two string or number values for a boolean result. Comparing values of types other than strings or numbers is unsupported, and the block will always evaluate to false.Note thatelse
can not be used withifeq
; you may useifneq
instead to simulateelse
.{{#ifeq finding.statusName "New"}} This finding is new {{/ifeq}}
will result inThis finding is new.
when a finding's status is new.
- ifneqThe
ifneq
helper behaves the same way asifeq
except it negates the boolean result of testing the equality between twostring
ornumber
values.{{#ifeq finding.severity.name "Critical"}} This finding is critical {{/ifeq}} {{#ifneq finding.severity.name "Critical"}} This finding is not critical {{/ifneq}}
will result inThis finding is not critical.
when a finding's severity is
not Critical
.
Iterating Lists
You can iterate over arrays by using the each helper.
{{#each allFindings}}
{{id}},
{{/each}}
1, 2, 3, 4,
when evaluated on a group of findings with the IDs of 1, 2, 3, and 4.
{{#each allFindings}}
{{#each results}}
{{{hostInfo.formattedHostInfo}}}
{{#each variants}}
Request:
{{{request-data}}}
Response:
{{{response-data}}}
{{/each}}
{{/each}}
{{/each}}
Understanding and utilizing {{#each}}
is important, because as you
can see in the above summary of the properties of the finding objects, many of the
properties are arrays and therefore can't simply be accessed directly—you need to
iterate over them and access each property inside the loop.