|
| 1 | +# ListDetector module - README |
| 2 | + |
| 3 | +## Description |
| 4 | +The module analyzes Unirec records by comparing them against a set of predefined rules in a rule list. |
| 5 | +Rule list can be blacklist or whitelist. It identifies and forwards records that do not match to the whitelist rules or match blacklist rules. |
| 6 | + |
| 7 | +## Interfaces |
| 8 | +- Input: 1 |
| 9 | +- Output: 1 |
| 10 | + |
| 11 | +## Parameters |
| 12 | +### Common TRAP parameters |
| 13 | +- `-h [trap,1]` Print help message for this module / for libtrap specific parameters. |
| 14 | +- `-i IFC_SPEC` Specification of interface types and their parameters. |
| 15 | +- `-v` Be verbose. |
| 16 | +- `-vv` Be more verbose. |
| 17 | +- `-vvv` Be even more verbose. |
| 18 | + |
| 19 | +### Module specific parameters |
| 20 | +- `-r, --rules <file>` ListDetector module rules in CSV format |
| 21 | +- `-lm, --listmode <file>` ListDetector mode - whitelist or blacklist |
| 22 | +- `-m, --appfs-mountpoint <path>` Path where the appFs directory will be mounted |
| 23 | + |
| 24 | +## CSV rules format |
| 25 | +The first row of CSV specifies the unirec types and names of fields that will be |
| 26 | +used for whitelisting or blacklisting. |
| 27 | + |
| 28 | +The supported unirec types are: `uint8`, `int8`, `uint16`, `int16`, `uint32`, `int32`, |
| 29 | +`uint64`, `int64`, `char`, `ipaddr` and `string`. |
| 30 | + |
| 31 | +- Empty values match everyting. |
| 32 | + |
| 33 | +- Numeric types match the exact value. |
| 34 | + |
| 35 | +- IP address (`ipaddr`) can be either ipv4 or ipv6 address. |
| 36 | +The ip address can optionally have a prefix. |
| 37 | +If there is no prefix, the address must match exactly. |
| 38 | + - Examples: `127.0.0.1`, `127.0.0.0/24` |
| 39 | + |
| 40 | +- String match a regex pattern. Regex patterns support extended grep syntax. |
| 41 | + - Examples: `R"(^www.google.com$)"`, `R"(.*google\.com$)"` |
| 42 | + |
| 43 | +### Example CSV file |
| 44 | + |
| 45 | +``` |
| 46 | +ipaddr SRC_IP,uint16 DST_PORT,uint16 SRC_PORT |
| 47 | +10.0.0.1,443,53530 |
| 48 | +10.0.0.2,443,53531 |
| 49 | +``` |
| 50 | + |
| 51 | +``` |
| 52 | +ipaddr SCR_IP,string QUIC_SNI |
| 53 | +10.0.0.1/24,R"(.*google\.com$)" |
| 54 | +``` |
| 55 | + |
| 56 | +## Usage Examples |
| 57 | +``` |
| 58 | +# Data from the input unix socket interface "trap_in" is processed, and entries that |
| 59 | +do not match the defined rules in the "csvWhitelist.csv" file are forwarded to the |
| 60 | +output interface "trap_out." |
| 61 | +
|
| 62 | +$ listDetector -i u:trap_in,u:trap_out -r csvWhitelist.csv |
| 63 | +``` |
| 64 | +``` |
| 65 | +# Data from the input unix socket interface "trap_in" is processed, and entries that |
| 66 | +match the defined rules in the "csvblacklist.csv" file are forwarded to the |
| 67 | +output interface "trap_out." |
| 68 | +
|
| 69 | +$ listDetector -i u:trap_in,u:trap_out -lm bl -r csvBlacklist.csv |
| 70 | +``` |
| 71 | + |
| 72 | +## Telemetry data format |
| 73 | +``` |
| 74 | +├─ input/ |
| 75 | +│ └─ stats |
| 76 | +└─ listDetector/ |
| 77 | + ├─ aggStats |
| 78 | + └─ rules/ |
| 79 | + ├─ 0 |
| 80 | + ├─ 1 |
| 81 | + └ ... |
| 82 | +``` |
| 83 | + |
| 84 | +Each rule has its own file named according to the order of the rules in the configuration file. |
0 commit comments