-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds CISA KEV managed enrichment table (#162)
- Loading branch information
1 parent
3f8bb9a
commit 27938d0
Showing
5 changed files
with
109 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
enrichment_type: dynamic | ||
write_mode: overwrite | ||
|
||
transform: | | ||
.event.kind = "enrichment" | ||
.event.category = ["vulnerability"] | ||
.vulnerability.category = [del(.json.product), del(.json.vendorProject)] | ||
.vulnerability.classification = "CVSS" | ||
.vulnerability.description = del(.json.shortDescription) | ||
.vulnerability.enumeration = "CVE" | ||
.vulnerability.id = del(.json.cveID) | ||
.cisa_kev.dateAdded = del(.json.dateAdded) | ||
.cisa_kev.requiredAction = del(.json.requiredAction) | ||
.cisa_kev.dueDate = del(.json.dueDate) | ||
.cisa_kev.notes = del(.json.notes) | ||
schema: | ||
ecs_field_names: | ||
- ecs.version | ||
- event.kind | ||
- event.category | ||
- vulnerability.category | ||
- vulnerability.classification | ||
- vulnerability.description | ||
- vulnerability.enumeration | ||
- vulnerability.id | ||
|
||
fields: | ||
- name: cisa_kev | ||
type: | ||
type: struct | ||
fields: | ||
- name: dateAdded | ||
type: string | ||
- name: requiredAction | ||
type: string | ||
- name: dueDate | ||
type: string | ||
- name: notes | ||
type: string |
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
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,58 @@ | ||
use anyhow::{anyhow, Context as AnyhowContext, Error, Result}; | ||
use async_trait::async_trait; | ||
use chrono::{DateTime, FixedOffset}; | ||
use log::{debug, error, info}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::{ | ||
collections::HashMap, | ||
io::{Read, Write}, | ||
}; | ||
|
||
use super::{PullLogs, PullLogsContext}; | ||
|
||
#[derive(Clone)] | ||
pub struct CisaKevPuller; | ||
|
||
|
||
const CISA_KEV_URL: &str = "https://www.cisa.gov/sites/default/files/csv/known_exploited_vulnerabilities.csv"; | ||
const CISA_KEV_HEADERS: [&str; 9] = [ | ||
"cveID", | ||
"vendorProject", | ||
"product", | ||
"vulnerabilityName", | ||
"dateAdded", | ||
"shortDescription", | ||
"requiredAction", | ||
"dueDate", | ||
"notes", | ||
]; | ||
|
||
#[async_trait] | ||
impl PullLogs for CisaKevPuller { | ||
async fn pull_logs( | ||
self, | ||
client: reqwest::Client, | ||
ctx: &PullLogsContext, | ||
start_dt: DateTime<FixedOffset>, | ||
end_dt: DateTime<FixedOffset>, | ||
) -> Result<Vec<u8>> { | ||
info!("Pulling CISA KEV..."); | ||
let resp = client.get(CISA_KEV_URL).send().await?.text().await?; | ||
|
||
let mut json_bytes = vec![]; | ||
|
||
let mut csv_reader = csv::ReaderBuilder::new() | ||
.comment(Some(b'#')) | ||
.from_reader(resp.as_bytes()); | ||
|
||
//csv_reader.set_headers(csv::StringRecord::from(CISA_KEV_HEADERS.to_vec())); | ||
for result in csv_reader.deserialize() { | ||
let record: HashMap<String, String> = result?; | ||
let bytes = serde_json::to_vec(&record)?; | ||
json_bytes.write(bytes.as_slice())?; | ||
json_bytes.write(b"\n")?; | ||
} | ||
|
||
return Ok(json_bytes); | ||
} | ||
} |
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