From 66bbabe15b227619251c4996aff974d976401c39 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 7 Oct 2022 14:46:12 +0200 Subject: [PATCH] Remove prerelease workaround Resolves: #455 --- src/advisories.rs | 34 ---------------------------------- src/advisories/diags.rs | 35 ----------------------------------- 2 files changed, 69 deletions(-) diff --git a/src/advisories.rs b/src/advisories.rs index 775705ef..e8d6258a 100644 --- a/src/advisories.rs +++ b/src/advisories.rs @@ -81,40 +81,6 @@ pub fn check( ctx.krates, pkg, ) { Some((i, krate)) => { - // This is a workaround for https://github.com/steveklabnik/semver/issues/172, - // it's not strictly correct so we do emit a warning to notify the user - // (though to be honest most people only run cargo-deny in CI and won't notice) - if let Some(versions) = versions { - if !krate.version.pre.is_empty() { - let rematch = semver::Version::new( - krate.version.major, - krate.version.minor, - krate.version.patch, - ); - - // Patches are usually (always) specified in ascending order, - // so we walk them in reverse to get the closest patch that - // may apply to the crate version in question - for patched in versions.patched().iter().rev() { - if patched.matches(&rematch) { - let skipped_diag = - ctx.diag_for_prerelease_skipped(krate, i, advisory, patched); - sink.push(skipped_diag); - return; - } - } - - for unaffected in versions.unaffected().iter().rev() { - if unaffected.matches(&rematch) { - let skipped_diag = - ctx.diag_for_prerelease_skipped(krate, i, advisory, unaffected); - sink.push(skipped_diag); - return; - } - } - } - } - let diag = ctx.diag_for_advisory(krate, i, advisory, versions, |index| { ignore_hits.as_mut_bitslice().set(index, true); }); diff --git a/src/advisories/diags.rs b/src/advisories/diags.rs index c3153345..5521a6ee 100644 --- a/src/advisories/diags.rs +++ b/src/advisories/diags.rs @@ -227,39 +227,4 @@ impl<'a> crate::CheckCtx<'a, super::cfg::ValidConfig> { ) .into() } - - pub(crate) fn diag_for_prerelease_skipped( - &self, - krate: &crate::Krate, - krate_index: krates::NodeId, - advisory: &Metadata, - matched: &semver::VersionReq, - ) -> Pack { - let mut pack = Pack::with_kid(Check::Advisories, krate.id.clone()); - - let notes = { - let mut n = vec![format!("ID: {}", advisory.id)]; - if let Some(url) = advisory.id.url() { - n.push(format!("Advisory: {url}")); - } - - n.push(format!("Satisfied version requirement: {matched}")); - - n - }; - - pack.push( - Diagnostic::new(Severity::Warning) - .with_message( - "advisory for a crate with a pre-release was skipped as it matched a patch", - ) - .with_code("A009") - .with_notes(notes) - .with_labels(vec![self - .krate_spans - .label_for_index(krate_index.index(), "pre-release crate")]), - ); - - pack - } }