From 8ca5b232e99ec72a5ceeb7159019a84d954e8df7 Mon Sep 17 00:00:00 2001 From: nikpivkin Date: Tue, 6 Aug 2024 15:46:58 +0700 Subject: [PATCH] refactor(misconf): use json.Valid to check validity of JSON Signed-off-by: nikpivkin --- pkg/iac/detection/detect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/iac/detection/detect.go b/pkg/iac/detection/detect.go index 6a7eb1f8ca3d..cec90a79cdca 100644 --- a/pkg/iac/detection/detect.go +++ b/pkg/iac/detection/detect.go @@ -45,8 +45,8 @@ func init() { return true } - var content any - return json.NewDecoder(r).Decode(&content) == nil + b, err := io.ReadAll(r) + return err == nil && json.Valid(b) } matchers[FileTypeYAML] = func(name string, r io.ReadSeeker) bool {