Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/src/api/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
4 changes: 2 additions & 2 deletions cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 5 additions & 5 deletions cli/src/bin/phylum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fn exit_fail(message: impl Display, exit_code: ExitCode) -> ! {
async fn api_factory(config: Config, timeout: Option<u64>) -> Result<PhylumApi> {
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()
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/extensions/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 4 additions & 3 deletions cli/src/commands/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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"));
Expand Down
35 changes: 19 additions & 16 deletions cli/src/commands/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ fn depfile_parsing_sandbox(canonical_manifest_path: &Path) -> Result<Birdcage> {

// 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()))?;

Expand Down Expand Up @@ -577,43 +577,46 @@ 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();
File::create(&lockfile_path).unwrap();

// 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"));
}
}
4 changes: 2 additions & 2 deletions cli/src/commands/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading
Loading