diff --git a/cmd/karma/tests/testscript/074_acl_extra_fileds.txt b/cmd/karma/tests/testscript/074_acl_extra_fileds.txt new file mode 100644 index 000000000..e58b90dd3 --- /dev/null +++ b/cmd/karma/tests/testscript/074_acl_extra_fileds.txt @@ -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 diff --git a/internal/config/acl.go b/internal/config/acl.go index f04e64dca..dbb5cf344 100644 --- a/internal/config/acl.go +++ b/internal/config/acl.go @@ -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) }