Add a conformance test for invalid end group tag.

Java and Python/C++ are both non-conformant, since they allow these invalid payloads.

PiperOrigin-RevId: 694312115
pull/19113/head
Mike Kruskal 5 months ago committed by Copybara-Service
parent 492029b3eb
commit fc048f4fe3
  1. 22
      conformance/binary_json_conformance_suite.cc
  2. 1
      conformance/binary_json_conformance_suite.h
  3. 4
      conformance/failure_list_java.txt
  4. 4
      conformance/failure_list_java_lite.txt
  5. 4
      conformance/failure_list_jruby.txt
  6. 5
      conformance/failure_list_python_cpp.txt
  7. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  8. 2
      python/build_targets.bzl

@ -1366,6 +1366,26 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestIllegalTags() {
}
}
template <typename MessageType>
void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestUnmatchedEndGroup() {
ExpectParseFailureForProto(tag(201, WireFormatLite::WIRETYPE_END_GROUP),
"UnmatchedEndGroup", REQUIRED);
ExpectParseFailureForProto(tag(1234, WireFormatLite::WIRETYPE_END_GROUP),
"UnmatchedEndGroupUnknown", REQUIRED);
ExpectParseFailureForProto(tag(1, WireFormatLite::WIRETYPE_END_GROUP),
"UnmatchedEndGroupWrongType", REQUIRED);
ExpectParseFailureForProto(
len(18, tag(1234, WireFormatLite::WIRETYPE_END_GROUP)),
"UnmatchedEndGroupNestedLen", REQUIRED);
ExpectParseFailureForProto(
group(201, tag(202, WireFormatLite::WIRETYPE_END_GROUP)),
"UnmatchedEndGroupNested", REQUIRED);
ExpectParseFailureForProto(
absl::StrCat(tag(1, WireFormatLite::WIRETYPE_END_GROUP),
len(2, "hello world")),
"UnmatchedEndGroupWithData", REQUIRED);
}
template <typename MessageType>
void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestUnknownWireType() {
for (uint8_t type : {0x6, 0x7}) {
@ -1553,7 +1573,7 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::RunAllTests() {
}
TestIllegalTags();
TestUnmatchedEndGroup();
TestUnknownWireType();
int64_t kInt64Min = -9223372036854775808ULL;

@ -143,6 +143,7 @@ class BinaryAndJsonConformanceSuiteImpl {
ConformanceLevel level);
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
void TestIllegalTags();
void TestUnmatchedEndGroup();
void TestUnknownWireType();
void TestOneofMessage();
void TestUnknownMessage();

@ -43,3 +43,7 @@ Required.*.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
Required.*.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt # Should have failed to parse, but didn't.
Required.*.JsonInput.StringFieldNotAString # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnknownOrdering.ProtobufOutput # Unknown field mismatch
Required.*.ProtobufInput.UnmatchedEndGroup # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupUnknown # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWithData # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWrongType # Should have failed to parse, but didn't.

@ -6,3 +6,7 @@
Required.*.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE # Should have failed to parse, but didn't.
Required.*.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroup # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupUnknown # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWithData # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWrongType # Should have failed to parse, but didn't.

@ -144,3 +144,7 @@ Required.Editions_Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.*.ProtobufInput.UnmatchedEndGroup # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupUnknown # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWithData # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWrongType # Should have failed to parse, but didn't.

@ -6,5 +6,8 @@
#
# TODO: insert links to corresponding bugs tracking the issue.
# Should we use GitHub issues or the Google-internal bug tracker?
Required.*.JsonInput.Int32FieldQuotedExponentialValue.* # Failed to parse input or produce output.
Required.*.ProtobufInput.UnmatchedEndGroup # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupUnknown # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWithData # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnmatchedEndGroupWrongType # Should have failed to parse, but didn't.

@ -1,17 +0,0 @@
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#endregion
namespace Google.Protobuf.Reflection;
internal sealed partial class FeatureSetDescriptor
{
// Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
private const string DefaultsBase64 =
"ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
}

@ -468,7 +468,7 @@ def build_targets(name):
conformance_test(
name = "conformance_test_cpp",
env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "cpp"},
failure_list = "//conformance:failure_list_python.txt",
failure_list = "//conformance:failure_list_python_cpp.txt",
target_compatible_with = select({
"@system_python//:none": ["@platforms//:incompatible"],
":use_fast_cpp_protos": [],

Loading…
Cancel
Save