1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-23 22:15:04 +02:00

Allow rules to register against multiple ast nodes

Update the AddRule interface to allow rules to register interest in
multiple ast.Nodes. Adds more flexibility to how rules can work, and was
needed to fix the hard coded credentials test specifically.
This commit is contained in:
Grant Murphy
2016-11-13 12:55:31 -08:00
parent c6587df4a5
commit bf103da519
16 changed files with 69 additions and 102 deletions

View File

@@ -50,14 +50,12 @@ func (r *NoErrorCheck) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err err
return nil, nil
}
func NewNoErrorCheck(conf map[string]interface{}) (r gas.Rule, n ast.Node) {
r = &NoErrorCheck{
func NewNoErrorCheck(conf map[string]interface{}) (gas.Rule, []ast.Node) {
return &NoErrorCheck{
MetaData: gas.MetaData{
Severity: gas.Low,
Confidence: gas.High,
What: "Errors unhandled.",
},
}
n = (*ast.AssignStmt)(nil)
return
}, []ast.Node{(*ast.AssignStmt)(nil)}
}