Class Redaction
java.lang.Object
codes.grow.packages.skywalking.core.Redaction
Redaction helpers for headers, URLs, structured fields and free text (SPEC section 2.6).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum length of vendor error text kept in error messages.static final StringReplacement for every redacted value. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisSensitiveField(String name, Collection<String> extraKeys) Returns whether a field or query parameter name is sensitive (case-insensitive substring).static booleanisSensitiveHeader(String name) Returns whether a header name is sensitive (case-insensitive).redactFields(Map<String, ?> fields) Same asredactFields(Map, Collection)without extra keys.redactFields(Map<String, ?> fields, Collection<String> extraKeys) Returns a deep copy of a structure with the values of sensitive keys replaced; recurses into nested maps and lists.redactHeaderLists(Map<String, List<String>> headers) Returns a copy of multi-valued headers with sensitive values replaced.redactHeaders(Map<String, String> headers) Returns a copy of single-valued headers with sensitive values replaced.static StringredactText(String text, Collection<String> knownSecrets) Replaces every occurrence of each known secret value (length 4 or more) with "[REDACTED]".static StringRedacts user-info passwords and the values of sensitive query parameters in a URL.static StringTruncates text tomaxcharacters, appending an ellipsis when cut.
-
Field Details
-
REDACTED
Replacement for every redacted value.- See Also:
-
MAX_VENDOR_TEXT
public static final int MAX_VENDOR_TEXTMaximum length of vendor error text kept in error messages.- See Also:
-
-
Method Details
-
isSensitiveHeader
Returns whether a header name is sensitive (case-insensitive).- Parameters:
name- header name- Returns:
- true when the value must be redacted
-
isSensitiveField
Returns whether a field or query parameter name is sensitive (case-insensitive substring).- Parameters:
name- field nameextraKeys- additional sensitive substrings, may be empty- Returns:
- true when the value must be redacted
-
redactHeaders
Returns a copy of single-valued headers with sensitive values replaced.- Parameters:
headers- header map- Returns:
- a new map in the same order
-
redactHeaderLists
Returns a copy of multi-valued headers with sensitive values replaced.- Parameters:
headers- header map, e.g.HttpHeaders.map()- Returns:
- a new map in the same order
-
redactUrl
Redacts user-info passwords and the values of sensitive query parameters in a URL.- Parameters:
url- absolute or relative URL- Returns:
- the redacted URL
-
redactFields
Returns a deep copy of a structure with the values of sensitive keys replaced; recurses into nested maps and lists.- Parameters:
fields- map to redactextraKeys- additional sensitive substrings- Returns:
- a new map in the same order
-
redactFields
Same asredactFields(Map, Collection)without extra keys.- Parameters:
fields- map to redact- Returns:
- a new map in the same order
-
redactText
Replaces every occurrence of each known secret value (length 4 or more) with "[REDACTED]". Longer secrets are replaced first.- Parameters:
text- text to clean, may be nullknownSecrets- secret values- Returns:
- the cleaned text (null stays null)
-
truncate
Truncates text tomaxcharacters, appending an ellipsis when cut.- Parameters:
text- text, may be nullmax- maximum length- Returns:
- the truncated text
-