Skip to content

Commit

Permalink
chore: Enable G401, G403, G501, G502, G503 and G505 rules for gosec (#…
Browse files Browse the repository at this point in the history
…13021)

Co-authored-by: Pawel Zak <Pawel Zak>
  • Loading branch information
zak-pawel authored Apr 4, 2023
1 parent 528c37b commit 079c501
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ linters-settings:
- G201
- G202
- G203
- G401
- G403
- G501
- G502
- G503
- G505
lll:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
Expand Down
5 changes: 3 additions & 2 deletions plugins/inputs/filestat/filestat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package filestat

import (
"crypto/md5"
"crypto/md5" //nolint:gosec // G501: Blocklisted import crypto/md5: weak cryptographic primitive - md5 hash is what is desired in this case
_ "embed"
"fmt"
"io"
Expand Down Expand Up @@ -116,14 +116,15 @@ func (f *FileStat) Gather(acc telegraf.Accumulator) error {
return nil
}

// Read given file and calculate an md5 hash.
// Read given file and calculate a md5 hash.
func getMd5(file string) (string, error) {
of, err := os.Open(file)
if err != nil {
return "", err
}
defer of.Close()

//nolint:gosec // G401: Use of weak cryptographic primitive - md5 hash is what is desired in this case
hash := md5.New()
_, err = io.Copy(hash, of)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/webhooks/artifactory/artifactory_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package artifactory

import (
"crypto/hmac"
"crypto/sha1"
"crypto/sha1" //nolint:gosec // G505: Blocklisted import crypto/sha1: weak cryptographic primitive - sha1 hash is what is desired in this case
"encoding/hex"
"encoding/json"
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/webhooks/github/github_webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package github

import (
"crypto/hmac"
"crypto/sha1"
"crypto/sha1" //nolint:gosec // G505: Blocklisted import crypto/sha1: weak cryptographic primitive - sha1 hash is what is desired in this case
"encoding/hex"
"encoding/json"
"io"
Expand Down

0 comments on commit 079c501

Please sign in to comment.