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:
Tony Arcieri
2019-01-13 17:50:37 -08:00
parent 927a5e314b
commit cb4f7d11af
2 changed files with 19 additions and 1 deletions

View File

@@ -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:

View File

@@ -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()
)
}
}
}
}
}