Skip to content

Commit 0137bca

Browse files
committed
Make allow insecure host a global option
Not verifying the certificates of certain hosts should be supported for all kinds of HTTPS connections, so we're making it a global option, just like native tls. This fixes the remaining places using a client but were not configuring allow insecure host. Fixes #6983 (i think) Closes #6983
1 parent 76bcb89 commit 0137bca

29 files changed

+408
-410
lines changed

crates/uv-cli/src/lib.rs

+20-117
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,26 @@ pub struct GlobalArgs {
205205
#[arg(global = true, long, overrides_with("offline"), hide = true)]
206206
pub no_offline: bool,
207207

208+
/// Allow insecure connections to a host.
209+
///
210+
/// Can be provided multiple times.
211+
///
212+
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
213+
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
214+
///
215+
/// WARNING: Hosts included in this list will not be verified against the system's certificate
216+
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
217+
/// bypasses SSL verification and could expose you to MITM attacks.
218+
#[arg(
219+
long,
220+
alias = "trusted-host",
221+
env = EnvVars::UV_INSECURE_HOST,
222+
value_delimiter = ' ',
223+
value_parser = parse_insecure_host,
224+
help_heading = "Index options"
225+
)]
226+
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
227+
208228
/// Whether to enable experimental, preview features.
209229
///
210230
/// Preview features may change without warning.
@@ -1768,25 +1788,6 @@ pub struct PipUninstallArgs {
17681788
#[arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER)]
17691789
pub keyring_provider: Option<KeyringProviderType>,
17701790

1771-
/// Allow insecure connections to a host.
1772-
///
1773-
/// Can be provided multiple times.
1774-
///
1775-
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
1776-
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
1777-
///
1778-
/// WARNING: Hosts included in this list will not be verified against the system's certificate
1779-
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
1780-
/// bypasses SSL verification and could expose you to MITM attacks.
1781-
#[arg(
1782-
long,
1783-
alias = "trusted-host",
1784-
env = EnvVars::UV_INSECURE_HOST,
1785-
value_delimiter = ' ',
1786-
value_parser = parse_insecure_host,
1787-
)]
1788-
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
1789-
17901791
/// Use the system Python to uninstall packages.
17911792
///
17921793
/// By default, uv uninstalls from the virtual environment in the current working directory or
@@ -2360,25 +2361,6 @@ pub struct VenvArgs {
23602361
#[arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER)]
23612362
pub keyring_provider: Option<KeyringProviderType>,
23622363

2363-
/// Allow insecure connections to a host.
2364-
///
2365-
/// Can be provided multiple times.
2366-
///
2367-
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
2368-
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
2369-
///
2370-
/// WARNING: Hosts included in this list will not be verified against the system's certificate
2371-
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
2372-
/// bypasses SSL verification and could expose you to MITM attacks.
2373-
#[arg(
2374-
long,
2375-
alias = "trusted-host",
2376-
env = EnvVars::UV_INSECURE_HOST,
2377-
value_delimiter = ' ',
2378-
value_parser = parse_insecure_host,
2379-
)]
2380-
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
2381-
23822364
/// Limit candidate packages to those that were uploaded prior to the given date.
23832365
///
23842366
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
@@ -4068,26 +4050,6 @@ pub struct InstallerArgs {
40684050
)]
40694051
pub keyring_provider: Option<KeyringProviderType>,
40704052

4071-
/// Allow insecure connections to a host.
4072-
///
4073-
/// Can be provided multiple times.
4074-
///
4075-
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
4076-
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
4077-
///
4078-
/// WARNING: Hosts included in this list will not be verified against the system's certificate
4079-
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
4080-
/// bypasses SSL verification and could expose you to MITM attacks.
4081-
#[arg(
4082-
long,
4083-
alias = "trusted-host",
4084-
env = EnvVars::UV_INSECURE_HOST,
4085-
value_delimiter = ' ',
4086-
value_parser = parse_insecure_host,
4087-
help_heading = "Index options"
4088-
)]
4089-
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
4090-
40914053
/// Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs.
40924054
#[arg(
40934055
long,
@@ -4230,26 +4192,6 @@ pub struct ResolverArgs {
42304192
)]
42314193
pub keyring_provider: Option<KeyringProviderType>,
42324194

4233-
/// Allow insecure connections to a host.
4234-
///
4235-
/// Can be provided multiple times.
4236-
///
4237-
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
4238-
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
4239-
///
4240-
/// WARNING: Hosts included in this list will not be verified against the system's certificate
4241-
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
4242-
/// bypasses SSL verification and could expose you to MITM attacks.
4243-
#[arg(
4244-
long,
4245-
alias = "trusted-host",
4246-
env = EnvVars::UV_INSECURE_HOST,
4247-
value_delimiter = ' ',
4248-
value_parser = parse_insecure_host,
4249-
help_heading = "Index options"
4250-
)]
4251-
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
4252-
42534195
/// The strategy to use when selecting between the different compatible versions for a given
42544196
/// package requirement.
42554197
///
@@ -4422,26 +4364,6 @@ pub struct ResolverInstallerArgs {
44224364
)]
44234365
pub keyring_provider: Option<KeyringProviderType>,
44244366

