You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to ignore the unhandled errors rule by pattern matching against the function name.
I am getting G104 errors from fatih/colorFprintf calls.
Updating the // #nosec G104 annotation to allow for an additional function pattern match:
// #nosec G104 /Fprint/ /Print/
package main
Or in a config file somewhere.
Actual behavior
Nosec annotation can only be added globally without exceptions or per line.
The text was updated successfully, but these errors were encountered:
DavidGamba
changed the title
How to ignore rule by pattern matching? Something like G104 /Print/
How to ignore rule by pattern matching? Something like // #nosec G104 /Print/
Apr 11, 2023
@DavidGamba This functionality is not available at the moment. It is possible to ignore one rule for an entire line by just adding the following comment:
// #nosec G104
I think this feature makes sense when there are multiple function calls returning the same warning (e.g. G104 for not checking the returned error) and one wants to ignore only some of these errors. Is this what you are thinking of?
Yes, adding the // #nosec G104 per line does the trick but given that I know that I want to ignore error for all Fprintf calls it would be great to do it globally. The code already ignores the stdlibs Fprintf calls globally by default.
The config file didn't work for me, even after trying different permutations:
Summary
I would like to ignore the unhandled errors rule by pattern matching against the function name.
I am getting G104 errors from
fatih/color
Fprintf
calls.Steps to reproduce the behavior
gosec version
2.15.0
Go version (output of 'go version')
go version go1.20.1 darwin/arm64
Operating system / Environment
MacOS 13
Expected behavior
Updating the
// #nosec G104
annotation to allow for an additional function pattern match:Or in a config file somewhere.
Actual behavior
Nosec annotation can only be added globally without exceptions or per line.
The text was updated successfully, but these errors were encountered: