Skip to content

Commit b8fef0d

Browse files
authored
fix(audit): honor configured CA stores (#36728)
Fixes #36726
1 parent 4bfbfeb commit b8fef0d

8 files changed

Lines changed: 59 additions & 3 deletions

File tree

cli/tools/pm/audit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::colors;
2121
use crate::factory::CliFactory;
2222
use crate::http_util;
2323
use crate::http_util::HttpClient;
24-
use crate::http_util::HttpClientProvider;
2524
use crate::util::console::escape_terminal_control_chars;
2625

2726
struct FixableAction {
@@ -45,7 +44,7 @@ pub async fn audit(
4544
let snapshot = npm_resolver.resolution().snapshot();
4645

4746
let npm_url = &factory.npmrc()?.default_config.registry_url;
48-
let http_provider = HttpClientProvider::new(None, None);
47+
let http_provider = factory.http_client_provider();
4948
let http_client = http_provider
5049
.get_or_create()
5150
.context("Failed to create HTTP client")?;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDIzCCAgugAwIBAgIJAMKPPW4tsOymMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV
3+
BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODIy
4+
WhgPMjExODA5MjcxNjI4MjJaMCcxCzAJBgNVBAYTAlVTMRgwFgYDVQQDDA9FeGFt
5+
cGxlLVJvb3QtQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMH/IO
6+
2qtHfyBKwANNPB4K0q5JVSg8XxZdRpTTlz0CwU0oRO3uHrI52raCCfVeiQutyZop
7+
eFZTDWeXGudGAFA2B5m3orWt0s+touPi8MzjsG2TQ+WSI66QgbXTNDitDDBtTVcV
8+
5G3Ic+3SppQAYiHSekLISnYWgXLl+k5CnEfTowg6cjqjVr0KjL03cTN3H7b+6+0S
9+
ws4rYbW1j4ExR7K6BFNH6572yq5qR20E6GqlY+EcOZpw4CbCk9lS8/CWuXze/vMs
10+
OfDcc6K+B625d27wyEGZHedBomT2vAD7sBjvO8hn/DP1Qb46a8uCHR6NSfnJ7bXO
11+
G1igaIbgY1zXirNdAgMBAAGjUDBOMB0GA1UdDgQWBBTzut+pwwDfqmMYcI9KNWRD
12+
hxcIpTAfBgNVHSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAMBgNVHRMEBTAD
13+
AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQB9AqSbZ+hEglAgSHxAMCqRFdhVu7MvaQM0
14+
P090mhGlOCt3yB7kdGfsIrUW6nQcTz7PPQFRaJMrFHPvFvPootkBUpTYR4hTkdce
15+
H6RCRu2Jxl4Y9bY/uezd9YhGCYfUtfjA6/TH9FcuZfttmOOlxOt01XfNvVMIR6RM
16+
z/AYhd+DeOXjr35F/VHeVpnk+55L0PYJsm1CdEbOs5Hy1ecR7ACuDkXnbM4fpz9I
17+
kyIWJwk2zJReKcJMgi1aIinDM9ao/dca1G99PHOw8dnr4oyoTiv8ao6PWiSRHHMi
18+
MNf4EgWfK+tZMnuqfpfO9740KzfcVoMNo4QJD4yn5YxroUOO/Azi
19+
-----END CERTIFICATE-----
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"tempDir": true,
3+
"steps": [
4+
{
5+
"args": "install",
6+
"output": "install.out"
7+
},
8+
{
9+
"args": "audit",
10+
"output": "audit.out",
11+
"envs": {
12+
"DENO_CERT": "$PWD/RootCA.pem",
13+
"NPM_CONFIG_REGISTRY": "https://localhost:5545/"
14+
}
15+
}
16+
]
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No known vulnerabilities found
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Download http://localhost:4260/@denotest%2fsay-hello
2+
Download http://localhost:4260/@denotest/say-hello/1.0.0.tgz
3+
Initialize @denotest/say-hello@1.0.0
4+
Installed 1 package in [WILDLINE]
5+
Reused 0 packages from cache
6+
Downloaded 0 packages from JSR
7+
Downloaded 1 package from npm
8+
+
9+
10+
Dependencies:
11+
+ npm:@denotest/say-hello 1.0.0
12+
[WILDLINE]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"@denotest/say-hello": "1.0.0"
4+
}
5+
}

tests/util/server/servers/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ async fn main_server(
417417
remote_addr: SocketAddr,
418418
) -> Result<Response<UnsyncBoxBody<Bytes, Infallible>>, anyhow::Error> {
419419
match (req.method(), req.uri().path()) {
420+
(&Method::POST, "/-/npm/v1/security/advisories/bulk") => {
421+
npm_registry::npm_security_advisories_bulk(req).await
422+
}
420423
(_, "/echo_server") => {
421424
let (parts, body) = req.into_parts();
422425
let mut response = Response::new(UnsyncBoxBody::new(Full::new(

tests/util/server/servers/npm_registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ fn npm_security_advisories_bulk_no_vulns()
604604
.map_err(|e| e.into())
605605
}
606606

607-
async fn npm_security_advisories_bulk(
607+
pub(super) async fn npm_security_advisories_bulk(
608608
req: Request<Incoming>,
609609
) -> Result<Response<UnsyncBoxBody<Bytes, Infallible>>, anyhow::Error> {
610610
// Respond with 400 for a request whose body can't be read or isn't valid

0 commit comments

Comments
 (0)