Interface Masker
- All Superinterfaces:
Function<String,,String> UnaryOperator<String>
- All Known Implementing Classes:
PathRedactor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A masker is a plain UnaryOperator<String>, so it can be handed to
any API that takes one. Implementations must accept null and return it unchanged, and
must be safe to use from several threads at once.
Masking is off by default: callers that are not configured otherwise use noOp().
hidingOutside(Path) and PathRedactor are the opt-in maskers.
- Since:
- 0.18.6
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic MaskerhidingOutside(Path root) Returns the opt-in masker that hides every absolute path outsiderootand every well-known credential shape.static MaskernoOp()Returns the masker that changes nothing; the default wherever masking is configurable.
-
Method Details
-
noOp
Returns the masker that changes nothing; the default wherever masking is configurable.- Returns:
- the identity masker
-
hidingOutside
Returns the opt-in masker that hides every absolute path outsiderootand every well-known credential shape.Credentials matching
CredentialPatternsare replaced by[REDACTED:KIND], with the kind namestnsai-quality'sPatternRedactoruses: PEM and PGP private-key blocks (to the end of the text when the END line is missing), OpenAI and Anthropic API keys, GitHub tokens, AWS access key ids, JWTs (unsigned ones too),Bearervalues, and Slack tokens and webhook URLs. A credential is found also when it is glued to a preceding word, as inAPI_KEY_sk-…. PII such as e-mail addresses or card numbers is not masked.Absolute POSIX paths outside
rootare replaced by[REDACTED:path]; paths under it are left as they are. A path is compared after lexical normalization, soROOT/../etc/passwdcounts as outside.rootis matched in its absolute normalized form and, when it exists at construction time, its real form with links resolved (on macOS/tmp/xis also/private/tmp/x). Paths found in the text are never resolved against the file system. A path ends at whitespace, a quote, a bracket,,,;,:or=, and a//inside it starts another path, soPATH=ROOT/bin:/home/xandROOT//home/xhide/home/x. A path glued to a command-line option, as in-I/home/x, is found too. A URL's path (https://host/x), relative paths,~/…, Windows drive paths, percent-encoded paths and the part of a path after a space are not recognised. A root of/leaves every path visible.The masker is immutable and thread-safe.
- Parameters:
root- the folder whose paths stay visible- Returns:
- a masker for
root - Throws:
NullPointerException- ifrootisnull
-