-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
template/text.Template execution methods: support reading arbitrary c…
…ontent
- Loading branch information
Showing
8 changed files
with
171 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
9 changes: 9 additions & 0 deletions
9
go/ql/test/library-tests/semmle/go/frameworks/serialization/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import go | ||
import TestUtilities.InlineFlowTest | ||
|
||
string getArgString(DataFlow::Node src, DataFlow::Node sink) { | ||
exists(sink) and | ||
result = src.(DataFlow::CallNode).getArgument(0).getExactValue() | ||
} | ||
|
||
import TaintFlowTestArgString<DefaultFlowConfig, getArgString/2> |
50 changes: 50 additions & 0 deletions
50
go/ql/test/library-tests/semmle/go/frameworks/serialization/texttemplate.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package xyz | ||
|
||
import ( | ||
"bytes" | ||
"text/template" | ||
) | ||
|
||
type Inner1 struct { | ||
Data string | ||
} | ||
|
||
type Inner2 struct { | ||
Data string | ||
} | ||
|
||
type Inner3 struct { | ||
Data string | ||
} | ||
|
||
type Outer struct { | ||
SliceField []Inner1 | ||
PtrField *Inner2 | ||
MapField map[string]Inner3 | ||
} | ||
|
||
func source(n int) string { return "dummy" } | ||
func sink(arg any) {} | ||
|
||
func test() { | ||
|
||
source1 := source(1) | ||
source2 := source(2) | ||
source3 := source(3) | ||
|
||
toSerialize := Outer{[]Inner1{{source1}}, &Inner2{source2}, map[string]Inner3{"key": {source3}}} | ||
buff1 := new(bytes.Buffer) | ||
buff2 := new(bytes.Buffer) | ||
bytes1 := make([]byte, 10) | ||
bytes2 := make([]byte, 10) | ||
|
||
tmpl, _ := template.New("test").Parse("Template text goes here (irrelevant for test)") | ||
tmpl.ExecuteTemplate(buff1, "test", toSerialize) | ||
buff1.Read(bytes1) | ||
sink(bytes1) // $ hasTaintFlow=1 hasTaintFlow=2 hasTaintFlow=3 | ||
|
||
tmpl.Execute(buff2, toSerialize) | ||
buff2.Read(bytes2) | ||
sink(bytes2) // $ hasTaintFlow=1 hasTaintFlow=2 hasTaintFlow=3 | ||
|
||
} |