From 83a91d5dce6e31b73bc0835327c93aeb23dbd962 Mon Sep 17 00:00:00 2001 From: Justus K Date: Sun, 30 Aug 2020 21:08:46 +0200 Subject: [PATCH 01/17] Add allow- deny- feature config entry --- deny.toml | 7 ++++-- src/bans/cfg.rs | 58 +++++++++++++++++++++++++++++++++++++++++++++---- src/cfg.rs | 12 ++++++++++ 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/deny.toml b/deny.toml index d8c8f538..b2145989 100644 --- a/deny.toml +++ b/deny.toml @@ -21,8 +21,6 @@ ignore = [ [bans] multiple-versions = "deny" -deny = [ -] skip = [ # clap uses an older version of ansi_term { name = "ansi_term", version = "=0.11.0" }, @@ -38,6 +36,11 @@ skip = [ { name = "cfg-if", version = "=0.1.10" }, ] +[[bans.deny]] +name = "crate1" +deny-features = ["badnews"] +exact-features = true + [sources] unknown-registry = "deny" unknown-git = "deny" diff --git a/src/bans/cfg.rs b/src/bans/cfg.rs index 3ec4c5f8..0a79ff24 100644 --- a/src/bans/cfg.rs +++ b/src/bans/cfg.rs @@ -19,7 +19,7 @@ pub struct CrateId { #[derive(Deserialize, Clone)] #[cfg_attr(test, derive(Debug, PartialEq))] -#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case", deny_unknown_fields)] pub struct CrateBan { pub name: Spanned, #[serde(default = "any")] @@ -28,6 +28,15 @@ pub struct CrateBan { /// direct dependency #[serde(default)] pub wrappers: Vec>, + /// All features that are allowed to be used. + #[serde(default)] + pub allow_features: Vec>, + /// All features that are denied. + #[serde(default)] + pub deny_features: Spanned>>, + /// The actual feature set has to match the `allow_features` sets. + #[serde(default)] + pub exact_features: Spanned, } #[derive(Deserialize, Clone)] @@ -141,6 +150,9 @@ impl crate::cfg::UnvalidatedConfig for Config { cb.name.span, ), wrappers: cb.wrappers, + allow_features: cb.allow_features, + deny_features: cb.deny_features, + exact_features: cb.exact_features, }) .collect(); denied.par_sort(); @@ -167,6 +179,12 @@ impl crate::cfg::UnvalidatedConfig for Config { ); }; + for a in &allowed { + if let Ok(si) = skipped.binary_search(&a) { + add_diag((a, "allow"), (&skipped[si], "skip")); + } + } + for d in &denied { if let Ok(ai) = allowed.binary_search(&d.id) { add_diag((&d.id, "deny"), (&allowed[ai], "allow")); @@ -176,9 +194,38 @@ impl crate::cfg::UnvalidatedConfig for Config { } } - for a in &allowed { - if let Ok(si) = skipped.binary_search(&a) { - add_diag((a, "allow"), (&skipped[si], "skip")); + for d in &denied { + for allowed_f in &d.allow_features { + if let Ok(fi) = &d.deny_features.value.binary_search(allowed_f) { + let deny_f = &d.deny_features.value[*fi]; + + diagnostics.push( + Diagnostic::error() + .with_message( + "a feature was specified in both `allowed-features` and `deny-features`", + ) + .with_labels(vec![ + Label::secondary(cfg_file, allowed_f.span.clone()) + .with_message("marked as `allow`"), + Label::secondary(cfg_file, deny_f.span.clone()) + .with_message("marked as `deny`"), + ]), + ); + } + } + + if d.exact_features.value && !d.deny_features.value.is_empty() { + // TODO: Should this really be like this? + diagnostics.push( + Diagnostic::error() + .with_message("can not deny features if `exact-features` is enabled") + .with_labels(vec![ + Label::secondary(cfg_file, d.exact_features.span.clone()) + .with_message("exact-features enabled here"), + Label::secondary(cfg_file, d.deny_features.span.clone()) + .with_message("features are denied here"), + ]), + ); } } @@ -206,6 +253,9 @@ pub(crate) type Skrate = Spanned; pub(crate) struct KrateBan { pub id: Skrate, pub wrappers: Vec>, + pub allow_features: Vec>, + pub deny_features: Spanned>>, + pub exact_features: Spanned, } use std::cmp::{Ord, Ordering}; diff --git a/src/cfg.rs b/src/cfg.rs index fcb72891..a4ce0c78 100644 --- a/src/cfg.rs +++ b/src/cfg.rs @@ -63,6 +63,18 @@ impl AsRef for Spanned { } } +impl Default for Spanned +where + T: Default, +{ + fn default() -> Self { + Self { + value: Default::default(), + span: 0..0, + } + } +} + impl std::fmt::Debug for Spanned where T: std::fmt::Debug, From 25453fc83e1b5bdb89f006d1aa1433d5d5956b80 Mon Sep 17 00:00:00 2001 From: Justus K Date: Sun, 30 Aug 2020 21:10:15 +0200 Subject: [PATCH 02/17] Remove test from deny.toml --- deny.toml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/deny.toml b/deny.toml index b2145989..d8c8f538 100644 --- a/deny.toml +++ b/deny.toml @@ -21,6 +21,8 @@ ignore = [ [bans] multiple-versions = "deny" +deny = [ +] skip = [ # clap uses an older version of ansi_term { name = "ansi_term", version = "=0.11.0" }, @@ -36,11 +38,6 @@ skip = [ { name = "cfg-if", version = "=0.1.10" }, ] -[[bans.deny]] -name = "crate1" -deny-features = ["badnews"] -exact-features = true - [sources] unknown-registry = "deny" unknown-git = "deny" From d8b5876384565929222ef501d7f2dd69afa4c1a8 Mon Sep 17 00:00:00 2001 From: Justus K Date: Wed, 9 Sep 2020 21:38:46 +0200 Subject: [PATCH 03/17] Start to implement feature checking --- src/bans/cfg.rs | 6 ++-- src/bans/mod.rs | 87 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/bans/cfg.rs b/src/bans/cfg.rs index 0a79ff24..ea22886e 100644 --- a/src/bans/cfg.rs +++ b/src/bans/cfg.rs @@ -30,7 +30,7 @@ pub struct CrateBan { pub wrappers: Vec>, /// All features that are allowed to be used. #[serde(default)] - pub allow_features: Vec>, + pub allow_features: Spanned>>, /// All features that are denied. #[serde(default)] pub deny_features: Spanned>>, @@ -195,7 +195,7 @@ impl crate::cfg::UnvalidatedConfig for Config { } for d in &denied { - for allowed_f in &d.allow_features { + for allowed_f in &d.allow_features.value { if let Ok(fi) = &d.deny_features.value.binary_search(allowed_f) { let deny_f = &d.deny_features.value[*fi]; @@ -253,7 +253,7 @@ pub(crate) type Skrate = Spanned; pub(crate) struct KrateBan { pub id: Skrate, pub wrappers: Vec>, - pub allow_features: Vec>, + pub allow_features: Spanned>>, pub deny_features: Spanned>>, pub exact_features: Spanned, } diff --git a/src/bans/mod.rs b/src/bans/mod.rs index 6f61b3f1..82e1fd60 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -222,8 +222,27 @@ pub fn check( sink.push(build_diags); } - let (denied_ids, ban_wrappers): (Vec<_>, Vec<_>) = - denied.into_iter().map(|kb| (kb.id, kb.wrappers)).unzip(); + struct KrateBanInfo { + wrappers: Vec>, + allow_features: Spanned>>, + deny_features: Spanned>>, + exact_features: Spanned, + } + + let (denied_ids, denied_info): (Vec<_>, Vec<_>) = denied + .into_iter() + .map(|kb| { + ( + kb.id, + KrateBanInfo { + wrappers: kb.wrappers, + allow_features: kb.allow_features, + deny_features: kb.deny_features, + exact_features: kb.exact_features, + }, + ) + }) + .unzip(); // Keep track of all the crates we skip, and emit a warning if // we encounter a skip that didn't actually match any crate version @@ -253,7 +272,7 @@ pub fn check( // The crate is banned, but it might have be allowed if it's wrapped // by one or more particular crates - let allowed_wrappers = &ban_wrappers[bind]; + let allowed_wrappers = &denied_info[bind].wrappers; let is_allowed = if !allowed_wrappers.is_empty() { let nid = ctx.krates.nid_for_kid(&krate.id).unwrap(); let graph = ctx.krates.graph(); @@ -302,8 +321,68 @@ pub fn check( false }; + // Ensure that the feature set of this krate, wherever it's used + // as a dependency, matches the ban entry. + let nid = ctx.krates.nid_for_kid(&krate.id).unwrap(); + let graph = ctx.krates.graph(); + let features_allowed = graph + .edges_directed(nid, Direction::Incoming) + .map(|edge| edge.source()) + .all(|nid| { + let node = &graph[nid]; + + let exact = &denied_info[bind].exact_features; + let af = &denied_info[bind].allow_features; + let df = &denied_info[bind].deny_features; + let cf = &node + .krate + .deps + .iter() + .find(|dep| dep.name == krate.name) + .unwrap() + .features; + + if exact.value { + // TODO: We need to properly report the invalid feature set. + // How should we report it? + let mut check_len = || { + if cf.len() == af.value.len() { + true + } else { + pack.push( + Diagnostic::error() + .with_message(format!("invalid feature set for {}", krate)) + .with_labels(vec![ + Label::primary(file_id, af.span.clone()) + .with_message("lengths of the feature sets do not match..."), + Label::secondary(file_id, exact.span.clone()) + .with_message("but they have to, because `exact_features` is defined here") + ]), + ); + false + } + }; + check_len() && af.value.iter().all(|f| cf.contains(&f.value)) + } else { + false + } + }); + + let is_allowed = if !is_allowed && features_allowed { + true + } else if is_allowed { + true + } else { + false + }; + if !is_allowed { - pack.push(diags::ExplicitlyBanned { krate, ban_cfg }); + pack.push( + Diagnostic::error() + .with_message(format!("detected banned crate {}", krate,)) + .with_labels(vec![Label::primary(file_id, ban.span.clone()) + .with_message("matching ban entry")]), + ); } } From eb6c96dc79a6d59926f0e1e5859c777163ecd0f3 Mon Sep 17 00:00:00 2001 From: Justus K Date: Wed, 16 Sep 2020 20:37:33 +0200 Subject: [PATCH 04/17] Implement feature banning if exact-features --- src/bans/mod.rs | 83 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index 82e1fd60..c92ba938 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -334,37 +334,78 @@ pub fn check( let exact = &denied_info[bind].exact_features; let af = &denied_info[bind].allow_features; let df = &denied_info[bind].deny_features; - let cf = &node + let dep = node .krate .deps .iter() .find(|dep| dep.name == krate.name) - .unwrap() - .features; + .unwrap(); + let cf = &dep.features; + + let mut cached_span = None; + let feature_set_span = |features: &[String]| match cached_span { + Some(cached) => cached, + None => { + let manifest = format!( + "[dependencies]\n{} = {{ version = {}, features = [{}] }}\n", + dep.name, + dep.req, + features + .iter() + .map(|name| format!("\"{}\"", name)) + .collect::>() + .join(", "), + ); + } + }; if exact.value { // TODO: We need to properly report the invalid feature set. // How should we report it? - let mut check_len = || { - if cf.len() == af.value.len() { - true - } else { - pack.push( - Diagnostic::error() - .with_message(format!("invalid feature set for {}", krate)) - .with_labels(vec![ - Label::primary(file_id, af.span.clone()) - .with_message("lengths of the feature sets do not match..."), - Label::secondary(file_id, exact.span.clone()) - .with_message("but they have to, because `exact_features` is defined here") - ]), - ); - false + if cf.len() == af.value.len() { + let mut allowed = true; + for f in &af.value { + if !cf.contains(&f.value) { + pack.push( + Diagnostic::error() + .with_message(format!( + "invalid feature set for {}", + krate + )) + .with_labels(vec![ + Label::primary( + spans_id, + krate_spans[nid.index()].clone(), + ) + .with_message(format!( + "this crate has feature `{}` enabled", + f.value + )), + Label::secondary(file_id, f.span.clone()) + .with_message("which is banned here"), + ]), + ); + allowed = false; + } } - }; - check_len() && af.value.iter().all(|f| cf.contains(&f.value)) + allowed + } else { + pack.push( + Diagnostic::error() + .with_message(format!("invalid feature set for {}", krate)) + .with_labels(vec![Label::primary(file_id, af.span.clone()) + .with_message( + "lengths of the feature sets do not match...", + )]) + .with_notes(vec![ + "but they have to, because `exact_features` is enabled" + .into(), + ]), + ); + false + } } else { - false + todo!() } }); From 5972447a7ca07cc3334fa0fcdb28f621e4fa5c42 Mon Sep 17 00:00:00 2001 From: Justus K Date: Wed, 16 Sep 2020 20:41:30 +0200 Subject: [PATCH 05/17] Simplify code --- src/bans/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index c92ba938..2e11a6c4 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -378,11 +378,11 @@ pub fn check( krate_spans[nid.index()].clone(), ) .with_message(format!( - "this crate has feature `{}` enabled", + "this crate has feature `{}` enabled...", f.value )), Label::secondary(file_id, f.span.clone()) - .with_message("which is banned here"), + .with_message("...which is banned here"), ]), ); allowed = false; @@ -409,13 +409,7 @@ pub fn check( } }); - let is_allowed = if !is_allowed && features_allowed { - true - } else if is_allowed { - true - } else { - false - }; + let is_allowed = is_allowed || features_allowed; if !is_allowed { pack.push( From e3e64128008fe02a4c7dc568d3c58408bb70d680 Mon Sep 17 00:00:00 2001 From: Justus K Date: Wed, 16 Sep 2020 20:46:45 +0200 Subject: [PATCH 06/17] Implement banned features --- src/bans/mod.rs | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index 2e11a6c4..df8c316f 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -342,23 +342,6 @@ pub fn check( .unwrap(); let cf = &dep.features; - let mut cached_span = None; - let feature_set_span = |features: &[String]| match cached_span { - Some(cached) => cached, - None => { - let manifest = format!( - "[dependencies]\n{} = {{ version = {}, features = [{}] }}\n", - dep.name, - dep.req, - features - .iter() - .map(|name| format!("\"{}\"", name)) - .collect::>() - .join(", "), - ); - } - }; - if exact.value { // TODO: We need to properly report the invalid feature set. // How should we report it? @@ -405,7 +388,29 @@ pub fn check( false } } else { - todo!() + let mut allowed = true; + for f in &df.value { + if !cf.contains(&f.value) { + pack.push( + Diagnostic::error() + .with_message(format!("invalid feature set for {}", krate)) + .with_labels(vec![ + Label::primary( + spans_id, + krate_spans[nid.index()].clone(), + ) + .with_message(format!( + "this crate has feature `{}` enabled...", + f.value + )), + Label::secondary(file_id, f.span.clone()) + .with_message("...which is banned here"), + ]), + ); + allowed = true; + } + } + allowed } }); From fed6ca2e73077676981568a527cd440f1f172317 Mon Sep 17 00:00:00 2001 From: Justus K Date: Wed, 16 Sep 2020 21:24:50 +0200 Subject: [PATCH 07/17] Fix tests and wrong allowed detection --- src/bans/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index df8c316f..395285e7 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -407,16 +407,16 @@ pub fn check( .with_message("...which is banned here"), ]), ); - allowed = true; + allowed = false; } } allowed } }); - let is_allowed = is_allowed || features_allowed; + let denied = !is_allowed || !features_allowed; - if !is_allowed { + if denied { pack.push( Diagnostic::error() .with_message(format!("detected banned crate {}", krate,)) From 44a5100238634b6f1ba970eb4586a8459685475b Mon Sep 17 00:00:00 2001 From: Justus K Date: Sat, 26 Sep 2020 09:54:13 +0200 Subject: [PATCH 08/17] Fix tests --- src/bans/mod.rs | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index 395285e7..fad53b5e 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -318,7 +318,11 @@ pub fn check( is_allowed }) } else { - false + let exact = &denied_info[bind].exact_features.value; + let af = &denied_info[bind].allow_features.value; + let df = &denied_info[bind].deny_features.value; + + false || (*exact || !af.is_empty() || !df.is_empty()) }; // Ensure that the feature set of this krate, wherever it's used @@ -364,8 +368,13 @@ pub fn check( "this crate has feature `{}` enabled...", f.value )), - Label::secondary(file_id, f.span.clone()) - .with_message("...which is banned here"), + Label::secondary(file_id, af.span.clone()) + .with_message( + "...which is not defined in `allow-features`...", + ), + ]) + .with_notes(vec![ + "but it has to, because `exact-features` is enabled".into(), ]), ); allowed = false; @@ -388,9 +397,10 @@ pub fn check( false } } else { + // TODO: Compare lengths of feature sets let mut allowed = true; for f in &df.value { - if !cf.contains(&f.value) { + if cf.contains(&f.value) { pack.push( Diagnostic::error() .with_message(format!("invalid feature set for {}", krate)) @@ -410,13 +420,34 @@ pub fn check( allowed = false; } } + + for f in cf { + if !af.value.iter().any(|af| af == f) { + pack.push( + Diagnostic::error() + .with_message(format!("invalid feature set for {}", krate)) + .with_labels(vec![ + Label::primary( + spans_id, + krate_spans[nid.index()].clone(), + ) + .with_message(format!( + "this crate has feature `{}` enabled...", f + )), + Label::secondary(file_id, af.span.clone()) + .with_message("...which is not allowed here"), + ]) + .with_notes(vec![format!("crate {} can only have features enabled that are explicitly allowed", krate.name)]), + ); + allowed = false; + } + } + allowed } }); - let denied = !is_allowed || !features_allowed; - - if denied { + if !is_allowed || !features_allowed { pack.push( Diagnostic::error() .with_message(format!("detected banned crate {}", krate,)) From 6024109bd3d328998527db8234524fd834e0204f Mon Sep 17 00:00:00 2001 From: Justus K Date: Sat, 26 Sep 2020 09:59:58 +0200 Subject: [PATCH 09/17] Fix clippy lint --- src/bans/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index fad53b5e..d4db84f9 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -322,7 +322,7 @@ pub fn check( let af = &denied_info[bind].allow_features.value; let df = &denied_info[bind].deny_features.value; - false || (*exact || !af.is_empty() || !df.is_empty()) + *exact || !af.is_empty() || !df.is_empty() }; // Ensure that the feature set of this krate, wherever it's used From a15d3dbb04f07d73ab6e06c2a3ccdf1c2f7eff76 Mon Sep 17 00:00:00 2001 From: Justus K Date: Sat, 26 Sep 2020 10:07:50 +0200 Subject: [PATCH 10/17] Add book entry for banning features --- docs/src/checks/bans/cfg.md | 24 ++++++++++++++++++++++++ tests/cfg/bans.toml | 9 +++++++++ 2 files changed, 33 insertions(+) diff --git a/docs/src/checks/bans/cfg.md b/docs/src/checks/bans/cfg.md index 938b6048..6b4a2595 100644 --- a/docs/src/checks/bans/cfg.md +++ b/docs/src/checks/bans/cfg.md @@ -8,6 +8,30 @@ Contains all of the configuration for `cargo deny check bans` {{#include ../../../../tests/cfg/bans.toml}} ``` +### The `deny-features` field (optional) + +If any of the denied features for a specific crate is used in the +dependency graph, cargo-deny will deny it. + +**Note:** If this field is provided, cargo-deny will not ban the crate, +unless it uses denied features. + +### The `allow-features` field (optional) + +A specific crate can only use the features provided in this config entry. +If this is an empty set, it will have no effect. + +**Note:** If this field is provided, cargo-deny will not ban the crate, +unless it uses non-allowed features. + +### The `exact-features` field (optional) + +Makes `allow-features` strict. If this is true, the feature set +of the crate must be exactly the same as the `allow-features` set. + +**Note:** If this field is provided, cargo-deny will not ban the crate, +unless the feature set doesn't match exactly. + ### The `multiple-versions` field (optional) Determines what happens when multiple versions of the same crate are diff --git a/tests/cfg/bans.toml b/tests/cfg/bans.toml index 22ccde49..f26f276f 100644 --- a/tests/cfg/bans.toml +++ b/tests/cfg/bans.toml @@ -18,6 +18,15 @@ wrappers = ["specific-versiona"] name = "specific-versiond" version = "=0.1.9" +[[bans.deny]] +name = "log" +deny-features = ["max_level_off"] + +[[bans.deny]] +name = "syn" +allow-features = ["full"] +exact-features = true + [[bans.skip]] name = "rand" version = "=0.6.5" From 1ca935bb7b896dd9a4152c7b12d0a58a820cb2ce Mon Sep 17 00:00:00 2001 From: Justus K Date: Sat, 26 Sep 2020 10:18:32 +0200 Subject: [PATCH 11/17] Fix tests --- src/bans/cfg.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bans/cfg.rs b/src/bans/cfg.rs index ea22886e..e74ade63 100644 --- a/src/bans/cfg.rs +++ b/src/bans/cfg.rs @@ -338,8 +338,17 @@ mod test { vec![kid!("all-versionsa"), kid!("specific-versiona", "<0.1.1")] ); assert_eq!( - validated.denied, - vec![kid!("all-versionsd"), kid!("specific-versiond", "=0.1.9")] + validated + .denied + .into_iter() + .map(|ban| ban.id.value) + .collect::>(), + vec![ + kid!("all-versionsd"), + kid!("log"), + kid!("specific-versiond", "=0.1.9"), + kid!("syn") + ] ); assert_eq!(validated.skipped, vec![kid!("rand", "=0.6.5")]); assert_eq!( From b62e37dae27613c60823308ee0096aa3a820fd1c Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Wed, 14 Oct 2020 07:37:32 +0200 Subject: [PATCH 12/17] Fixup rebase --- src/advisories/diags.rs | 14 +-- src/bans/cfg.rs | 4 +- src/bans/diags.rs | 86 ++++++++++++++++ src/bans/mod.rs | 221 ++++++++++++++++++---------------------- src/diag.rs | 12 +++ 5 files changed, 199 insertions(+), 138 deletions(-) diff --git a/src/advisories/diags.rs b/src/advisories/diags.rs index 98e2f68b..ec678cfb 100644 --- a/src/advisories/diags.rs +++ b/src/advisories/diags.rs @@ -269,18 +269,6 @@ impl<'a> Into for UnpatchableSource<'a> { } } -fn to_string(v: &[T]) -> String { - let mut dv = String::with_capacity(64); - - for req in v { - use std::fmt::Write; - write!(&mut dv, "{}, ", req).expect("failed to write string"); - } - - dv.truncate(dv.len() - 2); - dv -} - pub(crate) struct IncompatibleLocalKrate<'a> { pub(crate) local_krate: &'a Krate, pub(crate) dep_req: &'a semver::VersionReq, @@ -297,7 +285,7 @@ impl<'a> Into for IncompatibleLocalKrate<'a> { self.dep_req, self.dep.name, )) - .with_notes(vec![format!("Required versions: [{}]", to_string(self.required_versions))]) + .with_notes(vec![format!("Required versions: [{}]", crate::diag::to_string(self.required_versions))]) .with_code("AF005") .into(); diff --git a/src/bans/cfg.rs b/src/bans/cfg.rs index e74ade63..08e0d5a6 100644 --- a/src/bans/cfg.rs +++ b/src/bans/cfg.rs @@ -199,7 +199,7 @@ impl crate::cfg::UnvalidatedConfig for Config { if let Ok(fi) = &d.deny_features.value.binary_search(allowed_f) { let deny_f = &d.deny_features.value[*fi]; - diagnostics.push( + diags.push( Diagnostic::error() .with_message( "a feature was specified in both `allowed-features` and `deny-features`", @@ -216,7 +216,7 @@ impl crate::cfg::UnvalidatedConfig for Config { if d.exact_features.value && !d.deny_features.value.is_empty() { // TODO: Should this really be like this? - diagnostics.push( + diags.push( Diagnostic::error() .with_message("can not deny features if `exact-features` is enabled") .with_labels(vec![ diff --git a/src/bans/diags.rs b/src/bans/diags.rs index a6b659bd..c8d9d7db 100644 --- a/src/bans/diags.rs +++ b/src/bans/diags.rs @@ -219,6 +219,7 @@ impl<'a> Into for SkippedByRoot<'a> { fn into(self) -> Diag { Diagnostic::new(Severity::Help) .with_message(format!("skipping crate '{}' due to root skip", self.krate)) + .with_code("B011") .with_labels(vec![self .skip_root_cfg .into_label() @@ -226,3 +227,88 @@ impl<'a> Into for SkippedByRoot<'a> { .into() } } + +pub(crate) struct ExactFeaturesMismatch<'a> { + pub(crate) missing_allowed: Vec, + pub(crate) not_allowed: &'a [&'a str], + pub(crate) parent: &'a Krate, + pub(crate) dep_name: &'a str, + pub(crate) exact_coord: CfgCoord, +} + +impl<'a> Into for ExactFeaturesMismatch<'a> { + fn into(self) -> Diag { + let mut labels: Vec<_> = self + .missing_allowed + .into_iter() + .map(|ma| ma.into_label().with_message("allowed feature not present")) + .collect(); + + labels.push( + self.exact_coord + .into_label() + .with_message("exact-features declared here"), + ); + + Diagnostic::new(Severity::Error) + .with_message(format!( + "feature set declared by '{}' for '{}' did not match exactly", + self.parent, self.dep_name + )) + .with_code("B012") + .with_labels(labels) + .with_notes( + self.not_allowed + .iter() + .map(|na| format!("'{}' feature was enabled bot not explicitly allowed", na)) + .collect(), + ) + .into() + } +} + +pub(crate) struct FeaturesNotExplicitlyAllowed<'a> { + pub(crate) not_allowed: &'a [&'a str], + pub(crate) parent: &'a Krate, + pub(crate) dep_name: &'a str, +} + +impl<'a> Into for FeaturesNotExplicitlyAllowed<'a> { + fn into(self) -> Diag { + Diagnostic::new(Severity::Error) + .with_message(format!( + "features declared by '{}' for '{}' were not explicitly allowed", + self.parent, self.dep_name + )) + .with_code("B013") + .with_notes(vec![format!( + "Features: {}", + crate::diag::to_string(self.not_allowed) + )]) + .into() + } +} + +pub(crate) struct FeaturesExplicitlyDenied<'a> { + pub(crate) found_denied: Vec, + pub(crate) parent: &'a Krate, + pub(crate) dep_name: &'a str, +} + +impl<'a> Into for FeaturesExplicitlyDenied<'a> { + fn into(self) -> Diag { + Diagnostic::new(Severity::Error) + .with_message(format!( + "features declared by '{}' for '{}' were explicitly denied", + self.parent, self.dep_name + )) + .with_code("B014") + .with_labels( + self.found_denied + .into_iter() + .map(|fd| fd.into_label()) + .collect(), + ) + .into() + } +} diff --git a/src/bans/mod.rs b/src/bans/mod.rs index d4db84f9..7e9b510f 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -11,7 +11,7 @@ use anyhow::Error; use semver::{Version, VersionReq}; use std::{cmp::Ordering, fmt}; -#[derive(Eq)] +#[derive(Eq, Clone)] #[cfg_attr(test, derive(Debug))] pub struct KrateId { pub(crate) name: String, @@ -222,27 +222,15 @@ pub fn check( sink.push(build_diags); } - struct KrateBanInfo { - wrappers: Vec>, - allow_features: Spanned>>, - deny_features: Spanned>>, - exact_features: Spanned, - } + // struct KrateBanInfo { + // wrappers: Vec>, + // allow_features: Spanned>>, + // deny_features: Spanned>>, + // exact_features: Spanned, + // } - let (denied_ids, denied_info): (Vec<_>, Vec<_>) = denied - .into_iter() - .map(|kb| { - ( - kb.id, - KrateBanInfo { - wrappers: kb.wrappers, - allow_features: kb.allow_features, - deny_features: kb.deny_features, - exact_features: kb.exact_features, - }, - ) - }) - .unzip(); + let denied_ids: Vec<_> = denied.iter().map(|kb| kb.id.clone()).collect(); + let denied_info = denied; // Keep track of all the crates we skip, and emit a warning if // we encounter a skip that didn't actually match any crate version @@ -329,131 +317,118 @@ pub fn check( // as a dependency, matches the ban entry. let nid = ctx.krates.nid_for_kid(&krate.id).unwrap(); let graph = ctx.krates.graph(); - let features_allowed = graph + + let feature_set_allowed = graph .edges_directed(nid, Direction::Incoming) .map(|edge| edge.source()) - .all(|nid| { - let node = &graph[nid]; + .all(|pid| { + let parent = &graph[pid]; let exact = &denied_info[bind].exact_features; - let af = &denied_info[bind].allow_features; - let df = &denied_info[bind].deny_features; - let dep = node + let allowed_features = &denied_info[bind].allow_features; + let denied_features = &denied_info[bind].deny_features; + let dep = parent .krate .deps .iter() .find(|dep| dep.name == krate.name) .unwrap(); - let cf = &dep.features; + + let dep_features = &dep.features; + + // Gather features that were present, but not explicitly allowed + let not_allowed: Vec<_> = dep_features + .iter() + .filter_map(|df| { + if allowed_features + .value + .iter() + .find(|af| &af.value == df) + .is_none() + { + Some(df.as_ref()) + } else { + None + } + }) + .collect(); if exact.value { - // TODO: We need to properly report the invalid feature set. - // How should we report it? - if cf.len() == af.value.len() { - let mut allowed = true; - for f in &af.value { - if !cf.contains(&f.value) { - pack.push( - Diagnostic::error() - .with_message(format!( - "invalid feature set for {}", - krate - )) - .with_labels(vec![ - Label::primary( - spans_id, - krate_spans[nid.index()].clone(), - ) - .with_message(format!( - "this crate has feature `{}` enabled...", - f.value - )), - Label::secondary(file_id, af.span.clone()) - .with_message( - "...which is not defined in `allow-features`...", - ), - ]) - .with_notes(vec![ - "but it has to, because `exact-features` is enabled".into(), - ]), - ); - allowed = false; + // Gather features allowed, but not present + let missing_allowed: Vec<_> = allowed_features + .value + .iter() + .filter_map(|af| { + if dep_features.iter().find(|df| **df == af.value).is_none() { + Some(CfgCoord { + file: file_id, + span: af.span.clone(), + }) + } else { + None } - } - allowed + }) + .collect(); + + if missing_allowed.is_empty() && not_allowed.is_empty() { + true } else { - pack.push( - Diagnostic::error() - .with_message(format!("invalid feature set for {}", krate)) - .with_labels(vec![Label::primary(file_id, af.span.clone()) - .with_message( - "lengths of the feature sets do not match...", - )]) - .with_notes(vec![ - "but they have to, because `exact_features` is enabled" - .into(), - ]), - ); + pack.push(diags::ExactFeaturesMismatch { + missing_allowed, + not_allowed: ¬_allowed, + parent: &parent.krate, + dep_name: &dep.name, + exact_coord: CfgCoord { + file: file_id, + span: exact.span.clone(), + }, + }); false } } else { - // TODO: Compare lengths of feature sets - let mut allowed = true; - for f in &df.value { - if cf.contains(&f.value) { - pack.push( - Diagnostic::error() - .with_message(format!("invalid feature set for {}", krate)) - .with_labels(vec![ - Label::primary( - spans_id, - krate_spans[nid.index()].clone(), - ) - .with_message(format!( - "this crate has feature `{}` enabled...", - f.value - )), - Label::secondary(file_id, f.span.clone()) - .with_message("...which is banned here"), - ]), - ); - allowed = false; - } + // Add diagnostics if features were explicitly allowed, but weren't present + let mut feature_set_allowed = true; + if !allowed_features.value.is_empty() && !not_allowed.is_empty() { + pack.push(diags::FeaturesNotExplicitlyAllowed { + not_allowed: ¬_allowed, + parent: &parent.krate, + dep_name: &dep.name, + }); + + feature_set_allowed = false; } - for f in cf { - if !af.value.iter().any(|af| af == f) { - pack.push( - Diagnostic::error() - .with_message(format!("invalid feature set for {}", krate)) - .with_labels(vec![ - Label::primary( - spans_id, - krate_spans[nid.index()].clone(), - ) - .with_message(format!( - "this crate has feature `{}` enabled...", f - )), - Label::secondary(file_id, af.span.clone()) - .with_message("...which is not allowed here"), - ]) - .with_notes(vec![format!("crate {} can only have features enabled that are explicitly allowed", krate.name)]), - ); - allowed = false; - } + let found_denied: Vec<_> = denied_features + .value + .iter() + .filter_map(|deny_f| { + dep_features + .iter() + .find(|df| **df == deny_f.value) + .map(|_| CfgCoord { + file: file_id, + span: deny_f.span.clone(), + }) + }) + .collect(); + + // Add diagnostics for features that were explicitly denied + if !found_denied.is_empty() { + pack.push(diags::FeaturesExplicitlyDenied { + found_denied, + parent: &parent.krate, + dep_name: &dep.name, + }); + + feature_set_allowed = false; } - allowed + feature_set_allowed } }); - if !is_allowed || !features_allowed { - pack.push( - Diagnostic::error() - .with_message(format!("detected banned crate {}", krate,)) - .with_labels(vec![Label::primary(file_id, ban.span.clone()) - .with_message("matching ban entry")]), - ); + if !is_allowed || !feature_set_allowed { + pack.push(diags::ExplicitlyBanned { krate, ban_cfg }); } } diff --git a/src/diag.rs b/src/diag.rs index 16549ed0..e56ecfcd 100644 --- a/src/diag.rs +++ b/src/diag.rs @@ -235,3 +235,15 @@ struct NodePrint<'a> { id: krates::NodeId, kind: &'static str, } + +pub(crate) fn to_string(v: &[T]) -> String { + let mut dv = String::with_capacity(64); + + for req in v { + use std::fmt::Write; + write!(&mut dv, "{}, ", req).expect("failed to write string"); + } + + dv.truncate(dv.len() - 2); + dv +} From 2aab6f8533516c17776f6459339306fa1eeee5c9 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 15 Oct 2020 08:35:08 +0200 Subject: [PATCH 13/17] Add example for feature banning --- examples/10_feature_bans/Cargo.lock | 1379 +++++++++++++++++++++++++++ examples/10_feature_bans/Cargo.toml | 16 + examples/10_feature_bans/deny.toml | 7 + examples/10_feature_bans/src/lib.rs | 7 + 4 files changed, 1409 insertions(+) create mode 100644 examples/10_feature_bans/Cargo.lock create mode 100644 examples/10_feature_bans/Cargo.toml create mode 100644 examples/10_feature_bans/deny.toml create mode 100644 examples/10_feature_bans/src/lib.rs diff --git a/examples/10_feature_bans/Cargo.lock b/examples/10_feature_bans/Cargo.lock new file mode 100644 index 00000000..b58b1bbe --- /dev/null +++ b/examples/10_feature_bans/Cargo.lock @@ -0,0 +1,1379 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + +[[package]] +name = "bumpalo" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" + +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "cc" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "serde", + "time", + "winapi 0.3.9", +] + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "debugid" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" +dependencies = [ + "serde", + "uuid", +] + +[[package]] +name = "dtoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" + +[[package]] +name = "encoding_rs" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "feature-bans" +version = "0.1.0" +dependencies = [ + "reqwest", + "sentry", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures-channel" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a4d35f7401e948629c9c3d6638fb9bf94e0b2121e96c3b428cc4e631f3eb74" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d674eaa0056896d5ada519900dbf97ead2e46a7b6621e8160d79e2f2e1e2784b" + +[[package]] +name = "futures-io" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc94b64bb39543b4e432f1790b6bf18e3ee3b74653c5449f63310e9a74b123c" + +[[package]] +name = "futures-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f57ed14da4603b2554682e9f2ff3c65d7567b53188db96cb71538217fc64581b" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8764258ed64ebc5d9ed185cf86a95db5cac810269c5d20ececb32e0088abbd" + +[[package]] +name = "futures-task" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd26820a9f3637f1302da8bceba3ff33adbe53464b54ca24d4e2d4f1db30f94" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a894a0acddba51a2d49a6f4263b1e64b8c579ece8af50fa86503d52cd1eea34" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-task", + "memchr", + "pin-project", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "h2" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + +[[package]] +name = "hyper" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6" +dependencies = [ + "bytes", + "futures-util", + "hyper", + "log", + "rustls", + "tokio", + "tokio-rustls", + "webpki", +] + +[[package]] +name = "hyper-tls" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-tls", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "im" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111c1983f3c5bb72732df25cddacee9b546d08325fb584b5ebd38148be7b0246" +dependencies = [ + "bitmaps", + "rand_core", + "rand_xoshiro", + "sized-chunks", + "typenum", + "version_check", +] + +[[package]] +name = "indexmap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "ipnet" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "js-sys" +version = "0.3.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "net2" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "num-integer" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" + +[[package]] +name = "openssl" +version = "0.10.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "lazy_static", + "libc", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e555d9e657502182ac97b539fb3dae8b79cda19e3e4f8ffb5e8de4f18df93c95" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "ppv-lite86" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" + +[[package]] +name = "proc-macro-hack" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" + +[[package]] +name = "proc-macro-nested" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_xoshiro" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9fcdd2e881d02f1d9390ae47ad8e5696a9e4be7b547a1da2afbc61973217004" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "reqwest" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "hyper-rustls", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "mime_guess", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "tokio-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "ring" +version = "0.16.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.9", +] + +[[package]] +name = "rustls" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi 0.3.9", +] + +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "sentry" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144e85b28d129f056ef91664fe2b985eade906d2838752c2f61c9f233cd98e4a" +dependencies = [ + "reqwest", + "sentry-core", +] + +[[package]] +name = "sentry-core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fe4fe890b12416701f838c702898a9c5e574c333cfbbee9fb7855a14e6490a3" +dependencies = [ + "im", + "lazy_static", + "rand", + "sentry-types", + "serde", + "serde_json", +] + +[[package]] +name = "sentry-types" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8124f0e9bc1113ecbcc8c3746e0e590943cf23e7d09c70a088c116869bb12e3" +dependencies = [ + "chrono", + "debugid", + "serde", + "serde_json", + "thiserror", + "url", + "uuid", +] + +[[package]] +name = "serde" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url", +] + +[[package]] +name = "sized-chunks" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec31ceca5644fa6d444cc77548b88b67f46db6f7c71683b0f9336e671830d2f" +dependencies = [ + "bitmaps", + "typenum", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "socket2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "syn" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "thiserror" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", +] + +[[package]] +name = "tinyvec" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" + +[[package]] +name = "tokio" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "slab", +] + +[[package]] +name = "tokio-rustls" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" +dependencies = [ + "futures-core", + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "tracing" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", + "serde", +] + +[[package]] +name = "uuid" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +dependencies = [ + "rand", + "serde", +] + +[[package]] +name = "vcpkg" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasm-bindgen" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" +dependencies = [ + "cfg-if", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" + +[[package]] +name = "web-sys" +version = "0.3.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" +dependencies = [ + "webpki", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/examples/10_feature_bans/Cargo.toml b/examples/10_feature_bans/Cargo.toml new file mode 100644 index 00000000..2da18ba9 --- /dev/null +++ b/examples/10_feature_bans/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "feature-bans" +version = "0.1.0" +authors = ["Jake Shadle "] +edition = "2018" + +[dependencies] +reqwest = { version = "0.10.8", default-features = false } + +[dependencies.sentry] +version = "0.20.1" +default-features = false +features = ["with_rustls"] + +[dev-dependencies] +reqwest = { version = "0.10.8", features = ["rustls"] } \ No newline at end of file diff --git a/examples/10_feature_bans/deny.toml b/examples/10_feature_bans/deny.toml new file mode 100644 index 00000000..129ce5dd --- /dev/null +++ b/examples/10_feature_bans/deny.toml @@ -0,0 +1,7 @@ +[bans] +multiple-versions = "allow" # We don't care about these for this example + +[[bans.deny]] +name = "reqwest" +#deny-features = ["default-tls", "native-tls-crate"] +allow-features = ["rustls"] diff --git a/examples/10_feature_bans/src/lib.rs b/examples/10_feature_bans/src/lib.rs new file mode 100644 index 00000000..31e1bb20 --- /dev/null +++ b/examples/10_feature_bans/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} From 9136a1b7187fa93dee78069285b56584cc4a5290 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 15 Oct 2020 08:35:36 +0200 Subject: [PATCH 14/17] Add inline colorization to some diagnostics --- src/bans/diags.rs | 130 +++++++++++++++++++++++++++++++++++++--- src/cargo-deny/check.rs | 11 ++++ src/lib.rs | 2 + 3 files changed, 135 insertions(+), 8 deletions(-) diff --git a/src/bans/diags.rs b/src/bans/diags.rs index c8d9d7db..9c0cffa2 100644 --- a/src/bans/diags.rs +++ b/src/bans/diags.rs @@ -1,5 +1,5 @@ use crate::{ - diag::{CfgCoord, Check, Diag, Diagnostic, KrateCoord, Label, Pack, Severity}, + diag::{CfgCoord, Check, Diag, Diagnostic, FileId, KrateCoord, Label, Pack, Severity}, Krate, }; @@ -260,7 +260,7 @@ impl<'a> Into for ExactFeaturesMismatch<'a> { .with_notes( self.not_allowed .iter() - .map(|na| format!("'{}' feature was enabled bot not explicitly allowed", na)) + .map(|na| format!("'{}' feature was enabled but not explicitly allowed", na)) .collect(), ) .into() @@ -269,34 +269,109 @@ impl<'a> Into for ExactFeaturesMismatch<'a> { pub(crate) struct FeaturesNotExplicitlyAllowed<'a> { pub(crate) not_allowed: &'a [&'a str], + pub(crate) allowed: Vec, + pub(crate) enabled_features: &'a [&'a str], pub(crate) parent: &'a Krate, pub(crate) dep_name: &'a str, + pub(crate) colorize: bool, } impl<'a> Into for FeaturesNotExplicitlyAllowed<'a> { fn into(self) -> Diag { + use std::fmt::Write; + + let mut note = String::with_capacity(100); + write!(&mut note, "Enabled features: ").unwrap(); + + if self.colorize { + note.push('['); + + for enabled in self.enabled_features { + if self + .not_allowed + .iter() + .find(|na| **na == *enabled) + .is_some() + { + write!(&mut note, "{}, ", ansi_term::Color::Red.paint(*enabled)).unwrap(); + } else { + write!(&mut note, "{}, ", ansi_term::Color::Green.paint(*enabled)).unwrap(); + } + } + + note.truncate(note.len() - 2); + note.push(']'); + } else { + write!( + &mut note, + "[{}]", + crate::diag::to_string(self.enabled_features) + ) + .unwrap(); + } + Diagnostic::new(Severity::Error) .with_message(format!( "features declared by '{}' for '{}' were not explicitly allowed", self.parent, self.dep_name )) .with_code("B013") - .with_notes(vec![format!( - "Features: {}", - crate::diag::to_string(self.not_allowed) - )]) + .with_labels( + self.allowed + .into_iter() + .map(|cc| cc.into_label().with_message("feature allowed here")) + .collect(), + ) + .with_notes(vec![note]) .into() } } pub(crate) struct FeaturesExplicitlyDenied<'a> { - pub(crate) found_denied: Vec, + pub(crate) cfg_file_id: FileId, + pub(crate) found_denied: Vec<&'a crate::cfg::Spanned>, + pub(crate) enabled_features: &'a [&'a str], pub(crate) parent: &'a Krate, pub(crate) dep_name: &'a str, + pub(crate) colorize: bool, } impl<'a> Into for FeaturesExplicitlyDenied<'a> { fn into(self) -> Diag { + use std::fmt::Write; + + let mut note = String::with_capacity(100); + write!(&mut note, "Enabled features: ").unwrap(); + + if self.colorize { + note.push('['); + + for enabled in self.enabled_features { + if self + .found_denied + .iter() + .find(|fd| fd.value == *enabled) + .is_some() + { + write!(&mut note, "{}, ", ansi_term::Color::Red.paint(*enabled)).unwrap(); + } else { + write!(&mut note, "{}, ", enabled).unwrap(); + } + } + + note.truncate(note.len() - 2); + note.push(']'); + } else { + write!( + &mut note, + "[{}]", + crate::diag::to_string(self.enabled_features) + ) + .unwrap(); + } + + let cfg_file_id = self.cfg_file_id; + Diagnostic::new(Severity::Error) .with_message(format!( "features declared by '{}' for '{}' were explicitly denied", @@ -306,9 +381,48 @@ impl<'a> Into for FeaturesExplicitlyDenied<'a> { .with_labels( self.found_denied .into_iter() - .map(|fd| fd.into_label()) + .map(|fd| { + Label::primary(cfg_file_id, fd.span.clone()) + .with_message("feature denied here") + }) .collect(), ) + .with_notes(vec![note]) + .into() + } +} + +pub(crate) struct UnableToGetDefaultFeatures<'a> { + pub(crate) parent_krate: &'a Krate, + pub(crate) dep: &'a krates::cm::Dependency, +} + +impl<'a> Into for UnableToGetDefaultFeatures<'a> { + fn into(self) -> Diag { + Diagnostic::new(Severity::Warning) + .with_message(format!( + "unable to get default features for '{}' used by '{}'", + self.dep.name, self.parent_krate, + )) + .with_code("B015") .into() } } +// pub(crate) struct EnabledFeatures<'a> { +// pub(crate) enabled_features: &'a [&'a str], +// pub(crate) parent: &'a Krate, +// pub(crate) dep_name: &'a str, +// } + +// impl<'a> Into for EnabledFeatures<'a> { +// fn into(self) -> Diag { +// Diagnostic::new(Severity::Note) +// .with_message(format!( +// "enabled features for '{}' from '{}'", +// self.dep_name, self.parent +// )) +// .with_code("B015") +// .with_notes(vec![crate::diag::to_string(self.enabled_features)]) +// .into() +// } +// } diff --git a/src/cargo-deny/check.rs b/src/cargo-deny/check.rs index b9d05acf..d27ddaea 100644 --- a/src/cargo-deny/check.rs +++ b/src/cargo-deny/check.rs @@ -329,6 +329,13 @@ pub(crate) fn cmd( let audit_compatible_output = args.audit_compatible_output && log_ctx.format == crate::Format::Json; + let colorize = log_ctx.format == crate::Format::Human + && match log_ctx.color { + crate::Color::Auto => atty::is(atty::Stream::Stderr), + crate::Color::Always => true, + crate::Color::Never => false, + }; + rayon::scope(|s| { // Asynchronously displays messages sent from the checks s.spawn(|_| { @@ -354,6 +361,7 @@ pub(crate) fn cmd( krates: &krates, krate_spans: &krate_spans, serialize_extra, + colorize, }; s.spawn(move |_| { @@ -405,6 +413,7 @@ pub(crate) fn cmd( krates: &krates, krate_spans: &krate_spans, serialize_extra, + colorize, }; s.spawn(|_| { @@ -426,6 +435,7 @@ pub(crate) fn cmd( krates: &krates, krate_spans: &krate_spans, serialize_extra, + colorize, }; s.spawn(|_| { @@ -446,6 +456,7 @@ pub(crate) fn cmd( krates: &krates, krate_spans: &krate_spans, serialize_extra, + colorize, }; s.spawn(move |_| { diff --git a/src/lib.rs b/src/lib.rs index 611daf04..133fdcaa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -307,4 +307,6 @@ pub struct CheckCtx<'ctx, T> { /// Requests for additional information the check can provide to be /// serialized to the diagnostic pub serialize_extra: bool, + /// Allows for ANSI colorization of diagnostic content + pub colorize: bool, } From 308264c7334b5c6aee59ee6820dbe73eac3b22ce Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 15 Oct 2020 08:36:02 +0200 Subject: [PATCH 15/17] WIP: Correctly gather crate features --- src/bans/mod.rs | 123 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 27 deletions(-) diff --git a/src/bans/mod.rs b/src/bans/mod.rs index 7e9b510f..dbc488e0 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -185,6 +185,59 @@ impl TreeSkipper { } } +fn get_enabled_features<'a>( + edge: krates::petgraph::graph::EdgeReference<'a, krates::Edge>, + krates: &'a Krates, +) -> Option> { + let mut enabled = Vec::new(); + let mut add_default_features = false; + + // Walk up the dependency graph to figure out which features are actually, really + // enabled for the actual crate we've been asked to gather features for + let mut node_stack = + smallvec::SmallVec::<[krates::petgraph::graph::EdgeReference<'_, krates::Edge>; 10]>::new(); + node_stack.push(edge); + + let krate_name = &krates[edge.target()].name; + + while let Some(edge) = node_stack.pop() { + let dep = &krates[edge.target()]; + let parent = &krates[edge.source()]; + + let kind = edge.weight().kind; + // This should never happen, but better than panicing! + let dep_node = match parent + .deps + .iter() + .find(|d| krates::DepKind::from(d.kind) == kind && d.name == dep.name) + { + Some(d) => d, + None => return None, + }; + + dep_node.features.iter().map(|s| s.as_ref()).collect(); + } + + let dep = &krates[edge.target()]; + + if add_default_features && dep.features.contains_key("default") { + let mut feature_stack = vec!["default"]; + + while let Some(feat) = feature_stack.pop() { + enabled.push(feat); + if let Some(feats) = dep.features.get(feat) { + for sub_feat in feats { + feature_stack.push(sub_feat); + } + } + } + } + + enabled.sort(); + enabled.dedup(); + Some(enabled) +} + pub struct DupGraph { pub duplicate: String, pub graph: String, @@ -215,20 +268,14 @@ pub fn check( .. } = ctx.cfg; + let krates = &ctx.krates; let krate_spans = &ctx.krate_spans; - let (mut tree_skipper, build_diags) = TreeSkipper::build(tree_skipped, ctx.krates, file_id); + let (mut tree_skipper, build_diags) = TreeSkipper::build(tree_skipped, krates, file_id); if !build_diags.is_empty() { sink.push(build_diags); } - // struct KrateBanInfo { - // wrappers: Vec>, - // allow_features: Spanned>>, - // deny_features: Spanned>>, - // exact_features: Spanned, - // } - let denied_ids: Vec<_> = denied.iter().map(|kb| kb.id.clone()).collect(); let denied_info = denied; @@ -243,11 +290,13 @@ pub fn check( } let mut multi_detector = MultiDetector { - name: &ctx.krates.krates().next().unwrap().krate.name, + name: &krates.krates().next().unwrap().krate.name, dupes: smallvec::SmallVec::new(), }; - for (i, krate) in ctx.krates.krates().map(|kn| &kn.krate).enumerate() { + let colorize = ctx.colorize; + + for (i, krate) in krates.krates().map(|kn| &kn.krate).enumerate() { let mut pack = Pack::with_kid(Check::Bans, krate.id.clone()); //let krate_coord = krate_spans.get_coord(i); @@ -262,8 +311,8 @@ pub fn check( // by one or more particular crates let allowed_wrappers = &denied_info[bind].wrappers; let is_allowed = if !allowed_wrappers.is_empty() { - let nid = ctx.krates.nid_for_kid(&krate.id).unwrap(); - let graph = ctx.krates.graph(); + let nid = krates.nid_for_kid(&krate.id).unwrap(); + let graph = krates.graph(); // Ensure that every single crate that has a direct dependency // on the banned crate is an allowed wrapper @@ -272,7 +321,6 @@ pub fn check( .map(|edge| edge.source()) .all(|nid| { let node = &graph[nid]; - //let krate_coord = krate_spans.get_coord(nid.index()); let (diag, is_allowed): (Diag, _) = match allowed_wrappers .iter() @@ -315,8 +363,8 @@ pub fn check( // Ensure that the feature set of this krate, wherever it's used // as a dependency, matches the ban entry. - let nid = ctx.krates.nid_for_kid(&krate.id).unwrap(); - let graph = ctx.krates.graph(); + let nid = krates.nid_for_kid(&krate.id).unwrap(); + let graph = krates.graph(); let feature_set_allowed = graph .edges_directed(nid, Direction::Incoming) @@ -334,10 +382,22 @@ pub fn check( .find(|dep| dep.name == krate.name) .unwrap(); - let dep_features = &dep.features; + // We need to retrieve the features used by the dependency, and if default + // features are enabled, crawl all of them from the package itself + // to retrieve the true enabled set + let enabled_features = match get_enabled_features(&dep, krates) { + Some(ef) => ef, + None => { + pack.push(diags::UnableToGetDefaultFeatures { + parent_krate: &parent.krate, + dep, + }); + return false; + } + }; // Gather features that were present, but not explicitly allowed - let not_allowed: Vec<_> = dep_features + let not_allowed: Vec<_> = enabled_features .iter() .filter_map(|df| { if allowed_features @@ -359,7 +419,11 @@ pub fn check( .value .iter() .filter_map(|af| { - if dep_features.iter().find(|df| **df == af.value).is_none() { + if enabled_features + .iter() + .find(|df| **df == af.value) + .is_none() + { Some(CfgCoord { file: file_id, span: af.span.clone(), @@ -391,8 +455,18 @@ pub fn check( if !allowed_features.value.is_empty() && !not_allowed.is_empty() { pack.push(diags::FeaturesNotExplicitlyAllowed { not_allowed: ¬_allowed, + enabled_features: &enabled_features, parent: &parent.krate, dep_name: &dep.name, + allowed: allowed_features + .value + .iter() + .map(|af| CfgCoord { + file: file_id, + span: af.span.clone(), + }) + .collect(), + colorize, }); feature_set_allowed = false; @@ -401,23 +475,18 @@ pub fn check( let found_denied: Vec<_> = denied_features .value .iter() - .filter_map(|deny_f| { - dep_features - .iter() - .find(|df| **df == deny_f.value) - .map(|_| CfgCoord { - file: file_id, - span: deny_f.span.clone(), - }) - }) + .filter(|deny_f| enabled_features.contains(&deny_f.value.as_str())) .collect(); // Add diagnostics for features that were explicitly denied if !found_denied.is_empty() { pack.push(diags::FeaturesExplicitlyDenied { + cfg_file_id: file_id, found_denied, + enabled_features: &enabled_features, parent: &parent.krate, dep_name: &dep.name, + colorize, }); feature_set_allowed = false; From 6e3d1bbbbe3b86e5052252eb5a9ae53f878c90c6 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 15 Oct 2020 18:19:27 +0200 Subject: [PATCH 16/17] Add kube to example --- Cargo.lock | 70 +-- examples/10_feature_bans/Cargo.lock | 700 +++++++++++++++++++++++++++- examples/10_feature_bans/Cargo.toml | 8 +- 3 files changed, 742 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f561d77..caa94b13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,9 +17,9 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "aho-corasick" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" dependencies = [ "memchr", ] @@ -273,9 +273,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.11.1" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89fec17b16f1ac67908af82e47d0a90a7afd0e1827b181cd77504323d3263d35" +checksum = "a3a567c24b86754d629addc2db89e340ac9398d07b5875efcff837e3878e17ec" dependencies = [ "semver 0.10.0", "serde", @@ -404,9 +404,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0af3b5e4601de3837c9332e29e0aae47a0d46ebfa246d12b82f564bac233393" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" [[package]] name = "crates-index" @@ -534,9 +534,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78baca05127a115136a9898e266988fc49ca7ea2c839f60fc6e1fc9df1599168" +checksum = "e268162af1a5fe89917ae25ba3b0a77c8da752bdc58e7dbb4f15b91fbd33756e" dependencies = [ "curl-sys", "libc", @@ -549,9 +549,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.36+curl-7.71.1" +version = "0.4.38+curl-7.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68cad94adeb0c16558429c3c34a607acc9ea58e09a7b66310aabc9788fc5d721" +checksum = "498ecfb4f59997fd40023d62a9f1e506e768b2baeb59a1d311eb9751cdcd7e3f" dependencies = [ "cc", "libc", @@ -715,9 +715,9 @@ checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" [[package]] name = "git2" -version = "0.13.11" +version = "0.13.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e094214efbc7fdbbdee952147e493b00e99a4e52817492277e98967ae918165" +checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224" dependencies = [ "bitflags", "libc", @@ -901,9 +901,7 @@ dependencies = [ [[package]] name = "krates" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f8aaf078e1ecab63c4a43c97f087ed61085fd06449cd3cc1ffb2c72b6024703" +version = "0.4.2" dependencies = [ "cargo_metadata", "cfg-expr", @@ -931,9 +929,9 @@ checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" [[package]] name = "libgit2-sys" -version = "0.12.13+1.0.1" +version = "0.12.14+1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069eea34f76ec15f2822ccf78fe0cdb8c9016764d0a12865278585a74dbdeae5" +checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549" dependencies = [ "cc", "libc", @@ -1146,9 +1144,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "platforms" @@ -1302,9 +1300,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regex" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f45b719a674bf4b828ff318906d6c133264c793eff7a41e30074a45b5099e2" +checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" dependencies = [ "aho-corasick", "memchr", @@ -1314,9 +1312,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.19" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17be88d9eaa858870aa5e48cc406c206e4600e983fc4f06bbe5750d93d09761" +checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" [[package]] name = "remove_dir_all" @@ -1486,9 +1484,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a230ea9107ca2220eea9d46de97eddcb04cd00e92d13dda78e478dd33fa82bd4" +checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" dependencies = [ "itoa", "ryu", @@ -1549,6 +1547,12 @@ dependencies = [ "smallvec", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strip-ansi-escapes" version = "0.1.0" @@ -1566,9 +1570,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a7159e7d0dbcab6f9c980d7971ef50f3ff5753081461eeda120d5974a4ee95" +checksum = "126d630294ec449fae0b16f964e35bf3c74f940da9dca17ee9b905f7b3112eb8" dependencies = [ "clap", "lazy_static", @@ -1577,9 +1581,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc47de4dfba76248d1e9169ccff240eea2a4dc1e34e309b95b2393109b4b383" +checksum = "65e51c492f9e23a220534971ff5afc14037289de430e3c83f9daf6a1b6ae91e8" dependencies = [ "heck", "proc-macro-error", @@ -1734,9 +1738,13 @@ dependencies = [ [[package]] name = "twox-hash" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" +checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" +dependencies = [ + "cfg-if 0.1.10", + "static_assertions", +] [[package]] name = "typenum" diff --git a/examples/10_feature_bans/Cargo.lock b/examples/10_feature_bans/Cargo.lock index b58b1bbe..6ed397c3 100644 --- a/examples/10_feature_bans/Cargo.lock +++ b/examples/10_feature_bans/Cargo.lock @@ -1,11 +1,99 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + +[[package]] +name = "ahash" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" +dependencies = [ + "const-random", +] + +[[package]] +name = "aho-corasick" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" +dependencies = [ + "memchr", +] + +[[package]] +name = "arc-swap" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" + +[[package]] +name = "array_tool" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" + +[[package]] +name = "async-compression" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9021768bcce77296b64648cc7a7460e3df99979b97ed5c925c38d1cc83778d98" +dependencies = [ + "bytes", + "flate2", + "futures-core", + "memchr", + "pin-project-lite", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + [[package]] name = "autocfg" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "base-x" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1" + [[package]] name = "base64" version = "0.12.3" @@ -27,6 +115,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "blake2b_simd" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + [[package]] name = "bumpalo" version = "3.4.0" @@ -61,10 +160,42 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time", + "time 0.1.44", "winapi 0.3.9", ] +[[package]] +name = "const-random" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02dc82c12dc2ee6e1ded861cf7d582b46f66f796d1b6c93fa28b911ead95da02" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc757bbb9544aa296c2ae00c679e81f886b37e28e59097defe0cf524306f6685" +dependencies = [ + "getrandom 0.2.0", + "proc-macro-hack", +] + +[[package]] +name = "const_fn" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2" + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "core-foundation" version = "0.7.0" @@ -81,6 +212,37 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "dashmap" +version = "3.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f260e2fc850179ef410018660006951c1b55b79e8087e87111a2c388994b9b5" +dependencies = [ + "ahash", + "cfg-if", + "num_cpus", +] + [[package]] name = "debugid" version = "0.7.2" @@ -91,12 +253,61 @@ dependencies = [ "uuid", ] +[[package]] +name = "derivative" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dirs" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.9", +] + +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "dtoa" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + [[package]] name = "encoding_rs" version = "0.8.24" @@ -106,14 +317,40 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "feature-bans" version = "0.1.0" dependencies = [ + "kube-runtime", "reqwest", "sentry", ] +[[package]] +name = "flate2" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -151,6 +388,21 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8e3078b7b2a8a671cb7a3d17b4760e4181ea243227776ba83fd043b4ca034e" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.6" @@ -158,6 +410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a4d35f7401e948629c9c3d6638fb9bf94e0b2121e96c3b428cc4e631f3eb74" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -166,6 +419,17 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d674eaa0056896d5ada519900dbf97ead2e46a7b6621e8160d79e2f2e1e2784b" +[[package]] +name = "futures-executor" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc709ca1da6f66143b8c9bec8e6260181869893714e9b5a490b169b0414144ab" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.6" @@ -205,9 +469,11 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a894a0acddba51a2d49a6f4263b1e64b8c579ece8af50fa86503d52cd1eea34" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", + "futures-sink", "futures-task", "memchr", "pin-project", @@ -228,6 +494,17 @@ dependencies = [ "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "h2" version = "0.2.6" @@ -295,6 +572,15 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + [[package]] name = "hyper" version = "0.13.8" @@ -413,6 +699,36 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonpath_lib" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8727f6987896c010ec9add275f59de2ae418b672fafa77bc3673b4cee1f09ca" +dependencies = [ + "array_tool", + "env_logger", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "k8s-openapi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57f95fd36c08ce592e67400a0f1a66f432196997d5a7e9a97e8743c33d8a9312" +dependencies = [ + "base64", + "bytes", + "chrono", + "http", + "percent-encoding", + "serde", + "serde-value", + "serde_json", + "url", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -423,6 +739,55 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "kube" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3787d41d01ff816f93f1a73d20252f8a65887682206cfbf2d0f7d2d2b1b73fa" +dependencies = [ + "Inflector", + "base64", + "bytes", + "chrono", + "dirs", + "either", + "futures", + "futures-util", + "http", + "jsonpath_lib", + "k8s-openapi", + "log", + "openssl", + "pem", + "reqwest", + "serde", + "serde_json", + "serde_yaml", + "static_assertions", + "thiserror", + "time 0.2.22", + "tokio", + "url", +] + +[[package]] +name = "kube-runtime" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9abc7b19889353e501e6bc7b2b9d7062b2e008ec256f11e9428ed8e56d046d2f" +dependencies = [ + "dashmap", + "derivative", + "futures", + "k8s-openapi", + "kube", + "pin-project", + "serde", + "smallvec", + "snafu", + "tokio", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -435,6 +800,12 @@ version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" + [[package]] name = "log" version = "0.4.11" @@ -472,6 +843,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "mio" version = "0.6.22" @@ -491,6 +872,17 @@ dependencies = [ "winapi 0.2.8", ] +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio", +] + [[package]] name = "miow" version = "0.2.1" @@ -600,6 +992,26 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fe9037165d7023b1228bc4ae9a2fa1a2b0095eca6c2998c624723dfd01314a5" +dependencies = [ + "num-traits", +] + +[[package]] +name = "pem" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59698ea79df9bf77104aefd39cc3ec990cb9693fb59c3b0a70ddf2646fdffb4b" +dependencies = [ + "base64", + "once_cell", + "regex", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -671,6 +1083,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.7" @@ -686,7 +1104,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.15", "libc", "rand_chacha", "rand_core", @@ -709,7 +1127,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.15", ] [[package]] @@ -736,6 +1154,35 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_users" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +dependencies = [ + "getrandom 0.1.15", + "redox_syscall", + "rust-argon2", +] + +[[package]] +name = "regex" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -751,6 +1198,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" dependencies = [ + "async-compression", "base64", "bytes", "encoding_rs", @@ -800,6 +1248,27 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rust-argon2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +dependencies = [ + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + [[package]] name = "rustls" version = "0.18.1" @@ -862,6 +1331,21 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "sentry" version = "0.20.1" @@ -910,6 +1394,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.116" @@ -927,6 +1421,7 @@ version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" dependencies = [ + "indexmap", "itoa", "ryu", "serde", @@ -944,6 +1439,34 @@ dependencies = [ "url", ] +[[package]] +name = "serde_yaml" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3e2dd40a7cdc18ca80db804b7f461a39bb721160a85c9a1fa30134bf3c02a5" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "signal-hook-registry" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" +dependencies = [ + "arc-swap", + "libc", +] + [[package]] name = "sized-chunks" version = "0.6.2" @@ -960,6 +1483,35 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +[[package]] +name = "smallvec" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" + +[[package]] +name = "snafu" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c4e6046e4691afe918fd1b603fd6e515bcda5388a1092a9edbada307d159f09" +dependencies = [ + "doc-comment", + "futures-core", + "pin-project", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7073448732a89f2f3e6581989106067f403d378faeafb4a50812eb814170d3e5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "socket2" version = "0.3.15" @@ -978,6 +1530,70 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "standback" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4e0831040d2cf2bdfd51b844be71885783d489898a192f254ae25d57cce725c" +dependencies = [ + "version_check", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + [[package]] name = "syn" version = "1.0.44" @@ -1003,6 +1619,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.21" @@ -1023,6 +1648,15 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + [[package]] name = "time" version = "0.1.44" @@ -1034,6 +1668,44 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "time" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55b7151c9065e80917fbf285d9a5d1432f60db41d170ccafc749a136b41a93af" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi 0.3.9", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + [[package]] name = "tinyvec" version = "0.3.4" @@ -1051,11 +1723,15 @@ dependencies = [ "futures-core", "iovec", "lazy_static", + "libc", "memchr", "mio", + "mio-uds", "num_cpus", "pin-project-lite", + "signal-hook-registry", "slab", + "winapi 0.3.9", ] [[package]] @@ -1353,6 +2029,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1377,3 +2062,12 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] + +[[package]] +name = "yaml-rust" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" +dependencies = [ + "linked-hash-map", +] diff --git a/examples/10_feature_bans/Cargo.toml b/examples/10_feature_bans/Cargo.toml index 2da18ba9..36c10378 100644 --- a/examples/10_feature_bans/Cargo.toml +++ b/examples/10_feature_bans/Cargo.toml @@ -5,12 +5,16 @@ authors = ["Jake Shadle "] edition = "2018" [dependencies] -reqwest = { version = "0.10.8", default-features = false } +reqwest = { version = "=0.10.8", default-features = false } [dependencies.sentry] -version = "0.20.1" +version = "=0.20.1" default-features = false features = ["with_rustls"] +[dependencies.kube-runtime] +version = "=0.43.0" +default-features = true + [dev-dependencies] reqwest = { version = "0.10.8", features = ["rustls"] } \ No newline at end of file From 6e4d429691c6f65498db710764c8af6f729440bb Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 15 Oct 2020 18:19:43 +0200 Subject: [PATCH 17/17] Checkpoint again --- Cargo.toml | 3 ++ src/bans/mod.rs | 76 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 306133f4..24b1726a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,3 +103,6 @@ lazy_static = "1.4.0" # We use this for creating fake crate directories for # crawling license files on disk tempfile = "3.1.0" + +[patch.crates-io] +krates = { path = "../krates" } diff --git a/src/bans/mod.rs b/src/bans/mod.rs index dbc488e0..2d1a9f53 100644 --- a/src/bans/mod.rs +++ b/src/bans/mod.rs @@ -185,53 +185,95 @@ impl TreeSkipper { } } +fn get_features<'a>(krate: &'a Krate, dep: &'a krates::cm::Dependency) -> Vec<&'a str> { + let mut feats = Vec::with_capacity(10); + + let default = std::iter::once_with(|| { + if dep.uses_default_features { + "default" + } else { + "" + } + }); + + for feat in dep.features.iter().map(|s| s.as_str()).chain(default) { + if krate.features.contains_key(feat) { + let mut feat_stack = smallvec::SmallVec::<[&str; 10]>::new(); + feat_stack.push(feat); + + while let Some(feat) = feat_stack.pop() { + match feats.binary_search(&feat) { + Ok(i) => continue, + Err(i) => feats.insert(i, feat), + } + if let Some(feats) = krate.features.get(feat) { + for sub_feat in feats { + feat_stack.push(sub_feat); + } + } + } + } + } + + feats +} + fn get_enabled_features<'a>( edge: krates::petgraph::graph::EdgeReference<'a, krates::Edge>, krates: &'a Krates, ) -> Option> { - let mut enabled = Vec::new(); - let mut add_default_features = false; - // Walk up the dependency graph to figure out which features are actually, really // enabled for the actual crate we've been asked to gather features for let mut node_stack = smallvec::SmallVec::<[krates::petgraph::graph::EdgeReference<'_, krates::Edge>; 10]>::new(); node_stack.push(edge); - let krate_name = &krates[edge.target()].name; + let graph = krates.graph(); + + let dep_feature_stack = Vec::new(); while let Some(edge) = node_stack.pop() { let dep = &krates[edge.target()]; let parent = &krates[edge.source()]; let kind = edge.weight().kind; + + // We don't care about dev dependencies for non-workspace crates + if kind == krates::DepKind::Dev + && krates + .workspace_members() + .find(|n| n.id == parent.id) + .is_none() + { + continue; + } + // This should never happen, but better than panicing! let dep_node = match parent .deps .iter() - .find(|d| krates::DepKind::from(d.kind) == kind && d.name == dep.name) + .find(|d| kind == d.kind && dep.name == d.name) { Some(d) => d, None => return None, }; + if !parent.features.is_empty() { + for pedge in graph.edges_directed(edge.source(), krates::petgraph::Direction::Incoming) + { + node_stack.push(pedge); + } + } + dep_node.features.iter().map(|s| s.as_ref()).collect(); } - let dep = &krates[edge.target()]; + let mut enabled = Vec::new(); + let mut add_default_features = false; - if add_default_features && dep.features.contains_key("default") { - let mut feature_stack = vec!["default"]; + let dep = &krates[edge.target()]; - while let Some(feat) = feature_stack.pop() { - enabled.push(feat); - if let Some(feats) = dep.features.get(feat) { - for sub_feat in feats { - feature_stack.push(sub_feat); - } - } - } - } + if add_default_features && dep.features.contains_key("default") {} enabled.sort(); enabled.dedup();