mirror of
https://github.com/github/codeql.git
synced 2026-01-30 06:42:57 +01:00
Add tests for guarding functions proxied by a variable
Negation doesn't appear to be handled correctly, so one of the lines is marked as a false positive.
This commit is contained in:
@@ -825,4 +825,27 @@ func test() {
|
||||
}
|
||||
}
|
||||
|
||||
// Note we can also assign the result of a guarding function to a variable and use that in
|
||||
// the conditional.
|
||||
|
||||
{
|
||||
s := source()
|
||||
isInvalid := guardBool(s)
|
||||
if isInvalid {
|
||||
sink(s) // $dataflow=s
|
||||
} else {
|
||||
sink(s)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
s := source()
|
||||
isValid := !guardBool(s)
|
||||
if isValid {
|
||||
sink(s) // $f+:dataflow=s
|
||||
} else {
|
||||
sink(s) // $dataflow=s
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user