chore: Enable G401, G403, G501, G502, G503 and G505 rules for gosec (#13021)
Co-authored-by: Pawel Zak <Pawel Zak>
This commit is contained in:
parent
528c37bf8a
commit
079c50128b
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -116,7 +116,7 @@ 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 {
|
||||
|
|
@ -124,6 +124,7 @@ func getMd5(file string) (string, error) {
|
|||
}
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue