Skip to content
21 changes: 6 additions & 15 deletions cwe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// This will show examples related with the Common Weakness Enumeration (CWE).
function CWE_129(x) { // ARRAY_INDEX_NEGATIVE
var arr = [1, 2, 3];
if (x < 0) {
arr[x] = 3;
}
}

function CWE_398() { // IDENTICAL_BRANCHES
if (x >= 0) {
Expand Down Expand Up @@ -50,18 +56,3 @@
foo = url.replace(/\s/gi, "");
console.log(foo);
}

function CWE_628() { // TOO_MANY_ARGS
function add(x, y) {
return x + y;
}
var sum = add(1, 2, 3);
console.log(sum);
}

function CWE_670(x) { // STRAY_SEMICOLON
while (++x <= 10) ;
{
sum += x;
}
}