mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Rust: Add a few tests for modeled flow for Option
This commit is contained in:
@@ -50,6 +50,30 @@ mod my_clone {
|
||||
}
|
||||
}
|
||||
|
||||
mod flow_throug_option {
|
||||
use super::{source, sink};
|
||||
// Test the auto generated flow summaries for `Option`
|
||||
|
||||
fn zip_flow() {
|
||||
let a = Some(2);
|
||||
let b = Some(source(38));
|
||||
let z = a.zip(b);
|
||||
match z {
|
||||
Some((n, m)) => {
|
||||
sink(n);
|
||||
sink(m); // $ MISSING: hasValueFlow=38
|
||||
},
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
||||
fn higher_order_flow() {
|
||||
let a = Some(0);
|
||||
let b = a.map_or(3, |n| n + source(63));
|
||||
sink(b); // $ MISSING: hasTaintFlow=63
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
option_clone();
|
||||
result_clone();
|
||||
|
||||
Reference in New Issue
Block a user