Add more tests for variadic functions

This commit is contained in:
Owen Mansel-Chan
2021-11-25 16:40:20 -05:00
parent 8044fb2519
commit d9848fe515

View File

@@ -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
}