feat(backend): fail on unknown keys in ACL config file

This commit is contained in:
Łukasz Mierzwa
2020-09-27 12:47:38 +01:00
committed by Łukasz Mierzwa
parent bb5a5a4e14
commit 940eacd0ea
2 changed files with 37 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
# Raises an error if --authorization.acl points to a file that contains unknown keys
karma.bin-should-fail --log.format=text --log.config=false --check-config
! stdout .
! stderr 'msg="Configuration is valid"'
stderr 'msg="Reading silence ACL config file acl.yaml"'
stderr 'msg="Failed to parse silence ACL configuration file \\"acl.yaml\\": yaml: unmarshal errors:\\n line 6: field nameFoo not found in type config.SilenceFilters"'
-- karma.yaml --
authentication:
header:
name: "X-User"
value_re: "(.+)"
authorization:
groups:
- name: admins
members:
- alice
- bob
- name: users
members:
- john
acl:
silences: acl.yaml
alertmanager:
servers:
- name: default
uri: https://localhost:9093
-- acl.yaml --
rules:
- action: block
reason: prod cluster cannot be silenced
scope:
filters:
- nameFoo: cluster
value: prod

View File

@@ -52,7 +52,7 @@ func ReadSilenceACLConfig(path string) (*silencesACLSchema, error) {
return nil, fmt.Errorf("Failed to load silence ACL configuration file %q: %v", path, err)
}
err = yaml.Unmarshal(f, &cfg)
err = yaml.UnmarshalStrict(f, &cfg)
if err != nil {
return nil, fmt.Errorf("Failed to parse silence ACL configuration file %q: %v", path, err)
}