-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (41 loc) · 1.43 KB
/
index.js
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
35
36
37
38
39
40
41
42
43
44
45
46
const core = require('@actions/core');
const fs = require('fs')
const axios = require('axios');
try {
const path = core.getInput('cve-list-path');
var cveData = []
fs.existsSync(path) ? cveData = [...new Set(
fs.readFileSync(path, 'utf8').split('\n').filter(Boolean).filter(entry => !entry.startsWith("#")))
] : core.setFailed("CVE list file not found");
if (cveData.length > 0) {
const lastReviewed = Date.parse(cveData[0])
var promises = []
cveData = cveData.slice(1)
for (var key in cveData) {
promises.push(axios.get(`https://cve.circl.lu/api/cve/${cveData[key]}`))
}
axios.all(promises).then(axios.spread((...reqs) => {
var modifiedCVEs = 0
var CVElist = []
for (var i in reqs) {
if (reqs[i].data) {
if (Date.parse(reqs[i].data.Modified) > lastReviewed) {
console.log(`${reqs[i].data.id} was modified on ${reqs[i].data.Modified}`)
modifiedCVEs += 1
CVElist.push(reqs[i].data.id)
}
}
}
return {
modCveNumber: modifiedCVEs,
CVEs: CVElist
}
})).then( (result) => {
console.log(`Found the following CVE details: ${JSON.stringify(result)}`)
core.setOutput("modified_cves_number", result["modCveNumber"]);
core.setOutput("cves", result["CVEs"].join(", "));
})
}
} catch (error) {
core.setFailed(error.message);
}