Skip to content

Commit d18da6f

Browse files
committed
fix: update regexes to be more flexible
1 parent 9cdd90c commit d18da6f

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

cmd/root.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/*
2-
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
3-
*/
41
package cmd
52

63
import (
@@ -43,8 +40,8 @@ var rootCmd = &cobra.Command{
4340
cfg.Rules["shush:password"] = config.Rule{
4441
Description: "Password",
4542
RuleID: "Generic password",
46-
Regex: regexp.MustCompile("(password|pass|pwd|passwd|passphrase)( *:| *-) (.*)"),
47-
SecretGroup: 3,
43+
Regex: regexp.MustCompile("['\"]?(password|pass|pwd|passwd|passphrase)['\"]?[[:space:]]?[:-]?[[:space:]]?['\"]?([^'\"\r\n]*)['\"]?"),
44+
SecretGroup: 2,
4845
Keywords: []string{"password", "pass", "pwd", "passwd", "passphrase", "passphrase"},
4946
}
5047
}
@@ -53,8 +50,8 @@ var rootCmd = &cobra.Command{
5350
cfg.Rules["shush:secret"] = config.Rule{
5451
Description: "Secret",
5552
RuleID: "Generic secrets",
56-
Regex: regexp.MustCompile("secret( *:| *-) (.*)$"),
57-
SecretGroup: 1,
53+
Regex: regexp.MustCompile("['\"]?(secret)['\"]?[[:space:]]?[:-]?[[:space:]]?['\"]?([^'\"\r\n]*)['\"]?"),
54+
SecretGroup: 2,
5855
Keywords: []string{"secret"},
5956
}
6057
}

main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*
2-
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
3-
4-
*/
51
package main
62

73
import "github.com/bradcypert/shush/cmd"

0 commit comments

Comments
 (0)