-
-
Notifications
You must be signed in to change notification settings - Fork 642
nosec comment below another comment breaks the nosec annotation #743
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
Comments
Thanks for pointing this out. Previously gosec used to ignore the entire AST under the |
My very first idea of putting I got 2 solutions here:
Both are good to me. What's your idea @ccojocar ? |
Discarding what's in front of |
Summary
When annotating with
// #nosec
, if there is a comment directly above the annotation, the annotation does not work as the two comments are treated as a multiline comment.It appears that #735 changed whether a comment needs to only contain the annotation or whether the annotation needs to be at the beginning of a comment.
I don't necessarily think this should change now, but just wanted to highlight that this was a regression with
v2.9.3
and below.Steps to reproduce the behavior
gosec version
v2.9.5
Go version (output of 'go version')
go version go1.16.11 linux/amd64
Operating system / Environment
Linux
Expected behavior
gosec ignores the comment from above, or docs are updated to avoid multiline comments.
Actual behavior
gosec does not handle the nosec annotation.
The text was updated successfully, but these errors were encountered: