Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional tracing messages to diagnose missing audit criteria. #592

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,8 @@ async fn fetch_single_imported_audit(
if !ignored_audits.is_empty() {
warn!(
"Ignored {} invalid audits when importing from '{}'\n\
These audits may have been made with a more recent version of cargo-vet",
These audits may have been made with a more recent version of cargo-vet \
or may refer to undefined or unrecognized audit criteria",
ignored_audits.len(),
name
);
Expand Down Expand Up @@ -1341,9 +1342,14 @@ fn parse_imported_audit(valid_criteria: &[CriteriaName], value: toml::Value) ->
// Remove any unrecognized criteria to avoid later errors caused by being
// unable to find criteria, and ignore the entry if it names no known
// criteria.
audit
.criteria
.retain(|criteria_name| is_known_criteria(valid_criteria, criteria_name));
audit.criteria.retain(|criteria_name| {
if !is_known_criteria(valid_criteria, criteria_name) {
info!("discarding unknown criteria in imported audit: {criteria_name}");
return false;
}
true
});

if audit.criteria.is_empty() {
info!("imported audit parsing failed due to no known criteria");
return None;
Expand All @@ -1361,9 +1367,17 @@ fn parse_imported_wildcard_audit(
.map_err(|err| info!("imported wildcard audit parsing failed due to {err}"))
.ok()?;

audit
.criteria
.retain(|criteria_name| is_known_criteria(valid_criteria, criteria_name));
// Remove any unrecognized criteria to avoid later errors caused by being
// unable to find criteria, and ignore the entry if it names no known
// criteria.
audit.criteria.retain(|criteria_name| {
if !is_known_criteria(valid_criteria, criteria_name) {
info!("discarding unknown criteria in imported wildcard audit: {criteria_name}");
return false;
}
true
});

if audit.criteria.is_empty() {
info!("imported wildcard audit parsing failed due to no known criteria");
return None;
Expand Down
Loading