Skip to content

Commit fa0a8c3

Browse files
committed
add documentation examples as tests
1 parent b428246 commit fa0a8c3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

javascript/ql/test/query-tests/Security/CWE-200/PrivateFileExposure.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
| private-file-exposure.js:41:1:41:97 | app.use ... lar/')) | Serves the folder "/node_modules/angular/", which can contain private information. |
1919
| private-file-exposure.js:42:1:42:66 | app.use ... dir())) | Serves the home folder , which can contain private information. |
2020
| private-file-exposure.js:43:1:43:46 | app.use ... )("/")) | Serves the root folder, which can contain private information. |
21+
| private-file-exposure.js:51:5:51:88 | app.use ... les'))) | Serves the folder "../node_modules", which can contain private information. |

javascript/ql/test/query-tests/Security/CWE-200/private-file-exposure.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,23 @@ const connect = require("connect");
4040
app.use('/angular', connect.static(path.join(__dirname, "/node_modules") + '/angular/')); // NOT OK
4141
app.use('/angular', require('serve-static')(path.join(__dirname, "/node_modules") + '/angular/')); // NOT OK
4242
app.use('/home', require('serve-static')(require("os").homedir())); // NOT OK
43-
app.use('/root', require('serve-static')("/")); // NOT OK
43+
app.use('/root', require('serve-static')("/")); // NOT OK
44+
45+
// Bad documentation example
46+
function bad() {
47+
var express = require('express');
48+
49+
var app = express();
50+
51+
app.use('/node_modules', express.static(path.resolve(__dirname, '../node_modules'))); // NOT OK
52+
}
53+
54+
// Good documentation example
55+
function good() {
56+
var express = require('express');
57+
58+
var app = express();
59+
60+
app.use("jquery", express.static('./node_modules/jquery/dist')); // OK
61+
app.use("bootstrap", express.static('./node_modules/bootstrap/dist')); // OK
62+
}

0 commit comments

Comments
 (0)