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
As with all automated detection tools, there will be cases of false positives. In cases where gosec reports a failure that has been manually verified as being safe,
272
-
it is possible to annotate the code with a `#nosec` comment.
272
+
it is possible to annotate the code with a comment that starts with `#nosec`.
273
+
The `#nosec` comment should have the format `#nosec [RuleList] [-- Justification]`.
273
274
274
275
The annotation causes gosec to stop processing any further nodes within the
275
276
AST so can apply to a whole block or more granularly to a single expression.
@@ -294,6 +295,10 @@ When a specific false positive has been identified and verified as safe, you may
294
295
within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within
295
296
the `#nosec` annotation, e.g: `/* #nosec G401 */` or `// #nosec G201 G202 G203`
296
297
298
+
You could put the description or justification text for the annotation. The
299
+
justification should be after the rule(s) to suppress and start with two or
300
+
more dashes, e.g: `// #nosec G101 G102 -- This is a false positive`
301
+
297
302
In some cases you may also want to revisit places where `#nosec` annotations
298
303
have been used. To run the scanner and ignore any `#nosec` annotations you
299
304
can do the following:
@@ -302,6 +307,27 @@ can do the following:
302
307
gosec -nosec=true ./...
303
308
```
304
309
310
+
### Tracking suppressions
311
+
312
+
As described above, we could suppress violations externally (using `-include`/
313
+
`-exclude`) or inline (using `#nosec` annotations) in gosec. This suppression
314
+
inflammation can be used to generate corresponding signals for auditing
315
+
purposes.
316
+
317
+
We could track suppressions by the `-track-suppressions` flag as follows:
0 commit comments