-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): kve - new command for printing known exploited vulnerabili…
…ties
- Loading branch information
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
use security_advisories::http::get_client; | ||
use security_advisories::service::fetch_known_exploited_vulns; | ||
use std::error::Error; | ||
|
||
pub async fn execute() -> Result<(), Box<dyn Error>> { | ||
let client = get_client()?; | ||
let known_exploited_vulns = fetch_known_exploited_vulns(&client).await; | ||
|
||
println!("{}", known_exploited_vulns?); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
use reqwest::Client; | ||
use serde_json::Value; | ||
use std::error::Error; | ||
|
||
pub async fn fetch_known_exploited_vulns(client: &Client) -> Result<Value, Box<dyn Error>> { | ||
let home_url = "https://www.cisa.gov"; | ||
let feed_path = "sites/default/files/feeds"; | ||
let known_exploited_vulns = "known_exploited_vulnerabilities.json"; | ||
let url = format!("{}/{}/{}", home_url, feed_path, known_exploited_vulns); | ||
let mut headers = reqwest::header::HeaderMap::new(); | ||
headers.insert(reqwest::header::ACCEPT, "application/json".parse()?); | ||
let res = client.get(&url).headers(headers).send().await?; | ||
|
||
let json: Value = res.json().await?; | ||
Ok(json) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters