-
-
Notifications
You must be signed in to change notification settings - Fork 619
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
nosec statement ignored when additionally defined in front of function, const or variable segment #1105
Comments
Same issue is true for functions
will cause the same behaviour. Removing the first nosec-marker will solve this issue as well.. |
It seems like block-wide //#nosec G404
fmt.Printf("%d\n",
rand.Int()) In v2.18.2, the fmt.Printf("%d\n",
//#nosec G404
rand.Int()) Interestingly, there has to be a line-feed in the //#nosec G404
fmt.Printf("%d\n", rand.Int()) |
The nonsec directive was refactored to be more fined-grained instead of ignoring an entire AST node. |
Unfortunately, the use of #nosec is no longer predictable in the current version (2.19.0). Multiple tests show a different number of issues with the same code. With version 2.18.2, the problem does not occur at all. example Code: ...
_, _, err := procPathNameVolume.Call(
uintptr(unsafe.Pointer(volumeName)), //#nosec
uintptr(unsafe.Pointer(&nameBuffer[0])), //#nosec
uintptr(nameSize),
uintptr(unsafe.Pointer(&retSize))) //#nosec
... first run with 2.19.0:
second run with 2.19.0:
third run with 2.19.0:
run with 2.18.0:
|
The easiest and safest approach to satisfy the revive linter, as these functions must have this exact signature. The occurrences were mostly split between Cobra and tests, hence the separate commits for easier review. Fixes UDENG-2287 Note that the latest version of golangci-lint (currently 1.56.2) pulls in a version of gosec where the `#nosec` directive is sort of [broken](securego/gosec#1105), hence the additional influx of warnings in the [dependabot PR](#915).
The `nosec` directive [is broken](securego/gosec#1105) as of gosec 2.19 -- we can work around this by using the `nolint` directive from golangci-lint. The main drawback is that this disables the entire linter, not just one rule, but I still kept the rule name for reference. After this is merged we can bump golangci-lint to ~1.56.2~ 1.57.0.
Due to securego/gosec#1105 we need to use `nolint` instead of `nosec` for `gosec`.
Due to securego/gosec#1105 we need to use `nolint` instead of `nosec` for `gosec`.
Due to securego/gosec#1105 we need to use `nolint` instead of `nosec` for `gosec`.
Due to securego/gosec#1105 we need to use `nolint` instead of `nosec` for `gosec`.
* chore(deps): update dependency golangci-lint to v1.57.1 * chore(gosec): use `nolint` instead of `nosec` for `gosec` Due to securego/gosec#1105 we need to use `nolint` instead of `nosec` for `gosec`. * fix deprecation warning > WARN [config_reader] The configuration option `govet.check-shadowing` is deprecated. Please enable `shadow` instead, if you are not using `enable-all`. * fix local timeout issue --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Silvestre Zabala <[email protected]>
See securego/gosec#1105 Signed-off-by: nscuro <[email protected]>
Summary
Adding a
#nosec
marker in front of this const or var segment causes the parser to ignore the actual nosec statements.Steps to reproduce the behavior
will create this error message.
When removed, no error is shown.
gosec version
2.19.0 (latest on 14th February 2024)
Works fine with 2.18.
Go version (output of 'go version')
go version go1.21.4 windows/amd64
Operating system / Environment
Windows 11
Expected behavior
Should not show the ignored security errors.
Actual behavior
Ignores the
#nosec
statements and displays an error.The text was updated successfully, but these errors were encountered: