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
16 changes: 8 additions & 8 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions cli/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl PhylumApi {
// here and be done.
headers.insert(
"Authorization",
HeaderValue::from_str(&format!("Bearer {}", access_token)).unwrap(),
HeaderValue::from_str(&format!("Bearer {access_token}")).unwrap(),
);
headers.insert("Accept", HeaderValue::from_str("application/json").unwrap());

Expand Down Expand Up @@ -376,7 +376,7 @@ impl PhylumApi {
label: label.unwrap_or_else(|| "uncategorized".to_string()),
group_name,
};
log::debug!("==> Sending package submission: {:?}", req);
log::debug!("==> Sending package submission: {req:?}");
let resp: SubmitPackageResponse =
self.post(endpoints::post_submit_job(&self.config.connection.uri)?, req).await?;
Ok(resp.job_id)
Expand Down Expand Up @@ -451,7 +451,7 @@ impl PhylumApi {
&& project.organization_name.as_deref() == org
&& project.group_name.as_deref() == group
})
.ok_or_else(|| anyhow!("No project found with name {:?}", project_name).into())
.ok_or_else(|| anyhow!("No project found with name {project_name:?}").into())
.map(|project| project.id)
}

Expand Down Expand Up @@ -784,7 +784,7 @@ mod tests {

// Request should have been submitted with a bearer token
let bearer_token = token_holder.lock().unwrap().take();
assert_eq!(Some(format!("Bearer {}", DUMMY_ACCESS_TOKEN)), bearer_token);
assert_eq!(Some(format!("Bearer {DUMMY_ACCESS_TOKEN}")), bearer_token);

Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions cli/src/auth/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ async fn spawn_server_and_get_auth_code(

// Get OIDC auth url.
let state = state.into();
let callback_url = Url::parse(&format!("http://{}/", auth_address))?;
let callback_url = Url::parse(&format!("http://{auth_address}/"))?;
let authorization_url =
build_auth_url(redirect_type, locksmith_settings, &callback_url, code_challenge, &state)?;
debug!("Authorization url is {}", authorization_url);
debug!("Authorization url is {authorization_url}");

// Ensure external auth urls use https, rather than http.
let auth_host = authorization_url
Expand Down Expand Up @@ -162,7 +162,7 @@ async fn spawn_server_and_get_auth_code(
let router = Router::new().route("/", get(keycloak_callback_handler)).with_state(state.clone());

// Start server.
debug!("Starting local login server at {:?}", auth_address);
debug!("Starting local login server at {auth_address:?}");
axum::serve(listener, router)
.with_graceful_shutdown(async move { notify.notified().await })
.await?;
Expand Down Expand Up @@ -235,7 +235,7 @@ mod test {

let result = handle_auth_flow(AuthAction::Login, None, None, false, &api_uri).await?;

debug!("{:?}", result);
debug!("{result:?}");

Ok(())
}
Expand All @@ -251,7 +251,7 @@ mod test {

let result = handle_auth_flow(AuthAction::Register, None, None, false, &api_uri).await?;

debug!("{:?}", result);
debug!("{result:?}");

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/bin/phylum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async fn check_for_updates(config: &mut Config) -> Result<()> {

// Update last update check timestamp.
config.last_update = Some(now);
config.save().unwrap_or_else(|e| log::error!("Failed to save config: {}", e));
config.save().unwrap_or_else(|e| log::error!("Failed to save config: {e}"));

if update::needs_update(false).await {
print::print_update_message();
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub async fn handle_auth_token(config: &Config, matches: &clap::ArgMatches) -> C
let api_uri = &config.connection.uri;
let access_token =
auth::renew_access_token(refresh_token, config.ignore_certs(), api_uri).await?;
println!("{}", access_token);
println!("{access_token}");
Ok(ExitCode::Ok)
} else {
println!("{refresh_token}");
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn add_extensions_subcommands(command: Command) -> Command {
let extensions = match installed_extensions() {
Ok(extensions) => extensions,
Err(e) => {
error!("Couldn't list extensions: {}", e);
error!("Couldn't list extensions: {e}");
return command;
},
};
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/find_dependency_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ use crate::commands::{CommandResult, ExitCode};
pub fn handle_command() -> CommandResult {
let depfiles = phylum_lockfile::DepFiles::find_at(".");
let json = serde_json::to_string(&depfiles)?;
println!("{}", json);
println!("{json}");
Ok(ExitCode::Ok)
}
4 changes: 2 additions & 2 deletions cli/src/commands/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ pub async fn handle_analyze(
jobs_project.group,
)
.await?;
debug!("Response => {:?}", job_id);
debug!("Response => {job_id:?}");

if pretty_print {
print_user_success!("Job ID: {}", job_id);
print_user_success!("Job ID: {job_id}");

#[cfg(feature = "vulnreach")]
let packages: Vec<_> = packages
Expand Down
8 changes: 4 additions & 4 deletions cli/src/commands/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async fn handle_create_project(
let group = matches.get_one::<String>("group").cloned();
let org = config.org();

log::info!("Initializing new project: `{}`", project);
log::info!("Initializing new project: `{project}`");

let project_config =
create_project(api, project, org.map(|org| org.into()), group.clone(), repository_url)
Expand All @@ -121,14 +121,14 @@ async fn handle_create_project(
Ok(project) => project,
Err(PhylumApiError::Response(ResponseError { code: StatusCode::CONFLICT, .. })) => {
let formatted_project = format_project_reference(org, group.as_deref(), project, None);
print_user_failure!("Project {} already exists", formatted_project);
print_user_failure!("Project {formatted_project} already exists");
return Ok(ExitCode::AlreadyExists);
},
Err(err) => return Err(err.into()),
};

config::save_config(Path::new(PROJ_CONF_FILE), &project_config).unwrap_or_else(|err| {
print_user_failure!("Failed to save project file: {}", err);
print_user_failure!("Failed to save project file: {err}");
});

let project_id = Some(project_config.id.to_string());
Expand Down Expand Up @@ -307,7 +307,7 @@ async fn handle_link_project(
};

config::save_config(Path::new(PROJ_CONF_FILE), &project_config)
.unwrap_or_else(|err| log::error!("Failed to save user credentials to config: {}", err));
.unwrap_or_else(|err| log::error!("Failed to save user credentials to config: {err}"));

let project_id = Some(project_config.id.to_string());
let formatted_project =
Expand Down
12 changes: 6 additions & 6 deletions cli/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait Format: Serialize {
/// Output JSON format.
fn json<W: Write>(&self, writer: &mut W) {
let json = serde_json::to_string_pretty(&self).unwrap_or_else(|e| {
log::error!("Failed to serialize json response: {}", e);
log::error!("Failed to serialize json response: {e}");
"".to_string()
});
let _ = writeln!(writer, "{json}");
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Format for PhylumStatus {
) {
let label = style(label).blue();
let _ = match option {
Some(value) => writeln!(writer, "{label}: {}", value),
Some(value) => writeln!(writer, "{label}: {value}"),
None => writeln!(writer, "{label}: {}", style("null").italic().green()),
};
}
Expand Down Expand Up @@ -138,7 +138,7 @@ impl Format for PolicyEvaluationResponseRaw {
let domain = rejection
.source
.domain
.map_or_else(|| " ".into(), |domain| format!("[{}]", domain));
.map_or_else(|| " ".into(), |domain| format!("[{domain}]"));
let message = format!("{domain} {}", rejection.title);

let colored = match rejection.source.severity {
Expand All @@ -147,7 +147,7 @@ impl Format for PolicyEvaluationResponseRaw {
_ => style(message).red(),
};

let _ = writeln!(writer, " {}", colored);
let _ = writeln!(writer, " {colored}");
}
}
if !self.dependencies.is_empty() {
Expand All @@ -156,7 +156,7 @@ impl Format for PolicyEvaluationResponseRaw {

// Print web URI for the job results.
if let Some(job_link) = &self.job_link {
let _ = writeln!(writer, "You can find the interactive report here:\n {}", job_link);
let _ = writeln!(writer, "You can find the interactive report here:\n {job_link}");
}
}
}
Expand Down Expand Up @@ -508,7 +508,7 @@ impl Format for Vulnerability {
// Print the callchain as arrow-separated packages.
let _ = write!(writer, " {}", path[0]);
for package in &path[1..] {
let _ = write!(writer, " {} {}", arrow, package);
let _ = write!(writer, " {arrow} {package}");
}

let _ = writeln!(writer);
Expand Down
4 changes: 2 additions & 2 deletions cli/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub mod mockito {
query_params.get("redirect_uri").expect("redirect_uri not set").to_string();
ResponseTemplate::new(302).insert_header::<&str, &str>(
"Location",
&format!("{redirect_uri}/?code={}", DUMMY_AUTH_CODE),
&format!("{redirect_uri}/?code={DUMMY_AUTH_CODE}"),
)
})
.mount(&mock_server)
Expand Down Expand Up @@ -202,7 +202,7 @@ pub mod open {
Url::from_str(redirect_uri).expect("Failed to parse redirect_uri");
callback_url.query_pairs_mut().append_pair("code", code).append_pair("state", state);

log::debug!("Calling callback url: {}", callback_url);
log::debug!("Calling callback url: {callback_url}");

// Wait for the server to be up
tokio::time::sleep(Duration::from_millis(100)).await;
Expand Down
6 changes: 3 additions & 3 deletions cli/src/update/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn needs_update(prerelease: bool) -> bool {
match updater.get_latest_version(prerelease).await {
Ok(latest) => updater.needs_update(CURRENT_VERSION, &latest),
Err(e) => {
log::debug!("Failed to get the latest version for update check: {:?}", e);
log::debug!("Failed to get the latest version for update check: {e:?}");
false
},
}
Expand Down Expand Up @@ -150,7 +150,7 @@ impl ApplicationUpdater {
self.http_get_json::<GithubRelease>(&url).await?
};

log::debug!("Found latest version: {:?}", ver);
log::debug!("Found latest version: {ver:?}");

Ok(ver)
}
Expand Down Expand Up @@ -259,7 +259,7 @@ mod tests {

let updater = ApplicationUpdater::build_test_instance(mock_server);
let latest = updater.get_latest_version(false).await.unwrap();
log::error!("{:?}", latest);
log::error!("{latest:?}");
assert!("v1.2.3" == latest.tag_name);
assert!(updater.needs_update("1.0.2", &latest));

Expand Down
6 changes: 3 additions & 3 deletions cli/tests/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ fn fs_sandboxing_success() {
let js = format!("
const output = Phylum.runSandboxed({{
cmd: 'cat',
args: ['{}'],
exceptions: {{ run: true, read: ['{0:}'] }},
args: ['{file_path}'],
exceptions: {{ run: true, read: ['{file_path}'] }},
}});
Deno.exit(output.code);
", file_path);
");

test_cli
.extension(&js)
Expand Down
2 changes: 1 addition & 1 deletion lockfile/src/cyclonedx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ mod tests {
for path_str in test_paths {
let path_buf = PathBuf::from(path_str);
let is_lockfile = CycloneDX.is_path_lockfile(&path_buf);
assert!(is_lockfile, "Failed for path: {}", path_str);
assert!(is_lockfile, "Failed for path: {path_str}");
}
}

Expand Down
14 changes: 5 additions & 9 deletions lockfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ mod tests {

for (file, expected_type) in test_cases {
let pkg_type = get_path_format(Path::new(file));
assert_eq!(pkg_type, Some(*expected_type), "{}", file);
assert_eq!(pkg_type, Some(*expected_type), "{file}");
}
}

Expand Down Expand Up @@ -558,11 +558,10 @@ mod tests {
("cyclonedx", LockfileFormat::CycloneDX),
] {
let actual_format =
name.parse().unwrap_or_else(|e| panic!("Could not parse {:?}: {}", name, e));
name.parse().unwrap_or_else(|e| panic!("Could not parse {name:?}: {e}"));
assert_eq!(
expected_format, actual_format,
"{:?} should parse as {:?}",
name, expected_format,
"{name:?} should parse as {expected_format:?}",
);
}
}
Expand Down Expand Up @@ -591,8 +590,7 @@ mod tests {
let actual_name = format.to_string();
assert_eq!(
expected_name, &actual_name,
"{:?} should to_string as {:?}",
format, expected_name,
"{format:?} should to_string as {expected_name:?}",
);
}
}
Expand All @@ -604,9 +602,7 @@ mod tests {
assert_eq!(
&expected_name,
format.name(),
"{:?}.name() should be {:?}",
format,
expected_name,
"{format:?}.name() should be {expected_name:?}",
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lockfile/src/parse_depfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn try_get_packages(path: impl Into<String>, contents: &str) -> Result<ParsedLoc
for format in LockfileFormat::iter() {
let parser = format.parser();
if let Some(packages) = parser.parse(contents).ok().filter(|pkgs| !pkgs.is_empty()) {
log::info!("Identified lockfile type: {}", format);
log::info!("Identified lockfile type: {format}");

let packages = filter_packages(packages);

Expand Down Expand Up @@ -246,7 +246,7 @@ mod tests {
for (path, expected_format) in test_cases {
let contents = fs::read_to_string(path).unwrap();
let parsed = try_get_packages(path, &contents).unwrap();
assert_eq!(parsed.format, expected_format, "{}", path);
assert_eq!(parsed.format, expected_format, "{path}");
}
}
}
Loading