JavaScript response filter - Redis

The JavaScript request filter is the most flexible of all response filters. It can potentially be called for any packet type, and can modify traffic in any way it sees fit.

Parameters

  • Command patterns: optional. If specified, this filter will be invoked only if the current request matches this. Can be a comma-separated (or line break separated) list of strings or regular expressions.

  • Response patterns : optional. If specified, a comma-separated list of strings or regular expressions that the response must match

  • Client IPs: optional. If specified, a comma-separated (or line break separated) list of IP4 or IP6 addresses or regular expressions for IP addresses.

  • Users: optional. If specified, a comma-separated (or line break separated) list of user names or regular expressions for user names.


Example

We could catch the response to the query:

SCAN 250 MATCH *FOO* COUNT 100

by setting the Command patterns to:

SCAN

\d+

MATCH

regex:.*FOO.*

In addition, we could specify that this filter will execute only if the response matches the response patterns. For instance, if we assume that the response will be:

['apple', 'orange', [123, 234, 'apricot']]

we could set the Response patterns parameter to:

apple,orange

if that's what is relevant, or maybe:

regex:YADDA

which will match the last element and therefore cause the filter to execute.