rust-lang / rust-lang/cargo

Credential provider protocol fails with strings containing escaped characters

Open
#13,615 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-credential-provider C-bug S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

The structures defined in the credential provider protocol use borrowed string (&'a str) types that can only be deserialized if they don't contain any characters that need to be escaped by JSON. If escaping is required then the deserialization fails with:

invalid type: string "test\ning", expected a borrowed string

This can occur if, for example, the user attempts to use a " in a registry auth token. This is not a bug in the JSON protocol itself.

Steps
  1. Set up a credential provider
  2. Run cargo login
  3. Use a token that contains a "
Possible Solution(s)
  1. Switch to using Cow<'a, str> in the credential struct definitions.
  2. Switch to using String in the struct definitions.

Any solution seems to require a breaking change to the credential struct definitions.

Notes

No response

Version
cargo 1.78.0-nightly (fc1d58fd0 2024-02-09)
release: 1.78.0-nightly
commit-hash: fc1d58fd0531a57a6b942a14cdcdbcb82ece16f3
commit-date: 2024-02-09
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.26085 (Windows 11 Enterprise) [64-bit]

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 by locating the credential provider protocol definitions and the deserialization path exercised by cargo login. Reproduce the failure with a token containing an escaped character, then determine whether the protocol types should use Cow<'a, str> or String and add coverage for escaped credentials.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.