mirror of
https://github.com/securego/gosec.git
synced 2025-11-25 22:22:17 +02:00
Fix incorrect regexp matches
There are some cases where the '.' character would also match any character and could lead to incorrect results. For example the regular expression - `^ioutils.WriteFile$' would match ioutils.WriteFile, but also ioutils_WriteFile. Additionally made sure that all regexp were declared using raw strings to avoid any unnecesary string escaping that potentially make the regexp difficult to read.
This commit is contained in:
@@ -37,8 +37,8 @@ func (t *BadTempFile) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err erro
|
||||
|
||||
func NewBadTempFile() (r gas.Rule, n ast.Node) {
|
||||
r = &BadTempFile{
|
||||
call: regexp.MustCompile("ioutil.WriteFile|os.Create"),
|
||||
args: regexp.MustCompile("^/tmp/.*$|^/var/tmp/.*$"),
|
||||
call: regexp.MustCompile(`ioutil\.WriteFile|os\.Create`),
|
||||
args: regexp.MustCompile(`^/tmp/.*$|^/var/tmp/.*$`),
|
||||
MetaData: gas.MetaData{
|
||||
Severity: gas.Medium,
|
||||
Confidence: gas.High,
|
||||
|
||||
Reference in New Issue
Block a user