File tree Expand file tree Collapse file tree
test/query-tests/Security/CWE/CWE-253 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ where exists
4848 ctls .getControllingExpr ( ) = e1
4949 and e1 .getType ( ) .( TypedefType ) .hasName ( "HRESULT" )
5050 and not isHresultBooleanConverted ( e1 )
51+ and not ctls instanceof SwitchStmt // not controlled by a boolean condition
5152 and msg = "Direct usage of a type " + e1 .getType ( ) .toString ( ) + " as a conditional expression"
5253 )
5354 or
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ void IncorrectTypeConversionTest() {
106106 while (!HresultFunction ()) {}; // BUG
107107 while (FAILED (HresultFunction ())) {}; // Correct Usage
108108
109- switch (hr ) // Correct Usage [FALSE POSITIVE]
109+ switch (hr ) // Correct Usage
110110 {
111111 case S_OK :
112112 case S_FALSE :
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ void IncorrectTypeConversionTest() {
103103 while (!HresultFunction ()) {}; // BUG
104104 while (FAILED (HresultFunction ())) {}; // Correct Usage
105105
106- switch (hr) // Correct Usage [FALSE POSITIVE]
106+ switch (hr) // Correct Usage
107107 {
108108 case S_OK:
109109 case S_FALSE:
Original file line number Diff line number Diff line change 99| HResultBooleanConversion.c:82:10:82:11 | hr | Usage of a type HRESULT as an argument of a unary logical operation |
1010| HResultBooleanConversion.c:92:9:92:10 | hr | Direct usage of a type HRESULT as a conditional expression |
1111| HResultBooleanConversion.c:106:13:106:27 | call to HresultFunction | Usage of a type HRESULT as an argument of a unary logical operation |
12- | HResultBooleanConversion.c:109:12:109:13 | hr | Direct usage of a type HRESULT as a conditional expression |
1312| HResultBooleanConversion.cpp:39:12:39:23 | call to BoolFunction | Implicit conversion from BOOL to HRESULT |
1413| HResultBooleanConversion.cpp:44:12:44:24 | call to BoolFunction2 | Implicit conversion from bool to HRESULT |
1514| HResultBooleanConversion.cpp:50:15:50:16 | hr | Explicit conversion from HRESULT to BOOL |
2120| HResultBooleanConversion.cpp:79:10:79:11 | hr | Implicit conversion from HRESULT to bool |
2221| HResultBooleanConversion.cpp:89:9:89:10 | hr | Implicit conversion from HRESULT to bool |
2322| HResultBooleanConversion.cpp:103:13:103:27 | call to HresultFunction | Implicit conversion from HRESULT to bool |
24- | HResultBooleanConversion.cpp:106:12:106:13 | hr | Direct usage of a type HRESULT as a conditional expression |
You can’t perform that action at this time.
0 commit comments