Skip to content

Commit 3c74d74

Browse files
chore(semgrep): fix rules and ignore what is not fixable or relevant (#230)
1 parent d29d739 commit 3c74d74

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

internal/cli/cli.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
package cli
66

77
import (
8+
"errors"
89
"fmt"
9-
"io/ioutil"
10+
"io/fs"
1011
"os"
1112

1213
"sigs.k8s.io/yaml"
@@ -32,8 +33,8 @@ const (
3233
func Options(path string) (*operator.Options, error) {
3334
options := &operator.Options{}
3435

35-
optionsBytes, err := ioutil.ReadFile(path)
36-
if err != nil && !os.IsNotExist(err) {
36+
optionsBytes, err := os.ReadFile(path)
37+
if err != nil && !errors.Is(err, fs.ErrNotExist) {
3738
return nil, fmt.Errorf("reading configuration file %q: %w", path, err)
3839
}
3940

internal/mutator/pod/agent/injector.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,14 @@ func getAgentPassthroughEnvironment() string {
618618
return strings.Join(flags, ",")
619619
}
620620

621+
//nolint:gosec
621622
func (c configHash) calculate() (string, error) {
622623
b, err := yaml.Marshal(c)
623624
if err != nil {
624625
return "", fmt.Errorf("marshalling input: %w", err)
625626
}
626627

627-
h := sha1.New()
628+
h := sha1.New() // nosemgrep
628629
h.Write(b)
629630

630631
return fmt.Sprintf("%x", h.Sum(nil)), nil

internal/testutil/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func ContextWithDeadline(t *testing.T) context.Context {
2424
return context.Background()
2525
}
2626

27-
ctx, cancel := context.WithDeadline(context.Background(), deadline.Truncate(timeoutGracePeriod))
27+
ctx, cancel := context.WithDeadline(context.Background(), deadline.Truncate(timeoutGracePeriod)) // nosemgrep
2828

2929
t.Cleanup(cancel)
3030

0 commit comments

Comments
 (0)