diff --git a/src/agent/coverage/src/block/linux.rs b/src/agent/coverage/src/block/linux.rs index 84de709a5..504c1c135 100644 --- a/src/agent/coverage/src/block/linux.rs +++ b/src/agent/coverage/src/block/linux.rs @@ -273,7 +273,7 @@ impl Images { } if image.region().contains(&va) { - return Some(&image); + return Some(image); } } diff --git a/src/agent/onefuzz-agent/build.rs b/src/agent/onefuzz-agent/build.rs index 2ee0fd94f..a78618016 100644 --- a/src/agent/onefuzz-agent/build.rs +++ b/src/agent/onefuzz-agent/build.rs @@ -38,7 +38,7 @@ fn print_version(include_sha: bool, include_local: bool, sha: &str) -> Result<() if include_sha { version.push('-'); - version.push_str(&sha); + version.push_str(sha); // if we're a non-release build, check to see if git has // unstaged changes diff --git a/src/agent/onefuzz-agent/src/local/libfuzzer.rs b/src/agent/onefuzz-agent/src/local/libfuzzer.rs index 1a546b75f..5d6822553 100644 --- a/src/agent/onefuzz-agent/src/local/libfuzzer.rs +++ b/src/agent/onefuzz-agent/src/local/libfuzzer.rs @@ -138,7 +138,7 @@ pub fn args(name: &'static str) -> App<'static, 'static> { let mut used = HashSet::new(); - for args in &[ + for args in [ build_fuzz_args(), build_crash_args(), build_analysis_args(false), diff --git a/src/agent/onefuzz-agent/src/local/libfuzzer_test_input.rs b/src/agent/onefuzz-agent/src/local/libfuzzer_test_input.rs index 225bc38cd..5d800f0f3 100644 --- a/src/agent/onefuzz-agent/src/local/libfuzzer_test_input.rs +++ b/src/agent/onefuzz-agent/src/local/libfuzzer_test_input.rs @@ -24,7 +24,7 @@ pub async fn run(args: &clap::ArgMatches<'_>, event_sender: Option App<'static, 'static> { let mut app = SubCommand::with_name(name).about("run a local generator & crash reporting job"); let mut used = HashSet::new(); - for args in &[build_fuzz_args(), build_crash_args()] { + for args in [build_fuzz_args(), build_crash_args()] { for arg in args { if used.contains(arg.b.name) { continue; diff --git a/src/agent/onefuzz-agent/src/local/test_input.rs b/src/agent/onefuzz-agent/src/local/test_input.rs index f32dfb2fe..88ee680a2 100644 --- a/src/agent/onefuzz-agent/src/local/test_input.rs +++ b/src/agent/onefuzz-agent/src/local/test_input.rs @@ -27,7 +27,7 @@ pub async fn run(args: &clap::ArgMatches<'_>, event_sender: Option) -> Result< let mut read_dir = fs::read_dir(&crashes.local_path).await?; while let Some(file) = read_dir.next_entry().await? { debug!("Processing file {:?}", file); - run_tool(file.path(), &config, &reports_dir).await?; + run_tool(file.path(), config, reports_dir).await?; count += 1; // sync the analysis container after every 10 inputs @@ -158,10 +158,10 @@ async fn poll_inputs( let input_url = message .parse(|data| BlobUrl::parse(str::from_utf8(data)?)) .with_context(|| format!("unable to parse URL from queue: {:?}", message))?; - if !already_checked(&config, &input_url).await? { + if !already_checked(config, &input_url).await? { let destination_path = _copy(input_url, &tmp_dir).await?; - run_tool(destination_path, &config, &reports_dir).await?; + run_tool(destination_path, config, reports_dir).await?; config.analysis.sync_push().await? } message.delete().await?; @@ -206,13 +206,13 @@ pub async fn run_tool( .job_id(&config.common.job_id) .task_id(&config.common.task_id) .set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| { - tester.microsoft_telemetry_key(&key) + tester.microsoft_telemetry_key(key) }) .set_optional_ref(&config.common.instance_telemetry_key, |tester, key| { - tester.instance_telemetry_key(&key) + tester.instance_telemetry_key(key) }) - .set_optional_ref(&reports_dir, |tester, reports_dir| { - tester.reports_dir(&reports_dir) + .set_optional_ref(reports_dir, |tester, reports_dir| { + tester.reports_dir(reports_dir) }) .set_optional_ref(&config.crashes, |tester, crashes| { tester diff --git a/src/agent/onefuzz-agent/src/tasks/fuzz/generator.rs b/src/agent/onefuzz-agent/src/tasks/fuzz/generator.rs index 7b9e58bd9..08ae72e30 100644 --- a/src/agent/onefuzz-agent/src/tasks/fuzz/generator.rs +++ b/src/agent/onefuzz-agent/src/tasks/fuzz/generator.rs @@ -164,10 +164,10 @@ impl GeneratorTask { .task_id(&self.config.common.task_id) .set_optional_ref( &self.config.common.microsoft_telemetry_key, - |tester, key| tester.microsoft_telemetry_key(&key), + |tester, key| tester.microsoft_telemetry_key(key), ) .set_optional_ref(&self.config.common.instance_telemetry_key, |tester, key| { - tester.instance_telemetry_key(&key) + tester.instance_telemetry_key(key) }) .set_optional_ref(&self.config.tools, |expand, tools| { expand.tools_dir(&tools.local_path) diff --git a/src/agent/onefuzz-agent/src/tasks/fuzz/supervisor.rs b/src/agent/onefuzz-agent/src/tasks/fuzz/supervisor.rs index 80973056d..df950c281 100644 --- a/src/agent/onefuzz-agent/src/tasks/fuzz/supervisor.rs +++ b/src/agent/onefuzz-agent/src/tasks/fuzz/supervisor.rs @@ -179,7 +179,7 @@ async fn start_supervisor( .runtime_dir(&runtime_dir) .crashes(&crashes.local_path) .input_corpus(&inputs.local_path) - .reports_dir(&reports_dir) + .reports_dir(reports_dir) .setup_dir(&config.common.setup_dir) .job_id(&config.common.job_id) .task_id(&config.common.task_id) @@ -196,10 +196,10 @@ async fn start_supervisor( expand.target_options(target_options) }) .set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| { - tester.microsoft_telemetry_key(&key) + tester.microsoft_telemetry_key(key) }) .set_optional_ref(&config.common.instance_telemetry_key, |tester, key| { - tester.instance_telemetry_key(&key) + tester.instance_telemetry_key(key) }) .set_optional_ref( &config.crashes.remote_path.clone().and_then(|u| u.account()), diff --git a/src/agent/onefuzz-agent/src/tasks/merge/generic.rs b/src/agent/onefuzz-agent/src/tasks/merge/generic.rs index f8b7df00e..92668e421 100644 --- a/src/agent/onefuzz-agent/src/tasks/merge/generic.rs +++ b/src/agent/onefuzz-agent/src/tasks/merge/generic.rs @@ -143,10 +143,10 @@ async fn merge(config: &Config, output_dir: impl AsRef) -> Result<()> { .job_id(&config.common.job_id) .task_id(&config.common.task_id) .set_optional_ref(&config.common.microsoft_telemetry_key, |tester, key| { - tester.microsoft_telemetry_key(&key) + tester.microsoft_telemetry_key(key) }) .set_optional_ref(&config.common.instance_telemetry_key, |tester, key| { - tester.instance_telemetry_key(&key) + tester.instance_telemetry_key(key) }); let supervisor_path = expand.evaluate_value(&config.supervisor_exe)?; diff --git a/src/agent/onefuzz-agent/src/tasks/regression/common.rs b/src/agent/onefuzz-agent/src/tasks/regression/common.rs index dd02f4bf9..05874dbd7 100644 --- a/src/agent/onefuzz-agent/src/tasks/regression/common.rs +++ b/src/agent/onefuzz-agent/src/tasks/regression/common.rs @@ -40,7 +40,7 @@ pub async fn run( crashes, report_dirs, report_list, - ®ression_reports, + regression_reports, &heartbeat_client, ) .await @@ -50,7 +50,7 @@ pub async fn run( handle_inputs( handler, readonly_inputs, - ®ression_reports, + regression_reports, &heartbeat_client, ) .await diff --git a/src/agent/onefuzz-agent/src/tasks/report/generic.rs b/src/agent/onefuzz-agent/src/tasks/report/generic.rs index 02a94ac0a..1bad25720 100644 --- a/src/agent/onefuzz-agent/src/tasks/report/generic.rs +++ b/src/agent/onefuzz-agent/src/tasks/report/generic.rs @@ -73,7 +73,7 @@ impl ReportTask { info!("processing existing crashes"); if let Some(crashes) = &self.config.crashes { - self.poller.batch_process(&mut processor, &crashes).await?; + self.poller.batch_process(&mut processor, crashes).await?; } info!("processing crashes from queue"); diff --git a/src/agent/onefuzz-agent/src/tasks/report/libfuzzer_report.rs b/src/agent/onefuzz-agent/src/tasks/report/libfuzzer_report.rs index c0af8502c..42f6784db 100644 --- a/src/agent/onefuzz-agent/src/tasks/report/libfuzzer_report.rs +++ b/src/agent/onefuzz-agent/src/tasks/report/libfuzzer_report.rs @@ -89,7 +89,7 @@ impl ReportTask { let mut processor = AsanProcessor::new(self.config.clone()).await?; if let Some(crashes) = &self.config.crashes { - self.poller.batch_process(&mut processor, &crashes).await?; + self.poller.batch_process(&mut processor, crashes).await?; } if self.config.check_queue { diff --git a/src/agent/onefuzz-supervisor/build.rs b/src/agent/onefuzz-supervisor/build.rs index ab8cedf84..0be8a9695 100644 --- a/src/agent/onefuzz-supervisor/build.rs +++ b/src/agent/onefuzz-supervisor/build.rs @@ -38,7 +38,7 @@ fn print_version(include_sha: bool, include_local: bool, sha: &str) -> Result<() if include_sha { version.push('-'); - version.push_str(&sha); + version.push_str(sha); // if we're a non-release build, check to see if git has // unstaged changes diff --git a/src/agent/onefuzz-supervisor/src/panic.rs b/src/agent/onefuzz-supervisor/src/panic.rs index d6a0cc591..dc7c94225 100644 --- a/src/agent/onefuzz-supervisor/src/panic.rs +++ b/src/agent/onefuzz-supervisor/src/panic.rs @@ -14,7 +14,7 @@ pub fn set_panic_handler() { SET_HOOK.call_once(move || { let old_hook = panic::take_hook(); panic::set_hook(Box::new(move |info| { - panic_hook(&info); + panic_hook(info); old_hook(info); })); }); diff --git a/src/agent/onefuzz/src/expand.rs b/src/agent/onefuzz/src/expand.rs index 0bcdcb5a9..a83a250a0 100644 --- a/src/agent/onefuzz/src/expand.rs +++ b/src/agent/onefuzz/src/expand.rs @@ -325,7 +325,7 @@ impl<'a> Expand<'a> { Ok(arg) } ExpandedValue::Scalar(v) => { - arg = arg.replace(fmtstr, &v); + arg = arg.replace(fmtstr, v); Ok(arg) } ExpandedValue::List(value) => { @@ -335,7 +335,7 @@ impl<'a> Expand<'a> { Ok(arg) } ExpandedValue::Mapping(func) => { - if let Some(value) = func(self, &fmtstr) { + if let Some(value) = func(self, fmtstr) { let arg = self.replace_value(fmtstr, arg, &value)?; Ok(arg) } else { diff --git a/src/agent/onefuzz/src/input_tester.rs b/src/agent/onefuzz/src/input_tester.rs index f704b3d1f..3057df20a 100644 --- a/src/agent/onefuzz/src/input_tester.rs +++ b/src/agent/onefuzz/src/input_tester.rs @@ -302,10 +302,10 @@ impl<'a> Tester<'a> { let expand = Expand::new() .input_path(input_file) .target_exe(&self.exe_path) - .target_options(&self.arguments) + .target_options(self.arguments) .setup_dir(&self.setup_dir); - let argv = expand.evaluate(&self.arguments)?; + let argv = expand.evaluate(self.arguments)?; let mut env: HashMap = HashMap::new(); for (k, v) in self.environ { env.insert(k.clone(), expand.evaluate_value(v)?); @@ -314,15 +314,15 @@ impl<'a> Tester<'a> { let setup_dir = &self.setup_dir.to_path_buf(); if self.add_setup_to_path { let new_path = match env.get(PATH) { - Some(v) => update_path(v.clone().into(), &setup_dir)?, - None => get_path_with_directory(PATH, &setup_dir)?, + Some(v) => update_path(v.clone().into(), setup_dir)?, + None => get_path_with_directory(PATH, setup_dir)?, }; env.insert(PATH.to_string(), new_path.to_string_lossy().to_string()); } if self.add_setup_to_ld_library_path { let new_path = match env.get(LD_LIBRARY_PATH) { - Some(v) => update_path(v.clone().into(), &setup_dir)?, - None => get_path_with_directory(LD_LIBRARY_PATH, &setup_dir)?, + Some(v) => update_path(v.clone().into(), setup_dir)?, + None => get_path_with_directory(LD_LIBRARY_PATH, setup_dir)?, }; env.insert( LD_LIBRARY_PATH.to_string(), @@ -348,7 +348,7 @@ impl<'a> Tester<'a> { Err(error) => (None, Some(error), None), } } else { - match run_cmd(&self.exe_path, argv.clone(), &env, self.timeout).await { + match run_cmd(self.exe_path, argv.clone(), &env, self.timeout).await { Ok(output) => (None, None, Some(output)), Err(error) => (None, Some(error), None), } diff --git a/src/agent/onefuzz/src/libfuzzer.rs b/src/agent/onefuzz/src/libfuzzer.rs index fa5fb30c3..dabfe1001 100644 --- a/src/agent/onefuzz/src/libfuzzer.rs +++ b/src/agent/onefuzz/src/libfuzzer.rs @@ -80,7 +80,7 @@ impl<'a> LibFuzzer<'a> { let expand = Expand::new() .target_exe(&self.exe) - .target_options(&self.options) + .target_options(self.options) .setup_dir(&self.setup_dir) .set_optional(corpus_dir, |tester, corpus_dir| { tester.input_corpus(&corpus_dir) @@ -141,7 +141,7 @@ impl<'a> LibFuzzer<'a> { files.shuffle(&mut rng); } for file in files.iter().take(5) { - self.check_input(&file).await.with_context(|| { + self.check_input(file).await.with_context(|| { format!("checking input corpus: {}", file.display()) })?; seen_inputs = true; @@ -243,7 +243,7 @@ impl<'a> LibFuzzer<'a> { let mut options = self.options.to_owned(); options.push("{input}".to_string()); - let mut tester = Tester::new(&self.setup_dir, &self.exe, &options, &self.env) + let mut tester = Tester::new(&self.setup_dir, &self.exe, &options, self.env) .check_asan_stderr(true) .check_retry_count(retry) .add_setup_to_path(true) diff --git a/src/agent/onefuzz/src/monitor.rs b/src/agent/onefuzz/src/monitor.rs index d9b752d9a..1c162e7d8 100644 --- a/src/agent/onefuzz/src/monitor.rs +++ b/src/agent/onefuzz/src/monitor.rs @@ -14,7 +14,6 @@ pub struct DirectoryMonitor { dir: PathBuf, notify_events: UnboundedReceiver, watcher: notify::RecommendedWatcher, - terminated: bool, } impl DirectoryMonitor { @@ -32,7 +31,6 @@ impl DirectoryMonitor { dir, notify_events, watcher, - terminated: false, } } @@ -47,7 +45,6 @@ impl DirectoryMonitor { } pub fn stop(&mut self) -> Result<()> { - self.terminated = true; self.watcher.unwatch(self.dir.clone())?; Ok(()) } diff --git a/src/agent/onefuzz/src/triage.rs b/src/agent/onefuzz/src/triage.rs index 62e847835..9e7d70ede 100644 --- a/src/agent/onefuzz/src/triage.rs +++ b/src/agent/onefuzz/src/triage.rs @@ -285,7 +285,7 @@ impl From for Address { // Find the module-relative address of `addr`, if it exists. fn find_module_rva(addr: u64, maps: &[MapRange]) -> Option { - let mapping = find_mapping(addr, &maps)?; + let mapping = find_mapping(addr, maps)?; // Offset into the mapped image of some object file, but _not_ // the file itself. diff --git a/src/agent/stacktrace-parser/src/asan.rs b/src/agent/stacktrace-parser/src/asan.rs index 0c5f756cc..c123c1de4 100644 --- a/src/agent/stacktrace-parser/src/asan.rs +++ b/src/agent/stacktrace-parser/src/asan.rs @@ -151,13 +151,13 @@ pub(crate) fn parse_summary_base(text: &str) -> Option<(String, String, String)> } pub(crate) fn parse_summary(text: &str) -> Result<(String, String, String)> { - if let Some((summary, sanitizer, fault_type)) = parse_summary_base(&text) { + if let Some((summary, sanitizer, fault_type)) = parse_summary_base(text) { return Ok((summary, sanitizer, fault_type)); } - if let Some((summary, sanitizer, fault_type)) = parse_asan_abort_error(&text) { + if let Some((summary, sanitizer, fault_type)) = parse_asan_abort_error(text) { return Ok((summary, sanitizer, fault_type)); } - if let Some((summary, sanitizer, fault_type)) = parse_asan_runtime_error(&text) { + if let Some((summary, sanitizer, fault_type)) = parse_asan_runtime_error(text) { return Ok((summary, sanitizer, fault_type)); } diff --git a/src/agent/stacktrace-parser/src/lib.rs b/src/agent/stacktrace-parser/src/lib.rs index 446862166..19a97b49f 100644 --- a/src/agent/stacktrace-parser/src/lib.rs +++ b/src/agent/stacktrace-parser/src/lib.rs @@ -165,11 +165,11 @@ impl CrashLog { let stack_filter = get_stack_filter(); let mut minimized_stack_details: Vec = stack .iter() - .filter_map(|x| filter_funcs(x, &stack_filter)) + .filter_map(|x| filter_funcs(x, stack_filter)) .collect(); // if we don't have a minimized stack, if one of these functions is on // the stack, use it - for entry in &[ + for entry in [ "LLVMFuzzerTestOneInput", "fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long)", "main", @@ -177,7 +177,7 @@ impl CrashLog { if !minimized_stack_details.is_empty() { break; } - let value = Some(String::from(*entry)); + let value = Some(entry.to_string()); minimized_stack_details = stack .iter() .filter_map(|x| { @@ -268,13 +268,13 @@ fn stack_function_lines(stack: &[StackEntry]) -> Vec { fn parse_summary(text: &str) -> Result<(String, String, String)> { // eventually, this should be updated to support multiple callstack formats - asan::parse_summary(&text) + asan::parse_summary(text) } fn parse_scariness(text: &str) -> (Option, Option) { // eventually, this should be updated to support multiple callstack formats, // including building this value - match asan::parse_scariness(&text) { + match asan::parse_scariness(text) { Some((x, y)) => (Some(x), Some(y)), None => (None, None), } diff --git a/src/agent/win-util/src/aedebug.rs b/src/agent/win-util/src/aedebug.rs index 597a88982..9e8a5c246 100644 --- a/src/agent/win-util/src/aedebug.rs +++ b/src/agent/win-util/src/aedebug.rs @@ -26,7 +26,7 @@ fn edit_exclusion_list ::core::result::Result<(), std::io::Erro let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); // We want to set both the 32 and 64 bit registries. - for flags in &[0, KEY_WOW64_32KEY] { + for flags in [0, KEY_WOW64_32KEY] { let exclusion_list = hklm .open_subkey_with_flags(AEDEBUG_EXCLUSION_LIST, KEY_SET_VALUE | flags) .context("Opening AeDebug\\AutoExclusionList")?;