jerryshao commented on code in PR #14979:
URL: https://github.com/apache/gravitino/pull/14979#discussion_r4583100141


##########
core/src/main/java/org/apache/gravitino/job/JobRuntimeTemplateMaskUtils.java:
##########
@@ -205,10 +242,59 @@ private static String maskEqualsForm(@Nullable String 
arg) {
     for (String flag : JSON_ARGUMENT_FLAGS) {
       String prefix = flag + "=";
       if (arg.startsWith(prefix)) {
-        return prefix
-            + 
HiddenPropertyMaskUtils.maskSensitiveJsonValue(arg.substring(prefix.length()));
+        return prefix + 
safeMaskSensitiveJsonValue(arg.substring(prefix.length()));
       }
     }
     return null;
   }
+
+  /**
+   * @return {@code --conf=...} with a sensitive value masked, or {@code null} 
when {@code arg} is
+   *     not the equals form of {@link #CONF_ARGUMENT_FLAG}
+   */
+  @Nullable
+  private static String maskConfEqualsForm(@Nullable String arg) {
+    if (arg == null) {
+      return null;
+    }
+    String prefix = CONF_ARGUMENT_FLAG + "=";
+    if (!arg.startsWith(prefix)) {
+      return null;
+    }
+    return prefix + maskConfKeyValue(arg.substring(prefix.length()));
+  }
+
+  /**
+   * Masks {@code key=value} when {@code key} looks sensitive. Tokens without 
{@code =}, or with a
+   * non-sensitive key, are returned unchanged.
+   */
+  private static String maskConfKeyValue(String keyValue) {
+    int eq = keyValue.indexOf('=');
+    if (eq <= 0) {
+      return keyValue;
+    }
+    String key = keyValue.substring(0, eq);
+    if (!SecretPropertyUtils.isSensitivePropertyKey(key)) {
+      return keyValue;
+    }
+    return key + "=" + HiddenPropertyMaskUtils.MASKED_VALUE;
+  }
+
+  /**
+   * Masks one JSON argument value. Unexpected failures become {@link
+   * HiddenPropertyMaskUtils#MASKED_VALUE} so the argument walk can continue. 
Catches {@link
+   * Exception} (same scope as {@link 
HiddenPropertyMaskUtils#maskSensitiveJsonValue}) rather than
+   * only unchecked exceptions.
+   */
+  private static String safeMaskSensitiveJsonValue(String arg) {
+    try {
+      return HiddenPropertyMaskUtils.maskSensitiveJsonValue(arg);

Review Comment:
   [P2] If `--updater-options` receives `{} {"password":"secret"}` as one 
argument, the INFO log still includes `secret`. Jackson reads the empty first 
object, and `maskNestedJsonValue` returns the entire original argument because 
that object needed no redaction. Please enable `FAIL_ON_TRAILING_TOKENS` on the 
dedicated masking mapper and add a regression assertion that this argument 
becomes `MASKED_VALUE`. That would route concatenated objects through the 
fixed-text warning path for both local builders.



-- 
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]

Reply via email to