From f9af1317ac49dc642b7b596edac35afc8243e268 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sun, 22 Jul 2018 13:29:01 -0700 Subject: [PATCH] Update to 'rustsec' crate v0.7.0-alpha3 Testing the alpha crate on the live repository prior to a final release --- Cargo.toml | 4 ++-- src/lib.rs | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e46b550..b6f8875 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,11 @@ name = "rustsec-advisory-db" description = "Security advisory database for Rust crates published through crates.io" version = "0.0.0" authors = ["Tony Arcieri "] -license_file = "LICENSE.txt" +license-file = "LICENSE.txt" repository = "https://github.com/rustsec/advisory-db" documentation = "https://github.com/rustsec/advisory-db" categories = ["api-bindings", "development-tools"] keywords = ["rustsec", "security", "advisory", "vulnerability"] [dependencies] -rustsec = "^0.5.2" +rustsec = "0.7.0-alpha3" diff --git a/src/lib.rs b/src/lib.rs index 6d53758..5bc4333 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,24 +2,19 @@ extern crate rustsec; #[cfg(test)] mod tests { - // Name of the advisory database in the current repo - const ADVISORY_DB_FILE: &'static str = "Advisories.toml"; - - use rustsec::AdvisoryDatabase; - use std::fs::File; - use std::io::Read; - use std::path::Path; + use rustsec::{AdvisoryDatabase, Repository}; #[test] fn advisories_toml_is_well_formed() { - let path = Path::new(ADVISORY_DB_FILE); - - let mut file = File::open(&path).unwrap(); - - let mut toml = String::new(); - file.read_to_string(&mut toml).unwrap(); + let repo = Repository::open(".").unwrap(); // Ensure Advisories.toml parses - AdvisoryDatabase::from_toml(&toml).unwrap(); + let advisory_count = AdvisoryDatabase::from_repository(&repo) + .unwrap() + .advisories() + .count(); + + // Ensure we're parsing some advisories + assert!(advisory_count > 5); } }