Class SecretPatterns


  • public class SecretPatterns
    extends Object
    • Method Detail

      • getAggregateSecretPattern

        @NonNull
        public static Pattern getAggregateSecretPattern​(@NonNull
                                                        Collection<String> inputs)
        Constructs a regular expression to match against all known forms that the given collection of input strings may appear. This pattern is optimized such that longer masks are checked before shorter masks. By doing so, this makes inputs that are substrings of other inputs be masked as the longer input, though there is no guarantee this will work in every possible situation. Another consequence of this ordering is that inputs that require quoting will be masked before a substring of the input was matched, thus avoiding leakage of information. For example, bash -x will only quote arguments echoed when necessary. To avoid leaking the presence or absence of quoting, the longer form is masked.