Skip to content

Commit 0162c88

Browse files
nikpivkinfhielpos
authored andcommitted
perf(misconf): use json.Valid to check validity of JSON (aquasecurity#7308)
Signed-off-by: nikpivkin <[email protected]>
1 parent 88e2f2f commit 0162c88

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)