Skip to content

fix(sqlalchemy-bigquery): hide credentials_base64 in repr(engine) - #19198

Open
sindhuvy wants to merge 1 commit into
mainfrom
b581919830-credentials-base64
Open

sindhuvy wants to merge 1 commit into
mainfrom
b581919830-credentials-base64

Conversation

@sindhuvy

@sindhuvy sindhuvy commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

SQLAlchemy hides only the password when it prints an engine's URL, so repr(engine) showed the service account key passed in credentials_base64. The key is now hidden wherever the password is.

The README no longer suggests a website for encoding the key file.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes b/581919830 🦕

@sindhuvy
sindhuvy requested review from a team as code owners November 24, 2026 19:29
@sindhuvy
sindhuvy requested review from sycai and removed request for a team November 24, 2026 19:29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces security enhancements to prevent sensitive service account private keys in the credentials_base64 parameter from being exposed in SQLAlchemy engine URL representations and logs. It implements a custom _CredentialsHidingURL class to mask this parameter during string rendering and updates the BigQueryDialect to wrap engine URLs when the parameter is present. Documentation is also updated with warnings against exposing private keys in connection strings and using online base64 encoders. The review feedback correctly identifies a performance bottleneck in the custom __hash__ implementation of _CredentialsHidingURL, noting that the override is redundant and can be safely removed to avoid unnecessary object reconstruction.

@sindhuvy
sindhuvy marked this pull request as draft November 24, 2026 19:55
SQLAlchemy hides only the password when it prints an engine's URL, so
repr(engine) showed the service account key passed in
credentials_base64. The key is now hidden wherever the password is.

The README no longer suggests a website for encoding the key file.

Fixes b/581919830
@sindhuvy
sindhuvy force-pushed the b581919830-credentials-base64 branch from 70200ec to 9f6bf91 Compare November 24, 2026 20:11
@sindhuvy
sindhuvy marked this pull request as ready for review November 24, 2026 20:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant