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


##########
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:
   Thanks for catching this regression. I’ve separated multiline quoted-key 
assignments from line-oriented properties while retaining the token-start 
boundary.
    
     I also found and fixed two related cases (where \n represents an actual 
newline):
    
     - JSON with a newline before the colon: ```{"password"\n: "test-secret"}```
     - Flink DDL with a newline after the equals sign: ```WITH ('password'=\n 
'test-secret')```
    
   Regression tests cover these cases and your original example with LF/CRLF. 
Gateway tests, lint, and type checks pass on Python 3.11 and 3.12.
   



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