lasdf1234 commented on code in PR #14979:
URL: https://github.com/apache/gravitino/pull/14979#discussion_r4583632625
##########
core/src/main/java/org/apache/gravitino/connector/HiddenPropertyMaskUtils.java:
##########
@@ -75,10 +75,16 @@ public final class HiddenPropertyMaskUtils {
/**
* Mapper for nest-JSON masking. Uses {@link JsonNode} with big-decimal
floats so rewritten JSON
- * keeps numeric fidelity better than {@code Map}/{@code List} round-trips.
+ * keeps numeric fidelity better than {@code Map}/{@code List} round-trips.
{@link
+ * DeserializationFeature#FAIL_ON_TRAILING_TOKENS} rejects concatenated
values (for example {@code
+ * {} {"password":"secret"}}), so a no-op first object cannot leave a
trailing secret in the
+ * original string.
*/
private static final ObjectMapper NEST_JSON_MAPPER =
-
JsonUtils.anyFieldMapper().copy().enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
+ JsonUtils.anyFieldMapper()
+ .copy()
+ .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
+ .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
Review Comment:
Thanks — fixed in `1c2aa6932c`.
Enabled `FAIL_ON_READING_DUP_TREE_KEY` on the nest-JSON mapper, so inputs
like `{"config":{"password":"example"},"config":{}}` fail parse and become
`MASKED_VALUE` instead of returning the original argument (where the dropped
first field still held the secret).
Regression tests:
-
`TestHiddenPropertyMaskUtils#testMaskSensitiveJsonValueRequiresSingleJsonObject`
(duplicate-field case)
-
`TestJobRuntimeTemplateMaskUtils#testMaskSensitiveArgumentsMasksNonSingleJsonObjectBags`
(covers the same via `--updater-options`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]