From 4aa288bda1e821a3ad9dfef6878077bb69fa3c70 Mon Sep 17 00:00:00 2001 From: jihye1 <36979920+jihye1@users.noreply.github.com> Date: Fri, 11 Oct 2019 11:19:04 +0900 Subject: [PATCH 1/2] Update cwe.js --- cwe.js | 87 ++++++++-------------------------------------------------- 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/cwe.js b/cwe.js index 29299c8..2f91ea7 100644 --- a/cwe.js +++ b/cwe.js @@ -1,75 +1,12 @@ -// This will show examples related with the Common Weakness Enumeration (CWE). - - function CWE_398() { // IDENTICAL_BRANCHES - if (x >= 0) { - y = x; - } else { - y = x; - } - } - - function CWE_476() { // NULL_POINTER - var obj; - var y = obj.x; - console.log(y); - } - - function CWE_480() { // BAD_BITWISE_OPERATOR - var obj = null; - if (obj & obj.prop) { - console.log(obj.prop); - } - } - - function CWE_480_481() { // BAD_ASSIGN_IN_CONDITION - var x = -1; - if (x = -1) console.log('Error!', x); - } - - function CWE_482_665() { // UNUSED_EXPR - this.foo; - } - - function CWE_484() { // SWITCH_CASE_FALL_THROUGH - var x; - switch (x) { - case '1': console.log('Do one thing'); - case '2': console.log('Do another thing'); - } - } - - function CWE_489_569_570_571() { // CONSTANT_CONDITION - var x = "foo"; - if (x === "bar") { - console.log('Do something'); - } - } - - function CWE_561() { // UNREACHABLE_CODE - return; - - var bar = 1; - console.log(bar); - } - - function CWE_563(url) { // UNUSED_VAR_ASSIGN - var foo = url + "?query=deepscan"; - 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; - } - } - +function CWE_398() { // IDENTICAL_BRANCHES + if (x >= 0) { + y = x; + } else { + y = x; + } +} +function CWE_476() { // NULL_POINTER + var obj; + var y = obj.x; // UNINITIALIZED_LOCAL_VAR + console.log(y); +} From e4f1d59c766aa583e5531904e5af50dbfc5dc00d Mon Sep 17 00:00:00 2001 From: jihye1 <36979920+jihye1@users.noreply.github.com> Date: Thu, 16 Jan 2020 11:29:47 +0900 Subject: [PATCH 2/2] Update cwe.js --- cwe.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cwe.js b/cwe.js index 2f91ea7..63244f4 100644 --- a/cwe.js +++ b/cwe.js @@ -5,8 +5,3 @@ function CWE_398() { // IDENTICAL_BRANCHES y = x; } } -function CWE_476() { // NULL_POINTER - var obj; - var y = obj.x; // UNINITIALIZED_LOCAL_VAR - console.log(y); -}