Skip to content

Commit 1c7cae4

Browse files
authored
Merge pull request github#11547 from mattrothenberg/main
fix: use WHATWG URL for JS examples
2 parents 2653458 + 95f994a commit 1c7cae4

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

javascript/ql/src/Security/CWE-918/examples/RequestForgeryBad.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import http from 'http';
2-
import url from 'url';
32

4-
var server = http.createServer(function(req, res) {
5-
var target = url.parse(req.url, true).query.target;
3+
const server = http.createServer(function(req, res) {
4+
const target = new URL(req.url, "http://example.com").searchParams.get("target");
65

76
// BAD: `target` is controlled by the attacker
87
http.get('https://' + target + ".example.com/data/", res => {

javascript/ql/src/Security/CWE-918/examples/RequestForgeryGood.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import http from 'http';
2-
import url from 'url';
32

4-
var server = http.createServer(function(req, res) {
5-
var target = url.parse(req.url, true).query.target;
3+
const server = http.createServer(function(req, res) {
4+
const target = new URL(req.url, "http://example.com").searchParams.get("target");
65

7-
var subdomain;
6+
let subdomain;
87
if (target === 'EU') {
98
subdomain = "europe"
109
} else {

0 commit comments

Comments
 (0)