Skip to content

Commit

Permalink
Error on condition-only match blocks (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones authored Aug 16, 2024
1 parent 5780f08 commit 76409c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions policy/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ func (p *parserImpl) ParseMatch(ctx ParserContext, policy *Policy, node *yaml.No
p.visitor.MatchTag(ctx, keyID, fieldName, val, policy, m)
}
}
if !m.HasOutput() && !m.HasRule() {
p.ReportErrorAtID(id, "match does not specify a rule or output")
}
return m
}

Expand Down
3 changes: 3 additions & 0 deletions policy/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ rule:
err: `ERROR: <input>:4:7: unsupported match tag: name
| - name: "true"
| ......^
ERROR: <input>:4:7: match does not specify a rule or output
| - name: "true"
| ......^
ERROR: <input>:5:7: unsupported match tag: alt_name
| alt_name: "bool_true"
| ......^`,
Expand Down

0 comments on commit 76409c6

Please sign in to comment.