diff --git a/rules/readfile.go b/rules/readfile.go index 83b11f2..ce0c3fb 100644 --- a/rules/readfile.go +++ b/rules/readfile.go @@ -31,7 +31,6 @@ func (r *readfile) ID() string { return r.MetaData.ID } - // Match inspects AST nodes to determine if the match the methods `os.Open` or `ioutil.ReadFile` func (r *readfile) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) { if node := r.ContainsCallExpr(n, c); node != nil { @@ -50,14 +49,14 @@ func (r *readfile) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) { // NewReadFile detects cases where we read files func NewReadFile(id string, conf gas.Config) (gas.Rule, []ast.Node) { rule := &readfile{ - CallList: gas.NewCallList(), + CallList: gas.NewCallList(), MetaData: gas.MetaData{ ID: id, What: "Potential file inclusion via variable", Severity: gas.Medium, Confidence: gas.High, - }, - } + }, + } rule.Add("io/ioutil", "ReadFile") rule.Add("os", "Open") return rule, []ast.Node{(*ast.CallExpr)(nil)} diff --git a/rules/rulelist.go b/rules/rulelist.go index d914cfb..f6f21af 100644 --- a/rules/rulelist.go +++ b/rules/rulelist.go @@ -78,7 +78,7 @@ func Generate(filters ...RuleFilter) RuleList { {"G301", "Poor file permissions used when creating a directory", NewMkdirPerms}, {"G302", "Poor file permisions used when creation file or using chmod", NewFilePerms}, {"G303", "Creating tempfile using a predictable path", NewBadTempFile}, - {"G304", "File path provided as taint input", NewReadFile}, + {"G304", "File path provided as taint input", NewReadFile}, // crypto {"G401", "Detect the usage of DES, RC4, or MD5", NewUsesWeakCryptography},