cloudfoundry / cloudfoundry/cli

cf login doesn't work properly when password specified with mutliple special characters.

Open
#3,399 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.9k
Forks
990
Avg merge
1d 7h
Merged PRs (30d)
8

Description

Please fill out the issue checklist below and provide ALL the requested information.

  • [ x] I reviewed open and closed github issues that may be related to my problem.
  • [ x] I tried updating to the latest version of the CF CLI to see if it fixed my problem.
  • I attempted to run the command with CF_TRACE=1 to help debug the issue.
  • I am reporting a bug that others will be able to reproduce.

Describe the bug and the command you saw an issue with
Command CF login
I have an application that calls cf cli internally.
I run cf login -u username -p password
When the password has special characters , cf login fails.
For eg.,
for demo purpose let's say imaginary password "-ig@ZlHDVZl_"

cf login -o myOrg -s mySpace -u devUser1 -p "-ig@ZlHDVZl_"

What happened
It throws following error

Incorrect Usage: expected argument for flag `-p', but got option `-ig@ZlHDVZl_'

NAME:
   login - Log user in

This error seems to differ for different passwords. Escaping the characters didn't work as well.
But the same password works via interactive cf login.

Expected behavior
cf login should work via -u and -p options when password has special characters

Exact Steps To Reproduce
Steps to reproduce the behavior; include the exact CLI commands and verbose output:

  1. Run cf login -u username -p password with plenty of special characters in password especially "?" and "$_"
  2. See error
  3. Run interactive cf login and enter username and password on prompt, don't see error.

Provide more context

  • platform and shell details ( e.g. Mac OS 14.2 Built in terminal)
  • version of the CLI you are running : 8.9.0+c23186c.2024-12-02
  • version of the CC API Release you are on 3.186.0

What could be the reason for this behaviour? Do you have any recommendations on special characters in passwords when used directly in shell command?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the cf login command entry point and reproduce the reported command with the example password, comparing it with interactive login. Check how the -p argument is parsed when it begins with a hyphen or contains special characters; done means non-interactive login accepts the documented password cases without the shown flag error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.