Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eef0b8c

Browse files
author
Esben Sparre Andreasen
committed
JS: implement getADataNode for GotUrlRequest
1 parent 977b287 commit eef0b8c

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

javascript/ql/src/semmle/javascript/frameworks/ClientRequests.qll

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,26 +193,27 @@ private class FetchUrlRequest extends CustomClientRequest {
193193
*/
194194
private class GotUrlRequest extends CustomClientRequest {
195195

196-
DataFlow::Node url;
197-
198196
GotUrlRequest() {
199197
exists (string moduleName, DataFlow::SourceNode callee |
200198
this = callee.getACall() |
201199
moduleName = "got" and
202200
(
203201
callee = DataFlow::moduleImport(moduleName) or
204202
callee = DataFlow::moduleMember(moduleName, "stream")
205-
) and
206-
url = getArgument(0) and not exists (getOptionArgument(1, "baseUrl"))
203+
)
207204
)
208205
}
209206

210207
override DataFlow::Node getUrl() {
211-
result = url
208+
result = getArgument(0) and
209+
not exists (getOptionArgument(1, "baseUrl"))
212210
}
213211

214212
override DataFlow::Node getADataNode() {
215-
none()
213+
exists (string name |
214+
name = "headers" or name = "body" or name = "query" |
215+
result = getOptionArgument(1, name)
216+
)
216217
}
217218

218219
}

javascript/ql/test/library-tests/frameworks/ClientRequests/ClientRequest.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
| tst.js:57:5:57:39 | axios.p ... data2}) |
2222
| tst.js:59:5:59:52 | axios({ ... sData}) |
2323
| tst.js:61:5:61:60 | window. ... yData}) |
24+
| tst.js:63:5:63:68 | got(url ... yData}) |

javascript/ql/test/library-tests/frameworks/ClientRequests/ClientRequest_getADataNode.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
| tst.js:59:5:59:52 | axios({ ... sData}) | tst.js:59:41:59:50 | paramsData |
66
| tst.js:61:5:61:60 | window. ... yData}) | tst.js:61:33:61:42 | headerData |
77
| tst.js:61:5:61:60 | window. ... yData}) | tst.js:61:51:61:58 | bodyData |
8+
| tst.js:63:5:63:68 | got(url ... yData}) | tst.js:63:24:63:33 | headerData |
9+
| tst.js:63:5:63:68 | got(url ... yData}) | tst.js:63:42:63:49 | bodyData |

javascript/ql/test/library-tests/frameworks/ClientRequests/ClientRequest_getUrl.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
| tst.js:57:5:57:39 | axios.p ... data2}) | tst.js:57:16:57:16 | x |
2626
| tst.js:59:5:59:52 | axios({ ... sData}) | tst.js:59:11:59:51 | {header ... msData} |
2727
| tst.js:61:5:61:60 | window. ... yData}) | tst.js:61:18:61:20 | url |
28+
| tst.js:63:5:63:68 | got(url ... yData}) | tst.js:63:9:63:11 | url |

javascript/ql/test/library-tests/frameworks/ClientRequests/tst.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ import {ClientRequest, net} from 'electron';
5959
axios({headers: headerData, params: paramsData});
6060

6161
window.fetch(url, {headers: headerData, body: bodyData});
62+
63+
got(url, {headers: headerData, body: bodyData, quer: queryData});
64+
6265
});

0 commit comments

Comments
 (0)