elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

Whitelists on cardinality alarms

Open Gee94 opened this issue 8 years ago • 3 comments

Could anyone provide any information on implementing whitelists into my yaml file?

name: Port Scan Test alarm
timestamp_field: "@timestamp"
timestamp_type: unix_ms

type: cardinality
query_key: [sourceIPv4Address, destinationIPv4Address]
cardinality_field: "destinationTransportPort"

max_cardinality: 70

 minutes: 10




filter:
- query:
   match:
       packetDeltaCount: "2"


- "email"

email:
- "###########"

for example i'd like Whitelist: sourceIPv4Address 127.0.0.1, 127.0.0.2

I'm running elasticsearch 5 if that effects anything?

Gee94 avatar Dec 08 '17 14:12 Gee94

Add this to your filter

filter:
- query:
     query_string:
        query: "NOT sourceIPv4Address: 127.0.0.1 AND NOT sourceIPv4Address: 127.0.0.2"

You can do regular expressions too. See https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-query-string-query.html

Qmando avatar Dec 08 '17 18:12 Qmando

@Gee94

Just in case if you want to maintain a separate list of IP address to whitelist you can use something like below. Make sure you put the filter-whitelist-ip in the same rule folder

name: Port Scan Test alarm
timestamp_field: "@timestamp"
timestamp_type: unix_ms

type: cardinality
query_key: [sourceIPv4Address, destinationIPv4Address]
cardinality_field: "destinationTransportPort"

max_cardinality: 70

 minutes: 10

import:
  - filter-whitelist-ip


filter:
- query:
   match:
       packetDeltaCount: "2"


- "email"

email:
- "###########"

In - filter-whitelist-ip

cat filter-whitelist-ip

filter:
- query:
     query_string:
        query: "NOT sourceIPv4Address: (127.0.0.1 OR 10.1.1.1 OR 10.11.1.2)" 

The below filter will whitelist the entire 10.x/8 subnet range

   - query:
        query_string:
          query: "NOT srx-source-address: /10\\..*/"

sathishdsgithub avatar Dec 09 '17 14:12 sathishdsgithub

Hi Guys, Thanks for getting back to me, @Qmando that worked great thank you. @sathishdsgithub AttributeError: 'list' object has no attribute 'startswith'

did you come across the above error before?

Gee94 avatar Dec 11 '17 09:12 Gee94