mirror of
https://github.com/securego/gosec.git
synced 2025-12-01 22:41:54 +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:
@@ -40,7 +40,7 @@ func (w *WeakKeyStrength) Match(n ast.Node, c *gas.Context) (*gas.Issue, error)
|
||||
func NewWeakKeyStrength() (r gas.Rule, n ast.Node) {
|
||||
bits := 2048
|
||||
r = &WeakKeyStrength{
|
||||
pattern: regexp.MustCompile(`^rsa.GenerateKey$`),
|
||||
pattern: regexp.MustCompile(`^rsa\.GenerateKey$`),
|
||||
bits: bits,
|
||||
MetaData: gas.MetaData{
|
||||
Severity: gas.Medium,
|
||||
|
||||
Reference in New Issue
Block a user