Skip to content

Commit

Permalink
Ignore warning of the latest gosec tool
Browse files Browse the repository at this point in the history
This looks like a possible false positives, at least until we learn more at
securego/gosec#714

Addressing:
[/github/workspace/examples/falcon_sensor_download/main.go:104-108] - G307 (CWE-703): Deferring unsafe method "Close" on type "*os.File" (Confidence: HIGH, Severity: MEDIUM)
    103: 	}
  > 104: 	defer func() {
  > 105: 		if err := file.Close(); err != nil {
  > 106: 			fmt.Fprintf(os.Stderr, "Error closing file: %s\n", err)
  > 107: 		}
  > 108: 	}()
    109:
  • Loading branch information
isimluk committed Oct 18, 2021
1 parent 854c6ab commit 7358d0e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/falcon_sensor_download/main.go
Expand Up @@ -102,7 +102,8 @@ func download(client *client.CrowdStrikeAPISpecification, sensor *models.DomainS
panic(err)
}
defer func() {
if err := file.Close(); err != nil {
// (ignore possibly false positive https://github.com/securego/gosec/issues/714)
if err := file.Close(); err != nil { // #nosec
fmt.Fprintf(os.Stderr, "Error closing file: %s\n", err)
}
}()
Expand Down

0 comments on commit 7358d0e

Please sign in to comment.