Skip to content

Commit

Permalink
fix gosec issues #2694
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoReigota1 committed Apr 5, 2021
1 parent 115ac1c commit 8329147
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/console/kics.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func setupLogs() error {
}

if logFile {
file, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModePerm)
file, err := os.OpenFile(filepath.Clean(logPath), os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModePerm)
if err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/engine/source/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ func ReadMetadata(queryDir string) map[string]interface{} {

return nil
}
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
log.Err(err).
Msgf("Queries provider can't close file, file=%s", filepath.Clean(path.Join(queryDir, MetadataFileName)))
}
}()

var metadata map[string]interface{}
if err := json.NewDecoder(f).Decode(&metadata); err != nil {
Expand Down

0 comments on commit 8329147

Please sign in to comment.