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:
gotjosh 2022-06-28 11:51:06 +01:00
parent 0a9a48d60f
commit 05f073f42f
No known key found for this signature in database
GPG Key ID: A6E1DDE38FF3C74E
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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`,