Skip to content

Commit c08acc4

Browse files
Update configuration
Signed-off-by: Sascha Schwarze <[email protected]>
1 parent 0d396f5 commit c08acc4

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

.golangci.yaml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1+
version: "2"
2+
13
linters:
4+
disable:
5+
- errcheck
26
enable:
3-
- ineffassign
4-
- revive
57
- gosec
68
- govet
9+
- ineffassign
710
- misspell
11+
- revive
812
- staticcheck
9-
disable:
10-
- errcheck
13+
- unused
14+
15+
exclusions:
16+
rules:
17+
- path: test
18+
linters:
19+
- revive
1120

12-
linters-settings:
13-
gosec:
14-
excludes:
15-
- G101 # Look for hard coded credentials
16-
- G305 # File traversal when extracting zip/tar archive
17-
- G306 # Poor file permissions used when writing to a new file
21+
settings:
22+
gosec:
23+
excludes:
24+
- G101 # Look for hard coded credentials
25+
- G305 # File traversal when extracting zip/tar archive
26+
- G306 # Poor file permissions used when writing to a new file
1827

19-
issues:
20-
exclude-rules:
21-
- path: test
22-
linters:
23-
- revive
28+
revive:
29+
rules:
30+
- name: package-comments
31+
disabled: true

cmd/git/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ func checkEnvironment(ctx context.Context) error {
252252
if flagValues.verbose {
253253
log.Printf("Debug: %s %s\n", path, check.versionArg)
254254
}
255+
// #nosec G204 in the default container configuration, it is impossible to inject other binaries, as such it is safe that we have no hard-coded path
255256
out, err := exec.CommandContext(ctx, path, check.versionArg).CombinedOutput()
256257
if err != nil {
257258
log.Printf("Error: %s: %s\n", check.toolName, strings.TrimRight(string(out), "\n"))
@@ -474,13 +475,16 @@ func git(ctx context.Context, args ...string) (string, error) {
474475
fmt.Sprintf("safe.directory=%s", flagValues.target),
475476
}
476477
fullArgs = append(fullArgs, args...)
478+
// #nosec G204 arguments are well-defined by the code
477479
cmd := exec.CommandContext(ctx, "git", fullArgs...)
478480

479481
// Print the command to be executed, but replace the URL with a safe version
480482
log.Print(strings.ReplaceAll(cmd.String(), flagValues.url, displayURL))
481483

482484
// Make sure that the spawned process does not try to prompt for infos
483-
os.Setenv("GIT_TERMINAL_PROMPT", "0")
485+
if err := os.Setenv("GIT_TERMINAL_PROMPT", "0"); err != nil {
486+
return "", err
487+
}
484488
cmd.Stdin = nil
485489

486490
out, err := cmd.CombinedOutput()

cmd/git/main_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,14 @@ var _ = Describe("Git Resource", func() {
524524
git_config_nosystem := os.Getenv("GIT_CONFIG_NOSYSTEM")
525525

526526
// unset all pre-existing git configurations to avoid credential helpers and authentication
527-
os.Setenv("GIT_CONFIG_NOSYSTEM", "1")
528-
os.Setenv("GIT_CONFIG", "/dev/null")
529-
os.Setenv("GIT_CONFIG_GLOBAL", "/dev/null")
527+
Expect(os.Setenv("GIT_CONFIG_NOSYSTEM", "1")).To(Succeed())
528+
Expect(os.Setenv("GIT_CONFIG", "/dev/null")).To(Succeed())
529+
Expect(os.Setenv("GIT_CONFIG_GLOBAL", "/dev/null")).To(Succeed())
530530

531531
DeferCleanup(func() {
532-
os.Setenv("GIT_CONFIG_NOSYSTEM", git_config_nosystem)
533-
os.Setenv("GIT_CONFIG", git_config)
534-
os.Setenv("GIT_CONFIG_GLOBAL", git_global_config)
532+
Expect(os.Setenv("GIT_CONFIG_NOSYSTEM", git_config_nosystem)).To(Succeed())
533+
Expect(os.Setenv("GIT_CONFIG", git_config)).To(Succeed())
534+
Expect(os.Setenv("GIT_CONFIG_GLOBAL", git_global_config)).To(Succeed())
535535
})
536536
})
537537

cmd/waiter/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var _ = BeforeSuite(func() {
3131
var _ = Describe("Waiter", func() {
3232
// run creates a exec.Command instance using the arguments informed.
3333
var run = func(args ...string) *gexec.Session {
34+
// #nosec G204 necessary for the test
3435
cmd := exec.Command(executable)
3536
cmd.Args = append(cmd.Args, args...)
3637
stdin := &bytes.Buffer{}

pkg/bundle/bundle.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func Pack(directory string) (io.ReadCloser, error) {
9898
var split = func(path string) []string { return strings.Split(path, string(filepath.Separator)) }
9999

100100
var write = func(w io.Writer, path string) error {
101+
// #nosec G304 names are safe, they come from the listing
101102
file, err := os.Open(path)
102103
if err != nil {
103104
return err
@@ -127,6 +128,7 @@ func Pack(directory string) (io.ReadCloser, error) {
127128
}
128129

129130
var patterns []gitignore.Pattern
131+
// #nosec G304 names are safe
130132
if file, err := os.Open(filepath.Join(directory, shpIgnoreFilename)); err == nil {
131133
defer file.Close()
132134

@@ -293,13 +295,14 @@ func Unpack(in io.Reader, targetPath string) (*UnpackDetails, error) {
293295
return nil, err
294296
}
295297

298+
// #nosec G304 names are safe, they come from the listing
296299
file, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, fileMode(header))
297300
if err != nil {
298301
return nil, err
299302
}
300303

301304
if _, err := io.Copy(file, tr); err != nil {
302-
file.Close()
305+
_ = file.Close()
303306
return nil, err
304307
}
305308

pkg/metrics/pprof.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
// +build pprof_enabled
5+
//go:build pprof_enabled
66

77
package metrics
88

0 commit comments

Comments
 (0)