Skip to content

Commit

Permalink
Merge pull request #592 from anforowicz/import-logging
Browse files Browse the repository at this point in the history
Additional tracing messages to diagnose missing audit criteria.
  • Loading branch information
mystor committed Apr 2, 2024
2 parents a248d43 + c241882 commit 01227af
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/storage.rs
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

0 comments on commit 01227af

Please sign in to comment.