fhan688 commented on code in PR #20021: URL: https://github.com/apache/hudi/pull/20021#discussion_r4130181083
########## hudi-agent-gateway/skills/hudi-architect/redact_sensitive_values.py: ########## @@ -0,0 +1,140 @@ +#!/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( + r"^(?P<prefix>\s*[\"']?(?P<key>[A-Za-z0-9_.-]+)[\"']?\s*(?:=|:)\s*)" Review Comment: > [P1] Redact inline assignments and complete quoted secret values before quoting evidence > > The start-of-line anchor misses credentials in ordinary single-line Flink DDL. Running the helper at this revision with `CREATE TABLE src (id INT) WITH ('connector'='jdbc', 'password'='test-secret');` returns the entire statement unchanged, including the password. There are also partial leaks in the other patterns: `command --password "first second third" --table orders` becomes `command --password <redacted> second third" --table orders`, and JSON passwords containing an escaped quote retain the suffix after that quote. Since SKILL.md requires this helper before quoting supplied DDL, logs, and configuration, its output can expose credentials in responses or saved ADRs despite having been sanitized. Please handle inline SQL/property assignments and consume complete quoted/escaped values, with regression tests for these cases. Thanks for catching this. Fixed: the redactor now handles inline SQL/property assignments and consumes complete quoted values, including escaped quotes. I also added regression coverage for the SQL, CLI, and JSON cases from your comment. -- 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]
