From a5264ffba731f1267b77b0258189be9084cce88b Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Tue, 10 Mar 2026 15:24:00 +0100 Subject: [PATCH] Use strict JSON decoding --- collectors/smartmonMetric.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/collectors/smartmonMetric.go b/collectors/smartmonMetric.go index db49bef..346d157 100644 --- a/collectors/smartmonMetric.go +++ b/collectors/smartmonMetric.go @@ -1,6 +1,7 @@ package collectors import ( + "bytes" "encoding/json" "fmt" "os/exec" @@ -129,7 +130,9 @@ func (m *SmartMonCollector) Init(config json.RawMessage) error { // Read in the JSON configuration if len(config) > 0 { - if err := json.Unmarshal(config, &m.config); err != nil { + d := json.NewDecoder(bytes.NewReader(config)) + d.DisallowUnknownFields() + if err := d.Decode(&m.config); err != nil { return fmt.Errorf("%s Init(): Error reading config: %w", m.name, err) } }