@@ -17,10 +17,15 @@ type Inner3 struct {
17
17
Data string
18
18
}
19
19
20
+ type HasInner3Slice struct {
21
+ Slice []Inner3
22
+ }
23
+
20
24
type Outer struct {
21
25
SliceField []Inner1
22
26
PtrField * Inner2
23
27
MapField map [string ]Inner3
28
+ DeepField HasInner3Slice
24
29
}
25
30
26
31
func source (n int ) string { return "dummy" }
@@ -31,8 +36,10 @@ func test() {
31
36
source1 := source (1 )
32
37
source2 := source (2 )
33
38
source3 := source (3 )
39
+ source4 := source (4 )
34
40
35
- toSerialize := Outer {[]Inner1 {{source1 }}, & Inner2 {source2 }, map [string ]Inner3 {"key" : {source3 }}}
41
+ toSerialize := Outer {[]Inner1 {{source1 }}, & Inner2 {source2 }, map [string ]Inner3 {"key" : {source3 }},
42
+ HasInner3Slice {[]Inner3 {{source4 }}}}
36
43
buff1 := new (bytes.Buffer )
37
44
buff2 := new (bytes.Buffer )
38
45
bytes1 := make ([]byte , 10 )
@@ -41,13 +48,13 @@ func test() {
41
48
tmpl , _ := template .New ("test" ).Parse ("Template text goes here (irrelevant for test)" )
42
49
tmpl .ExecuteTemplate (buff1 , "test" , toSerialize )
43
50
buff1 .Read (bytes1 )
44
- sink (bytes1 ) // $ hasTaintFlow=1 hasTaintFlow=2 hasTaintFlow=3
51
+ sink (bytes1 ) // $ hasTaintFlow=1 hasTaintFlow=2 hasTaintFlow=3 hasTaintFlow=4
45
52
46
53
// Read `buff2` via an `any`-typed variable, to ensure the static type of the argument to tmpl.Execute makes no difference to the result
47
54
var toSerializeAsAny any
48
55
toSerializeAsAny = toSerialize
49
56
tmpl .Execute (buff2 , toSerializeAsAny )
50
57
buff2 .Read (bytes2 )
51
- sink (bytes2 ) // $ hasTaintFlow=1 hasTaintFlow=2 hasTaintFlow=3
58
+ sink (bytes2 ) // $ hasTaintFlow=1 hasTaintFlow=2 hasTaintFlow=3 hasTaintFlow=4
52
59
53
60
}
0 commit comments