Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/openSearch/osquery/boolQueryBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (q *BoolQueryBuilder) AddFilterRequest(request *filter.Request) error {
if handler, ok := operatorMapping[field.Operator]; ok {
value := field.Value

if field.Operator == filter.CompareOperatorExists {
if field.Operator == filter.CompareOperatorExists || field.Operator == filter.CompareOperatorDoesNotExist {
value = "" // exists operator does not need a value, but for more consistent handling just pass a dummy value
}
if value == nil {
Expand Down Expand Up @@ -289,5 +289,9 @@ func defaultCompareOperators() []CompareOperator {
Operator: filter.CompareOperatorExists,
Handler: HandleCompareOperatorExists, MustCondition: true,
},
{
Operator: filter.CompareOperatorDoesNotExist,
Handler: HandleCompareOperatorExists, MustCondition: false,
},
}
}
9 changes: 9 additions & 0 deletions pkg/openSearch/osquery/boolQueryBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,15 @@ func TestBoolQueryBuilder_AddFilterRequest(t *testing.T) {
wantDocuments: []ostesting.TestType{doc0, doc1, doc2},
})

// MustNotExists operator
addTest("operator must not Exists", testCase{
filterRequest: singleFilter(filter.RequestField{
Name: "keywordOmitEmptyField",
Operator: filter.CompareOperatorDoesNotExist,
}),
wantDocuments: []ostesting.TestType{doc0},
})

// BetweenDates operator
addTest("operator BetweenDates (date time string)", testCase{
filterRequest: singleFilter(filter.RequestField{
Expand Down
1 change: 1 addition & 0 deletions pkg/query/filter/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ CompareOperator ENUM(
betweenDates

exists
doesNotExist

isEqualToRating
isNotEqualToRating
Expand Down
4 changes: 4 additions & 0 deletions pkg/query/filter/type_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading