Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.

Commit f06ac21

Browse files
committed
Use new format!() syntax
1 parent 0e84060 commit f06ac21

File tree

8 files changed

+20
-23
lines changed

8 files changed

+20
-23
lines changed

src/aws.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn check_aws_keys(matches: Vec<ScannerMatch>) -> Result<Vec<LiveKey>> {
6767
});
6868
}
6969
Err(e) => {
70-
eprintln!("sts error: {:?}", e);
70+
eprintln!("sts error: {e:?}");
7171
continue;
7272
}
7373
}

src/main.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ fn run(state_path: PathBuf, save: bool, limit: usize, sources: Vec<SourceType>)
8181
.map(|s| -> Result<_> {
8282
let source_data = state.data_for_source(&s);
8383
let mut source = s.create_source(source_data).expect("Error creating source");
84-
println!("Fetching data for source {}", source);
84+
println!("Fetching data for source {source}");
8585
let packages = source
8686
.get_new_packages_to_process(limit)
87-
.with_context(|| format!("Failed to get packages to process for source {:?}", s))?;
87+
.with_context(|| format!("Failed to get packages to process for source {s:?}"))?;
8888
println!("Source {:?} found {} packages", s, packages.len());
8989
let stats = source.get_stats();
9090
stats.add_packages_searched(packages.len() as u64);
@@ -114,13 +114,11 @@ fn run(state_path: PathBuf, save: bool, limit: usize, sources: Vec<SourceType>)
114114
let source = download.package.source.clone();
115115
let result = scanner.quick_check(download).with_context(|| {
116116
format!(
117-
"Error running quick check on {:?} / {} @ {}",
118-
source, name, version
117+
"Error running quick check on {source:?} / {name} @ {version}"
119118
)
120119
});
121120
println!(
122-
"Finished quick check on {:?} / {} @ {}",
123-
source, name, version
121+
"Finished quick check on {source:?} / {name} @ {version}"
124122
);
125123
result
126124
})
@@ -143,7 +141,7 @@ fn run(state_path: PathBuf, save: bool, limit: usize, sources: Vec<SourceType>)
143141

144142
let live_keys = check_aws_keys(all_matches?.into_iter().flatten().collect())
145143
.context("Error checking AWS keys")?;
146-
println!("Live keys: {:?}", live_keys);
144+
println!("Live keys: {live_keys:?}");
147145

148146
create_findings(live_keys)?;
149147

src/reporter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn create_findings(items: Vec<LiveKey>) -> Result<()> {
8787
));
8888
let _ = fs::create_dir_all(output_dir);
8989
fs::write(&output_path, rendered).unwrap();
90-
println!("Created file {:?}", output_path);
90+
println!("Created file {output_path:?}");
9191
}
9292
Ok(())
9393
}

src/scanners/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl Scanner {
116116
"--json",
117117
package.downloaded_package.extract_dir.to_str().unwrap(),
118118
])?;
119-
println!("matches: {:?}", matches);
119+
println!("matches: {matches:?}");
120120
let mut matched_keys = vec![];
121121
// The output may contain multiple matches for our second-stage regex.
122122
// Here we create a cartesian product product of all matches.

src/scanners/ripgrep.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ pub fn run_ripgrep(args: &[&str]) -> Result<Vec<RipGrepMatch>> {
3636
let output = Command::new("rg")
3737
.args(args)
3838
.output()
39-
.with_context(|| format!("Error running rg with args {:?}", args))?;
39+
.with_context(|| format!("Error running rg with args {args:?}"))?;
4040

4141
if !output.stderr.is_empty() {
4242
for line in output.stderr.lines().flatten() {
43-
eprintln!("{}", line);
43+
eprintln!("{line}");
4444
}
4545
}
4646

src/sources/hexpm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Source for HexPmSource {
6060
if results.len() >= limit {
6161
break;
6262
}
63-
let url = format!("{}&page={}", base_url, page);
63+
let url = format!("{base_url}&page={page}");
6464
// ToDo: Replace the user agent with a link to the repo
6565
let response = client
6666
.get(url)

src/sources/pypi.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Source for PyPiSource {
5757
Request::new("changelog_since_serial").arg(self.changelog_serial as i32);
5858
let res = changelog_request
5959
.call_url("https://pypi.org/pypi")
60-
.with_context(|| format!("Error getting changelog serial: {:?}", changelog_request))?;
60+
.with_context(|| format!("Error getting changelog serial: {changelog_request:?}"))?;
6161
let changelog_items: Vec<_> = match res {
6262
Value::Array(items) => {
6363
let only_xml_vecs = items.iter().filter_map(|item| match item {
@@ -84,7 +84,7 @@ impl Source for PyPiSource {
8484
.max_by_key(|v| *v)
8585
.ok_or_else(|| anyhow!("No changelog items found"))?;
8686

87-
println!("Highest timestamp: {}", highest_datetime);
87+
println!("Highest timestamp: {highest_datetime}");
8888

8989
self.changelog_serial = highest_serial;
9090
self.last_package_timestamp = Some(highest_datetime);
@@ -105,7 +105,7 @@ impl Source for PyPiSource {
105105
.into_par_iter()
106106
.map(|((name, version), changelogs)| {
107107
fetch_download_url_for_package(&name, &version, changelogs)
108-
.with_context(|| format!("Error fetching PyPi package {} - {}", name, version))
108+
.with_context(|| format!("Error fetching PyPi package {name} - {version}"))
109109
})
110110
.collect();
111111
let mut flattened_packages: Vec<_> = packages_to_process
@@ -177,7 +177,7 @@ fn fetch_download_url_for_package(
177177
.get(&url)
178178
.header("User-Agent", "https://github.com/orf/aws-creds-scanner")
179179
.send()
180-
.with_context(|| format!("Failed to request URL {}", url))?;
180+
.with_context(|| format!("Failed to request URL {url}"))?;
181181
// Some versions are not valid URLs. For example, `weightless-core @ 0.5.2.3-seecr-%`
182182
// These result in 400's, in which case we just return [].
183183
if response.status() == 404 || response.status() == 400 {
@@ -189,11 +189,10 @@ fn fetch_download_url_for_package(
189189

190190
let text = response
191191
.text()
192-
.with_context(|| format!("Error fetching text for URL {}", url))?;
192+
.with_context(|| format!("Error fetching text for URL {url}"))?;
193193
let response: PyPiResponse = serde_json::from_str(&text).with_context(|| {
194194
format!(
195-
"Failed to read JSON for URL {} - Status: {}. Text: {}",
196-
url, status, text
195+
"Failed to read JSON for URL {url} - Status: {status}. Text: {text}"
197196
)
198197
})?;
199198

src/sources/rubygems.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ impl Source for RubyGemsSource {
6161
if results.len() >= limit {
6262
break;
6363
}
64-
let url = format!("{}&page={}", base_url, page);
64+
let url = format!("{base_url}&page={page}");
6565
let response = reqwest::blocking::get(&url)
66-
.with_context(|| format!("Failed to request {}", url))?;
66+
.with_context(|| format!("Failed to request {url}"))?;
6767
let ruby_response: Vec<RubyGemsResponse> = response
6868
.json()
69-
.with_context(|| format!("Failed to parse JSON from {}", url))?;
69+
.with_context(|| format!("Failed to parse JSON from {url}"))?;
7070
if ruby_response.is_empty() {
7171
break;
7272
} else {

0 commit comments

Comments
 (0)