Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ config:
@$(CONFIG_SCRIPT)

.PHONY: all
all: config dependencies tidy fmt vet staticcheck gosec test build install
all: config dependencies tidy fmt vet staticcheck gosec semgrep test build install

# Update CI tools used by ./.github/workflows/pr_test.yml
.PHONY: dependencies
Expand All @@ -62,6 +62,7 @@ dependencies:
$(GO_BIN) install honnef.co/go/tools/cmd/[email protected]
$(GO_BIN) install github.com/mgechev/revive@latest
$(GO_BIN) install github.com/goreleaser/[email protected]
if [[ "$$(uname)" == 'Darwin' ]]; then brew install semgrep; fi

# Clean up Go modules file.
.PHONY: tidy
Expand Down Expand Up @@ -89,6 +90,12 @@ revive:
gosec:
gosec -quiet -exclude=G104 ./{cmd,pkg}/...

# Run semgrep checker.
# NOTE: We can only exclude the import-text-template rule via a semgrep CLI flag
.PHONY: semgrep
semgrep:
if command -v semgrep &> /dev/null; then semgrep ci --config auto --exclude-rule go.lang.security.audit.xss.import-text-template.import-text-template; fi

# Run third-party static analysis.
.PHONY: staticcheck
staticcheck:
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/undocumented/undocumented.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Get(host, path, token string, c api.HTTPClient) (data []byte, err error) {

data, err = io.ReadAll(res.Body)
if err != nil {
return data, NewError(err, res.StatusCode)
return []byte{}, NewError(err, res.StatusCode)
}

return data, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func processCommandInput(

cmdName, err = app.Parse(opts.Args)
if err != nil {
return command, cmdName, help(vars, err)
return command, "", help(vars, err)
}

// Restore output writers
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/secretstoreentry/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (c *CreateCommand) Exec(in io.Reader, out io.Writer) error {

case c.secretFile != "":
var err error
// nosemgrep: trailofbits.go.questionable-assignment.questionable-assignment
if c.Input.Secret, err = os.ReadFile(c.secretFile); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/testutil/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func NewEnv(opts EnvOpts) (rootdir string) {
// gosec flagged this:
// G204 (CWE-78): Subprocess launched with function call as argument or cmd arguments
// Disabling as we trust the source of the variable.
/* #nosec */
// #nosec
// nosemgrep: go.lang.security.audit.dangerous-exec-command.dangerous-exec-command
cmd := exec.Command(opts.Exec[0], opts.Exec[1:]...)
cmd.Dir = rootdir
if err := cmd.Run(); err != nil {
Expand Down