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:
Paweł Żak 2023-04-04 13:17:38 +02:00 committed by GitHub
parent 528c37bf8a
commit 079c50128b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -100,6 +100,12 @@ linters-settings:
- G201 - G201
- G202 - G202
- G203 - G203
- G401
- G403
- G501
- G502
- G503
- G505
lll: lll:
# Max line length, lines longer will be reported. # 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. # '\t' is counted as 1 character by default, and can be changed with the tab-width option.

View File

@ -2,7 +2,7 @@
package filestat package filestat
import ( 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" _ "embed"
"fmt" "fmt"
"io" "io"
@ -116,7 +116,7 @@ func (f *FileStat) Gather(acc telegraf.Accumulator) error {
return nil return nil
} }
// Read given file and calculate an md5 hash. // Read given file and calculate a md5 hash.
func getMd5(file string) (string, error) { func getMd5(file string) (string, error) {
of, err := os.Open(file) of, err := os.Open(file)
if err != nil { if err != nil {
@ -124,6 +124,7 @@ func getMd5(file string) (string, error) {
} }
defer of.Close() defer of.Close()
//nolint:gosec // G401: Use of weak cryptographic primitive - md5 hash is what is desired in this case
hash := md5.New() hash := md5.New()
_, err = io.Copy(hash, of) _, err = io.Copy(hash, of)
if err != nil { if err != nil {

View File

@ -2,7 +2,7 @@ package artifactory
import ( import (
"crypto/hmac" "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/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"

View File

@ -2,7 +2,7 @@ package github
import ( import (
"crypto/hmac" "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/hex"
"encoding/json" "encoding/json"
"io" "io"