Skip to content

fix: do not show the password of a plugin download URL - #1379

Open
ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/redact-plugin-url-credentials
Open

ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/redact-plugin-url-credentials

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

Fixes #1378.

notation plugin install --url used the URL from the user in its messages as it is, so a URL with user info showed the password in the parse error, in the Downloading plugin from line, in the download error and in the bad status and size limit errors of DownloadPluginFromURL.

This uses (*url.URL).Redacted() for the messages (https://user:xxxxx@host/...). The parse error no longer contains the URL, because the error of url.Parse embeds it. That error is now failed to parse plugin download URL with error: invalid URL escape "%", so the existing unit test for it is updated. The e2e test that matches failed to download plugin from URL https://localhost.test is not affected, since that URL has no credentials.

Tests:

  • TestInstall: a parse error and a refused connection with credentials in the URL
  • TestDownloadPluginFromURL_BadStatusRedactsCredentials: a 404 from a local test server

They fail without the change.

notation plugin install --url put the URL given by the user into its
messages as it is. A URL with user info (https://user:pass@host/...)
therefore showed the password in the parse error, in the
"Downloading plugin from" line on stdout, in the download error and in
the bad status and size limit errors of DownloadPluginFromURL.

Use the redacted form of the URL for these messages and drop the URL from
the parse error, because the error of url.Parse contains it.

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.19%. Comparing base (9ba75db) to head (35749e7).

Files with missing lines Patch % Lines
cmd/notation/internal/plugin/plugin.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1379      +/-   ##
==========================================
+ Coverage   80.10%   80.19%   +0.09%     
==========================================
  Files          68       68              
  Lines        3076     3080       +4     
==========================================
+ Hits         2464     2470       +6     
+ Misses        403      402       -1     
+ Partials      209      208       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

plugin install --url shows the password of a URL with credentials in its messages

1 participant