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 22
22
| file://:0:0:0:0 | Rectangle | expressions.cs:351:18:351:26 | call to constructor Object | file://:0:0:0:0 | Object |
23
23
| file://:0:0:0:0 | Rectangle2 | expressions.cs:361:18:361:27 | call to constructor Object | file://:0:0:0:0 | Object |
24
24
| 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 |
25
26
| file://:0:0:0:0 | TestConversionOperator | expressions.cs:330:11:330:32 | call to constructor Object | file://:0:0:0:0 | Object |
26
27
| file://:0:0:0:0 | TestCreations | expressions.cs:383:18:383:30 | call to constructor Object | file://:0:0:0:0 | Object |
27
28
| 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
1
3
FoldedLiterals.cs:
2
4
# 1| [Class] FoldedLiterals
3
5
# 3| 5: [Method] Test
@@ -2406,3 +2408,24 @@ expressions.cs:
2406
2408
# 520| -1: [TypeMention] object
2407
2409
# 520| 3: [ConstructorInitializer] call to constructor ClassC1
2408
2410
# 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 70
70
| expressions.cs:483:17:483:26 | access to field value | expressions.cs:483:17:483:20 | this access |
71
71
| expressions.cs:488:32:488:39 | access to field value | expressions.cs:488:32:488:33 | access to parameter c1 |
72
72
| 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
518
518
class ClassC1 ( object oc1 ) { }
519
519
520
520
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
+ }
521
533
}
Original file line number Diff line number Diff line change @@ -95,6 +95,17 @@ public void GetDataSetByCategory()
95
95
var result = new DataSet ( ) ;
96
96
adapter . Fill ( result ) ;
97
97
}
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
+ }
98
109
}
99
110
100
111
System . Windows . Forms . TextBox box1 ;
You can’t perform that action at this time.
0 commit comments