4425-
/// Allow insecure connections to a host.
4426-
///
4427-
/// Can be provided multiple times.
4428-
///
4429-
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
4430-
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
4431-
///
4432-
/// WARNING: Hosts included in this list will not be verified against the system's certificate
4433-
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
4434-
/// bypasses SSL verification and could expose you to MITM attacks.
4435-
#[arg(
4436-
long,
4437-
alias = "trusted-host",
4438-
env = EnvVars::UV_INSECURE_HOST,
4439-
value_delimiter = ' ',
4440-
value_parser = parse_insecure_host,
4441-
help_heading = "Index options"
4442-
)]
4443-
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
4444-
44454367
/// The strategy to use when selecting between the different compatible versions for a given
44464368
/// package requirement.
44474369
///
@@ -4645,25 +4567,6 @@ pub struct PublishArgs {
46454567
/// Defaults to `disabled`.
46464568
#[arg(long, value_enum, env = EnvVars::UV_KEYRING_PROVIDER)]
46474569
pub keyring_provider: Option<KeyringProviderType>,
4648-
4649-
/// Allow insecure connections to a host.
4650-
///
4651-
/// Can be provided multiple times.
4652-
///
4653-
/// Expects to receive either a hostname (e.g., `localhost`), a host-port pair (e.g.,
4654-
/// `localhost:8080`), or a URL (e.g., `https://localhost`).
4655-
///
4656-
/// WARNING: Hosts included in this list will not be verified against the system's certificate
4657-
/// store. Only use `--allow-insecure-host` in a secure network with verified sources, as it
4658-
/// bypasses SSL verification and could expose you to MITM attacks.
4659-
#[arg(
4660-
long,
4661-
alias = "trusted-host",
4662-
env = EnvVars::UV_INSECURE_HOST,
4663-
value_delimiter = ' ',
4664-
value_parser = parse_insecure_host,
4665-
)]
4666-
pub allow_insecure_host: Option<Vec<Maybe<TrustedHost>>>,
46674570
}
46684571

46694572
/// See [PEP 517](https://peps.python.org/pep-0517/) and

crates/uv-cli/src/options.rs

-35
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ impl From<ResolverArgs> for PipOptions {
4040
upgrade_package,
4141
index_strategy,
4242
keyring_provider,
43-
allow_insecure_host,
4443
resolution,
4544
prerelease,
4645
pre,
@@ -58,12 +57,6 @@ impl From<ResolverArgs> for PipOptions {
5857
upgrade_package: Some(upgrade_package),
5958
index_strategy,
6059
keyring_provider,
61-
allow_insecure_host: allow_insecure_host.map(|allow_insecure_host| {
62-
allow_insecure_host
63-
.into_iter()
64-
.filter_map(Maybe::into_option)
65-
.collect()
66-
}),
6760
resolution,
6861
prerelease: if pre {
6962
Some(PrereleaseMode::Allow)
@@ -91,7 +84,6 @@ impl From<InstallerArgs> for PipOptions {
9184
reinstall_package,
9285
index_strategy,
9386
keyring_provider,
94-
allow_insecure_host,
9587
config_setting,
9688
no_build_isolation,
9789
build_isolation,
@@ -107,12 +99,6 @@ impl From<InstallerArgs> for PipOptions {
10799
reinstall_package: Some(reinstall_package),
108100
index_strategy,
109101
keyring_provider,
110-
allow_insecure_host: allow_insecure_host.map(|allow_insecure_host| {
111-
allow_insecure_host
112-
.into_iter()
113-
.filter_map(Maybe::into_option)
114-
.collect()
115-
}),
116102
config_settings: config_setting
117103
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
118104
no_build_isolation: flag(no_build_isolation, build_isolation),
@@ -137,7 +123,6 @@ impl From<ResolverInstallerArgs> for PipOptions {
137123
reinstall_package,
138124
index_strategy,
139125
keyring_provider,
140-
allow_insecure_host,
141126
resolution,
142127
prerelease,
143128
pre,
@@ -159,12 +144,6 @@ impl From<ResolverInstallerArgs> for PipOptions {
159144
reinstall_package: Some(reinstall_package),
160145
index_strategy,
161146
keyring_provider,
162-
allow_insecure_host: allow_insecure_host.map(|allow_insecure_host| {
163-
allow_insecure_host
164-
.into_iter()
165-
.filter_map(Maybe::into_option)
166-
.collect()
167-
}),
168147
resolution,
169148
prerelease: if pre {
170149
Some(PrereleaseMode::Allow)
@@ -235,7 +214,6 @@ pub fn resolver_options(
235214
upgrade_package,
236215
index_strategy,
237216
keyring_provider,
238-
allow_insecure_host,
239217
resolution,
240218
prerelease,
241219
pre,
@@ -289,12 +267,6 @@ pub fn resolver_options(
289267
upgrade_package: Some(upgrade_package),
290268
index_strategy,
291269
keyring_provider,
292-
allow_insecure_host: allow_insecure_host.map(|allow_insecure_host| {
293-
allow_insecure_host
294-
.into_iter()
295-
.filter_map(Maybe::into_option)
296-
.collect()
297-
}),
298270
resolution,
299271
prerelease: if pre {
300272
Some(PrereleaseMode::Allow)
@@ -331,7 +303,6 @@ pub fn resolver_installer_options(
331303
reinstall_package,
332304
index_strategy,
333305
keyring_provider,
334-
allow_insecure_host,
335306
resolution,
336307
prerelease,
337308
pre,
@@ -397,12 +368,6 @@ pub fn resolver_installer_options(
397368
},
398369
index_strategy,
399370
keyring_provider,
400-
allow_insecure_host: allow_insecure_host.map(|allow_insecure_host| {
401-
allow_insecure_host
402-
.into_iter()
403-
.filter_map(Maybe::into_option)
404-
.collect()
405-
}),
406371
resolution,
407372
prerelease: if pre {
408373
Some(PrereleaseMode::Allow)

0 commit comments

Comments
 (0)