Skip to content

Commit

Permalink
perf(misconf): use json.Valid to check validity of JSON (#7308)
Browse files Browse the repository at this point in the history
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
  • Loading branch information
nikpivkin authored Aug 6, 2024
1 parent 13789b7 commit c766831
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 c766831

Please sign in to comment.