@@ -56,15 +56,19 @@ export const buildReasonMessageUtil = ({ rule, mergedDoc }: BuildReasonMessageUt
5656
5757 const fieldPresenceTracker = { hasFieldOfInterest : false } ;
5858
59- const getFieldTemplateValue = ( field : string | string [ ] | undefined | null ) : string => {
60- if ( ! field || ! field . length || ( field . length === 1 && field [ 0 ] === '-' ) ) return 'null' ;
61- if ( ! fieldPresenceTracker . hasFieldOfInterest ) fieldPresenceTracker . hasFieldOfInterest = true ;
59+ const getFieldTemplateValue = (
60+ field : string | string [ ] | undefined | null ,
61+ isFieldOfInterest ?: boolean
62+ ) : string | null => {
63+ if ( ! field || ! field . length || ( field . length === 1 && field [ 0 ] === '-' ) ) return null ;
64+ if ( isFieldOfInterest && ! fieldPresenceTracker . hasFieldOfInterest )
65+ fieldPresenceTracker . hasFieldOfInterest = true ;
6266 return Array . isArray ( field ) ? field . join ( ', ' ) : field ;
6367 } ;
6468
6569 return i18n . translate ( 'xpack.securitySolution.detectionEngine.signals.alertReasonDescription' , {
6670 defaultMessage : `{eventCategory, select, null {} other {{eventCategory}{whitespace}}}event\
67- {hasFieldOfInterest, select, null {} other {{whitespace}with}}\
71+ {hasFieldOfInterest, select, false {} other {{whitespace}with}}\
6872{processName, select, null {} other {{whitespace}process {processName},} }\
6973{processParentName, select, null {} other {{whitespace}parent process {processParentName},} }\
7074{fileName, select, null {} other {{whitespace}file {fileName},} }\
@@ -76,15 +80,15 @@ created {alertSeverity} alert {alertName}.`,
7680 values : {
7781 alertName : rule . name ,
7882 alertSeverity : rule . severity ,
79- destinationAddress : getFieldTemplateValue ( destinationAddress ) ,
80- destinationPort : getFieldTemplateValue ( destinationPort ) ,
83+ destinationAddress : getFieldTemplateValue ( destinationAddress , true ) ,
84+ destinationPort : getFieldTemplateValue ( destinationPort , true ) ,
8185 eventCategory : getFieldTemplateValue ( eventCategory ) ,
82- fileName : getFieldTemplateValue ( fileName ) ,
86+ fileName : getFieldTemplateValue ( fileName , true ) ,
8387 hostName : getFieldTemplateValue ( hostName ) ,
84- processName : getFieldTemplateValue ( processName ) ,
85- processParentName : getFieldTemplateValue ( processParentName ) ,
86- sourceAddress : getFieldTemplateValue ( sourceAddress ) ,
87- sourcePort : getFieldTemplateValue ( sourcePort ) ,
88+ processName : getFieldTemplateValue ( processName , true ) ,
89+ processParentName : getFieldTemplateValue ( processParentName , true ) ,
90+ sourceAddress : getFieldTemplateValue ( sourceAddress , true ) ,
91+ sourcePort : getFieldTemplateValue ( sourcePort , true ) ,
8892 userName : getFieldTemplateValue ( userName ) ,
8993 hasFieldOfInterest : fieldPresenceTracker . hasFieldOfInterest , // Tracking if we have any fields to show the 'with' word
9094 whitespace : ' ' , // there isn't support for the unicode /u0020 for whitespace, and leading spaces are deleted, so to prevent double-whitespace explicitly passing the space in.
0 commit comments