mirror of
https://github.com/rustsec/advisory-db.git
synced 2025-12-27 01:54:07 -05:00
lint: Check that affected_paths start with crate name
Uses the crate name as fetched from the crates.io API to ensure all `affected_paths` begin with the crate name (i.e. are canonical)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
language: rust
|
||||
script: cargo run check # check that the advisory-db is well-formed
|
||||
cache: cargo
|
||||
|
||||
# check that the advisory-db is well-formed
|
||||
script: cargo run check
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
||||
15
src/main.rs
15
src/main.rs
@@ -102,4 +102,19 @@ fn check_advisory(cratesio_client: &crates_io_api::SyncClient, advisory: &rustse
|
||||
advisory.package.as_str()
|
||||
);
|
||||
}
|
||||
|
||||
// Check that each path in `affected_paths` starts with the crate name
|
||||
if let Some(ref version_req_paths) = advisory.affected_paths {
|
||||
for (_, paths) in version_req_paths.iter() {
|
||||
for path in paths {
|
||||
if path.crate_name() != response.crate_data.name {
|
||||
panic!(
|
||||
"{}: affected_path does not begin with crate name: {}",
|
||||
response.crate_data.name,
|
||||
path.crate_name()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user