Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit c2ff2df

Browse files
committed
Add test showing false-negative for MarshalState
1 parent 42d6250 commit c2ff2df

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

ql/test/library-tests/semmle/go/frameworks/Protobuf/FunctionModel.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@
4040
| testModernApi.go:123:18:123:36 | untrustedSerialized | testModernApi.go:122:2:122:6 | definition of query |
4141
| testModernApi.go:143:33:143:37 | query | testModernApi.go:143:2:143:38 | ... := ...[0] |
4242
| testModernApi.go:154:33:154:37 | query | testModernApi.go:154:2:154:38 | ... := ...[0] |
43+
| testModernApi.go:168:12:168:16 | query | testModernApi.go:168:12:168:31 | call to ProtoReflect |

ql/test/library-tests/semmle/go/frameworks/Protobuf/testModernApi.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,22 @@ func testSubmessageAliasFalseNegativeModern() {
155155

156156
sinkBytes(serialized) // BAD (but not noticed by our current implementation)
157157
}
158+
159+
// This test should be flagged, but we don't notice that marshalState2.Message is the
160+
// same as marshalState.Message.
161+
func testMarshalStateFalseNegative() {
162+
query := &query.Query{}
163+
query.Description = getUntrustedString()
164+
165+
options := proto.MarshalOptions{}
166+
emptyArray := []byte{}
167+
marshalState := protoiface.MarshalInput{
168+
Message: query.ProtoReflect(),
169+
Buf: emptyArray,
170+
Flags: 0,
171+
}
172+
marshalState2 := marshalState
173+
serialized, _ := options.MarshalState(marshalState2)
174+
175+
sinkBytes(serialized.Buf) // BAD (but not noticed by our current implementation)
176+
}

0 commit comments

Comments
 (0)