danny0405 commented on code in PR #20021:
URL: https://github.com/apache/hudi/pull/20021#discussion_r4140583205


##########
hudi-agent-gateway/skills/hudi-architect/redact_sensitive_values.py:
##########
@@ -0,0 +1,194 @@
+#!/usr/bin/env python3
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""Redact common credentials from evidence before the skill quotes it.
+
+This utility deliberately treats its input as opaque text. It does not parse or
+execute DDL, shell commands, URLs, or configuration supplied by the user.
+"""
+
+from __future__ import annotations
+
+import argparse
+import re
+import sys
+from pathlib import Path
+
+REDACTED = "<redacted>"
+
+SENSITIVE_KEY = re.compile(
+    r"(?ix)(?:"
+    r"authorization|password|passwd|pwd|secret|token|credential|"
+    r"api[._-]?key|access[._-]?key|secret[._-]?key|client[._-]?secret|"
+    r"private[._-]?key"
+    r")"
+)
+
+ASSIGNMENT = re.compile(
+    # Try only token starts, not every suffix of long non-secret values.
+    r"(?<![A-Za-z0-9_.-])"
+    r"(?P<prefix>(?P<key_quote>[\"']?)(?P<key>[A-Za-z0-9_.-]+)"
+    r"(?P=key_quote)[ \t]*(?:=|:)[ \t]*)"

Review Comment:
   [P1] Consume newline-separated JSON values before declaring them redacted
   
   Replacing the whitespace match with `[ \t]*` introduces a full credential 
leak for valid JSON whose value begins on the next line. For example:
   
   ```json
   {"password":
     "test-secret",
     "table": "orders"}
   ```
   
   At this revision, the CLI outputs `{"password":<redacted>` on the first line 
but copies the next line's `"test-secret"` unchanged. The assignment match now 
ends immediately before the newline, and `_consume_assignment_value` redacts an 
empty value before the remaining text is appended. I confirmed the same input 
was fully redacted at `2f7f1b8`; LF and CRLF both reproduce the regression. 
Since the skill quotes the helper's output as sanitized evidence, please 
consume the actual JSON value across allowed whitespace (or conservatively omit 
an ambiguous continuation) and add regression cases for newline-separated 
keys/values. The token-start boundary can still prevent the quadratic suffix 
scan.



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