Skip to content

Commit 2eeeb01

Browse files
committed
Bump MSRV for rustsec to 1.88 (for time)
1 parent 5a1cc15 commit 2eeeb01

File tree

8 files changed

+88
-90
lines changed

8 files changed

+88
-90
lines changed

.github/workflows/cargo-audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
persist-credentials: false
6969
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
7070
with:
71-
toolchain: 1.85.0
71+
toolchain: 1.88.0
7272
override: true
7373
profile: minimal
7474
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

.github/workflows/rustsec.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
matrix:
3030
rust:
31-
- 1.85.0 # MSRV
31+
- 1.88.0 # MSRV
3232
- stable
3333
steps:
3434
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -53,7 +53,7 @@ jobs:
5353
persist-credentials: false
5454
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
5555
with:
56-
toolchain: 1.85.0 # MSRV
56+
toolchain: 1.88.0 # MSRV
5757
override: true
5858
profile: minimal
5959
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2

cargo-audit/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
categories = ["development-tools::cargo-plugins"]
1111
keywords = ["cargo-subcommand", "security", "audit", "vulnerability"]
1212
edition = "2024"
13-
rust-version = "1.85"
13+
rust-version = "1.88"
1414
exclude = ["tests/"]
1515

1616
[badges]

cargo-audit/src/auditor.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ impl Auditor {
6262
);
6363
// If the directory is locked, print a message and wait for it to become unlocked.
6464
// If we don't print the message, `cargo audit` would just hang with no explanation.
65-
if let Err(e) = &result {
66-
if e.kind() == ErrorKind::LockTimeout {
67-
status_warn!(
68-
"directory {} is locked, waiting for up to {} seconds for it to become available",
69-
advisory_db_path.display(),
70-
DEFAULT_LOCK_TIMEOUT.as_secs()
71-
);
72-
result = rustsec::repository::git::Repository::fetch(
73-
advisory_db_url,
74-
&advisory_db_path,
75-
!config.database.stale,
76-
DEFAULT_LOCK_TIMEOUT,
77-
);
78-
}
65+
if let Err(e) = &result
66+
&& e.kind() == ErrorKind::LockTimeout
67+
{
68+
status_warn!(
69+
"directory {} is locked, waiting for up to {} seconds for it to become available",
70+
advisory_db_path.display(),
71+
DEFAULT_LOCK_TIMEOUT.as_secs()
72+
);
73+
result = rustsec::repository::git::Repository::fetch(
74+
advisory_db_url,
75+
&advisory_db_path,
76+
!config.database.stale,
77+
DEFAULT_LOCK_TIMEOUT,
78+
);
7979
}
8080

8181
let advisory_db_repo = result.unwrap_or_else(|e| {
@@ -122,15 +122,15 @@ impl Auditor {
122122

123123
// If the directory is locked, print a message and wait for it to become unlocked.
124124
// If we don't print the message, `cargo audit` would just hang with no explanation.
125-
if let Err(e) = &result {
126-
if e.kind() == ErrorKind::LockTimeout {
127-
status_warn!(
128-
"directory {} is locked, waiting for up to {} seconds for it to become available",
129-
advisory_db_path.display(),
130-
DEFAULT_LOCK_TIMEOUT.as_secs()
131-
);
132-
result = registry::CachedIndex::fetch(DEFAULT_LOCK_TIMEOUT);
133-
}
125+
if let Err(e) = &result
126+
&& e.kind() == ErrorKind::LockTimeout
127+
{
128+
status_warn!(
129+
"directory {} is locked, waiting for up to {} seconds for it to become available",
130+
advisory_db_path.display(),
131+
DEFAULT_LOCK_TIMEOUT.as_secs()
132+
);
133+
result = registry::CachedIndex::fetch(DEFAULT_LOCK_TIMEOUT);
134134
}
135135

136136
match result {
@@ -148,15 +148,15 @@ impl Auditor {
148148

149149
// If the directory is locked, print a message and wait for it to become unlocked.
150150
// If we don't print the message, `cargo audit` would just hang with no explanation.
151-
if let Err(e) = &result {
152-
if e.kind() == ErrorKind::LockTimeout {
153-
status_warn!(
154-
"directory {} is locked, waiting for up to {} seconds for it to become available",
155-
advisory_db_path.display(),
156-
DEFAULT_LOCK_TIMEOUT.as_secs()
157-
);
158-
result = registry::CachedIndex::open(DEFAULT_LOCK_TIMEOUT)
159-
}
151+
if let Err(e) = &result
152+
&& e.kind() == ErrorKind::LockTimeout
153+
{
154+
status_warn!(
155+
"directory {} is locked, waiting for up to {} seconds for it to become available",
156+
advisory_db_path.display(),
157+
DEFAULT_LOCK_TIMEOUT.as_secs()
158+
);
159+
result = registry::CachedIndex::open(DEFAULT_LOCK_TIMEOUT)
160160
}
161161

162162
match result {

rustsec/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
categories = ["api-bindings", "development-tools"]
1111
keywords = ["audit", "rustsec", "security", "advisory", "vulnerability"]
1212
edition = "2024"
13-
rust-version = "1.85"
13+
rust-version = "1.88"
1414

1515
[dependencies]
1616
cargo-lock = { workspace = true }

rustsec/src/advisory/linter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ impl Linter {
157157
}
158158
}
159159
"url" => {
160-
if let Some(url) = value.as_str() {
161-
if !url.starts_with("https://") {
162-
self.errors.push(Error {
163-
kind: ErrorKind::value("url", value.to_string()),
164-
section: Some("advisory"),
165-
message: Some("URL must start with https://"),
166-
});
167-
}
160+
if let Some(url) = value.as_str()
161+
&& !url.starts_with("https://")
162+
{
163+
self.errors.push(Error {
164+
kind: ErrorKind::value("url", value.to_string()),
165+
section: Some("advisory"),
166+
message: Some("URL must start with https://"),
167+
});
168168
}
169169
}
170170
"date" => {

rustsec/src/database.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,20 @@ impl Database {
120120
/// Query the database according to the given query object
121121
pub fn query(&self, query: &Query) -> Vec<&Advisory> {
122122
// Use indexes if we know a package name and collection
123-
if let Some(name) = &query.package_name {
124-
if let Some(collection) = query.collection {
125-
return match collection {
126-
Collection::Crates => self.crate_index.get(name),
127-
Collection::Rust => self.rust_index.get(name),
128-
}
129-
.map(|slots| {
130-
slots
131-
.map(|slot| self.advisories.get(*slot).unwrap())
132-
.filter(|advisory| query.matches(advisory))
133-
.collect()
134-
})
135-
.unwrap_or_else(Vec::new);
123+
if let Some(name) = &query.package_name
124+
&& let Some(collection) = query.collection
125+
{
126+
return match collection {
127+
Collection::Crates => self.crate_index.get(name),
128+
Collection::Rust => self.rust_index.get(name),
136129
}
130+
.map(|slots| {
131+
slots
132+
.map(|slot| self.advisories.get(*slot).unwrap())
133+
.filter(|advisory| query.matches(advisory))
134+
.collect()
135+
})
136+
.unwrap_or_else(Vec::new);
137137
}
138138

139139
self.iter()

rustsec/src/database/query.rs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,22 @@ impl Query {
160160

161161
/// Does this query match a given advisory?
162162
pub fn matches(&self, advisory: &Advisory) -> bool {
163-
if let Some(collection) = self.collection {
164-
if Some(collection) != advisory.metadata.collection {
165-
return false;
166-
}
163+
if let Some(collection) = self.collection
164+
&& Some(collection) != advisory.metadata.collection
165+
{
166+
return false;
167167
}
168168

169-
if let Some(package_name) = &self.package_name {
170-
if package_name != &advisory.metadata.package {
171-
return false;
172-
}
169+
if let Some(package_name) = &self.package_name
170+
&& package_name != &advisory.metadata.package
171+
{
172+
return false;
173173
}
174174

175-
if let Some(package_version) = &self.package_version {
176-
if !advisory.versions.is_vulnerable(package_version) {
177-
return false;
178-
}
175+
if let Some(package_version) = &self.package_version
176+
&& !advisory.versions.is_vulnerable(package_version)
177+
{
178+
return false;
179179
}
180180

181181
if let Some(package_source) = &self.package_source {
@@ -194,12 +194,11 @@ impl Query {
194194
}
195195
}
196196

197-
if let Some(severity_threshold) = self.severity {
198-
if let Some(advisory_severity) = advisory.severity() {
199-
if advisory_severity < severity_threshold {
200-
return false;
201-
}
202-
}
197+
if let Some(severity_threshold) = self.severity
198+
&& let Some(advisory_severity) = advisory.severity()
199+
&& advisory_severity < severity_threshold
200+
{
201+
return false;
203202
}
204203

205204
if let Some(affected) = &advisory.affected {
@@ -224,24 +223,23 @@ impl Query {
224223
}
225224
}
226225

227-
if let Some(query_year) = self.year {
228-
if let Some(advisory_year) = advisory.metadata.id.year() {
229-
if query_year != advisory_year {
230-
return false;
231-
}
232-
}
226+
if let Some(query_year) = self.year
227+
&& let Some(advisory_year) = advisory.metadata.id.year()
228+
&& query_year != advisory_year
229+
{
230+
return false;
233231
}
234232

235-
if let Some(withdrawn) = self.withdrawn {
236-
if withdrawn != advisory.metadata.withdrawn.is_some() {
237-
return false;
238-
}
233+
if let Some(withdrawn) = self.withdrawn
234+
&& withdrawn != advisory.metadata.withdrawn.is_some()
235+
{
236+
return false;
239237
}
240238

241-
if let Some(informational) = self.informational {
242-
if informational != advisory.metadata.informational.is_some() {
243-
return false;
244-
}
239+
if let Some(informational) = self.informational
240+
&& informational != advisory.metadata.informational.is_some()
241+
{
242+
return false;
245243
}
246244

247245
true

0 commit comments

Comments
 (0)