fix: redact credentials in plugin source URLs#2154
Draft
jpshackelford wants to merge 1 commit intomainfrom
Draft
fix: redact credentials in plugin source URLs#2154jpshackelford wants to merge 1 commit intomainfrom
jpshackelford wants to merge 1 commit intomainfrom
Conversation
Addresses issue #2152 - Credentials in plugin source URLs were being exposed in logs, exception messages, and persisted state. Changes: - Add redact_url_credentials() function in git/utils.py - Update git command logging to redact credentials from URLs - Update plugin fetch error messages to use redacted URLs - Update ResolvedPluginSource.from_plugin_source() to automatically redact credentials before persistence - Add comprehensive tests for URL redaction This ensures that sensitive credentials (tokens, passwords) in authenticated git URLs (e.g., https://oauth2:TOKEN@gitlab.com/repo) are replaced with '****' in: - Application logs - Exception messages - Persisted conversation state (StoredConversation, ResolvedPluginSource) Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #2152 - Credentials in plugin source URLs were being exposed in logs, exception messages, and persisted state.
Problem
When fetching plugins from private repositories using authenticated URLs (e.g.,
https://oauth2:<token>@gitlab.com/org/private-marketplace), credentials were exposed in multiple places:StoredConversationandResolvedPluginSourceSolution
Added
redact_url_credentials()utility function and applied it to all places where URLs might be logged, included in errors, or persisted:Changes
git/utils.py: Addedredact_url_credentials()function that replaces credentials in HTTPS URLs with****https://user:pass@host,https://oauth2:token@host,https://x-token-auth:token@hostgit/utils.py: Added_redact_args_for_logging()helper and updatedrun_git_command()to redact credentials from git command logging and error messagesgit/cached_repo.py: Updated clone log message to use redacted URLplugin/fetch.py: Updated error messages and warnings to use redacted URLsplugin/types.py: UpdatedResolvedPluginSource.from_plugin_source()to automatically redact credentials from the source URL before persistenceExample
Testing
Added comprehensive unit tests in
tests/sdk/git/test_url_redaction.pycovering:ResolvedPluginSourcecredential redaction on persistenceAll existing tests pass (45 git tests, 213 plugin tests)
Security Notes
ResolvedPluginSourcefor persistenceresolved_ref(commit SHA) uniquely identifies the exact plugin version, allowing resume operations to use the cached copy@jpshackelford can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:2aecf2a-pythonRun
All tags pushed for this build
About Multi-Architecture Support
2aecf2a-python) is a multi-arch manifest supporting both amd64 and arm642aecf2a-python-amd64) are also available if needed