Skip to content

Commit

Permalink
perf(misconf): use json.Valid to check validity of JSON (aquasecurity…
Browse files Browse the repository at this point in the history
…#7308)

Signed-off-by: nikpivkin <[email protected]>
  • Loading branch information
nikpivkin authored and fhielpos committed Dec 20, 2024
1 parent 88e2f2f commit 0162c88
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/iac/detection/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0162c88

Please sign in to comment.