mirror of
https://github.com/prometheus/alertmanager.git
synced 2026-02-05 15:45:34 +01:00
Ensure matcher values are present when parsing matchers from strings
Fixes #2936 Signed-off-by: gotjosh <josue.abreu@gmail.com>
This commit is contained in:
@@ -120,8 +120,12 @@ func ParseMatcher(s string) (_ *Matcher, err error) {
|
||||
return nil, errors.Errorf("bad matcher format: %s", s)
|
||||
}
|
||||
|
||||
rawValue := ms[3]
|
||||
if len(rawValue) == 0 {
|
||||
return nil, errors.Errorf("matcher value is not present: %s", s)
|
||||
}
|
||||
|
||||
var (
|
||||
rawValue = ms[3]
|
||||
value strings.Builder
|
||||
escaped bool
|
||||
expectTrailingQuote bool
|
||||
|
||||
@@ -189,6 +189,10 @@ func TestMatchers(t *testing.T) {
|
||||
return append(ms, m, m2)
|
||||
}(),
|
||||
},
|
||||
{
|
||||
input: `job=`,
|
||||
err: `matcher value is not present: job=`,
|
||||
},
|
||||
{
|
||||
input: `job="value`,
|
||||
err: `matcher value contains unescaped double quote: "value`,
|
||||
|
||||
Reference in New Issue
Block a user