mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
35 lines
521 B
Rust
35 lines
521 B
Rust
fn source(i: i64) -> &'static str {
|
|
"source"
|
|
}
|
|
|
|
fn sink(s: &str) {
|
|
println!("{}", s);
|
|
}
|
|
|
|
fn sanitize(s: &str) -> &str {
|
|
match s {
|
|
"dangerous" => "",
|
|
s => s,
|
|
}
|
|
}
|
|
|
|
fn directly() {
|
|
sink(source(1)); // $ hasValueFlow=1
|
|
}
|
|
|
|
fn through_variable() {
|
|
let s = source(1);
|
|
sink(s); // $ hasValueFlow=1
|
|
}
|
|
|
|
fn with_barrier() {
|
|
let s = source(1);
|
|
let s = sanitize(s);
|
|
sink(s); // $ SPURIOUS: hasValueFlow=1
|
|
}
|
|
|
|
fn main() {
|
|
let s = source(1);
|
|
sink(s); // $ hasValueFlow=1
|
|
}
|