File tree Expand file tree Collapse file tree 7 files changed +52
-0
lines changed
library-tests/expressions
query-tests/Security Features/CWE-089 Expand file tree Collapse file tree 7 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 2222| file://:0:0:0:0 | Rectangle | expressions.cs:351:18:351:26 | call to constructor Object | file://:0:0:0:0 | Object |
2323| file://:0:0:0:0 | Rectangle2 | expressions.cs:361:18:361:27 | call to constructor Object | file://:0:0:0:0 | Object |
2424| file://:0:0:0:0 | ReducedClass | ReducedExpression.cs:2:7:2:18 | call to constructor Object | file://:0:0:0:0 | Object |
25+ | file://:0:0:0:0 | SuppressNullableWarning | expressions.cs:522:11:522:33 | call to constructor Object | file://:0:0:0:0 | Object |
2526| file://:0:0:0:0 | TestConversionOperator | expressions.cs:330:11:330:32 | call to constructor Object | file://:0:0:0:0 | Object |
2627| file://:0:0:0:0 | TestCreations | expressions.cs:383:18:383:30 | call to constructor Object | file://:0:0:0:0 | Object |
2728| file://:0:0:0:0 | TestUnaryOperator | expressions.cs:292:11:292:27 | call to constructor Object | file://:0:0:0:0 | Object |
Original file line number Diff line number Diff line change 1+ expressions.cs:
2+ # 530| [MethodCall] call to method Api
13FoldedLiterals.cs:
24# 1| [Class] FoldedLiterals
35# 3| 5: [Method] Test
@@ -2406,3 +2408,24 @@ expressions.cs:
24062408# 520| -1: [TypeMention] object
24072409# 520| 3: [ConstructorInitializer] call to constructor ClassC1
24082410# 520| 0: [ParameterAccess] access to parameter oc2
2411+ # 522| 24: [Class] SuppressNullableWarning
2412+ # 525| 5: [Method] Api
2413+ # 525| -1: [TypeMention] object
2414+ # 525| 4: [ObjectCreation] object creation of type Object
2415+ # 525| 0: [TypeMention] object
2416+ # 527| 6: [Method] Test
2417+ # 527| -1: [TypeMention] Void
2418+ #-----| 2: (Parameters)
2419+ # 527| 0: [Parameter] arg0
2420+ # 527| -1: [TypeMention] object
2421+ # 528| 4: [BlockStmt] {...}
2422+ # 529| 0: [LocalVariableDeclStmt] ... ...;
2423+ # 529| 0: [LocalVariableDeclAndInitExpr] Object x = ...
2424+ # 529| -1: [TypeMention] object
2425+ # 529| 0: [LocalVariableAccess] access to local variable x
2426+ # 529| 1: [SuppressNullableWarningExpr] ...!
2427+ # 529| 0: [ParameterAccess] access to parameter arg0
2428+ # 530| 1: [LocalVariableDeclStmt] ... ...;
2429+ # 530| 0: [LocalVariableDeclAndInitExpr] Object y = ...
2430+ # 530| -1: [TypeMention] object
2431+ # 530| 0: [LocalVariableAccess] access to local variable y
Original file line number Diff line number Diff line change 7070| expressions.cs:483:17:483:26 | access to field value | expressions.cs:483:17:483:20 | this access |
7171| expressions.cs:488:32:488:39 | access to field value | expressions.cs:488:32:488:33 | access to parameter c1 |
7272| expressions.cs:488:43:488:50 | access to field value | expressions.cs:488:43:488:44 | access to parameter c2 |
73+ | expressions.cs:530:21:530:25 | call to method Api | expressions.cs:530:21:530:25 | this access |
Original file line number Diff line number Diff line change 1+ | expressions.cs:529:21:529:25 | ...! |
Original file line number Diff line number Diff line change 1+ import csharp
2+
3+ select any ( SuppressNullableWarningExpr e )
Original file line number Diff line number Diff line change @@ -518,4 +518,16 @@ struct MyInlineArray
518518 class ClassC1 ( object oc1 ) { }
519519
520520 class ClassC2 ( object oc2 ) : ClassC1 ( oc2 ) { }
521+
522+ class SuppressNullableWarning
523+ {
524+
525+ public object ? Api ( ) => new object ( ) ;
526+
527+ public void Test ( object ? arg0 )
528+ {
529+ var x = arg0 ! ;
530+ var y = Api ( ) ! ;
531+ }
532+ }
521533}
Original file line number Diff line number Diff line change @@ -95,6 +95,17 @@ public void GetDataSetByCategory()
9595 var result = new DataSet ( ) ;
9696 adapter . Fill ( result ) ;
9797 }
98+
99+ // BAD: Input from the command line. (also implicitly check flow via suppress nullable warning `!`)
100+ using ( var connection = new SqlConnection ( connectionString ) )
101+ {
102+ var queryString = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='"
103+ + Console . ReadLine ( ) ! + "' ORDER BY PRICE" ;
104+ var cmd = new SqlCommand ( queryString ) ;
105+ var adapter = new SqlDataAdapter ( cmd ) ;
106+ var result = new DataSet ( ) ;
107+ adapter . Fill ( result ) ;
108+ }
98109 }
99110
100111 System . Windows . Forms . TextBox box1 ;
You can’t perform that action at this time.
0 commit comments