Skip to content

Commit 0f9e1bf

Browse files
committed
Add support for axios.postForm in ClientRequest.
1 parent 51cf155 commit 0f9e1bf

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ module ClientRequest {
222222
method = "request"
223223
or
224224
this = axios().getMember(method).getACall() and
225-
method = [httpMethodName(), "request"]
225+
method = [httpMethodName(), "request", "postForm"]
226226
}
227227

228228
private int getOptionsArgIndex() {
@@ -254,6 +254,8 @@ module ClientRequest {
254254
method = ["post", "put"] and
255255
result = [this.getArgument(1), this.getOptionArgument(2, "data")]
256256
or
257+
method = ["postForm"] and result = this.getArgument(1)
258+
or
257259
result = this.getOptionArgument([0 .. 2], ["headers", "params"])
258260
}
259261

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ test_ClientRequest
9797
| tst.js:319:5:319:26 | superag ... ', url) |
9898
| tst.js:320:5:320:23 | superagent.del(url) |
9999
| tst.js:321:5:321:32 | superag ... st(url) |
100+
| tst.js:325:5:325:37 | axios.p ... config) |
100101
test_getADataNode
101102
| axiosTest.js:12:5:17:6 | axios({ ... \\n }) | axiosTest.js:15:18:15:55 | { 'Cont ... json' } |
102103
| axiosTest.js:12:5:17:6 | axios({ ... \\n }) | axiosTest.js:16:15:16:35 | {x: 'te ... 'test'} |
@@ -140,6 +141,7 @@ test_getADataNode
140141
| tst.js:257:1:262:2 | form.su ... rs()\\n}) | tst.js:255:25:255:35 | 'new_value' |
141142
| tst.js:286:20:286:55 | new Web ... :8080') | tst.js:288:21:288:35 | 'Hello Server!' |
142143
| tst.js:321:5:321:32 | superag ... st(url) | tst.js:321:39:321:42 | data |
144+
| tst.js:325:5:325:37 | axios.p ... config) | tst.js:325:25:325:28 | data |
143145
test_getHost
144146
| tst.js:87:5:87:39 | http.ge ... host}) | tst.js:87:34:87:37 | host |
145147
| tst.js:89:5:89:23 | axios({host: host}) | tst.js:89:18:89:21 | host |
@@ -254,6 +256,7 @@ test_getUrl
254256
| tst.js:319:5:319:26 | superag ... ', url) | tst.js:319:23:319:25 | url |
255257
| tst.js:320:5:320:23 | superagent.del(url) | tst.js:320:20:320:22 | url |
256258
| tst.js:321:5:321:32 | superag ... st(url) | tst.js:321:29:321:31 | url |
259+
| tst.js:325:5:325:37 | axios.p ... config) | tst.js:325:20:325:22 | url |
257260
test_getAResponseDataNode
258261
| axiosTest.js:4:5:7:6 | axios({ ... \\n }) | axiosTest.js:4:5:7:6 | axios({ ... \\n }) | json | true |
259262
| axiosTest.js:12:5:17:6 | axios({ ... \\n }) | axiosTest.js:12:5:17:6 | axios({ ... \\n }) | json | true |
@@ -334,3 +337,4 @@ test_getAResponseDataNode
334337
| tst.js:319:5:319:26 | superag ... ', url) | tst.js:319:5:319:26 | superag ... ', url) | stream | true |
335338
| tst.js:320:5:320:23 | superagent.del(url) | tst.js:320:5:320:23 | superagent.del(url) | stream | true |
336339
| tst.js:321:5:321:32 | superag ... st(url) | tst.js:321:5:321:32 | superag ... st(url) | stream | true |
340+
| tst.js:325:5:325:37 | axios.p ... config) | tst.js:325:5:325:37 | axios.p ... config) | json | true |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function useSuperagent(url){
322322
}
323323

324324
function moreAxiosTests(url, data, config){
325-
axios.postForm(url, data, config); // not flagged
325+
axios.postForm(url, data, config);
326326
axios.putForm(url, data); // not flagged
327327
axios.putForm(url, data, config); // not flagged
328328
axios.patchForm(url, data); // not flagged

0 commit comments

Comments
 (0)