fork/cargo

git clone https://git.julia.blue/fork/cargo

Weihang Lodocs(cargo-yank): clarify yank behavior with leaked credentials (#16274)9a303219f

master
8.5 KiB192 linesraw
1CARGO-YANK(1)
2
3NAME
4       cargo-yank — Remove a pushed crate from the index
5
6SYNOPSIS
7       cargo yank [options] crate@version
8       cargo yank [options] --version version [crate]
9
10DESCRIPTION
11       The yank command removes a previously published crate’s version from
12       the server’s index. This command does not delete any data, and the
13       crate will still be available for download via the registry’s download
14       link.
15
16       Cargo will not use a yanked version for any new project or checkout
17       without a pre-existing lockfile, and will generate an error if there are
18       no longer any compatible versions for your crate.
19
20       This command requires you to be authenticated with either the --token
21       option or using cargo-login(1).
22
23       If the crate name is not specified, it will use the package name from
24       the current directory.
25
26   How yank works
27       For example, the foo crate published version 1.5.0 and another crate bar
28       declared a dependency on version foo = "1.5". Now foo releases a new,
29       but not semver compatible, version 2.0.0, and finds a critical issue
30       with 1.5.0. If 1.5.0 is yanked, no new project or checkout without an
31       existing lockfile will be able to use crate bar as it relies on 1.5.
32
33       In this case, the maintainers of foo should first publish a semver
34       compatible version such as 1.5.1 prior to yanking 1.5.0 so that bar and
35       all projects that depend on bar will continue to work.
36
37       As another example, consider a crate bar with published versions 1.5.0,
38       1.5.1, 1.5.2, 2.0.0 and 3.0.0. The following table identifies the
39       versions cargo could use in the absence of a lockfile for different
40       SemVer requirements, following a given release being yanked:
41
42       +------------------------+----------------------+----------+----------+
43       | Yanked Version /       | bar = "1.5.0"        | bar =    | bar =    |
44       | SemVer requirement     |                      | "=1.5.0" | "2.0.0"  |
45       +------------------------+----------------------+----------+----------+
46       | 1.5.0                  | Use either 1.5.1 or  | Return   | Use      |
47       |                        | 1.5.2                | Error    | 2.0.0    |
48       +------------------------+----------------------+----------+----------+
49       | 1.5.1                  | Use either 1.5.0 or  | Use      | Use      |
50       |                        | 1.5.2                | 1.5.0    | 2.0.0    |
51       +------------------------+----------------------+----------+----------+
52       | 2.0.0                  | Use either 1.5.0,    | Use      | Return   |
53       |                        | 1.5.1 or 1.5.2       | 1.5.0    | Error    |
54       +------------------------+----------------------+----------+----------+
55
56   When to yank
57       Crates should only be yanked in exceptional circumstances, for example,
58       an accidental publish, an unintentional SemVer breakages, or a
59       significantly broken and unusable crate. In the case of security
60       vulnerabilities, RustSec <https://rustsec.org/> is typically a less
61       disruptive mechanism to inform users and encourage them to upgrade, and
62       avoids the possibility of significant downstream disruption irrespective
63       of susceptibility to the vulnerability in question.
64
65       A common workflow is to yank a crate having already published a semver
66       compatible version, to reduce the probability of preventing dependent
67       crates from compiling.
68
69       When addressing copyright, licensing, or personal data issues with a
70       published crate, simply yanking it may not suffice. In such cases,
71       contact the maintainers of the registry you used. For crates.io, refer
72       to their policies <https://crates.io/policies> and contact them at
73       <help@crates.io>.
74
75       If credentials have been leaked, the recommended course of action is to
76       revoke them immediately. Once a crate has been published, it is
77       impossible to determine if the leaked credentials have been copied.
78       Yanking only prevents Cargo from selecting this version when resolving
79       dependencies by default. Existing lock files or direct downloads are not
80       affected, so yanking cannot stop further spreading of the leaked
81       credentials.
82
83OPTIONS
84   Yank Options
85       --vers version, --version version
86           The version to yank or un-yank.
87
88       --undo
89           Undo a yank, putting a version back into the index.
90
91       --token token
92           API token to use when authenticating. This overrides the token
93           stored in the credentials file (which is created by cargo-login(1)).
94
95           Cargo config <https://doc.rust-lang.org/cargo/reference/config.html>
96           environment variables can be used to override the tokens stored in
97           the credentials file. The token for crates.io may be specified with
98           the CARGO_REGISTRY_TOKEN environment variable. Tokens for other
99           registries may be specified with environment variables of the form
100           CARGO_REGISTRIES_NAME_TOKEN where NAME is the name of the registry
101           in all capital letters.
102
103       --index index
104           The URL of the registry index to use.
105
106       --registry registry
107           Name of the registry to use. Registry names are defined in Cargo
108           config files
109           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
110           specified, the default registry is used, which is defined by the
111           registry.default config key which defaults to crates-io.
112
113   Display Options
114       -v, --verbose
115           Use verbose output. May be specified twice for “very verbose”
116           output which includes extra output such as dependency warnings and
117           build script output. May also be specified with the term.verbose
118           config value
119           <https://doc.rust-lang.org/cargo/reference/config.html>.
120
121       -q, --quiet
122           Do not print cargo log messages. May also be specified with the
123           term.quiet config value
124           <https://doc.rust-lang.org/cargo/reference/config.html>.
125
126       --color when
127           Control when colored output is used. Valid values:
128
129           o  auto (default): Automatically detect if color support is
130              available on the terminal.
131
132           o  always: Always display colors.
133
134           o  never: Never display colors.
135
136           May also be specified with the term.color config value
137           <https://doc.rust-lang.org/cargo/reference/config.html>.
138
139   Common Options
140       +toolchain
141           If Cargo has been installed with rustup, and the first argument to
142           cargo begins with +, it will be interpreted as a rustup toolchain
143           name (such as +stable or +nightly). See the rustup documentation
144           <https://rust-lang.github.io/rustup/overrides.html> for more
145           information about how toolchain overrides work.
146
147       --config KEY=VALUE or PATH
148           Overrides a Cargo configuration value. The argument should be in
149           TOML syntax of KEY=VALUE, or provided as a path to an extra
150           configuration file. This flag may be specified multiple times. See
151           the command-line overrides section
152           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
153           for more information.
154
155       -C PATH
156           Changes the current working directory before executing any specified
157           operations. This affects things like where cargo looks by default
158           for the project manifest (Cargo.toml), as well as the directories
159           searched for discovering .cargo/config.toml, for example. This
160           option must appear before the command name, for example cargo -C
161           path/to/my-project build.
162
163           This option is only available on the nightly channel
164           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
165           requires the -Z unstable-options flag to enable (see #10098
166           <https://github.com/rust-lang/cargo/issues/10098>).
167
168       -h, --help
169           Prints help information.
170
171       -Z flag
172           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
173           details.
174
175ENVIRONMENT
176       See the reference
177       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
178       for details on environment variables that Cargo reads.
179
180EXIT STATUS
181       o  0: Cargo succeeded.
182
183       o  101: Cargo failed to complete.
184
185EXAMPLES
186       1. Yank a crate from the index:
187
188              cargo yank foo@1.0.7
189
190SEE ALSO
191       cargo(1), cargo-login(1), cargo-publish(1)
192