@@ -500,6 +500,29 @@ fn test_io_file() -> std::io::Result<()> {
500500 sink ( byte) ; // $ hasTaintFlow="file.txt"
501501 }
502502
503+ // --- OpenOptions ---
504+
505+ {
506+ let mut f1 = std:: fs:: OpenOptions :: new ( ) . open ( "f1.txt" ) . unwrap ( ) ; // $ MISSING: Alert[rust/summary/taint-sources]
507+ let mut buffer = [ 0u8 ; 1024 ] ;
508+ let _bytes = f1. read ( & mut buffer) ?;
509+ sink ( & buffer) ; // $ MISSING: hasTaintFlow="f1.txt"
510+ }
511+
512+ {
513+ let mut f2 = std:: fs:: OpenOptions :: new ( ) . create_new ( true ) . open ( "f2.txt" ) . unwrap ( ) ; // $ MISSING: Alert[rust/summary/taint-sources]
514+ let mut buffer = [ 0u8 ; 1024 ] ;
515+ let _bytes = f2. read ( & mut buffer) ?;
516+ sink ( & buffer) ; // $ MISSING: hasTaintFlow="f2.txt"
517+ }
518+
519+ {
520+ let mut f3 = std:: fs:: OpenOptions :: new ( ) . read ( true ) . write ( true ) . truncate ( true ) . create ( true ) . open ( "f3.txt" ) . unwrap ( ) ; // $ MISSING: Alert[rust/summary/taint-sources]
521+ let mut buffer = [ 0u8 ; 1024 ] ;
522+ let _bytes = f3. read ( & mut buffer) ?;
523+ sink ( & buffer) ; // $ MISSING: hasTaintFlow="f3.txt"
524+ }
525+
503526 // --- misc operations ---
504527
505528 {
@@ -568,6 +591,15 @@ async fn test_tokio_file() -> std::io::Result<()> {
568591 sink ( & buffer) ; // $ MISSING: hasTaintFlow="file.txt" -- we cannot resolve the `read_buf` call above, which comes from `impl<R: AsyncRead + ?Sized> AsyncReadExt for R {}` in `async_read_ext.rs`
569592 }
570593
594+ // --- OpenOptions ---
595+
596+ {
597+ let mut f1 = tokio:: fs:: OpenOptions :: new ( ) . open ( "f1.txt" ) . await ?; // $ MISSING: Alert[rust/summary/taint-sources]
598+ let mut buffer = [ 0u8 ; 1024 ] ;
599+ let _bytes = f1. read ( & mut buffer) . await ?;
600+ sink ( & buffer) ; // $ MISSING: hasTaintFlow="f1.txt"
601+ }
602+
571603 // --- misc operations ---
572604
573605 {
@@ -590,6 +622,21 @@ async fn test_tokio_file() -> std::io::Result<()> {
590622 Ok ( ( ) )
591623}
592624
625+ use async_std:: io:: ReadExt ;
626+
627+ async fn test_async_std_file ( ) -> std:: io:: Result < ( ) > {
628+ // --- OpenOptions ---
629+
630+ {
631+ let mut f1 = async_std:: fs:: OpenOptions :: new ( ) . open ( "f1.txt" ) . await ?; // $ MISSING: Alert[rust/summary/taint-sources]
632+ let mut buffer = [ 0u8 ; 1024 ] ;
633+ let _bytes = f1. read ( & mut buffer) . await ?;
634+ sink ( & buffer) ; // $ MISSING: hasTaintFlow="f1.txt"
635+ }
636+
637+ Ok ( ( ) )
638+ }
639+
593640use std:: net:: ToSocketAddrs ;
594641
595642async fn test_std_tcpstream ( case : i64 ) -> std:: io:: Result < ( ) > {
@@ -863,6 +910,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
863910 Err ( e) => println ! ( "error: {}" , e) ,
864911 }
865912
913+ println ! ( "test_async_std_file..." ) ;
914+ match futures:: executor:: block_on ( test_async_std_file ( ) ) {
915+ Ok ( _) => println ! ( "complete" ) ,
916+ Err ( e) => println ! ( "error: {}" , e) ,
917+ }
918+
866919 println ! ( "test_std_tcpstream..." ) ;
867920 match futures:: executor:: block_on ( test_std_tcpstream ( case) ) {
868921 Ok ( _) => println ! ( "complete" ) ,
0 commit comments