File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
rust/ql/test/library-tests/dataflow/taint Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,44 @@ mod string {
40
40
}
41
41
}
42
42
43
+ mod array_source {
44
+ fn source ( i : i64 ) -> [ i64 ; 3 ] {
45
+ [ i; 3 ]
46
+ }
47
+
48
+ fn sink ( i : i64 ) {
49
+ println ! ( "{}" , i) ;
50
+ }
51
+
52
+ pub fn array_tainted ( ) {
53
+ let arr = source ( 76 ) ;
54
+ sink ( arr[ 1 ] ) ; // $ MISSING: hasTaintFlow=76
55
+ }
56
+ }
57
+
58
+ mod array_sink {
59
+ fn source ( i : i64 ) -> i64 {
60
+ i
61
+ }
62
+
63
+ fn sink ( s : [ i64 ; 3 ] ) {
64
+ println ! ( "{}" , s[ 1 ] ) ;
65
+ }
66
+
67
+ pub fn array_with_taint ( ) {
68
+ let mut arr2 = [ 1 , 2 , 3 ] ;
69
+ arr2[ 1 ] = source ( 36 ) ;
70
+ sink ( arr2) ; // $ MISSING: hasTaintFlow=36
71
+ }
72
+ }
73
+
43
74
use string:: * ;
44
75
45
76
fn main ( ) {
46
77
addition ( ) ;
47
78
negation ( ) ;
48
79
cast ( ) ;
49
80
string_slice ( ) ;
81
+ array_source:: array_tainted ( ) ;
82
+ array_sink:: array_with_taint ( ) ;
50
83
}
You can’t perform that action at this time.
0 commit comments