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
|
- 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.
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue