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 {
4040 }
4141}
4242
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+
4374use string:: * ;
4475
4576fn main ( ) {
4677 addition ( ) ;
4778 negation ( ) ;
4879 cast ( ) ;
4980 string_slice ( ) ;
81+ array_source:: array_tainted ( ) ;
82+ array_sink:: array_with_taint ( ) ;
5083}
You can’t perform that action at this time.
0 commit comments