Skip to content

Commit

Permalink
chore(regex): simplify secretPrefix, suffix
Browse files Browse the repository at this point in the history
combined character ranges,
removed duplicates in same character range,
replaced \x060 with literal `
combined \s with \r\n
  • Loading branch information
Ben-grmbl committed Nov 5, 2024
1 parent 48a2e0e commit 41c671b
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 140 deletions.
7 changes: 3 additions & 4 deletions cmd/generate/config/utils/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ const (
identifierCaseInsensitivePrefix = `[\w.-]{0,50}?(?i:`
identifierCaseInsensitiveSuffix = `)`
identifierPrefix = `[\w.-]{0,50}?(?:`
identifierSuffix = `)(?:[ \t\w.-]{0,20})(?:[\s|']|[\s|"]){0,3}`
identifierSuffix = `)(?:[ \t\w.-]{0,20})[\s'"|]{0,3}`

// commonly used assignment operators or function call
//language=regexp
operator = `(?:=|>|:{1,3}=|\|\|:|<=|=>|:|\?=)`

// boundaries for the secret
// \x60 = `
secretPrefixUnique = `\b(`
secretPrefix = `(?:'|\"|\s|=|\x60){0,5}(`
secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)`
secretPrefix = "[`" + `'"\s=]{0,5}(`
secretSuffix = ")(?:[`" + `'"\s;]|$)`
)

func GenerateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
Expand Down
Loading

0 comments on commit 41c671b

Please sign in to comment.