Skip to content

Commit e860131

Browse files
committed
JS: Manually fix up some errors made by the script
1 parent 09b4250 commit e860131

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

javascript/ql/test/query-tests/Comments/CommentedOutCode/commentedCode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function sayHello() {
8080
* }
8181
*/
8282

83-
83+
// good
8484

8585
// ====
8686
// ----
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
2-
* NOT OK: Parameter y is not documented.
3-
*
42
* @param x The first operand.
53
*/
6-
function f(x, y) {
4+
function f(x, y) { // $ Alert
75
return x+y;
86
}
97

@@ -14,14 +12,14 @@ function g(x, y) {
1412
return x+y;
1513
}
1614

17-
/** // $ Alert
15+
/**
1816
* @param {int} x
1917
* @param {float} y
2018
*/
2119
var o = {
2220
/**
2321
* @param {String} x first argument.
2422
*/
25-
f : function(x, y) {
23+
f : function(x, y) { // $ Alert
2624
}
2725
};

javascript/ql/test/query-tests/Security/CWE-094/CodeInjection/bad-code-sanitization.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ app.get('/some/path', function(req, res) {
5858
setTimeout(`(function(){${JSON.stringify(taint)}))`); // OK - the source is remote-flow, and the sink is code-injection.
5959
});
6060

61-
function createObjectWrite() { // $ Alert - documentation example:
61+
// Bad documentation example:
62+
function createObjectWrite() {
6263
const assignment = `obj[${JSON.stringify(key)}]=42`;
6364
return `(function(){${assignment}})` // $ Alert[js/bad-code-sanitization]
6465
}
6566

66-
// OK - documentation example:
67+
// Good documentation example:
6768
function good() {
6869
const charMap = {
6970
'<': '\\u003C',

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ app.use('/angular', require('serve-static')(path.join(__dirname, "/node_modules"
4242
app.use('/home', require('serve-static')(require("os").homedir())); // $ Alert
4343
app.use('/root', require('serve-static')("/")); // $ Alert
4444

45-
function bad() { // $ Alert - documentation example
45+
// Bad documentation example
46+
function bad() {
4647
var express = require('express');
4748

4849
var app = express();
4950

5051
app.use('/node_modules', express.static(path.resolve(__dirname, '../node_modules'))); // $ Alert
5152
}
5253

53-
// OK - documentation example
54+
// Good documentation example
5455
function good() {
5556
var express = require('express');
5657

javascript/ql/test/query-tests/Security/CWE-327/bad-random.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ var good = (a[i] * 0x100000000) + a[i + 6]; // OK - generating a large number fr
112112
var good = (a[i + 2] * 0x10000000) + a[i + 6]; // OK - generating a large number from smaller bytes.
113113
var foo = 0xffffffffffff + 0xfffffffffff + 0xffffffffff + 0xfffffffff + 0xffffffff + 0xfffffff + 0xffffff
114114

115-
const digits = []; // $ Alert - documentation example:
115+
// Bad documentation example:
116+
const digits = [];
116117
for (let i = 0; i < 10; i++) {
117118
digits.push(crypto.randomBytes(1)[0] % 10); // $ Alert
118119
}
119120

120-
// OK - documentation example:
121+
// Good documentation example:
121122
const digits = [];
122123
while (digits.length < 10) {
123124
const byte = crypto.randomBytes(1)[0];

0 commit comments

Comments
 (0)