Skip to content

gosec: global options are not being honored #3778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
bcho opened this issue Apr 15, 2023 · 1 comment · Fixed by #3779
Closed
4 tasks done

gosec: global options are not being honored #3778

bcho opened this issue Apr 15, 2023 · 1 comment · Fixed by #3779
Labels
bug Something isn't working

Comments

@bcho
Copy link
Contributor

bcho commented Apr 15, 2023

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

In the official document https://golangci-lint.run/usage/linters#gosec , it says user can set the global option via config.global block. However, the settings under global section are not being honored.

We can reproduce with following settings:

linters-settings:
  gosec:
    config:
      global:
        nosec: true

Code:

//golangcitest:args -Egosec
//golangcitest:config_path testdata/configs/gosec_global_option.yml
package testdata

import (
	"crypto/md5" // want "G501: Blocklisted import crypto/md5: weak cryptographic primitive"
	"log"
)

func Gosec() {
	// #nosec G401
	h := md5.New() // want "G401: Use of weak cryptographic primitive"
	log.Print(h)
}

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

I believe this issue affects all versions.

Configuration file

$ cat .golangci.yml
# paste output here

See above.

Go environment

$ go version && go env
# paste output here

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

Code example or link to a public repository

// add your code here
@bcho bcho added the bug Something isn't working label Apr 15, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 15, 2023

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez ldez changed the title gosec global options are not being honored gosec: global options are not being honored Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant