mirror of
https://github.com/github/codeql.git
synced 2026-06-19 03:41:07 +02:00
Add result node test with SPURIOUS result
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
| main.go:21:9:21:10 | 23 | Result node with index 0 |
|
||||
| main.go:21:13:21:14 | 42 | Result node with index 1 |
|
||||
| resultParameters.go:5:10:5:10 | 0 | Result node with index 0 |
|
||||
| resultParameters.go:9:10:9:10 | 1 | Result node with index 0 |
|
||||
| resultParameters.go:11:10:11:10 | 2 | Result node with index 0 |
|
||||
| resultParameters.go:13:9:13:9 | 3 | Result node with index 0 |
|
||||
| resultParameters.go:16:26:16:26 | implicit read of r | Result node with index 0 |
|
||||
| resultParameters.go:21:38:21:38 | implicit read of r | Result node with index 0 |
|
||||
| resultParameters.go:24:10:24:10 | 1 | Result node with index 0 |
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @kind problem
|
||||
* @id result-node
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
from DataFlow::ResultNode r
|
||||
select r, "Result node with index " + r.getIndex()
|
||||
@@ -0,0 +1,2 @@
|
||||
query: ResultNode.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
@@ -18,5 +18,5 @@ func f() {
|
||||
}
|
||||
|
||||
func test() (int, int) {
|
||||
return 23, 42
|
||||
return 23, 42 // $ Alert[result-node]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
func multipleReturns(selector int) int {
|
||||
if selector == 0 {
|
||||
return 0 // $ Alert[result-node]
|
||||
}
|
||||
switch selector {
|
||||
case 1:
|
||||
return 1 // $ Alert[result-node]
|
||||
case 2:
|
||||
return 2 // $ Alert[result-node]
|
||||
}
|
||||
return 3 // $ Alert[result-node]
|
||||
}
|
||||
|
||||
func resultParameter1() (r int) { // $ Alert[result-node] // implicit reads of result parameters are located at the result parameter declaration
|
||||
r = 0
|
||||
return
|
||||
}
|
||||
|
||||
func resultParameter2(selector int) (r int) { // $ Alert[result-node] // implicit reads of result parameters are located at the result parameter declaration
|
||||
r = 0
|
||||
if selector == 1 {
|
||||
return 1 // $ SPURIOUS: Alert[result-node]
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user