diff --git a/20250409.js b/20250409.js new file mode 100644 index 0000000..264f4e3 --- /dev/null +++ b/20250409.js @@ -0,0 +1,4 @@ + + function CWE_482_665() { // UNUSED_EXPR + this.foo; + } diff --git a/cwe.js b/cwe.js index bb09a12..b97bc21 100644 --- a/cwe.js +++ b/cwe.js @@ -1,19 +1,5 @@ // 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) { @@ -60,7 +46,7 @@ } function CWE_670(x) { // STRAY_SEMICOLON - while (++x <= 10) ; + while (++x <= 100) { sum += x; } diff --git a/cwe/cwe.js b/cwe/cwe.js new file mode 100644 index 0000000..2f91ea7 --- /dev/null +++ b/cwe/cwe.js @@ -0,0 +1,12 @@ +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); +} diff --git a/react-rule.js b/react-rule.js new file mode 100644 index 0000000..8848038 --- /dev/null +++ b/react-rule.js @@ -0,0 +1,22 @@ +const instance = ReactDOM.render(, rootElement); +foo(instance); // ASYNC_RENDER_RETURN_VALUE alarm + +import ReactDOM from 'react-dom'; + +ReactDOM.render( +
+ {/* BAD_DANGER_WITH_CHILDREN alarm */} +
, document.getElementById("root") +); + +import React from 'react'; + +class Hello extends React.Component { + render() { + return ( +
{/* BAD_EVENT_HANDLER alarm */} + Hello +
+ ); + } +}