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

Add "unknown advisory" detection #275

Merged
merged 3 commits into from
Oct 4, 2020
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
24 changes: 24 additions & 0 deletions src/advisories/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,30 @@ pub fn check(
}
}

// Check for advisory identifers that were set to be ignored, but
// are not actually in any database. Warn the user about.
for (ignored, mut ignored_hit) in ctx.cfg.ignore.iter().zip(ignore_hits.iter_mut()) {
if advisory_dbs.get(&ignored.value).is_none() {
sender
.send(
(
Check::Advisories,
Diagnostic::warning()
.with_message("this advisory is not in any RustSec database")
.with_labels(vec![Label::primary(
ctx.cfg.file_id,
ignored.span.clone(),
)
.with_message("unknown advisory")]),
)
.into(),
)
.unwrap();
// Set advisory as used. Otherwise we would get two warings for the same advisory.
*ignored_hit = true;
}
}

// Check for advisory identifers that were set to be ignored, but
// were not actually encountered, for cases where a crate, or specific
// verison of that crate, has been removed or replaced and the advisory
Expand Down