From 180da1ba653574bbe2fa4ad8bfd9d9e65f4a64eb Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Sat, 24 Oct 2015 17:12:34 +0200 Subject: [PATCH] Add overflow check in TLS config --- config/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/config.go b/config/config.go index 2be3524d1..b52d783b5 100644 --- a/config/config.go +++ b/config/config.go @@ -314,6 +314,18 @@ type TLSConfig struct { KeyFile string `yaml:"key_file,omitempty"` // Disable target certificate validation. InsecureSkipVerify bool `yaml:"insecure_skip_verify"` + + // Catches all undefined fields and must be empty after parsing. + XXX map[string]interface{} `yaml:",inline"` +} + +// UnmarshalYAML implements the yaml.Unmarshaler interface. +func (c *TLSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + type plain TLSConfig + if err := unmarshal((*plain)(c)); err != nil { + return err + } + return checkOverflow(c.XXX, "TLS config") } // ScrapeConfig configures a scraping unit for Prometheus.