Be more strict, when parsing json

This commit is contained in:
Holger Obermaier
2023-10-13 09:53:49 +02:00
parent 595399e7d9
commit 0b509ca9e4
10 changed files with 45 additions and 23 deletions

View File

@@ -272,8 +272,10 @@ func NewHttpSink(name string, config json.RawMessage) (Sink, error) {
// Read config
if len(config) > 0 {
err := json.Unmarshal(config, &s.config)
if err != nil {
d := json.NewDecoder(bytes.NewReader(config))
d.DisallowUnknownFields()
if err := d.Decode(&s.config); err != nil {
cclog.ComponentError(s.name, "Error reading config:", err.Error())
return nil, err
}
}