GeezerVison is showing github.com — Fix PDM env shadowing uv projects · SocketDev/socket-patch@810f39b
File treeExpand file treeCollapse file tree Open diff view settings repair_vendor_flavors_e2e
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/apply.rs +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,9 +2,7 @@ use clap::Args; | 2 | 2 | use socket_patch_core::api::blob_fetcher::get_missing_blobs; | 3 | 3 | use socket_patch_core::api::client::{get_api_client_with_overrides, ApiClient}; | 4 | 4 | use socket_patch_core::crawlers::ruby_crawler::config_path_ignored_warning; | 5 | | -use socket_patch_core::crawlers::{ | 6 | | - detect_npm_pkg_manager, Ecosystem, NpmPkgManager, RubyCrawler, | 7 | | -}; | | 5 | +use socket_patch_core::crawlers::{detect_npm_pkg_manager, Ecosystem, NpmPkgManager, RubyCrawler}; | 8 | 6 | use socket_patch_core::manifest::operations::read_manifest; | 9 | 7 | use socket_patch_core::manifest::schema::{PatchFileInfo, PatchManifest, PatchRecord}; | 10 | 8 | use socket_patch_core::patch::apply::{ | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/list.rs +12-3Lines changed: 12 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -431,7 +431,10 @@ pub async fn run(args: ListArgs) -> i32 { | 431 | 431 | detail: detail.clone(), | 432 | 432 | }); | 433 | 433 | } else if !args.common.silent { | 434 | | - eprintln!("Warning: {}", crate::commands::rollback::capitalize_first(detail)); | | 434 | + eprintln!( | | 435 | + "Warning: {}", | | 436 | + crate::commands::rollback::capitalize_first(detail) | | 437 | + ); | 435 | 438 | } | 436 | 439 | } | 437 | 440 | let vendor_state = crate::commands::vendor_state_lenient(&loaded.vendor, args.common.silent); | @@ -773,12 +776,18 @@ mod tests { | 773 | 776 | let listings = HostedListing::from_pins( | 774 | 777 | &[ | 775 | 778 | | 776 | | - | | 779 | + pin( | | 780 | + | | 781 | + "33333333-3333-4333-8333-333333333333", | | 782 | + ), | 777 | 783 | ], | 778 | 784 | Some(&legacy), | 779 | 785 | ); | 780 | 786 | assert_eq!(listings[0].record, record); | 781 | | - assert_eq!(listings[1].record.uuid, "33333333-3333-4333-8333-333333333333"); | | 787 | + assert_eq!( | | 788 | + listings[1].record.uuid, | | 789 | + "33333333-3333-4333-8333-333333333333" | | 790 | + ); | 782 | 791 | assert!(listings[1].record.vulnerabilities.is_empty()); | 783 | 792 | assert_eq!(listings[1].lockfiles, vec!["yarn.lock".to_string()]); | 784 | 793 | } | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/mod.rs +11-11Lines changed: 11 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | pub mod apply; | 2 | 2 | pub(crate) mod bun_preflight; | 3 | | -pub(crate) mod context; | 4 | 3 | pub(crate) mod composer_hints; | | 4 | +pub(crate) mod context; | 5 | 5 | pub(crate) mod fetch_stage; | 6 | 6 | pub mod get; | 7 | 7 | pub mod hosted_bundle; | 8 | 8 | pub mod list; | 9 | 9 | pub(crate) mod lock_cli; | 10 | 10 | pub mod remove; | 11 | 11 | pub mod repair; | 12 | | -pub(crate) mod vendored_backend; | 13 | 12 | pub mod rollback; | 14 | 13 | pub mod scan; | 15 | 14 | pub mod update; | 16 | 15 | pub mod vendor; | | 16 | +pub(crate) mod vendored_backend; | 17 | 17 | pub mod vex; | 18 | 18 | pub(crate) mod vex_consumed; | 19 | 19 | pub(crate) mod vex_sources; | @@ -135,9 +135,11 @@ pub(crate) async fn hosted_state_from_lockfiles( | 135 | 135 | common: &crate::args::GlobalArgs, | 136 | 136 | root: &Path, | 137 | 137 | ) -> socket_patch_core::patch::redirect::RedirectState { | 138 | | - hosted_state_from_pins(&socket_patch_core::patch::redirect::upstream::HostedPin::all( | 139 | | - &discover_wiring(common, root).await, | 140 | | - )) | | 138 | + hosted_state_from_pins( | | 139 | + &socket_patch_core::patch::redirect::upstream::HostedPin::all( | | 140 | + &discover_wiring(common, root).await, | | 141 | + ), | | 142 | + ) | 141 | 143 | } | 142 | 144 |
| 143 | 145 | /// [`hosted_state_from_lockfiles`] over already-discovered pins. A purl | @@ -147,18 +149,17 @@ pub(crate) fn hosted_state_from_pins( | 147 | 149 | ) -> socket_patch_core::patch::redirect::RedirectState { | 148 | 150 | let mut state = socket_patch_core::patch::redirect::RedirectState::new(); | 149 | 151 | for pin in pins { | 150 | | - state | 151 | | - .records | 152 | | - .entry(pin.purl.clone()) | 153 | | - .or_insert_with(|| socket_patch_core::manifest::schema::PatchRecord { | | 152 | + state.records.entry(pin.purl.clone()).or_insert_with(|| { | | 153 | + socket_patch_core::manifest::schema::PatchRecord { | 154 | 154 | uuid: pin.uuid.clone(), | 155 | 155 | exported_at: String::new(), | 156 | 156 | files: Default::default(), | 157 | 157 | vulnerabilities: Default::default(), | 158 | 158 | description: String::new(), | 159 | 159 | license: String::new(), | 160 | 160 | tier: String::new(), | 161 | | - }); | | 161 | + } | | 162 | + }); | 162 | 163 | } | 163 | 164 | state | 164 | 165 | } | @@ -185,4 +186,3 @@ pub(crate) fn vendor_state_lenient( | 185 | 186 | } | 186 | 187 | } | 187 | 188 | } | 188 | | - |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/remove.rs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,9 +17,9 @@ use super::rollback::{ | 17 | 17 | pin_before_hash_blobs, rollback_patches_inner, run_hosted_leg, sweep_failure, | 18 | 18 | sweep_unused_artifacts, HostedLegOutcome, InnerSelection, | 19 | 19 | }; | 20 | | -use crate::commands::vendored_backend::{RevertedEntry, VendorRevertStep, VendoredBackend}; | 21 | 20 | use crate::args::{apply_env_toggles, GlobalArgs}; | 22 | 21 | use crate::commands::lock_cli::acquire_or_emit; | | 22 | +use crate::commands::vendored_backend::{RevertedEntry, VendorRevertStep, VendoredBackend}; | 23 | 23 | use crate::json_envelope::{Command, Envelope, EnvelopeError, PatchAction, PatchEvent, Status}; | 24 | 24 | use crate::ui::plural; | 25 | 25 |
| |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/rollback.rs +8-3Lines changed: 8 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,13 +10,13 @@ use socket_patch_core::manifest::operations::{ | 10 | 10 | }; | 11 | 11 | use socket_patch_core::manifest::schema::{PatchFileInfo, PatchManifest, PatchRecord}; | 12 | 12 | use socket_patch_core::patch::apply::select_installed_variants; | | 13 | +use socket_patch_core::patch::redirect::upstream::HostedPin; | 13 | 14 | use socket_patch_core::patch::rollback::{ | 14 | 15 | cannot_rollback_error, rollback_package_patch, verify_file_rollback, RollbackResult, | 15 | 16 | VerifyRollbackResult, VerifyRollbackStatus, | 16 | 17 | }; | 17 | 18 | use socket_patch_core::telemetry::{track_patch_rollback_failed, track_patch_rolled_back}; | 18 | 19 | use socket_patch_core::utils::purl::{patch_matches, strip_purl_qualifiers}; | 19 | | -use socket_patch_core::patch::redirect::upstream::HostedPin; | 20 | 20 | use socket_patch_core::vendor::{purl_keys_cover, RevertOpts, VendorState}; | 21 | 21 | use std::collections::{HashMap, HashSet}; | 22 | 22 | use std::path::{Path, PathBuf}; | @@ -1026,7 +1026,8 @@ pub(crate) async fn run_hosted_leg(common: &GlobalArgs, pins: &[HostedPin]) -> H | 1026 | 1026 | .iter() | 1027 | 1027 | .map(|(code, detail)| (code.to_string(), detail.clone())), | 1028 | 1028 | ); | 1029 | | - out.edited_files.extend(outcome.reverted_files.iter().cloned()); | | 1029 | + out.edited_files | | 1030 | + .extend(outcome.reverted_files.iter().cloned()); | 1030 | 1031 | let unwound: Vec<_> = vlt_targets | 1031 | 1032 | .into_iter() | 1032 | 1033 | .filter(|t| out.reverted.iter().any(|p| p == &t.purl)) | @@ -1170,7 +1171,11 @@ pub async fn run(args: RollbackArgs) -> i32 { | 1170 | 1171 | } else if !args.common.silent { | 1171 | 1172 | println!( | 1172 | 1173 | "{} the pre-v5 hosted ledger {}: no lockfile pins a hosted patch.", | 1173 | | - if args.common.dry_run { "Would remove" } else { "Removed" }, | | 1174 | + if args.common.dry_run { | | 1175 | + "Would remove" | | 1176 | + } else { | | 1177 | + "Removed" | | 1178 | + }, | 1174 | 1179 | socket_patch_core::patch::redirect::REDIRECT_STATE_REL | 1175 | 1180 | ); | 1176 | 1181 | } | |
Collapse file Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/scan/hosted.rs +43-11Lines changed: 43 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -934,7 +934,8 @@ pub(crate) async fn run_redirect_selected( | 934 | 934 | socket_patch_core::utils::fs::read_regular_to_string_sync(path).ok() | 935 | 935 | }) | 936 | 936 | }; | 937 | | - let rewrite_options = || RewriteOptions { | | 937 | + let rewrite_options = || { | | 938 | + RewriteOptions { | 938 | 939 | dry_run: common.dry_run, | 939 | 940 | targets_pipenv_lock, | 940 | 941 | pipenv_major, | @@ -946,6 +947,7 @@ pub(crate) async fn run_redirect_selected( | 946 | 947 | npm_allow_remote_config: !common.no_npm_allow_remote_config, | 947 | 948 | npm_outer: &npm_outer, | 948 | 949 | blocking: true, | | 950 | + } | 949 | 951 | }; | 950 | 952 | // The rollout gate plans again without its deferred rows: keep what | 951 | 953 | // the second pass needs. | @@ -2171,13 +2173,19 @@ fn join_names(names: &[String], max: usize) -> String { | 2171 | 2173 | /// artifacts, then verify with `vex`. After a vendored→hosted takeover | 2172 | 2174 | /// (`vendored_removed`) the commit also has to carry the deleted vendored | 2173 | 2175 | /// ledger entries and artifacts. | 2174 | | -fn format_next_steps(files: &[String], edits: &[socket_patch_core::patch::redirect::FileEdit], vendored_removed: bool) -> Vec<String> { | | 2176 | +fn format_next_steps( | | 2177 | + files: &[String], | | 2178 | + edits: &[socket_patch_core::patch::redirect::FileEdit], | | 2179 | + vendored_removed: bool, | | 2180 | +) -> Vec<String> { | 2175 | 2181 | if files.is_empty() && !vendored_removed { | 2176 | 2182 | return Vec::new(); | 2177 | 2183 | } | 2178 | 2184 | let mut commit: Vec<String> = Vec::new(); | 2179 | 2185 | if vendored_removed { | 2180 | | - commit.push(".socket/vendor/ (the removed vendored ledger entries and artifacts)".to_string()); | | 2186 | + commit.push( | | 2187 | + ".socket/vendor/ (the removed vendored ledger entries and artifacts)".to_string(), | | 2188 | + ); | 2181 | 2189 | } | 2182 | 2190 | commit.extend(files.iter().cloned()); | 2183 | 2191 | let npm = files | @@ -4162,19 +4170,43 @@ mod tests { | 4162 | 4170 | use super::npm_allow_remote_one_line; | 4163 | 4171 | let hosts = ["patch.socket.dev"]; | 4164 | 4172 | let cases = [ | 4165 | | - (npm_allow_remote_configured_detail(&hosts, true, false), "Note: set"), | 4166 | | - (npm_allow_remote_configured_detail(&hosts, false, false), "Note: set"), | 4167 | | - (npm_allow_remote_configured_detail(&hosts, true, true), "Note: would set"), | 4168 | | - (npm_allow_remote_already_detail(&hosts), "Note: .npmrc already"), | 4169 | | - (npm_allow_remote_user_set_detail(&hosts, "none"), "Warning: npm >=12"), | 4170 | | - (npm_allow_remote_env_set_detail(&hosts, "npm_config_allow_remote", "none"), "Warning: npm >=12"), | | 4173 | + ( | | 4174 | + npm_allow_remote_configured_detail(&hosts, true, false), | | 4175 | + "Note: set", | | 4176 | + ), | | 4177 | + ( | | 4178 | + npm_allow_remote_configured_detail(&hosts, false, false), | | 4179 | + "Note: set", | | 4180 | + ), | | 4181 | + ( | | 4182 | + npm_allow_remote_configured_detail(&hosts, true, true), | | 4183 | + "Note: would set", | | 4184 | + ), | | 4185 | + ( | | 4186 | + npm_allow_remote_already_detail(&hosts), | | 4187 | + "Note: .npmrc already", | | 4188 | + ), | | 4189 | + ( | | 4190 | + npm_allow_remote_user_set_detail(&hosts, "none"), | | 4191 | + "Warning: npm >=12", | | 4192 | + ), | | 4193 | + ( | | 4194 | + npm_allow_remote_env_set_detail(&hosts, "npm_config_allow_remote", "none"), | | 4195 | + "Warning: npm >=12", | | 4196 | + ), | 4171 | 4197 | (npm_allow_remote_manual_detail(&hosts), "Warning: npm >=12"), | 4172 | | - (npm_allow_remote_unreadable_detail(&hosts, "is a symlink"), "Warning: npm >=12"), | | 4198 | + ( | | 4199 | + npm_allow_remote_unreadable_detail(&hosts, "is a symlink"), | | 4200 | + "Warning: npm >=12", | | 4201 | + ), | 4173 | 4202 | ]; | 4174 | 4203 | for (detail, start) in cases { | 4175 | 4204 | let line = npm_allow_remote_one_line(&detail); | 4176 | 4205 | assert!(line.starts_with(start), "{line}"); | 4177 | | - assert!(!line.contains('\n') && line.ends_with("(details: --verbose)."), "{line}"); | | 4206 | + assert!( | | 4207 | + !line.contains('\n') && line.ends_with("(details: --verbose)."), | | 4208 | + "{line}" | | 4209 | + ); | 4178 | 4210 | } | 4179 | 4211 | } | 4180 | 4212 | } |
|