Skip to content

Commit 2806e07

Browse files
committed
Model additions to encoding in Go 1.24
Add models for `BinaryAppender` and `TextAppender`.
1 parent a21dfc9 commit 2806e07

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

go/ql/lib/ext/encoding.model.yml

+4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ extensions:
33
pack: codeql/go-all
44
extensible: summaryModel
55
data:
6+
- ["encoding", "BinaryAppender", True, "AppendBinary", "", "", "Argument[receiver]", "ReturnValue[0]", "taint", "manual"]
7+
- ["encoding", "BinaryAppender", True, "AppendBinary", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
68
- ["encoding", "BinaryMarshaler", True, "MarshalBinary", "", "", "Argument[receiver]", "ReturnValue[0]", "taint", "manual"]
79
- ["encoding", "BinaryUnmarshaler", True, "UnmarshalBinary", "", "", "Argument[0]", "Argument[receiver]", "taint", "manual"]
10+
- ["encoding", "TextAppender", True, "AppendText", "", "", "Argument[receiver]", "ReturnValue[0]", "taint", "manual"]
11+
- ["encoding", "TextAppender", True, "AppendText", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
812
- ["encoding", "TextMarshaler", True, "MarshalText", "", "", "Argument[receiver]", "ReturnValue[0]", "taint", "manual"]
913
- ["encoding", "TextUnmarshaler", True, "UnmarshalText", "", "", "Argument[0]", "Argument[receiver]", "taint", "manual"]

go/ql/test/library-tests/semmle/go/frameworks/StdlibTaintFlow/Encoding.go

+48-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
2-
31
package main
42

53
import "encoding"
@@ -30,6 +28,34 @@ func TaintStepTest_EncodingTextUnmarshalerUnmarshalText_B0I0O0(sourceCQL interfa
3028
return intoTextUnmarshaler443
3129
}
3230

31+
func TaintStepTest_EncodingBinaryAppenderAppendBinary_manual1(sourceCQL interface{}) interface{} {
32+
fromBinaryAppender := sourceCQL.(encoding.BinaryAppender)
33+
var arg0 []byte
34+
intoByte, _ := fromBinaryAppender.AppendBinary(arg0)
35+
return intoByte
36+
}
37+
38+
func TaintStepTest_EncodingBinaryAppenderAppendBinary_manual2(sourceCQL interface{}) interface{} {
39+
var recv encoding.BinaryAppender
40+
fromByteSlice := sourceCQL.([]byte)
41+
intoByte, _ := recv.AppendBinary(fromByteSlice)
42+
return intoByte
43+
}
44+
45+
func TaintStepTest_EncodingTextAppenderAppendText_manual1(sourceCQL interface{}) interface{} {
46+
fromTextAppender := sourceCQL.(encoding.TextAppender)
47+
var arg0 []byte
48+
intoByte, _ := fromTextAppender.AppendText(arg0)
49+
return intoByte
50+
}
51+
52+
func TaintStepTest_EncodingTextAppenderAppendText_manual2(sourceCQL interface{}) interface{} {
53+
var recv encoding.TextAppender
54+
fromByteSlice := sourceCQL.([]byte)
55+
intoByte, _ := recv.AppendText(fromByteSlice)
56+
return intoByte
57+
}
58+
3359
func RunAllTaints_Encoding() {
3460
{
3561
source := newSource(0)
@@ -51,4 +77,24 @@ func RunAllTaints_Encoding() {
5177
out := TaintStepTest_EncodingTextUnmarshalerUnmarshalText_B0I0O0(source)
5278
sink(3, out)
5379
}
80+
{
81+
source := newSource(4)
82+
out := TaintStepTest_EncodingBinaryAppenderAppendBinary_manual1(source)
83+
sink(4, out)
84+
}
85+
{
86+
source := newSource(5)
87+
out := TaintStepTest_EncodingBinaryAppenderAppendBinary_manual2(source)
88+
sink(5, out)
89+
}
90+
{
91+
source := newSource(6)
92+
out := TaintStepTest_EncodingTextAppenderAppendText_manual1(source)
93+
sink(6, out)
94+
}
95+
{
96+
source := newSource(7)
97+
out := TaintStepTest_EncodingTextAppenderAppendText_manual2(source)
98+
sink(7, out)
99+
}
54100
}

0 commit comments

Comments
 (0)