File tree Expand file tree Collapse file tree 3 files changed +191
-91
lines changed
rust/ql/test/library-tests/dataflow/models Expand file tree Collapse file tree 3 files changed +191
-91
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,37 @@ fn test_trait_model<T: Ord>(x: T) {
410410 sink ( x7) ;
411411}
412412
413+ pub fn generated_source ( i : i64 ) -> i64 {
414+ 0
415+ }
416+
417+ pub fn neutral_generated_source ( i : i64 ) -> i64 {
418+ 0
419+ }
420+
421+ pub fn neutral_manual_source ( i : i64 ) -> i64 {
422+ 0
423+ }
424+
425+ pub fn generated_sink ( i : i64 ) { }
426+
427+ pub fn neutral_generated_sink ( i : i64 ) { }
428+
429+ pub fn neutral_manual_sink ( i : i64 ) { }
430+
431+ fn test_neutrals ( ) {
432+ // neutral models should cause corresponding generated models to be ignored.
433+ // Thus, the `neutral_generated_*` source/sink, which have both a
434+ // generated and a neutral model, should not have flow.
435+
436+ sink ( generated_source ( 1 ) ) ; // $ hasValueFlow=1
437+ sink ( neutral_generated_source ( 2 ) ) ; // $ SPURIOUS: hasValueFlow=2
438+ sink ( neutral_manual_source ( 3 ) ) ; // $ hasValueFlow=3
439+ generated_sink ( source ( 4 ) ) ; // $ hasValueFlow=4
440+ neutral_generated_sink ( source ( 5 ) ) ; // $ SPURIOUS: hasValueFlow=5
441+ neutral_manual_sink ( source ( 6 ) ) ; // $ hasValueFlow=6
442+ }
443+
413444#[ tokio:: main]
414445async fn main ( ) {
415446 test_identify ( ) ;
@@ -431,5 +462,6 @@ async fn main() {
431462 test_simple_sink ( ) ;
432463 test_get_async_number ( ) . await ;
433464 test_arg_source ( ) ;
465+ test_neutrals ( ) ;
434466 let dummy = Some ( 0 ) ; // ensure that the the `lang:core` crate is extracted
435467}
You can’t perform that action at this time.
0 commit comments