Skip to content

Commit 310a2c8

Browse files
authored
Merge pull request github#5655 from erik-krogh/cert
Approved by esbena
2 parents 2656a52 + 32737a1 commit 310a2c8

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* The query "Disabling certificate validation" (`js/disabling-certificate-validation`) has been improved to recognize many more request libraries.

javascript/ql/src/Security/CWE-295/DisablingCertificateValidation.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import javascript
1616
*/
1717
DataFlow::ObjectLiteralNode tlsOptions() {
1818
exists(DataFlow::InvokeNode invk | result.flowsTo(invk.getAnArgument()) |
19-
invk instanceof NodeJSLib::NodeJSClientRequest
19+
invk instanceof ClientRequest
2020
or
2121
invk = DataFlow::moduleMember("https", "Agent").getAnInstantiation()
2222
or

javascript/ql/test/query-tests/Security/CWE-295/DisablingCertificateValidation.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| tst2.js:8:5:8:29 | rejectU ... : false | Disabling certificate validation is strongly discouraged. |
12
| tst.js:15:3:15:27 | rejectU ... : false | Disabling certificate validation is strongly discouraged. |
23
| tst.js:18:1:18:40 | process ... HORIZED | Disabling certificate validation is strongly discouraged. |
34
| tst.js:21:3:21:27 | rejectU ... : false | Disabling certificate validation is strongly discouraged. |
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const request = require('request');
2+
3+
let requestOptions = {
4+
headers: {
5+
"content-type": "application/json",
6+
"accept": "application/json"
7+
},
8+
rejectUnauthorized: false,
9+
requestCert: true,
10+
agent: false
11+
}
12+
13+
module.exports.post = (url, requestBody, apiContext) => {
14+
Object.assign(requestOptions, {
15+
body: JSON.stringify(requestBody),
16+
headers : Object.assign(requestOptions.headers, apiContext)
17+
})
18+
19+
return request.post(url, requestOptions).then((res) => {
20+
return Promise.resolve(res.body);
21+
}).catch((err) => {
22+
return Promise.resolve(err);
23+
})
24+
}

0 commit comments

Comments
 (0)