@@ -111,8 +111,16 @@ func (o *Operator) Compile() error {
111111 return nil
112112 }
113113
114- // the only operator Type that can have the Data field empty is List.
115- if o .Type != List && o .Operand != OpTrue && o .Data == "" {
114+ // The only operator Type that can have the Data field empty are:
115+ // Simple, Regexp, List.
116+ // For List, because it uses List field and not Data field.
117+ // For Simple and Regexp, because it can be useful to match on some
118+ // operands that can in practice be equal to an empty string. This is the
119+ // case, for example, when a request has a "bare" IP instead of a domain
120+ // name, therefore DstHost field will be empty. You can match empty string
121+ // with simple comparison or the "^$" regexp pattern.
122+ if ! (o .Type == Simple || o .Type == Regexp || o .Type == List ) &&
123+ o .Operand != OpTrue && o .Data == "" {
116124 return fmt .Errorf ("Operand %s cannot be empty (%s)" , o .Operand , o .Type )
117125 }
118126
@@ -343,7 +351,7 @@ func (o *Operator) Match(con *conman.Connection, hasChecksums bool) bool {
343351 return false
344352 } else if o .Operand == OpProcessCmd {
345353 return o .cb (strings .Join (con .Process .Args , " " ))
346- } else if o .Operand == OpDstHost && con . DstHost != "" {
354+ } else if o .Operand == OpDstHost {
347355 return o .cb (con .DstHost )
348356 } else if o .Operand == OpDstIP {
349357 return o .cb (con .DstIP .String ())
0 commit comments