mirror of
https://github.com/securego/gosec.git
synced 2025-11-25 22:22:17 +02:00
Change the exclude syntax to be a part of #nosec
This commit is contained in:
12
analyzer.go
12
analyzer.go
@@ -154,16 +154,16 @@ func (gas *Analyzer) ignore(n ast.Node) ([]string, bool) {
|
||||
for _, group := range groups {
|
||||
if strings.Contains(group.Text(), "#nosec") {
|
||||
gas.stats.NumNosec++
|
||||
return nil, true
|
||||
}
|
||||
|
||||
if strings.Contains(group.Text(), "#exclude") {
|
||||
gas.stats.NumNosec++
|
||||
|
||||
// Pull out the specific rules that are listed to be ignored.
|
||||
re := regexp.MustCompile("!(G\\d{3})")
|
||||
re := regexp.MustCompile("(G\\d{3})")
|
||||
matches := re.FindAllStringSubmatch(group.Text(), -1)
|
||||
|
||||
// If no specific rules were given, ignore everything.
|
||||
if matches == nil || len(matches) == 0 {
|
||||
return nil, true
|
||||
}
|
||||
|
||||
// Find the rule IDs to ignore.
|
||||
var ignores []string
|
||||
for _, v := range matches {
|
||||
|
||||
Reference in New Issue
Block a user