-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInsightAppSecClient.js
More file actions
54 lines (44 loc) · 1.4 KB
/
InsightAppSecClient.js
File metadata and controls
54 lines (44 loc) · 1.4 KB
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
47
48
49
50
51
52
53
54
const axios = require("axios");
const APPLICATION_JSON = "application/json";
const USER_AGENT_HEADER = "r7:insightappsec-github-actions/1.3.1";
class InsightAppSecClient {
constructor(region, apiKey) {
this.baseUrl = `https://${region}.api.insight.rapid7.com/ias/v1/`;
this.axiosInst = axios.create({
baseURL: this.baseUrl,
headers: {
"Accept": APPLICATION_JSON,
"x-api-key": apiKey,
"User-Agent": USER_AGENT_HEADER
},
timeout: 60000
});
this.axiosInst.defaults.headers.post["Content-Type"] = APPLICATION_JSON;
}
startScan(scanConfigId) {
return this.axiosInst.post("scans", {
scan_config: {
id: scanConfigId
}
});
}
getScan(scanId) {
return this.axiosInst.get(`scans/${scanId}`);
}
cancelScan(scanId){
return this.axiosInst.put(`scans/${scanId}/action`, {
action: "CANCEL"
});
}
getScanVulnerabilities(scanId, vulnQuery, nextLink) {
let query = `vulnerability.scans.id='${scanId}'`;
if (vulnQuery){
query = `${query} && (${vulnQuery})`;
}
return this.axiosInst.post(nextLink || "search", {
type: "VULNERABILITY",
query: query
});
}
}
module.exports = InsightAppSecClient;