mirror of
https://github.com/github/codeql.git
synced 2026-01-29 22:32:58 +01:00
Add more tests for variadic functions
This commit is contained in:
@@ -11,17 +11,40 @@ type A struct {
|
||||
f string
|
||||
}
|
||||
|
||||
func functionWithVarArgsOfStructsParameter(s ...A) {
|
||||
sink(s[0].f) // $ MISSING: taintflow dataflow
|
||||
func functionWithSliceParameter(s []string) string {
|
||||
return s[1]
|
||||
}
|
||||
|
||||
func functionWithVarArgsParameter(s ...string) string {
|
||||
return s[1]
|
||||
}
|
||||
|
||||
func functionWithSliceOfStructsParameter(s []A) string {
|
||||
return s[1].f
|
||||
}
|
||||
|
||||
func functionWithVarArgsOfStructsParameter(s ...A) string {
|
||||
return s[1].f
|
||||
}
|
||||
|
||||
func main() {
|
||||
stringSlice := []string{source()}
|
||||
sink(stringSlice[0]) // $ taintflow dataflow
|
||||
|
||||
arrayOfStructs := []A{{f: source()}}
|
||||
sink(arrayOfStructs[0].f) // $ taintflow dataflow
|
||||
s0 := ""
|
||||
s1 := source()
|
||||
sSlice := []string{s0, s1}
|
||||
sink(functionWithSliceParameter(sSlice)) // $ taintflow dataflow
|
||||
sink(functionWithVarArgsParameter(sSlice...)) // $ taintflow dataflow
|
||||
sink(functionWithVarArgsParameter(s0, s1)) // $ MISSING: taintflow dataflow
|
||||
|
||||
a := A{f: source()}
|
||||
functionWithVarArgsOfStructsParameter(a)
|
||||
sliceOfStructs := []A{{f: source()}}
|
||||
sink(sliceOfStructs[0].f) // $ taintflow dataflow
|
||||
|
||||
a0 := A{f: ""}
|
||||
a1 := A{f: source()}
|
||||
aSlice := []A{a0, a1}
|
||||
sink(functionWithSliceOfStructsParameter(aSlice)) // $ taintflow dataflow
|
||||
sink(functionWithVarArgsOfStructsParameter(aSlice...)) // $ taintflow dataflow
|
||||
sink(functionWithVarArgsOfStructsParameter(a0, a1)) // $ MISSING: taintflow dataflow
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user