We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd1593d commit 3e5313dCopy full SHA for 3e5313d
tools/dev-server/dev-server.ts
@@ -27,7 +27,7 @@ export class DevServer {
27
port: this.port,
28
notify: false,
29
ghostMode: false,
30
- server: true,
+ server: false,
31
middleware: (req, res) => this._bazelMiddleware(req, res),
32
};
33
@@ -59,7 +59,14 @@ export class DevServer {
59
*/
60
private _bazelMiddleware(req: http.IncomingMessage, res: http.ServerResponse) {
61
if (!req.url) {
62
- res.end('No url specified. Error');
+ res.end('Error: No url specified');
63
+ return;
64
+ }
65
+
66
+ // Throw an error if the requested URL contains two consecutive `.` characters
67
+ // (%2e is `.` url-encoded).
68
+ if (/(\.|%2e){2,}/.test(req.url)) {
69
+ res.end('Error: Detected directory traversal');
70
return;
71
}
72
0 commit comments