Skip to content

Commit 942f40a

Browse files
author
Travis McPeak
committed
Fix nosec to work as documented
This commit fixes the nosec feature to check for '#nosec' instead of 'nosec'. This should help reduce false positives associated with comments that have 'nosec' in them somewhere.
1 parent 3911321 commit 942f40a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/analyzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ func (gas *Analyzer) ProcessSource(filename string, source string) error {
183183
return err
184184
}
185185

186-
// ignore a node (and sub-tree) if it is tagged with a "nosec" comment
186+
// ignore a node (and sub-tree) if it is tagged with a "#nosec" comment
187187
func (gas *Analyzer) ignore(n ast.Node) bool {
188188
if groups, ok := gas.context.Comments[n]; ok && !gas.ignoreNosec {
189189
for _, group := range groups {
190-
if strings.Contains(group.Text(), "nosec") {
190+
if strings.Contains(group.Text(), "#nosec") {
191191
gas.Stats.NumNosec++
192192
return true
193193
}

0 commit comments

Comments
 (0)