Skip to content

fix: warn on prefixed secret flags and read from cmd stdin - #2331

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
Hrushikesh-ramilla:fix/secret-flag-warnings-and-cmd-stdin
Nov 14, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
Hrushikesh-ramilla:fix/secret-flag-warnings-and-cmd-stdin

Conversation

@Hrushikesh-ramilla

Copy link
Copy Markdown
Contributor

Relates to #2280

Remote.readSecret checked the unprefixed password and identity-token flag names instead of adding flagPrefix, so prefixed flags such as --from-password, --to-password, --from-identity-token, and --to-identity-token skipped the insecure CLI secret warning. It also read --password-stdin / --identity-token-stdin directly from os.Stdin.

This updates Remote.readSecret to check remo.flagPrefix + flag (keeping the -stdin hint when that stdin flag is registered on the command) and read stdin via cmd.InOrStdin(), and updates login, blob delete, and manifest delete to pass cmd.InOrStdin() instead of hardcoding os.Stdin (keeping terminal password masking via term.ReadPassword when cmd.InOrStdin() is a terminal *os.File).

Added unit tests covering unprefixed and prefixed CLI secret warnings, reading secrets from cmd.InOrStdin() (including error propagation), interactive login prompts, and blob delete / manifest delete confirmation prompts via cmd.SetIn. Verified locally with go vet ./... and go test -race -count=1 -skip containersConfigFullStack ./... (skipping the two Linux-specific certs.d colon directory tests on Windows).

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.86%. Comparing base (02ffd9d) to head (8108ad6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/login.go 57.14% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2331      +/-   ##
==========================================
+ Coverage   73.51%   74.86%   +1.34%     
==========================================
  Files         157      157              
  Lines        6582     6592      +10     
==========================================
+ Hits         4839     4935      +96     
+ Misses       1454     1368      -86     
  Partials      289      289              

☔ 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.

@TerryHowe
TerryHowe merged commit 7e2dcaf into oras-project:main Nov 14, 2026
10 checks passed
@TerryHowe TerryHowe mentioned this pull request Nov 17, 2026
4 tasks done
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.

2 participants