Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -525,18 +525,22 @@ private Object getMaskedValueForCurrentPath() {
return null;
}
/**
* @param value the value to potentially mask
* @param originalValue the value to potentially mask
* @return the masked value for the current path and value if the value should be masked.
* otherwise returns null.
*/
private Object getMaskedValueForCurrentPathAndValue(Object value) {
private Object getMaskedValueForCurrentPathAndValue(Object originalValue) {
JsonStreamContext context = getOutputContext();
Object localValue = originalValue;
for (ValueMasker valueMasker : valueMaskers) {
Object maskedValue = valueMasker.mask(context, value);
Object maskedValue = valueMasker.mask(context, localValue);
if (maskedValue != null) {
return maskedValue;
localValue = maskedValue;
}
}
if (localValue != originalValue) {
return localValue;
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public void maskedAndUnmaskedField() throws IOException {
"value.");
}

@Test
public void maskedSubstrings() throws IOException {
testMaskByValue(
"{\"fieldA\":\"tomask1\",\"fieldB\":\"tomask2\",\"fieldC\":\" tomask1-tomask2 \"}",
"{\"fieldA\":\"****\",\"fieldB\":\"****\",\"fieldC\":\" ****-**** \"}",
"tomask1", "tomask2");
}

@Test
public void onlyMaskedField() throws IOException {
testMaskByPath(
Expand Down