Skip to content

Commit 69fe251

Browse files
committed
Add support for axios.postForm in ClientRequest.
1 parent e79f460 commit 69fe251

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
@@ -103,6 +103,7 @@ test_ClientRequest
103103
| tst.js:334:5:334:25 | got.pag ... rl, {}) |
104104
| tst.js:337:5:337:20 | jsonClient.get() |
105105
| tst.js:340:5:340:21 | jsonClient2.get() |
106+
| tst.js:344:5:344:37 | axios.p ... config) |
106107
test_getADataNode
107108
| axiosTest.js:12:5:17:6 | axios({ ... \\n }) | axiosTest.js:15:18:15:55 | { 'Cont ... json' } |
108109
| axiosTest.js:12:5:17:6 | axios({ ... \\n }) | axiosTest.js:16:15:16:35 | {x: 'te ... 'test'} |
@@ -146,6 +147,7 @@ test_getADataNode
146147
| tst.js:257:1:262:2 | form.su ... rs()\\n}) | tst.js:255:25:255:35 | 'new_value' |
147148
| tst.js:286:20:286:55 | new Web ... :8080') | tst.js:288:21:288:35 | 'Hello Server!' |
148149
| tst.js:321:5:321:32 | superag ... st(url) | tst.js:321:39:321:42 | data |
150+
| tst.js:344:5:344:37 | axios.p ... config) | tst.js:344:25:344:28 | data |
149151
test_getHost
150152
| tst.js:87:5:87:39 | http.ge ... host}) | tst.js:87:34:87:37 | host |
151153
| tst.js:89:5:89:23 | axios({host: host}) | tst.js:89:18:89:21 | host |
@@ -268,6 +270,7 @@ test_getUrl
268270
| tst.js:337:5:337:20 | jsonClient.get() | tst.js:336:41:336:43 | url |
269271
| tst.js:340:5:340:21 | jsonClient2.get() | tst.js:339:42:339:44 | url |
270272
| tst.js:340:5:340:21 | jsonClient2.get() | tst.js:339:61:339:63 | url |
273+
| tst.js:344:5:344:37 | axios.p ... config) | tst.js:344:20:344:22 | url |
271274
test_getAResponseDataNode
272275
| axiosTest.js:4:5:7:6 | axios({ ... \\n }) | axiosTest.js:4:5:7:6 | axios({ ... \\n }) | json | true |
273276
| axiosTest.js:12:5:17:6 | axios({ ... \\n }) | axiosTest.js:12:5:17:6 | axios({ ... \\n }) | json | true |
@@ -354,3 +357,4 @@ test_getAResponseDataNode
354357
| tst.js:334:5:334:25 | got.pag ... rl, {}) | tst.js:334:5:334:25 | got.pag ... rl, {}) | text | true |
355358
| tst.js:337:5:337:20 | jsonClient.get() | tst.js:337:5:337:20 | jsonClient.get() | text | true |
356359
| tst.js:340:5:340:21 | jsonClient2.get() | tst.js:340:5:340:21 | jsonClient2.get() | text | true |
360+
| tst.js:344:5:344:37 | axios.p ... config) | tst.js:344:5:344: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
@@ -341,7 +341,7 @@ function gotTests(url){
341341
}
342342

343343
function moreAxiosTests(url, data, config){
344-
axios.postForm(url, data, config); // not flagged
344+
axios.postForm(url, data, config);
345345
axios.putForm(url, data); // not flagged
346346
axios.putForm(url, data, config); // not flagged
347347
axios.patchForm(url, data); // not flagged

0 commit comments

Comments
 (0)