Skip to content

Replaced the dependency github.com/howeyc/gopass#126

Merged
peterhaochen47 merged 2 commits intocloudfoundry:mainfrom
bsoroushian:dependecy-alternative-gopass
Apr 29, 2025
Merged

Replaced the dependency github.com/howeyc/gopass#126
peterhaochen47 merged 2 commits intocloudfoundry:mainfrom
bsoroushian:dependecy-alternative-gopass

Conversation

@bsoroushian
Copy link
Contributor

@bsoroushian bsoroushian commented Apr 29, 2025

In case of tests golang.org/x/term failing because stdin is not terminal as such in the case
the input is not a terminal then a bufio.NewReader is used to read a line

The behavior of password prompt is different and mask * wont be shown.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 29, 2025

CLA Not Signed

  In case of tests golang.org/x/term failing because stdin is not terminal as such in the case
  the input is not a terminal then a bufio.NewReader is used to read a line
setConfigAuthUrl(uaaServer.URL())
session := runCommandWithStdin(strings.NewReader("user\npass\n"), "login")
Eventually(session.Out).Should(Say("username:"))
Eventually(session.Out).Should(Say(`password: \*\*\*\*`))
Copy link
Member

Choose a reason for hiding this comment

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

Is there a replacement for this test, like in commands/set_test.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the comment! However the behavior of prompt is different and although one will see the prompt password but the front of prompt will remain empty and also don't progress. So no * would be present on the password line.

session := runCommandWithStdin(strings.NewReader("potatoes\n"), "set", "-n", "my-password", "-t", "password")

Eventually(string(session.Out.Contents())).Should(ContainSubstring("password: ********"))
Eventually(string(session.Out.Contents())).Should(ContainSubstring("password: "))
Copy link
Member

@peterhaochen47 peterhaochen47 Apr 29, 2025

Choose a reason for hiding this comment

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

Is it possible / easy to maintain the old output (********) which is broadly / conventionally understood as masked creds. The new output (just empty) does not signal the same thing and might be slightly confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately there is not an option to keep the old output of *. But the prompt is enough common and looks like:

"In Go, the golang.org/x/term package provides functionalities to handle terminal input, including reading passwords securely. When using the ReadPassword function from this package, the terminal will typically mask the input, and the user might see a key symbol or asterisks instead of the characters they are typing. This is handled by the terminal itself in response to the settings applied by the ReadPassword function, rather than by the Go code directly displaying these symbols"

On my machine I see:
image

@peterhaochen47 peterhaochen47 self-requested a review April 29, 2025 21:08
@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Apr 29, 2025
@peterhaochen47 peterhaochen47 merged commit e748200 into cloudfoundry:main Apr 29, 2025
1 check failed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants