Skip to content

Commit

Permalink
Address linting 2
Browse files Browse the repository at this point in the history
  • Loading branch information
chainchad committed Nov 24, 2024
1 parent da8130b commit c37c8f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tools/gomod-required-updater/internal/updater/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package updater

import (
"fmt"
"errors"
"os"
"time"

Expand All @@ -19,9 +19,9 @@ const (
// Errors that can be returned by the updater package
var (
// ErrModOperation indicates a failure in a module-related operation
ErrModOperation = fmt.Errorf("module operation failed")
ErrModOperation = errors.New("module operation failed")
// ErrInvalidConfig indicates invalid configuration parameters
ErrInvalidConfig = fmt.Errorf("invalid configuration")
ErrInvalidConfig = errors.New("invalid configuration")
)

// ModuleOperator handles Git repository operations and module version management.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func validateGitInput(remote, branch string) error {

// GetGitInfo retrieves the latest commit SHA and timestamp from a Git repository
func (m *moduleOperator) GetGitInfo(remote, branch string) (string, time.Time, error) {
// Validate remote and branch against strict regex patterns before using in exec
if err := validateGitInput(remote, branch); err != nil {
return "", time.Time{}, err
}
Expand All @@ -74,7 +75,7 @@ func (m *moduleOperator) GetGitInfo(remote, branch string) (string, time.Time, e
cmd := exec.CommandContext(ctx, "git", "ls-remote", remote, "refs/heads/"+branch)

Check failure on line 75 in tools/gomod-required-updater/internal/updater/module_operator.go

View workflow job for this annotation

GitHub Actions / lint

G204: Subprocess launched with a potential tainted input or cmd arguments (gosec)
out, err := cmd.Output()
if err != nil {
return "", time.Time{}, fmt.Errorf("%w: failed to get SHA: %v", ErrModOperation, err)
return "", time.Time{}, fmt.Errorf("%w: failed to get SHA: %w", ErrModOperation, err)
}
if len(out) == 0 {
return "", time.Time{}, fmt.Errorf("%w: no output from git ls-remote", ErrModOperation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import (
"path/filepath"
)

const (
defaultFileMode = 0644
)

type systemOperator struct{}

func NewSystemOperator() SystemOperator {
Expand Down

0 comments on commit c37c8f5

Please sign in to comment.