Skip to content

Commit c766831

Browse files
authored
perf(misconf): use json.Valid to check validity of JSON (#7308)
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
1 parent 13789b7 commit c766831

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/iac/detection/detect.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func init() {
4545
return true
4646
}
4747

48-
var content any
49-
return json.NewDecoder(r).Decode(&content) == nil
48+
b, err := io.ReadAll(r)
49+
return err == nil && json.Valid(b)
5050
}
5151

5252
matchers[FileTypeYAML] = func(name string, r io.ReadSeeker) bool {

0 commit comments

Comments
 (0)