fix(toml)!: Disallow source-less dependencies
### What does this PR try to resolve?
This is part of #13629 addressing “dependency without path, version, git, workspace specified”.
This turns deps like
```toml
foo = { optional = true }
```
from `version="*"` deps with a warning into errors. This breaking change was deemed acceptable because this behavior has been considered a bug from the beginning.
We have gotten little to no feedback about people wanting this behavior.
This improves our forwards-compatibility story as we can add new dependency sources and they won't be considered a wildcard registry dependency on older cargo.
### How should we test and review this PR?
I removed the `cargo_add` test because it is redundant.
We no longer get the “unused key” warnings because those warnings get deferred to after this error gets reported.
### Additional information
fix(msrv): Put MSRV-aware resolver behind a config
### What does this PR try to resolve?
This is a part of #13540 which is a party of #9930.
The config is `resolver.something-like-precedence` with values:
- `something-like-maximum` (default)
- `something-like-rust-version`
This is punting on the actual config schema so we can implement
`package.resolver` and `edition = "2024"` support as we want the
MSRV-aware resolver available without `cargo_features`.
### How should we test and review this PR?
One of the included test cases shows a bug with `cargo install`. Resolving that will be tracked in #9930
### Additional information
This is part of #13629
This turns deps like
```toml
foo = { optional = true }
```
from `version="*"` deps with a warning into errors.
This breaking change was deemed acceptable because this behavior has
been considered a bug from the beginning.
We have gotten little to no feedback about people wanting this behavior.
This improves our forwards-compatibility story as we can add new
dependency sources and they won't be considered a wildcard registry
dependency on older cargo.
fix(msrv): Error, rather than panic, on rust-version 'x'
### What does this PR try to resolve?
Fixes#13768
### How should we test and review this PR?
### Additional information
fix(credential): trim newlines in tokens from stdin
### What does this PR try to resolve?
`cargo login` when using a credential provider other than `cargo:token` does not automatically trim whitespace from tokens.
This can lead to extra whitespace being included in the pasted token value (usually a trailing newline) that makes the token invalid.
### How should we test and review this PR?
First commit adds a test showing the problematic behavior. Second commit fixes it.
This is a part of #13540 which is a party of #9930.
The config is `resolver.something-like-precedence` with values:
- `something-like-maximum` (default)
- `something-like-rust-version`
This is punting on the actual config schema so we can implement
`package.resolver` and `edition = "2024"` support as we want the
MSRV-aware resolver available without `cargo_features`.
test(msrv): Re-organize MSRV tests
### What does this PR try to resolve?
- Merge test cases
- Clarify names
- Focus on `cargo tree`, rather than `cargo check` (faster and more to
what we are testing)
### How should we test and review this PR?
### Additional information
feat(install): Including Locking message
### What does this PR try to resolve?
This extends #13561 to include `cargo install`, like #13759 did for `cargo update`.
As we switch to MSRV-aware resolver, this will help users work out why
MSRV-aware resolving isn't helping them.
This will also make it more obvious if we breaking things when
developing the MSRV-aware resolver.
### How should we test and review this PR?
### Additional information
This still leaves `cargo publish` and a couple other misc situations that I'm intentionally avoiding because
- They hit some weird cases that can confuse the user (e.g. causing `cargo install --locked` to show that 1 package is being added) and we can't distinguish these cases too well from where this is happening
- The value is lower
fix(toml): Error on `[project]` in Edition 2024
### What does this PR try to resolve?
`[package]` was added in 86b2a2a432 in the pre-1.0 days but `[project]` was never removed nor did we warn on its use until recently in #11135. So likely we can't remove it completely but we can remove it in Edition 2024+.
This includes `cargo fix` support which is hard coded directly into the `cargo fix` command.
This is part of
- #13629
- rust-lang/rust#123754
While we haven't signed off on everything in #13629, I figured this (and a couple other changes) are not very controversial.
### How should we test and review this PR?
Per commit. Tests are added to show the behavior changes, including in `cargo fix`.
### Additional information
As we switch to MSRV-aware resolver, this will help users work out why
MSRV-aware resolving isn't helping them.
This will also make it more obvious if we breaking things when
developing the MSRV-aware resolver.
feat(update): Include a Locking message
### What does this PR try to resolve?
This extends #13561 to `cargo update`. I previously left it out because the locking message was redundant. However the `Locking` message has been extended in #13754 to include the resolving policy which can be a useful point of interest (e.g. "why does `cargo update` do nothing? Oh, `-Zminimal-versions` is enabled").
I still left out the message for `--precise` because the user is overriding all of that.
I'd still like to extend all of this to `cargo install` (and maybe all resolves) but that is taking more investigation.
### How should we test and review this PR?
### Additional information
chore(deps): update rust crate gix to 0.62.0 [security]
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Type | Update | Change |
|---|---|---|---|
| [gix](https://togithub.com/Byron/gitoxide) | workspace.dependencies | minor | `0.61.0` -> `0.62.0` |
### GitHub Vulnerability Alerts
#### [GHSA-98p4-xjmm-8mfh](https://togithub.com/Byron/gitoxide/security/advisories/GHSA-98p4-xjmm-8mfh)
### Summary
`gix-transport` does not check the username part of a URL for text that the external `ssh` program would interpret as an option. A specially crafted clone URL can smuggle options to SSH. The possibilities are syntactically limited, but if a malicious clone URL is used by an application whose current working directory contains a malicious file, arbitrary code execution occurs.
### Details
This is related to the patched vulnerability https://github.com/advisories/GHSA-rrjw-j4m2-mf34, but appears less severe due to a greater attack complexity. Since [https://github.com/Byron/gitoxide/pull/1032](https://togithub.com/Byron/gitoxide/pull/1032), `gix-transport` checks the host and path portions of a URL for text that has a `-` in a position that will cause `ssh` to interpret part of all of the URL as an option argument. But it does not check the non-mandatory username portion of the URL.
As in Git, when an address is a URL of the form `ssh://username@hostname/path`, or when it takes the special form `username@hostname:dirs/repo`, this is treated as an SSH URL. `gix-transport` will replace some characters in `username` with their `%`-based URL encodings, but otherwise passes `username@hostname` as an argument to the external `ssh` command. This happens even if `username` begins with a hyphen. In that case, `ssh` treats that argument as an option argument, and attempts to interpret and honor it as a sequence of one or more options possibly followed by an operand for the last option.
This is harder to exploit than GHSA-rrjw-j4m2-mf34, because the possibilities are constrained by:
- The difficulty of forming an option argument `ssh` accepts, given that characters such as `=`, `/`, and `\`, are URL-encoded, `:` is removed, and the argument passed to `ssh` contains the ``@`` sign and subsequent host identifier, which in an effective attack must be parseable as a suffix of the operand passed to the last option.
The inability to include a literal `=` prevents the use of `-oNAME=VALUE` (e.g., `-oProxyCommand=payload`). The inability to include a literal `/` or `\` prevents smuggling in a path operand residing outside the current working directory, incuding on Windows. (Although a `~` character may be smuggled in, `ssh` does not perform its own tilde expansion, so it does not form an absolute path.)
- The difficulty, or perhaps impossibility, of completing a connection (other than when arbitrary code execution has been achieved). This complicates or altogether prevents the use of options such as `-A` and `-X` together with a connection to a real but malicious server. The reason a connection cannot generally be completed when exploiting this vulnerability is that, because the argument `gix-transport` intends as a URL is treated as an option argument, `ssh` treats the subsequent non-option argument `git-upload-pack` as the host instead of the command, but it is not a valid host name.
Although `ssh` supports aliases for hosts, even if `git-upload-pack` could be made an alias, that is made difficult by the URL-encoding transformation.
However, an attacker who is able to cause a specially named `ssh` configuration file to be placed in the current working directory can smuggle in an `-F` option referencing the file, and this allows arbitrary command execution.
This scenario is especially plausible because programs that operate on git repositories are often run in untrusted git repositories, sometimes even to operate on another repository. Situations where this is likely, such that an attacker could predict or arrange it, may for some applications include a malicious repository with a malicious submodule configuration.
Other avenues of exploitation exist, but appear to be less severe. For example, the `-E` option can be smuggled to create or append to a file in the current directory (or its target, if it is a symlink). There may also be other significant ways to exploit this that have not yet been discovered, or that would arise with new options in future versions of `ssh`.
### PoC
To reproduce the known case that facilitates arbitrary code execution, first create a file in the current directory named `configfile@example.com`, of the form
```text
ProxyCommand payload
```
where `payload` is a command with an observable side effect. On Unix-like systems, this could be `date | tee vulnerable` or an `xdg-open`, `open`, or other command command to launch a graphical application. On Windows, this could be the name of a graphical application already in the search path, such as `calc.exe`.
(Although the syntax permitted in the value of `ProxyCommand` may vary by platform, this is not limited to running commands in the current directory. That limitation only applies to paths directly smuggled in the username, not to the contents of a separate malicious configuration file. Arbitrary other settings may be specified in `configfile@example.com` as well.)
Then run:
```sh
gix clone 'ssh://-Fconfigfile@example.com/abc'
```
Or:
```sh
gix clone -- '-Fconfigfile@example.com:abc/def'
```
(The `--` is required to ensure that `gix` is really passing the argument as a URL for use in `gix-transport`, rather than interpreting it as an option itself, which would not necessarily be a vulnerability.)
In either case, the payload specified in `configfile@example.com` runs, and its side effect can be observed.
Other cases may likewise be produced, in either of the above two forms of SSH addresses. For example, to create or append to the file `errors@example.com`, or to create or append to its target if it is a symlink:
```sh
gix clone 'ssh://-Eerrors@example.com/abc'
```
```sh
gix clone -- '-Eerrors@example.com:abc/def'
```
### Impact
As in https://github.com/advisories/GHSA-rrjw-j4m2-mf34, this would typically require user interaction to trigger an attempt to clone or otherwise connect using the malicious URL. Furthermore, known means of exploiting this vulnerability to execute arbitrary commands require further preparatory steps to establish a specially named file in the current directory. The impact is therefore expected to be lesser, though it is difficult to predict it with certainty because it is not known exactly what scenarios will arise when using the `gix-transport` library.
Users who use applications that make use of `gix-transport` are potentially vulnerable, especially:
- On repositories with submodules that are automatically added, depending how the application manages submodules.
- When operating on other repositories from inside an untrusted repository.
- When reviewing contributions from untrusted developers by checking out a branch from an untrusted fork and performing clones from that location.
---
### Release Notes
<details>
<summary>Byron/gitoxide (gix)</summary>
### [`v0.62.0`](https://togithub.com/Byron/gitoxide/releases/tag/gix-v0.62.0): gix v0.62
[Compare Source](https://togithub.com/Byron/gitoxide/compare/gix-v0.61.1...gix-v0.62.0)
Please note that this release contains a security fix originally implemented in `gix-transport` via [this PR](https://togithub.com/Byron/gitoxide/pull/1342) which prevents `ssh` options to be smuggled into the `ssh` command-line invocation with a username provided to a clone or fetch URL.
Details can be found [in the advisory](https://togithub.com/Byron/gitoxide/security/advisories/GHSA-98p4-xjmm-8mfh).
##### Bug Fixes
- `into_index_worktree_iter()` now takes an iterator, instead of a Vec.
This makes the API more consistent, and one can pass `None`
as well.
- show submodules in status independently of their active state.
Even inactive submodules are shown in the status by `git status`,
so `gix` should do the same.
First observed in [https://github.com/helix-editor/helix/pull/5645#issuecomment-2016798212](https://togithub.com/helix-editor/helix/pull/5645#issuecomment-2016798212)
- forward `curl` rustls feature from `gix-transport` to avoid `curl` in `gix`.
This removes the `curl` dependency just for configuring it, and removes
a hazard which became evident with reqwest.
##### Bug Fixes (BREAKING)
- Make `topo` more similar to `Ancestors`, but also rename `Ancestors` to `Simple`
##### Commit Statistics
- 16 commits contributed to the release over the course of 20 calendar days.
- 22 days passed between releases.
- 4 commits were understood as [conventional](https://www.conventionalcommits.org/).
- 1 unique issue was worked on: [https://github.com/Byron/gitoxide/issues/1328](https://togithub.com/Byron/gitoxide/issues/1328)
##### Thanks Clippy
[Clippy](https://togithub.com/rust-lang/rust-clippy) helped 1 time to make code idiomatic.
##### Commit Details
- **[https://github.com/Byron/gitoxide/issues/1328](https://togithub.com/Byron/gitoxide/issues/1328)**
- Forward `curl` rustls feature from `gix-transport` to avoid `curl` in `gix`. (98cfbec512)
- **Uncategorized**
- Prepare changelogs prior to release (57552717f4)
- Merge pull request [https://github.com/Byron/gitoxide/pull/1341](https://togithub.com/Byron/gitoxide/pull/1341) from szepeviktor/typos (55f379bc47)
- Fix typos (f72ecce45b)
- Merge branch 'add-topo-walk' (b590a9d2b6)
- Adapt to changes in `gix-traverse` (1cfeb11f1f)
- Make `topo` more similar to `Ancestors`, but also rename `Ancestors` to `Simple` (2a9c178326)
- Adapt to changes in `gix-traverse` (6154bf3a34)
- Thanks clippy (7f6bee5452)
- Merge branch 'status' (45edd2ea66)
- `into_index_worktree_iter()` now takes an iterator, instead of a Vec. (18b2921aaa)
- Show submodules in status independently of their active state. (719ced8a79)
- Make it easier to discover `is_path_excluded()` in documentation (c13632959e)
- Adapt to changes in `gix-index` (1e1fce11a9)
- Merge branch 'patch-1' (9e9c653a83)
- Remove dep reqwest from gix (e3eedd8b53)
### [`v0.61.1`](https://togithub.com/Byron/gitoxide/releases/tag/gix-v0.61.1): gix v0.61.1
[Compare Source](https://togithub.com/Byron/gitoxide/compare/gix-v0.61.0...gix-v0.61.1)
This release also updates `reqwest` to v0.12, bringing hyper 1.0 and a more recent `rustls` version.
##### Bug Fixes
- missing closing backtick in gix lib documentation
##### Commit Statistics
- 7 commits contributed to the release over the course of 2 calendar days.
- 3 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
##### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
- **Uncategorized**
- Prepare changelogs prior to release ([`7018a92`](https://togithub.com/Byron/gitoxide/commit/7018a92))
- Merge branch 'patch-1' ([`8fde62b`](https://togithub.com/Byron/gitoxide/commit/8fde62b))
- Turn`curl` into a workspace package ([`adee500`](https://togithub.com/Byron/gitoxide/commit/adee500))
- Make reqwest a workspace package ([`369cf1b`](https://togithub.com/Byron/gitoxide/commit/369cf1b))
- Merge pull request [#​1325](https://togithub.com/Byron/gitoxide/issues/1325) from kdelorey/fix/simple-docs-formatting ([`3b34699`](https://togithub.com/Byron/gitoxide/commit/3b34699))
- Fixed opening of backtick in documentation. ([`f1bc4cd`](https://togithub.com/Byron/gitoxide/commit/f1bc4cd))
- Missing closing backtick in gix lib documentation ([`e1fec3c`](https://togithub.com/Byron/gitoxide/commit/e1fec3c))
</details>
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/rust-lang/cargo).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
feat(resolve): Tell the user the style of resovle done
### What does this PR try to resolve?
This is to help with https://github.com/rust-lang/cargo/issues/9930
Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest compatible version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest compatible versions
```
Benefits
- The package count is of "added" packages and this makes that more
logically clear
- This gives users transparency into what is happening, especially with
- what rust-version is use
- the transition to this feature in the new edition
- whether the planned config was applied or not (as I don't want it to
require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
`cargo install` (that will be explored in a follow up PR)
This does come at the cost of more verbose output but hopefully not too
verbose. This is why I left off other factors, like avoid-dev-deps.
### How should we test and review this PR?
### Additional information
docs: update `checkout` GitHub action version
### What does this PR try to resolve?
This PR updates the GitHub CI examples in The Cargo Book to use the latest version of the `actions/checkout` GitHub action, since using `actions/checkout@v3` (currently used in the examples) produces warnings about deprecated Node.js 16 (see also [GitHub Actions: Transitioning from Node 16 to Node 20](https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/) blog post).
Also, v4 is already used in the "Verifying `rust-version`" example:
a9f86addbc/src/doc/src/guide/continuous-integration.md?plain=1#L174
Recategorize cargo test's `--doc` flag under "Target Selection"
### What does this PR try to resolve?
In `cargo help test`, the `--doc` flag is listed under a section called "Target Selection" next to `--lib`, `--bin`, `--bins`, `--example`, `--examples`, `--test`, `--tests`, `--bench`, `--benches`, and `--all-targets`.
But in `cargo test --help`, it was instead listed in an "Options" section next to `--no-run`, `--message-format`, `--color`, etc, which seems less appropriate than "Target Selection".
### How should we test and review this PR?
- `cargo build --release`
- `cargo test --release --test testsuite -- cargo_test::help::case`
- `target/release/cargo test --help`
- `target/release/cargo help test` (unchanged)