@@ -96,7 +96,7 @@ async fn test_hyper_http(case: i64) -> Result<(), Box<dyn std::error::Error>> {
96
96
97
97
// create the connection
98
98
println ! ( "connecting to {}..." , address) ;
99
- let stream = tokio:: net:: TcpStream :: connect ( address) . await ?;
99
+ let stream = tokio:: net:: TcpStream :: connect ( address) . await ?; // $ Alert[rust/summary/taint-sources]
100
100
let io = hyper_util:: rt:: TokioIo :: new ( stream) ;
101
101
let ( mut sender, conn) = hyper:: client:: conn:: http1:: handshake ( io) . await ?;
102
102
@@ -597,26 +597,26 @@ async fn test_std_tcpstream(case: i64) -> std::io::Result<()> { // Result<(), Bo
597
597
598
598
if case == 1 {
599
599
// create the connection
600
- let mut stream = std:: net:: TcpStream :: connect ( address) ?;
600
+ let mut stream = std:: net:: TcpStream :: connect ( address) ?; // $ Alert[rust/summary/taint-sources]
601
601
602
602
// send request
603
603
let _ = stream. write_all ( b"GET / HTTP/1.1\n Host:example.com\n \n " ) ;
604
604
605
605
// read response
606
606
let mut buffer = vec ! [ 0 ; 32 * 1024 ] ;
607
- let _ = stream. read ( & mut buffer) ; // $ MISSING: Alert[rust/summary/taint-sources]
607
+ let _ = stream. read ( & mut buffer) ;
608
608
609
609
println ! ( "data = {:?}" , buffer) ;
610
- sink ( & buffer) ; // $ MISSING: hasTaintFlow
611
- sink ( buffer[ 0 ] ) ; // $ MISSING: hasTaintFlow
610
+ sink ( & buffer) ; // $ hasTaintFlow=address
611
+ sink ( buffer[ 0 ] ) ; // $ hasTaintFlow=address
612
612
613
613
let buffer_string = String :: from_utf8_lossy ( & buffer) ;
614
614
println ! ( "string = {}" , buffer_string) ;
615
615
sink ( buffer_string) ; // $ MISSING: hasTaintFlow
616
616
} else {
617
617
// create the connection
618
618
let sock_addr = address. to_socket_addrs ( ) . unwrap ( ) . next ( ) . unwrap ( ) ;
619
- let mut stream = std:: net:: TcpStream :: connect_timeout ( & sock_addr, std:: time:: Duration :: new ( 1 , 0 ) ) ?;
619
+ let mut stream = std:: net:: TcpStream :: connect_timeout ( & sock_addr, std:: time:: Duration :: new ( 1 , 0 ) ) ?; // $ Alert[rust/summary/taint-sources]
620
620
621
621
// send request
622
622
let _ = stream. write_all ( b"GET / HTTP/1.1\n Host:example.com\n \n " ) ;
@@ -627,14 +627,14 @@ async fn test_std_tcpstream(case: i64) -> std::io::Result<()> { // Result<(), Bo
627
627
let mut reader = std:: io:: BufReader :: new ( stream) . take ( 256 ) ;
628
628
let mut line = String :: new ( ) ;
629
629
loop {
630
- match reader. read_line ( & mut line) { // $ MISSING: Alert[rust/summary/taint-sources]
630
+ match reader. read_line ( & mut line) {
631
631
Ok ( 0 ) => {
632
632
println ! ( "end" ) ;
633
633
break ;
634
634
}
635
635
Ok ( _n) => {
636
636
println ! ( "line = {}" , line) ;
637
- sink ( & line) ; // $ MISSING: hasTaintFlow
637
+ sink ( & line) ; // $ hasTaintFlow=&sock_addr
638
638
line. clear ( ) ;
639
639
}
640
640
Err ( e) => {
@@ -668,27 +668,27 @@ async fn test_tokio_tcpstream(case: i64) -> std::io::Result<()> {
668
668
669
669
// create the connection
670
670
println ! ( "connecting to {}..." , address) ;
671
- let mut tokio_stream = tokio:: net:: TcpStream :: connect ( address) . await ?;
671
+ let mut tokio_stream = tokio:: net:: TcpStream :: connect ( address) . await ?; // $ Alert[rust/summary/taint-sources]
672
672
673
673
// send request
674
674
tokio_stream. write_all ( b"GET / HTTP/1.1\n Host:example.com\n \n " ) . await ?;
675
675
676
676
if case == 1 {
677
677
// peek response
678
678
let mut buffer1 = vec ! [ 0 ; 2 * 1024 ] ;
679
- let _ = tokio_stream. peek ( & mut buffer1) . await ?; // $ MISSING: Alert[rust/summary/taint-sources]
679
+ let _ = tokio_stream. peek ( & mut buffer1) . await ?;
680
680
681
681
// read response
682
682
let mut buffer2 = vec ! [ 0 ; 2 * 1024 ] ;
683
- let n2 = tokio_stream. read ( & mut buffer2) . await ?; // $ MISSING: Alert[rust/summary/taint-sources]
683
+ let n2 = tokio_stream. read ( & mut buffer2) . await ?;
684
684
685
685
println ! ( "buffer1 = {:?}" , buffer1) ;
686
- sink ( & buffer1) ; // $ MISSING: hasTaintFlow
687
- sink ( buffer1[ 0 ] ) ; // $ MISSING: hasTaintFlow
686
+ sink ( & buffer1) ; // $ hasTaintFlow=address
687
+ sink ( buffer1[ 0 ] ) ; // $ hasTaintFlow=address
688
688
689
689
println ! ( "buffer2 = {:?}" , buffer2) ;
690
- sink ( & buffer2) ; // $ MISSING: hasTaintFlow
691
- sink ( buffer2[ 0 ] ) ; // $ MISSING: hasTaintFlow
690
+ sink ( & buffer2) ; // $ hasTaintFlow=address
691
+ sink ( buffer2[ 0 ] ) ; // $ hasTaintFlow=address
692
692
693
693
let buffer_string = String :: from_utf8_lossy ( & buffer2[ ..n2] ) ;
694
694
println ! ( "string = {}" , buffer_string) ;
@@ -703,7 +703,7 @@ async fn test_tokio_tcpstream(case: i64) -> std::io::Result<()> {
703
703
}
704
704
Ok ( _n) => {
705
705
println ! ( "buffer = {:?}" , buffer) ;
706
- sink ( & buffer) ; // $ MISSING: hasTaintFlow
706
+ sink ( & buffer) ; // $ hasTaintFlow=address
707
707
break ; // (or we could wait for more data)
708
708
}
709
709
Err ( ref e) if e. kind ( ) == std:: io:: ErrorKind :: WouldBlock => {
@@ -726,7 +726,7 @@ async fn test_tokio_tcpstream(case: i64) -> std::io::Result<()> {
726
726
}
727
727
Ok ( _n) => {
728
728
println ! ( "buffer = {:?}" , buffer) ;
729
- sink ( & buffer) ; // $ MISSING: hasTaintFlow
729
+ sink ( & buffer) ; // $ hasTaintFlow=address
730
730
break ; // (or we could wait for more data)
731
731
}
732
732
Err ( ref e) if e. kind ( ) == std:: io:: ErrorKind :: WouldBlock => {
@@ -750,7 +750,7 @@ async fn test_std_to_tokio_tcpstream() -> std::io::Result<()> {
750
750
751
751
// create the connection
752
752
println ! ( "connecting to {}..." , address) ;
753
- let std_stream = std:: net:: TcpStream :: connect ( address) ?;
753
+ let std_stream = std:: net:: TcpStream :: connect ( address) ?; // $ Alert[rust/summary/taint-sources]
754
754
755
755
// convert to tokio stream
756
756
std_stream. set_nonblocking ( true ) ?;
0 commit comments