mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
19 lines
517 B
JavaScript
19 lines
517 B
JavaScript
const fs = require('fs'),
|
|
http = require('http'),
|
|
path = require('path'),
|
|
url = require('url');
|
|
|
|
const ROOT = "/var/www/";
|
|
|
|
var server = http.createServer(function(req, res) {
|
|
let filePath = url.parse(req.url, true).query.path;
|
|
|
|
// OK - Verify that the file path is under the root directory
|
|
filePath = fs.realpathSync(path.resolve(ROOT, filePath));
|
|
if (!filePath.startsWith(ROOT)) {
|
|
res.statusCode = 403;
|
|
res.end();
|
|
return;
|
|
}
|
|
res.write(fs.readFileSync(filePath, 'utf8'));
|
|
}); |