func compileStringsToRegex(words []string) []*regexp.Regexp {
	compiledRegexps := make([]*regexp.Regexp, 0, len(words))
	forbiddenSymbols := regexp.MustCompile("[^a-zA-Z0-9_*]")

	for _, word := range words {
		if forbiddenSymbols.MatchString(word) {
			log.Warnf("data scrubber: %s skipped. The sensitive word must "+
				"contain only alphanumeric characters, underscores or wildcards ('*')", word)
			continue
		}

		if word == "*" {
			log.Warn("data scrubber: ignoring wildcard-only ('*') sensitive word as it is not supported")
			continue
		}

		originalRunes := []rune(word)
		var enhancedWord bytes.Buffer
		valid := true
		for i, rune := range originalRunes {
			if rune == '*' {
				if i == len(originalRunes)-1 {
					enhancedWord.WriteString("[^ =:]*")
				} else if originalRunes[i+1] == '*' {
					log.Warnf("data scrubber: %s skipped. The sensitive word "+
						"must not contain two consecutives '*'", word)
					valid = false
					break
				} else {
					enhancedWord.WriteString(fmt.Sprintf("[^\\s=:$/]*"))
				}
			} else {
				enhancedWord.WriteString(string(rune))
			}
		}

		if !valid {
			continue
		}

		pattern := "(?P<key>( +| -{1,2})(?i)" + enhancedWord.String() + ")(?P<delimiter> +|=|:)(?P<value>[^\\s]*)"
		r, err := regexp.Compile(pattern)
		if err == nil {
			compiledRegexps = append(compiledRegexps, r)
		} else {
			log.Warnf("data scrubber: %s skipped. It couldn't be compiled into a regex expression", word)
		}
	}

	return compiledRegexps
}
// compileStringsToRegex compile each word in the slice into a regex pattern to match
// against the cmdline arguments (originally imported from pkg/process/config)
// The word must contain only word characters ([a-zA-z0-9_]) or wildcards *
compileStringsToRegex compile each word in the slice into a regex pattern to match
against the cmdline arguments (originally imported from pkg/process/config)
The word must contain only word characters ([a-zA-z0-9_]) or wildcards
// compileStringsToRegex compile each word in the slice into a regex pattern to match // against the cmdline arguments ( originally imported from pkg / process / config ) // The word must contain only word characters ( [ a - zA - z0 - 9_ ] ) or wildcards *
func compileStringsToRegex(words []string) []*regexp.Regexp {
	compiledRegexps := make([]*regexp.Regexp, 0, len(words))
	forbiddenSymbols := regexp.MustCompile("[^a-zA-Z0-9_*]")
	for _, word := range words {
		if forbiddenSymbols.MatchString(word) {
			log.Warnf("data scrubber: %s skipped. The sensitive word must "+
				"contain only alphanumeric characters, underscores or wildcards ('*')", word)
			continue
		}
		if word == "*" {
			log.Warn("data scrubber: ignoring wildcard-only ('*') sensitive word as it is not supported")
			continue
		}
		originalRunes := []rune(word)
		var enhancedWord bytes.Buffer
		valid := true
		for i, rune := range originalRunes {
			if rune == '*' {
				if i == len(originalRunes)-1 {
					enhancedWord.WriteString("[^ =:]*")
				} else if originalRunes[i+1] == '*' {
					log.Warnf("data scrubber: %s skipped. The sensitive word "+
						"must not contain two consecutives '*'", word)
					valid = false
					break
				} else {
					enhancedWord.WriteString(fmt.Sprintf("[^\\s=:$/]*"))
				}
			} else {
				enhancedWord.WriteString(string(rune))
			}
		}
		if !valid {
			continue
		}
		pattern := "(?P<key>( +| -{1,2})(?i)" + enhancedWord.String() + ")(?P<delimiter> +|=|:)(?P<value>[^\\s]*)"
		r, err := regexp.Compile(pattern)
		if err == nil {
			compiledRegexps = append(compiledRegexps, r)
		} else {
			log.Warnf("data scrubber: %s skipped. It couldn't be compiled into a regex expression", word)
		}
	}
	return compiledRegexps
}
func compileStringsToRegex ( words [ ] string ) [ ] * regexp . Regexp { compiledRegexps := make ( [ ] * regexp . Regexp , 0 , len ( words ) ) forbiddenSymbols := regexp . MustCompile ( " " ) for _ , word := range words { if forbiddenSymbols . MatchString ( word ) { log . Warnf ( " " + " " , word ) continue } if word == " " { log . Warn ( " " ) continue } originalRunes := [ ] rune ( word ) var enhancedWord bytes . Buffer valid := true for i , rune := range originalRunes { if rune == '*' { if i == len ( originalRunes ) - 1 { enhancedWord . WriteString ( " " ) } else if originalRunes [ i + 1 ] == '*' { log . Warnf ( " " + " " , word ) valid = false break } else { enhancedWord . WriteString ( fmt . Sprintf ( " \\ " ) ) } } else { enhancedWord . WriteString ( string ( rune ) ) } } if ! valid { continue } pattern := " " + enhancedWord . String ( ) + " \\ " r , err := regexp . Compile ( pattern ) if err == nil { compiledRegexps = append ( compiledRegexps , r ) } else { log . Warnf ( " " , word ) } } return compiledRegexps }
compileStringsToRegex compile each word in the slice into a regex pattern to match
against the cmdline arguments (originally imported from pkg/process/config)
The word must contain only word characters ([a-zA-z0-9_]) or wildcards
compileStringsToRegex compile each word in the slice into a regex pattern to match against the cmdline arguments ( originally imported from pkg / process / config ) The word must contain only word characters ( [ a - zA - z0 - 9_ ] ) or wildcards