Repository navigation
Conversation
The uname line in `airflow info` reports platform.uname(), whose node field is the machine hostname. On managed devices this hostname often encodes an asset tag or device name, but --anonymize never masked it even though it already redacts the home directory, OS username, and database credentials elsewhere in the report. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Building a synthetic uname_result inline is clearer than caching a real one at import time to work around mock.patch timing. Co-Authored-By: Claude Sonnet 5 <[email protected]>
potiuk
left a comment
There was a problem hiding this comment.
Thanks. The hostname should not be in an anonymized report, but this only covers one of the places it shows up (inline). A few other points:
- Please drop
airflow-core/newsfragments/73074.bugfix.rst. Under the current policyairflow-coreuses onlysignificantnewsfragments, for changes users must read before upgrading, and this small fix isn't one. - An end-to-end test that the real hostname does not appear anywhere in the
airflow info --anonymizeoutput would protect the actual promise, rather than only theunamefield. platform.unameis patched withoutautospec, and sinceArchitecture.get_current()readsplatform.machine()through the same patched module, the architecture in these tests is faked as well.
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
| operating_system = OperatingSystem.get_current() | ||
| arch = Architecture.get_current() | ||
| uname = platform.uname() | ||
| uname = uname._replace(node=self.anonymizer.process_hostname(uname.node)) |
There was a problem hiding this comment.
This replaces the hostname only in the uname node field. It still leaks through the database URL's host (postgresql://u:[email protected]/airflow, which process_url leaves alone) and through any path that contains it (process_path only replaces HOME and USER). Adding socket.gethostname(): "${HOSTNAME}" to PiiAnonymizer._path_replacements, and applying the same replacements in process_url, would scrub it everywhere and cover this line too, without the new process_hostname() method.
There was a problem hiding this comment.
A correction to my suggestion above, since it has some problems:
- Please don't run the hostname replacement over the whole URL in
process_url. A plain substring replace has the same problem Keep the URL scheme out of path masking in airflow info --anonymize #73599 fixed for the username: on a machine namedpostgres, the scheme would become${HOSTNAME}ql+psycopg2://. Compare only the URL's host, without the port, and replace it if it matches the machine's hostname. - My
db01.corp.exampleexample was misleading. This only catches a database host that is the same machine, and a separate database host is out of scope here. - The
unameline isn't covered automatically, because_system_infodoesn't pass it throughprocess_path. It needs that call too.
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
| def process_hostname(self, value) -> str: | ||
| """Remove pii from hostname.""" |
There was a problem hiding this comment.
Adding a required method to the Anonymizer protocol breaks any outside implementation with only the three existing methods: _system_info now calls process_hostname() unconditionally and raises AttributeError. Nothing in the repo is affected, but the replacement-based approach above avoids the protocol change entirely.
airflow info --anonymizeis meant to strip personally identifying information. It already redacts the home directory, OS username, and database credentials but it never touched theunameline, which leaks the machine hostname.The problem
platform.uname()returns a named tuple whosenodefield is the machine hostname, and on manageddevices that hostname routinely encodes a real name or an asset tag:
Before / after, same machine:
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 5) following the guidelines
🤖 Generated with Claude Code