From 1c40a5964aafdc7a155fa439e7e14d1c2686b50c Mon Sep 17 00:00:00 2001 From: cn-kali-team Date: Tue, 25 Jul 2023 17:41:10 +0800 Subject: [PATCH] format --- examples/cpe.rs | 8 +++++--- examples/cve.rs | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/cpe.rs b/examples/cpe.rs index 4748566..1392329 100644 --- a/examples/cpe.rs +++ b/examples/cpe.rs @@ -1,11 +1,12 @@ +use cpe::dictionary::CPEList; use std::fs::File; use std::io::BufReader; -use cpe::dictionary::CPEList; // https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.zip // https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz fn main() { - let gz_open_file = File::open("/home/kali-team/IdeaProjects/nvd-rs/official-cpe-dictionary_v2.3.xml.gz").unwrap(); - let gz_decoder =flate2::read::GzDecoder::new(gz_open_file); + let gz_open_file = + File::open("/home/kali-team/IdeaProjects/nvd-rs/official-cpe-dictionary_v2.3.xml.gz").unwrap(); + let gz_decoder = flate2::read::GzDecoder::new(gz_open_file); let file = BufReader::new(gz_decoder); let c: CPEList = quick_xml::de::from_reader(file).unwrap(); // let zip_open_file = File::open("/home/kali-team/IdeaProjects/nvd-rs/cpe.xml").unwrap(); @@ -15,5 +16,6 @@ fn main() { // let c: CPEList = quick_xml::de::from_reader(file).unwrap(); for cpe_item in c.cpe_item { println!("{:#?}", &cpe_item); + break; } } diff --git a/examples/cve.rs b/examples/cve.rs index 1ce3c8e..a5e5971 100644 --- a/examples/cve.rs +++ b/examples/cve.rs @@ -1,14 +1,14 @@ +use cve::CVEContainer; use std::fs::File; use std::io::BufReader; -use cve::CVEContainer; - -// https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.zip -// https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz +// 下载数据 +// curl -o- -s -k -v https://nvd.nist.gov/vuln/data-feeds >data-feeds.html +// cat data-feeds.html|grep -Eo '(/feeds/[^"]*\.gz)'|xargs -I % wget -c https://nvd.nist.gov% fn main() { let open_file = File::open("/home/kali-team/IdeaProjects/nvd-rs/nvdcve-1.1-recent.json").unwrap(); let file = BufReader::new(open_file); let c: CVEContainer = serde_json::from_reader(file).unwrap(); - println!("{:#?}",c.CVE_data_timestamp); + println!("{:#?}", c.CVE_data_timestamp); for cve_item in c.CVE_Items { println!("{:#?}", &cve_item); break;