diff --git a/Cargo.lock b/Cargo.lock index 32c5dc0e3..b60db77fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,7 +411,7 @@ dependencies = [ "http 1.5.0", "http-body 1.1.0", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "itoa", "matchit", @@ -782,12 +782,12 @@ checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] name = "chacha20" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", - "cpufeatures 0.3.0", + "cpufeatures 0.3.1", "rand_core 0.10.1", ] @@ -996,9 +996,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" dependencies = [ "libc", ] @@ -1395,7 +1395,7 @@ dependencies = [ "error_reporter", "http 1.5.0", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-rustls", "hyper-util", "ipnet", @@ -1473,7 +1473,7 @@ dependencies = [ "http 1.5.0", "httparse", "hyper 0.14.32", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "itertools 0.10.5", "memmem", @@ -1632,12 +1632,12 @@ dependencies = [ "elliptic-curve", "errno 0.2.8", "faster-hex", - "h2 0.4.18", + "h2 0.4.19", "hkdf", "home", "http 1.5.0", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "idna 0.3.0", "indexmap", @@ -1773,7 +1773,7 @@ dependencies = [ "http 1.5.0", "http-body-util", "hyper 0.14.32", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "libc", "log", @@ -1923,10 +1923,10 @@ dependencies = [ "deno_permissions", "deno_tls", "fastwebsockets", - "h2 0.4.18", + "h2 0.4.19", "http 1.5.0", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "once_cell", "rustls-tokio-stream", @@ -2496,7 +2496,7 @@ dependencies = [ "base64 0.21.7", "bytes", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "pin-project", "rand 0.8.5", @@ -2567,12 +2567,12 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" dependencies = [ "crc32fast", - "miniz_oxide 0.8.9", + "miniz_oxide 0.9.1", "zlib-rs", ] @@ -3019,9 +3019,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839c0e8a181239723652be9062bb56ca5bf5f64011f73b623f6f4fc59086a228" +checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16" dependencies = [ "atomic-waker", "bytes", @@ -3238,15 +3238,15 @@ dependencies = [ [[package]] name = "hyper" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22053281f852e11534f5198498373cbb59295120a20771d90f7ed1897490a72" +checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43" dependencies = [ "atomic-waker", "bytes", "futures-channel", "futures-core", - "h2 0.4.18", + "h2 0.4.19", "http 1.5.0", "http-body 1.1.0", "httparse", @@ -3265,7 +3265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" dependencies = [ "http 1.5.0", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "rustls", "rustls-native-certs 0.8.4", @@ -3286,7 +3286,7 @@ dependencies = [ "futures-util", "http 1.5.0", "http-body 1.1.0", - "hyper 1.11.0", + "hyper 1.11.1", "pin-project-lite", "socket2 0.5.10", "tokio", @@ -3826,9 +3826,9 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d0a00925a9f930d679b6789b721e3a7f9ed110f41b86d2497caa780c3a070a" +checksum = "d7955dfc218a8afb29dfeffd540e3a6e96baeb94fe7138228dd7cc6937fbbf96" dependencies = [ "bitflags 2.9.4", "libc", @@ -4051,6 +4051,16 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + [[package]] name = "mio" version = "0.8.11" @@ -4373,9 +4383,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "open" -version = "5.4.1" +version = "5.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cfef937e9c486488c7e3d949ae31c0f1d06bdacd75b99c086cb35356e30408" +checksum = "ade3be4664bc1ef537ce133015f04c176b737815c2ba9fd60edf212d6e90dd55" dependencies = [ "is-wsl", "libc", @@ -5466,7 +5476,7 @@ dependencies = [ "http 1.5.0", "http-body 1.1.0", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-rustls", "hyper-util", "ipnet", @@ -8210,7 +8220,7 @@ dependencies = [ "futures", "http 1.5.0", "http-body-util", - "hyper 1.11.0", + "hyper 1.11.1", "hyper-util", "log", "once_cell", diff --git a/cli/src/api/endpoints.rs b/cli/src/api/endpoints.rs index 5680149ab..d265156fb 100644 --- a/cli/src/api/endpoints.rs +++ b/cli/src/api/endpoints.rs @@ -383,8 +383,8 @@ mod test { "https://example.com/a/api/v0/", ); - // Maybe an error should be reported in this case instead of stripping the - // extras. + // Maybe an error should be reported in this case instead of stripping + // the extras. assert_eq!( get_api_path("https://example.com/search?q=invalid#search").unwrap().as_str(), "https://example.com/search/api/v0/", diff --git a/cli/src/app.rs b/cli/src/app.rs index 1f23ba681..a983e72e2 100644 --- a/cli/src/app.rs +++ b/cli/src/app.rs @@ -25,8 +25,8 @@ const FILTER_ABOUT: &str = r#"Provide a filter used to limit the issues displaye "#; pub fn app() -> Command { - // NOTE: We do not use the `arg!` macro here since it causes a stack overflow on - // Windows. + // NOTE: We do not use the `arg!` macro here since it causes a stack + // overflow on Windows. #[allow(unused_mut)] let mut app = Command::new("phylum") .bin_name("phylum") diff --git a/cli/src/bin/phylum.rs b/cli/src/bin/phylum.rs index 9baf3513f..899a91bda 100644 --- a/cli/src/bin/phylum.rs +++ b/cli/src/bin/phylum.rs @@ -38,8 +38,8 @@ fn exit_fail(message: impl Display, exit_code: ExitCode) -> ! { async fn api_factory(config: Config, timeout: Option) -> Result { let api = PhylumApi::new(config, timeout).await?; - // PhylumApi may have had to log in, updating the auth info so we should save - // the config + // PhylumApi may have had to log in, updating the auth info so we should + // save the config let api_config = api.config(); api_config .save() @@ -119,9 +119,9 @@ async fn handle_commands() -> CommandResult { check_for_updates(&mut config).await?; } - // Get the future, but don't await. Commands that require access to the API will - // await on this, so that the API is not instantiated ahead of time for - // subcommands that don't require it. + // Get the future, but don't await. Commands that require access to the API + // will await on this, so that the API is not instantiated ahead of time + // for subcommands that don't require it. let api = api_factory(config.clone(), timeout); match subcommand { diff --git a/cli/src/commands/extensions/api.rs b/cli/src/commands/extensions/api.rs index a3dbb8460..c40ee8197 100644 --- a/cli/src/commands/extensions/api.rs +++ b/cli/src/commands/extensions/api.rs @@ -360,8 +360,8 @@ async fn create_project( let state = ExtensionState::from(op_state); let api = state.api().await?; - // Retrieve the id if the project already exists, otherwise return the id or the - // error. + // Retrieve the id if the project already exists, otherwise return the id or + // the error. match api.create_project(&name, organization.clone(), group.clone(), repository_url).await { Err(PhylumApiError::Response(ResponseError { code: StatusCode::CONFLICT, .. })) => api .get_project_id(&name, organization.as_deref(), group.as_deref()) diff --git a/cli/src/commands/extensions/mod.rs b/cli/src/commands/extensions/mod.rs index e361bf506..97b34de17 100644 --- a/cli/src/commands/extensions/mod.rs +++ b/cli/src/commands/extensions/mod.rs @@ -179,7 +179,8 @@ async fn handle_install_extension( accept_permissions: bool, overwrite: bool, ) -> CommandResult { - // NOTE: Extension installation without slashes is reserved for the marketplace. + // NOTE: Extension installation without slashes is reserved for the + // marketplace. if !path.contains('/') && !path.contains('\\') { return Err(anyhow!("Ambiguous extension URI '{}', use './{0}' instead", path)); } @@ -318,8 +319,8 @@ async fn handle_uninstall_extension(name: &str) -> CommandResult { pub async fn handle_create_extension(path: &str) -> CommandResult { // Error out when target is already occupied. // - // This allows use to use [`fs::create_dir_all`] without having to worry about - // reusing an existing directory. + // This allows use to use [`fs::create_dir_all`] without having to worry + // about reusing an existing directory. let extension_path = PathBuf::from(path); if extension_path.exists() { return Err(anyhow!("Destination {path:?} already exists")); diff --git a/cli/src/commands/parse.rs b/cli/src/commands/parse.rs index c12d647be..c4b7e6b3e 100644 --- a/cli/src/commands/parse.rs +++ b/cli/src/commands/parse.rs @@ -427,8 +427,8 @@ fn depfile_parsing_sandbox(canonical_manifest_path: &Path) -> Result { // Allow any executable in common binary directories. // - // Reading binaries shouldn't be an attack vector, but significantly simplifies - // complex ecosystems (like Python's symlinks). + // Reading binaries shouldn't be an attack vector, but significantly + // simplifies complex ecosystems (like Python's symlinks). permissions::add_exception(&mut birdcage, Exception::ExecuteAndRead("/usr/bin".into()))?; permissions::add_exception(&mut birdcage, Exception::ExecuteAndRead("/bin".into()))?; @@ -577,9 +577,9 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let tempdir = tempdir.path().canonicalize().unwrap(); - // Create a sample project directory named "sample" inside the "projects" - // directory. Also create a "Cargo.lock" file inside the "sample" - // directory. + // Create a sample project directory named "sample" inside the + // "projects" directory. Also create a "Cargo.lock" file inside + // the "sample" directory. let sample_dir = tempdir.join("sample"); let lockfile_path = sample_dir.join("Cargo.lock"); fs::create_dir_all(&sample_dir).unwrap(); @@ -587,33 +587,36 @@ mod tests { // Change the current directory to the "sample" project directory. let path = relative_path(&sample_dir, &lockfile_path).unwrap(); - // The path to the lockfile should now be just the filename since it's in the - // current directory. + // The path to the lockfile should now be just the filename since it's + // in the current directory. assert_eq!(path.as_os_str(), "Cargo.lock"); - // Create a subdirectory named "sub" within the "sample" project directory. + // Create a subdirectory named "sub" within the "sample" project + // directory. let sub_dir = sample_dir.join("sub"); fs::create_dir_all(&sub_dir).unwrap(); // Change the current directory to the new "sub" directory. let rel_lockfile_path = sub_dir.join("../Cargo.lock"); - // Get the relative path from the sub directory to the lockfile in the sample - // directory. + // Get the relative path from the sub directory to the lockfile in the + // sample directory. let path = relative_path(&sample_dir, &rel_lockfile_path).unwrap(); - // The path to the lockfile should be the same as before since we are looking - // relative to the sample directory. + // The path to the lockfile should be the same as before since we are + // looking relative to the sample directory. assert_eq!(path.as_os_str(), "Cargo.lock"); - // Create another "Cargo.lock" file one level above the "sample" directory. + // Create another "Cargo.lock" file one level above the "sample" + // directory. let above_lockfile_path = tempdir.join("Cargo.lock"); File::create(above_lockfile_path).unwrap(); let rel_lockfile_path = sub_dir.join("../../Cargo.lock"); - // Although the current directory is still "sub", get the relative path to the - // lockfile above the "sample" directory. + // Although the current directory is still "sub", get the relative path + // to the lockfile above the "sample" directory. let path = relative_path(&sample_dir, &rel_lockfile_path).unwrap(); - // The path to the lockfile should be relative to the "sample" directory. + // The path to the lockfile should be relative to the "sample" + // directory. assert_eq!(path, Path::new("../Cargo.lock")); } } diff --git a/cli/src/commands/sandbox.rs b/cli/src/commands/sandbox.rs index 5dab33ab2..62c71f0f6 100644 --- a/cli/src/commands/sandbox.rs +++ b/cli/src/commands/sandbox.rs @@ -32,8 +32,8 @@ pub async fn handle_sandbox(matches: &ArgMatches) -> CommandResult { }; if let Some(mut code) = status.code() { - // Remap exit code if it matches our sandbox start failure indicator, to ensure - // we can detect the failure reliably. + // Remap exit code if it matches our sandbox start failure indicator, to + // ensure we can detect the failure reliably. if code == i32::from(&ExitCode::SandboxStart) { code = i32::from(&ExitCode::SandboxStartCollision); } diff --git a/cli/src/config.rs b/cli/src/config.rs index 2410c6cfa..459db0b68 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -156,8 +156,9 @@ where // Use target directory for temporary file path. // - // It's not possible to create the file on tmpfs since the configuration file is - // usually not on the same device, which causes `fs::rename` to fail. + // It's not possible to create the file on tmpfs since the configuration + // file is usually not on the same device, which causes `fs::rename` to + // fail. let file_name = path .file_name() .and_then(|name| name.to_str()) diff --git a/cli/src/deno.rs b/cli/src/deno.rs index 1c86fc2c6..3f9e07384 100644 --- a/cli/src/deno.rs +++ b/cli/src/deno.rs @@ -190,9 +190,9 @@ impl ModuleLoader for ExtensionsModuleLoader { } // Determine source file type. - // We do not care about invalid URLs yet: This match statement is inexpensive, - // bears no risk and does not do I/O -- it operates fully off of the - // contents of the URL. + // We do not care about invalid URLs yet: This match statement is + // inexpensive, bears no risk and does not do I/O -- it + // operates fully off of the contents of the URL. let media_type = MediaType::from_specifier(&module_specifier); let (module_type, should_transpile) = match media_type { MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => { @@ -210,9 +210,9 @@ impl ModuleLoader for ExtensionsModuleLoader { _ => return Err(anyhow!("Unknown JS module format: {}", module_specifier)), }; - // Load either a local file under the extensions directory, or a Deno standard - // library module. Reject all URLs that do not fit these two use - // cases. + // Load either a local file under the extensions directory, or a + // Deno standard library module. Reject all URLs that do + // not fit these two use cases. let code = match module_specifier.scheme() { "file" => { ExtensionsModuleLoader::load_from_filesystem(&extension_path, &module_specifier) diff --git a/cli/src/fs_compare.rs b/cli/src/fs_compare.rs index a94a7fe54..c725d16df 100644 --- a/cli/src/fs_compare.rs +++ b/cli/src/fs_compare.rs @@ -68,8 +68,9 @@ fn file_compare, B: AsRef>(a: A, b: B) -> Result { let cmp_len = std::cmp::min(a_buf.len(), b_buf.len()); if cmp_len == 0 { // Only 1 EOF. Files are different - // Note: Because of the file length check above, this should be impossible - // except perhaps if a file is actively being changed. + // Note: Because of the file length check above, this should be + // impossible except perhaps if a file is actively being + // changed. log::trace!("File length mismatch (race condition?)"); return Ok(false); } diff --git a/cli/src/permissions.rs b/cli/src/permissions.rs index 5d98e0de0..3e570d879 100644 --- a/cli/src/permissions.rs +++ b/cli/src/permissions.rs @@ -34,9 +34,9 @@ impl Default for Permission { } impl Permission { - // XXX In Deno, `Some(vec![])` actually means "allow all". We don't want empty - // `Vec` permissions to allow access to all resources, so we - // manually convert these instances into `None`. + // XXX In Deno, `Some(vec![])` actually means "allow all". We don't want + // empty `Vec` permissions to allow access to all resources, so + // we manually convert these instances into `None`. pub fn get(&self) -> Option<&Vec> { const EMPTY_VEC: &Vec = &Vec::new(); match &self { @@ -114,8 +114,8 @@ impl Permission { let without_parent: Vec<_> = child .iter() .filter_map(|child| { - // Using Path::starts_with rather than String::starts_with in order to get - // the correct semantics. + // Using Path::starts_with rather than String::starts_with in + // order to get the correct semantics. if parent.iter().any(|p| Path::new(&child).starts_with(p)) { None } else { @@ -124,8 +124,8 @@ impl Permission { }) .collect::>(); - // The above list must be empty for all child paths to be a subset of the - // parent. + // The above list must be empty for all child paths to be a subset of + // the parent. if !without_parent.is_empty() { Err(without_parent) } else { @@ -315,8 +315,8 @@ pub fn default_sandbox() -> SandboxResult { // Allow access to DNS list. // - // While this is required to send DNS requests for network queries, this does - // not automatically allow any network access. + // While this is required to send DNS requests for network queries, this + // does not automatically allow any network access. add_exception(&mut birdcage, Exception::Read("/etc/resolv.conf".into()))?; // Allow reading SSL certificates. @@ -408,7 +408,8 @@ mod tests { assert!(permissions_options.allow_env.is_none()); assert!(permissions_options.allow_run.is_none()); - // NOTE: Net is an exception since we allow our own API domains by default. + // NOTE: Net is an exception since we allow our own API domains by + // default. assert_eq!( permissions_options.allow_net, Some(vec!["api.staging.phylum.io".into(), "api.phylum.io".into()]) @@ -490,13 +491,15 @@ mod tests { assert!(paths_subset(&["/tmp"], &["/"]).is_err()); assert!(paths_subset(&["/tmp"], &["/etc/something"]).is_err()); - // A << B if for each a in A, there exist at least one b in B such that a < b. + // A << B if for each a in A, there exist at least one b in B such that + // a < b. assert!(paths_subset(&["/tmp", "/etc"], &["/etc/something"]).is_ok()); assert!(paths_subset(&["/tmp", "/etc"], &["/etc", "/tmp/something"]).is_ok()); assert!(paths_subset(&["/tmp", "/etc"], &["/tmp", "/etc/something"]).is_ok()); assert!(paths_subset(&["/tmp", "/etc"], &["/etc/something", "/tmp/something"]).is_ok()); - // Not A << B if there exists one a in A such that for each b in B, not a < b. + // Not A << B if there exists one a in A such that for each b in B, not + // a < b. assert!(paths_subset(&["/tmp", "/etc"], &["/something"]).is_err()); assert!(paths_subset(&["/tmp", "/etc"], &["/tmp", "/etc", "/something"]).is_err()); assert!(paths_subset(&["/tmp", "/etc"], &["/tmp/a", "/etc/b", "/something"]).is_err()); diff --git a/cli/tests/extensions/mod.rs b/cli/tests/extensions/mod.rs index a97b3b70f..53cadf8cd 100644 --- a/cli/tests/extensions/mod.rs +++ b/cli/tests/extensions/mod.rs @@ -70,7 +70,8 @@ fn successful_installation_prints_message() { .success() .stdout(predicate::str::contains("Extension sample installed successfully")); - // Installing the same extension twice is also fine (because we're using --yes) + // Installing the same extension twice is also fine (because we're using + // --yes) test_cli .install_extension(&fixtures_path().join("sample")) .success() diff --git a/lockfile/src/csharp.rs b/lockfile/src/csharp.rs index 30d664a9f..4e2ccb27b 100644 --- a/lockfile/src/csharp.rs +++ b/lockfile/src/csharp.rs @@ -45,7 +45,8 @@ impl Parse for PackagesLock { None => return false, }; - // Accept both `packages.lock.json` and `packages..lock.json`. + // Accept both `packages.lock.json` and + // `packages..lock.json`. file_name.starts_with("packages.") && file_name.ends_with(".lock.json") } diff --git a/lockfile/src/javascript.rs b/lockfile/src/javascript.rs index 3d69d9219..59876737b 100644 --- a/lockfile/src/javascript.rs +++ b/lockfile/src/javascript.rs @@ -49,15 +49,18 @@ impl Parse for PackageLock { for (name, keys) in deps { // Discard version information of local packages. // - // In NPM, versions for filesystem dependencies are in the object with the - // `name` corresponding to the path of the module, without any mention of the + // In NPM, versions for filesystem dependencies are in the + // object with the `name` corresponding to the + // path of the module, without any mention of the // module's name itself. // - // The module's name then shows up as a separate package with the `name` as - // `node_modules/`, the path as `resolved`, `"link": true` and no version. + // The module's name then shows up as a separate package with + // the `name` as `node_modules/`, the path + // as `resolved`, `"link": true` and no version. // - // Since we care more about the name of a local dependency than its package, we - // discard the version here and include the package later when it's mentioned by + // Since we care more about the name of a local dependency than + // its package, we discard the version here and + // include the package later when it's mentioned by // name. if !name.starts_with("node_modules/") { continue; @@ -517,12 +520,13 @@ mod tests { #[test] fn lock_parse_yarn_v1_simple() { - // This file contains only one package and that package has no dependencies. - // This makes the file valid YAML according to serde_yaml. + // This file contains only one package and that package has no + // dependencies. This makes the file valid YAML according to + // serde_yaml. // - // We need to make sure we don't take the v2 lockfile code path because this is - // not a v2 lockfile and parsing it as one will produce incorrect - // results. + // We need to make sure we don't take the v2 lockfile code path because + // this is not a v2 lockfile and parsing it as one will produce + // incorrect results. let pkgs = YarnLock.parse(include_str!("../../tests/fixtures/yarn-v1.simple.lock")).unwrap(); @@ -667,9 +671,9 @@ mod tests { #[test] fn empty_yarn_v2() { - // While this uses the same parser as the `empty_yarn_v1` test, this should make - // sure we do not accidentally introduce a regression if we ever remove the v1 - // parser. + // While this uses the same parser as the `empty_yarn_v1` test, this + // should make sure we do not accidentally introduce a + // regression if we ever remove the v1 parser. let pkgs = YarnLock.parse("").unwrap(); assert!(pkgs.is_empty()); } diff --git a/lockfile/src/lib.rs b/lockfile/src/lib.rs index 3e81707a4..9ad977522 100644 --- a/lockfile/src/lib.rs +++ b/lockfile/src/lib.rs @@ -138,10 +138,10 @@ impl LockfileFormat { /// Iterate over all supported lockfile formats. pub fn iter() -> impl Iterator { - // NOTE: Without explicit override, the lockfile generator will always pick the - // first matching format for the manifest. To ensure best possible support, - // common formats should be returned **before** less common ones (i.e. NPM - // before Yarn). + // NOTE: Without explicit override, the lockfile generator will always + // pick the first matching format for the manifest. To ensure + // best possible support, common formats should be returned + // **before** less common ones (i.e. NPM before Yarn). const FORMATS: &[LockfileFormat] = &[ LockfileFormat::Npm, LockfileFormat::Yarn, @@ -322,9 +322,10 @@ impl DepFiles { let parser = format.parser(); let mut format_found = false; - // GoMod can represent a manifest and lockfile which causes duplicate - // lockfiles being submitted when a go.sum is present. This removes - // go.mod files from being automatically recognized as a lockfile. + // GoMod can represent a manifest and lockfile which causes + // duplicate lockfiles being submitted when a + // go.sum is present. This removes go.mod files + // from being automatically recognized as a lockfile. if format != LockfileFormat::GoMod && parser.is_path_lockfile(path) { depfiles.lockfiles.push((path.to_path_buf(), format)); format_found = true; @@ -364,8 +365,8 @@ pub fn find_depfiles_at(root: impl AsRef) -> Vec<(PathBuf, LockfileFormat) let (manifest_path, _) = &depfiles.manifests[i]; - // Filter out manifest if there's a lockfile with a matching format at or above - // the manifest. + // Filter out manifest if there's a lockfile with a matching format at + // or above the manifest. let mut lockfile_dirs = depfiles.lockfiles.iter().filter_map(|(path, format)| Some((path.parent()?, format))); remove |= lockfile_dirs.any(|(mut lockfile_dir, lockfile_format)| { @@ -382,8 +383,8 @@ pub fn find_depfiles_at(root: impl AsRef) -> Vec<(PathBuf, LockfileFormat) && manifest_path.starts_with(lockfile_dir) }); - // Filter out manifest if there's a manifest with a matching format above the - // manifest. + // Filter out manifest if there's a manifest with a matching format + // above the manifest. let mut manifest_dirs = depfiles.manifests.iter().filter_map(|(path, format)| { let parent = path.parent()?; (path != manifest_path).then_some((parent, format)) diff --git a/lockfile/src/parse_depfile.rs b/lockfile/src/parse_depfile.rs index 14327f976..37e491fef 100644 --- a/lockfile/src/parse_depfile.rs +++ b/lockfile/src/parse_depfile.rs @@ -88,10 +88,10 @@ pub fn parse_depfile( } } - // Attempt to generate a lockfile for likely manifests when feature and option - // are enabled. This is a best effort attempt for files that are known at this - // point to not be a valid/parseable lockfile but may parse as a manifest with - // a non-standard name. + // Attempt to generate a lockfile for likely manifests when feature and + // option are enabled. This is a best effort attempt for files that are + // known at this point to not be a valid/parseable lockfile but may + // parse as a manifest with a non-standard name. #[cfg(feature = "generator")] if let Some(generation_path) = _generation_path.filter(|_| !maybe_lockfile || maybe_manifest) { if parser.generator().is_some() { diff --git a/lockfile/src/parsers/gem.rs b/lockfile/src/parsers/gem.rs index f1b7d5993..f09643bd4 100644 --- a/lockfile/src/parsers/gem.rs +++ b/lockfile/src/parsers/gem.rs @@ -49,7 +49,8 @@ impl<'a> Section<'a> { } else if consumed.ends_with("BUNDLED WITH") { break; } else { - // Unreachable since our parser fails if none of the headers are found. + // Unreachable since our parser fails if none of the headers are + // found. unreachable!(); }; @@ -205,10 +206,10 @@ fn package(input: &str) -> Result, NomErr version, Err(_) => return Ok(None), diff --git a/lockfile/src/parsers/go_mod.rs b/lockfile/src/parsers/go_mod.rs index c3632fb2d..90ccbba37 100644 --- a/lockfile/src/parsers/go_mod.rs +++ b/lockfile/src/parsers/go_mod.rs @@ -98,8 +98,8 @@ pub fn parse(input: &str) -> IResult<&str, GoDeps> { for replacement in replacement_set { let module_path = &replacement.path; - // Check if the replacement module version is available and remove any modules - // marked for replacement. + // Check if the replacement module version is available and remove any + // modules marked for replacement. match &replacement.version { Some(version) => { let module = Module { @@ -110,7 +110,8 @@ pub fn parse(input: &str) -> IResult<&str, GoDeps> { modules.remove(&module); }, None => { - // Remove all modules with the same path since version isn't specified. + // Remove all modules with the same path since version isn't + // specified. modules.retain(|m| (&m.path != module_path) || m.indirect); }, } diff --git a/lockfile/src/parsers/pypi.rs b/lockfile/src/parsers/pypi.rs index e64dd60d4..46ab04890 100644 --- a/lockfile/src/parsers/pypi.rs +++ b/lockfile/src/parsers/pypi.rs @@ -55,8 +55,8 @@ fn line<'a>(input: &'a str, registry: &mut Option<&'a str>) -> IResult<&'a str, // Ignore index config options. // - // Since `ThirdPartyVersion` only allows a single registry, we only record the - // primary one. + // Since `ThirdPartyVersion` only allows a single registry, we only record + // the primary one. if let Some(index_url) = line .strip_prefix("--index-url") .and_then(|line| line.strip_prefix(['=', ' '])) diff --git a/lockfile/src/parsers/yarn.rs b/lockfile/src/parsers/yarn.rs index 293109db1..a4f67b84a 100644 --- a/lockfile/src/parsers/yarn.rs +++ b/lockfile/src/parsers/yarn.rs @@ -76,8 +76,8 @@ fn entry_version(input: &str) -> IResult<&str, Option> { // Ignore HTTP(S) dependencies. // - // These could be either git or tar dependencies, so to avoid miscategorization - // we just ignore them. + // These could be either git or tar dependencies, so to avoid + // miscategorization we just ignore them. if input.starts_with("@http://") || input.starts_with("@https://") { return Ok((input, None)); } diff --git a/lockfile/src/ruby.rs b/lockfile/src/ruby.rs index 35f7451e7..7696de59a 100644 --- a/lockfile/src/ruby.rs +++ b/lockfile/src/ruby.rs @@ -22,8 +22,8 @@ impl Parse for GemLock { .map_err(|e| anyhow!(convert_error(data, e))) .context("Failed to parse gem lockfile")?; - // Remove duplicate dependencies, which can occur when a dependency is included - // with multiple different platform suffixes. + // Remove duplicate dependencies, which can occur when a dependency is + // included with multiple different platform suffixes. packages.sort_unstable(); packages.dedup(); diff --git a/lockfile_generator/src/lib.rs b/lockfile_generator/src/lib.rs index 4729a2db9..a0ac69a6b 100644 --- a/lockfile_generator/src/lib.rs +++ b/lockfile_generator/src/lib.rs @@ -108,8 +108,9 @@ struct FileRelocator { impl Drop for FileRelocator { fn drop(&mut self) { - // We can't do anything about failure here, but the original file should stay - // around allowing users to still resolve these issues manually. + // We can't do anything about failure here, but the original file should + // stay around allowing users to still resolve these issues + // manually. let _ = fs::rename(&self.backup_path, &self.original_path); } } diff --git a/lockfile_generator/src/pip.rs b/lockfile_generator/src/pip.rs index b09b11f48..6f7a41015 100644 --- a/lockfile_generator/src/pip.rs +++ b/lockfile_generator/src/pip.rs @@ -65,7 +65,8 @@ impl Generator for Pip { // Execute pip inside the project. // - // We still change directory here since it could impact pip's report generation. + // We still change directory here since it could impact pip's report + // generation. let mut command = self.command(&canonicalized); command.current_dir(project_path); command.stdin(Stdio::null()); diff --git a/phylum_project/src/lib.rs b/phylum_project/src/lib.rs index a1b786a03..7c20075e6 100644 --- a/phylum_project/src/lib.rs +++ b/phylum_project/src/lib.rs @@ -220,9 +220,9 @@ mod tests { #[cfg(any(unix, windows))] #[test] fn find_project_conf_can_recurse_up() { - // To verify the behavior of navigation to parent directories, we must construct - // a filesystem where the parent directory cannot be reached by removing path - // components. + // To verify the behavior of navigation to parent directories, we must + // construct a filesystem where the parent directory cannot be + // reached by removing path components. // // temp: // - r: @@ -249,8 +249,8 @@ mod tests { #[cfg(unix)] std::os::unix::fs::symlink(&subdir, &cwd).unwrap(); - // This only works on Windows if the user is an administrator or developer mode - // is on. + // This only works on Windows if the user is an administrator or + // developer mode is on. #[cfg(windows)] std::os::windows::fs::symlink_dir(&subdir, &cwd).unwrap();