Skip to content

Commit 7b66b85

Browse files
authored
Update golangci-lint and increase timeout + fix doc (#1117)
* Update golangci-lint and increase timeout * Fix incorrect doc + format issue * clarify filtering doc
1 parent 4154a69 commit 7b66b85

File tree

4 files changed

+53
-41
lines changed

4 files changed

+53
-41
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ifneq ($(CLEAN_BUILD),)
4141
LDFLAGS ?= -X 'main.buildVersion=${VERSION}-${BUILD_SHA}' -X 'main.buildDate=${BUILD_DATE}'
4242
endif
4343

44-
GOLANGCI_LINT_VERSION = v2.2.1
44+
GOLANGCI_LINT_VERSION = v2.6.0
4545
KIND_VERSION = v0.22.0
4646

4747
FLP_BIN_FILE=flowlogs-pipeline
@@ -119,7 +119,7 @@ vendors: ## Check go vendors
119119

120120
.PHONY: lint
121121
lint: prereqs ## Lint the code
122-
./bin/golangci-lint-${GOLANGCI_LINT_VERSION} run ./... --timeout=3m
122+
./bin/golangci-lint-${GOLANGCI_LINT_VERSION} run ./... --timeout=5m
123123

124124
.PHONY: compile
125125
compile: ## Compile main flowlogs-pipeline and config generator

README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -357,32 +357,44 @@ parameters:
357357

358358
### Transform Filter
359359

360-
The filter transform module allows setting rules to remove complete entries from
361-
the output, or just remove specific keys and values from entries.
360+
The filter transform module allows setting rules to remove complete flow logs from the output, or just remove specific keys and values from logs.
362361

363362
For example, suppose we have a flow log with the following syntax:
364363
```json
365-
{"Bytes":20800,"DstAddr":"10.130.2.2","DstPort":36936,"Packets":400,"Proto":6,"SequenceNum":1919,"SrcAddr":"10.130.2.13","SrcHostIP":"10.0.197.206","SrcPort":3100,"TCPFlags":0,"TimeFlowStart":0,"TimeReceived":1637501832}
364+
{
365+
"Bytes":20800,
366+
"DstAddr":"10.130.2.2",
367+
"DstPort":36936,
368+
"Packets":400,
369+
"Proto":6,
370+
"SequenceNum":1919,
371+
"SrcAddr":"10.130.2.13",
372+
"SrcHostIP":"10.0.197.206",
373+
"SrcPort":3100,
374+
"TCPFlags":0,
375+
"TimeFlowStart":0,
376+
"TimeReceived":1637501832
377+
}
366378
```
367379

368-
The below configuration will remove (filter) the entry from the output
380+
The below configuration will skip that log, removing it from the output.
369381

370382
```yaml
371-
pipeline:
372-
transform:
373-
- type: filter
383+
parameters:
384+
- name: filter1
385+
transform:
386+
type: filter
374387
filter:
375388
rules:
376389
- type: remove_entry_if_exists
377390
removeEntry:
378-
input: SrcPort
391+
input: TCPFlags
379392
```
380393

381-
Using `remove_entry_if_doesnt_exist` in the rule reverses the logic and will not remove the above example entry
382-
Using `remove_field` in the rule `type` instead, results in outputting the entry after
383-
removal of only the `SrcPort` key and value
384-
Using `remove_entry_if_equal` will remove the entry if the specified field exists and is equal to the specified value.
385-
Using `remove_entry_if_not_equal` will remove the entry if the specified field exists and is not equal to the specified value.
394+
- `type: remove_entry_if_doesnt_exist` reverses the logic and will not remove the above example entry.
395+
- `type: remove_field` keeps the entry but changes its content, removing the `TCPFlags` key and value.
396+
- `type: remove_entry_if_equal` removes the entry if the specified field exists and is equal to the specified value.
397+
- `type: remove_entry_if_not_equal` removes the entry if the specified field exists and is not equal to the specified value.
386398

387399
#### Transform Filter: query language
388400

docs/api.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ Following is the supported API format for filter transformations:
159159
filter:
160160
rules: list of filter rules, each includes:
161161
type: (enum) one of the following:
162-
remove_field: removes the field from the entry
163-
remove_entry_if_exists: removes the entry if the field exists
164-
remove_entry_if_doesnt_exist: removes the entry if the field does not exist
165-
remove_entry_if_equal: removes the entry if the field value equals specified value
166-
remove_entry_if_not_equal: removes the entry if the field value does not equal specified value
167-
remove_entry_all_satisfied: removes the entry if all of the defined rules are satisfied
168-
keep_entry_query: keeps the entry if it matches the query
162+
remove_field: removes the field from the flow log
163+
remove_entry_if_exists: removes the entry (ie. the flow log) if the field exists
164+
remove_entry_if_doesnt_exist: removes the entry (ie. the flow log) if the field does not exist
165+
remove_entry_if_equal: removes the entry (ie. the flow log) if the field value equals the specified value
166+
remove_entry_if_not_equal: removes the entry (ie. the flow log) if the field value does not equal the specified value
167+
remove_entry_all_satisfied: removes the entry (ie. the flow log) if all of the defined rules are satisfied
168+
keep_entry_query: keeps the entry (ie. the flow log) if it matches the query
169169
add_field: adds (input) field to the entry; overrides previous value if present (key=input, value=value)
170170
add_field_if_doesnt_exist: adds a field to the entry if the field does not exist
171171
add_field_if: add output field set to assignee if input field satisfies criteria from parameters field
@@ -183,10 +183,10 @@ Following is the supported API format for filter transformations:
183183
castInt: set true to cast the value field as an int (numeric values are float64 otherwise)
184184
removeEntryAllSatisfied: configuration for remove_entry_all_satisfied rule
185185
type: (enum) one of the following:
186-
remove_entry_if_exists: removes the entry if the field exists
187-
remove_entry_if_doesnt_exist: removes the entry if the field does not exist
188-
remove_entry_if_equal: removes the entry if the field value equals specified value
189-
remove_entry_if_not_equal: removes the entry if the field value does not equal specified value
186+
remove_entry_if_exists: removes the entry (ie. the flow log) if the field exists
187+
remove_entry_if_doesnt_exist: removes the entry (ie. the flow log) if the field does not exist
188+
remove_entry_if_equal: removes the entry (ie. the flow log) if the field value equals the specified value
189+
remove_entry_if_not_equal: removes the entry (ie. the flow log) if the field value does not equal the specified value
190190
removeEntry: configuration for remove_entry_* rules
191191
input: entry input field
192192
value: specified value of input field:
@@ -224,10 +224,10 @@ Following is the supported API format for filter transformations:
224224
value: sampling interval: 1 flow on <sampling> is kept
225225
rules: rules to be satisfied for this sampling configuration
226226
type: (enum) one of the following:
227-
remove_entry_if_exists: removes the entry if the field exists
228-
remove_entry_if_doesnt_exist: removes the entry if the field does not exist
229-
remove_entry_if_equal: removes the entry if the field value equals specified value
230-
remove_entry_if_not_equal: removes the entry if the field value does not equal specified value
227+
remove_entry_if_exists: removes the entry (ie. the flow log) if the field exists
228+
remove_entry_if_doesnt_exist: removes the entry (ie. the flow log) if the field does not exist
229+
remove_entry_if_equal: removes the entry (ie. the flow log) if the field value equals the specified value
230+
remove_entry_if_not_equal: removes the entry (ie. the flow log) if the field value does not equal the specified value
231231
removeEntry: configuration for remove_entry_* rules
232232
input: entry input field
233233
value: specified value of input field:

pkg/api/transform_filter.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ type TransformFilterEnum string
3232

3333
const (
3434
// For doc generation, enum definitions must match format `Constant Type = "value" // doc`
35-
RemoveField TransformFilterEnum = "remove_field" // removes the field from the entry
36-
RemoveEntryIfExists TransformFilterEnum = "remove_entry_if_exists" // removes the entry if the field exists
37-
RemoveEntryIfDoesntExist TransformFilterEnum = "remove_entry_if_doesnt_exist" // removes the entry if the field does not exist
38-
RemoveEntryIfEqual TransformFilterEnum = "remove_entry_if_equal" // removes the entry if the field value equals specified value
39-
RemoveEntryIfNotEqual TransformFilterEnum = "remove_entry_if_not_equal" // removes the entry if the field value does not equal specified value
40-
RemoveEntryAllSatisfied TransformFilterEnum = "remove_entry_all_satisfied" // removes the entry if all of the defined rules are satisfied
41-
KeepEntryQuery TransformFilterEnum = "keep_entry_query" // keeps the entry if it matches the query
35+
RemoveField TransformFilterEnum = "remove_field" // removes the field from the flow log
36+
RemoveEntryIfExists TransformFilterEnum = "remove_entry_if_exists" // removes the entry (ie. the flow log) if the field exists
37+
RemoveEntryIfDoesntExist TransformFilterEnum = "remove_entry_if_doesnt_exist" // removes the entry (ie. the flow log) if the field does not exist
38+
RemoveEntryIfEqual TransformFilterEnum = "remove_entry_if_equal" // removes the entry (ie. the flow log) if the field value equals the specified value
39+
RemoveEntryIfNotEqual TransformFilterEnum = "remove_entry_if_not_equal" // removes the entry (ie. the flow log) if the field value does not equal the specified value
40+
RemoveEntryAllSatisfied TransformFilterEnum = "remove_entry_all_satisfied" // removes the entry (ie. the flow log) if all of the defined rules are satisfied
41+
KeepEntryQuery TransformFilterEnum = "keep_entry_query" // keeps the entry (ie. the flow log) if it matches the query
4242
AddField TransformFilterEnum = "add_field" // adds (input) field to the entry; overrides previous value if present (key=input, value=value)
4343
AddFieldIfDoesntExist TransformFilterEnum = "add_field_if_doesnt_exist" // adds a field to the entry if the field does not exist
4444
AddFieldIf TransformFilterEnum = "add_field_if" // add output field set to assignee if input field satisfies criteria from parameters field
@@ -51,10 +51,10 @@ const (
5151
type TransformFilterRemoveEntryEnum string
5252

5353
const (
54-
RemoveEntryIfExistsD TransformFilterRemoveEntryEnum = "remove_entry_if_exists" // removes the entry if the field exists
55-
RemoveEntryIfDoesntExistD TransformFilterRemoveEntryEnum = "remove_entry_if_doesnt_exist" // removes the entry if the field does not exist
56-
RemoveEntryIfEqualD TransformFilterRemoveEntryEnum = "remove_entry_if_equal" // removes the entry if the field value equals specified value
57-
RemoveEntryIfNotEqualD TransformFilterRemoveEntryEnum = "remove_entry_if_not_equal" // removes the entry if the field value does not equal specified value
54+
RemoveEntryIfExistsD TransformFilterRemoveEntryEnum = "remove_entry_if_exists" // removes the entry (ie. the flow log) if the field exists
55+
RemoveEntryIfDoesntExistD TransformFilterRemoveEntryEnum = "remove_entry_if_doesnt_exist" // removes the entry (ie. the flow log) if the field does not exist
56+
RemoveEntryIfEqualD TransformFilterRemoveEntryEnum = "remove_entry_if_equal" // removes the entry (ie. the flow log) if the field value equals the specified value
57+
RemoveEntryIfNotEqualD TransformFilterRemoveEntryEnum = "remove_entry_if_not_equal" // removes the entry (ie. the flow log) if the field value does not equal the specified value
5858
)
5959

6060
type TransformFilterRule struct {

0 commit comments

Comments
 (0)