Skip to content

Commit

Permalink
🐛 If all conditions are filtered out, don't add the rule (konveyor#291)
Browse files Browse the repository at this point in the history
Closes konveyor#289

Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>
  • Loading branch information
fabianvf authored Aug 10, 2023
1 parent fba062e commit 54d8d87
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions parser/rule_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ func (r *RuleParser) getConditions(conditionsInterface []interface{}) ([]engine.
if err != nil {
return nil, nil, err
}
// There was no error so the conditions have all been filtered
// Return early to prevent constructing an empty rule
if len(conds) == 0 && len(conds) != len(iConditions) {
return []engine.ConditionEntry{}, nil, nil
}
ce = engine.ConditionEntry{
From: from,
As: as,
Expand All @@ -631,6 +636,11 @@ func (r *RuleParser) getConditions(conditionsInterface []interface{}) ([]engine.
if err != nil {
return nil, nil, err
}
// There was no error so the conditions have all been filtered
// Return early to prevent constructing an empty rule
if len(conds) == 0 && len(conds) != len(iConditions) {
return []engine.ConditionEntry{}, nil, nil
}
ce = engine.ConditionEntry{
From: from,
As: as,
Expand Down

0 comments on commit 54d8d87

Please sign in to comment.