Skip to content

Commit

Permalink
misc: small fix or general refactoring i did not bother commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Dec 22, 2023
1 parent 4aeef60 commit e1cf997
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions filters/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ func (f *JSON) DoFilter(msg *data.Message) (bool, error) {
}

if doc, err := jsonquery.Parse(strings.NewReader(jsonData)); err == nil {
atLeastOne := false
for _, node := range jsonquery.Find(doc, f.selector) {
atLeastOne = true
clone := msg.Clone()
clone.SetMessage(node.Value())
f.Propagate(clone)

Check warning on line 81 in filters/json.go

View check run for this annotation

Codecov / codecov/patch

filters/json.go#L75-L81

Added lines #L75 - L81 were not covered by tests
}

return atLeastOne, nil

Check warning on line 84 in filters/json.go

View check run for this annotation

Codecov / codecov/patch

filters/json.go#L84

Added line #L84 was not covered by tests

} else {
log.Debug("'%v' could not be parsed as JSON: %v", text, err)
return false, nil

Check warning on line 88 in filters/json.go

View check run for this annotation

Codecov / codecov/patch

filters/json.go#L86-L88

Added lines #L86 - L88 were not covered by tests
Expand Down

0 comments on commit e1cf997

Please sign in to comment.