1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { blob } from "https://esm.town/v/std/blob";
import { email } from "https://esm.town/v/std/email";
const KEV_URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json";
const BLOB_KEY = "seen_cves";
async function checkNewVulnerabilities() {
const response = await fetch(KEV_URL);
const data = await response.json();
const currentVulnerabilities = new Set(data.vulnerabilities.map(v => v.cveID));
const storedCVEs = await blob.getJSON(BLOB_KEY);
let seenCVEs = new Set(Array.isArray(storedCVEs) ? storedCVEs : []);
const newCVEs = [...currentVulnerabilities].filter(cve => !seenCVEs.has(cve));
if (newCVEs.length > 0) {
const subject = `New Vulnerabilities in CISA KEV Catalog`;
const text = `The following new CVEs have been added to the CISA Known Exploited Vulnerabilities catalog:\n\n${
newCVEs.join("\n")
}`;
await email({ subject, text });
await blob.setJSON(BLOB_KEY, [...currentVulnerabilities]);
return newCVEs.join("; ");
}
return "";
}
export default async function kevCron() {
return await checkNewVulnerabilities();
}