Internal change PiperOrigin-RevId: 494043842
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 6b750b1..360d298 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc
@@ -330,7 +330,8 @@ , /*decltype(_impl_.lazy_)*/false , /*decltype(_impl_.unverified_lazy_)*/false , /*decltype(_impl_.deprecated_)*/false - , /*decltype(_impl_.weak_)*/false} {} + , /*decltype(_impl_.weak_)*/false + , /*decltype(_impl_.debug_redact_)*/false} {} struct FieldOptionsDefaultTypeInternal { PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FieldOptionsDefaultTypeInternal() {} @@ -848,6 +849,7 @@ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.debug_redact_), PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_), 0, 2, @@ -856,6 +858,7 @@ 4, 5, 6, + 7, ~0u, ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_), @@ -1025,18 +1028,18 @@ { 206, 220, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, { 226, 255, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, { 276, 289, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, - { 294, 310, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, - { 318, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, - { 327, 338, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, - { 341, 351, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, - { 353, 363, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, - { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, - { 379, 389, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, - { 391, 406, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, - { 413, 426, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, - { 431, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, - { 440, 453, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, - { 458, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, + { 294, 311, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, + { 320, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, + { 329, 340, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, + { 343, 353, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, + { 355, 365, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, + { 367, 378, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, + { 381, 391, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, + { 393, 408, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, + { 415, 428, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, + { 433, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, + { 442, 455, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, + { 460, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -1170,67 +1173,68 @@ "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" "(\0132$.google.protobuf.UninterpretedOption" "*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020" - "\n\"\276\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goog" + "\n\"\333\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goog" "le.protobuf.FieldOptions.CType:\006STRING\022\016" "\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google." "protobuf.FieldOptions.JSType:\tJS_NORMAL\022" "\023\n\004lazy\030\005 \001(\010:\005false\022\036\n\017unverified_lazy\030" "\017 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" - "\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_op" - "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" - "tedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001" - "\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMA" - "L\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200" - "\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptio" - "ns\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 " - "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption*" - "\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\n" - "deprecated\030\001 \001(\010:\005false\022C\n\024uninterpreted" - "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" - "pretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOption" - "s\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninterp" - "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" - "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodO" - "ptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021ide" - "mpotency_level\030\" \001(\0162/.google.protobuf.M" - "ethodOptions.IdempotencyLevel:\023IDEMPOTEN" - "CY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption\"" - "P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKNO" - "WN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020" - "\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004" - "name\030\002 \003(\0132-.google.protobuf.Uninterpret" - "edOption.NamePart\022\030\n\020identifier_value\030\003 " - "\001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negat" - "ive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(" - "\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_val" - "ue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022" - "\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo" - "\022:\n\010location\030\001 \003(\0132(.google.protobuf.Sou" - "rceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pat" - "h\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading" - "_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001" - "(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\234\002" - "\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132" - "-.google.protobuf.GeneratedCodeInfo.Anno" - "tation\032\303\001\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022" - "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e" - "nd\030\004 \001(\005\022H\n\010semantic\030\005 \001(\01626.google.prot" - "obuf.GeneratedCodeInfo.Annotation.Semant" - "ic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALI" - "AS\020\002B~\n\023com.google.protobufB\020DescriptorP" - "rotosH\001Z-google.golang.org/protobuf/type" - "s/descriptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobu" - "f.Reflection" + "\023\n\004weak\030\n \001(\010:\005false\022\033\n\014debug_redact\030\020 \001" + "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013" + "2$.google.protobuf.UninterpretedOption\"/" + "\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_" + "PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_S" + "TRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"" + "^\n\014OneofOptions\022C\n\024uninterpreted_option\030" + "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" + "tion*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptions\022\023\n\013allow" + "_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" + "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." + "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J" + "\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\ndeprecated\030" + "\001 \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 " + "\003(\0132$.google.protobuf.UninterpretedOptio" + "n*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprec" + "ated\030! \001(\010:\005false\022C\n\024uninterpreted_optio" + "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" + "Option*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodOptions\022\031\n\nd" + "eprecated\030! \001(\010:\005false\022_\n\021idempotency_le" + "vel\030\" \001(\0162/.google.protobuf.MethodOption" + "s.IdempotencyLevel:\023IDEMPOTENCY_UNKNOWN\022" + "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." + "protobuf.UninterpretedOption\"P\n\020Idempote" + "ncyLevel\022\027\n\023IDEMPOTENCY_UNKNOWN\020\000\022\023\n\017NO_" + "SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020\002*\t\010\350\007\020\200\200\200\200" + "\002\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(\0132" + "-.google.protobuf.UninterpretedOption.Na" + "mePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022posi" + "tive_int_value\030\004 \001(\004\022\032\n\022negative_int_val" + "ue\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string" + "_value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n" + "\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_exten" + "sion\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010locatio" + "n\030\001 \003(\0132(.google.protobuf.SourceCodeInfo" + ".Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001" + "\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003" + " \001(\t\022\031\n\021trailing_comments\030\004 \001(\t\022!\n\031leadi" + "ng_detached_comments\030\006 \003(\t\"\234\002\n\021Generated" + "CodeInfo\022A\n\nannotation\030\001 \003(\0132-.google.pr" + "otobuf.GeneratedCodeInfo.Annotation\032\303\001\n\n" + "Annotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\023\n\013source_f" + "ile\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003end\030\004 \001(\005\022H\n" + "\010semantic\030\005 \001(\01626.google.protobuf.Genera" + "tedCodeInfo.Annotation.Semantic\"(\n\010Seman" + "tic\022\010\n\004NONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALIAS\020\002B~\n\023com" + ".google.protobufB\020DescriptorProtosH\001Z-go" + "ogle.golang.org/protobuf/types/descripto" + "rpb\370\001\001\242\002\003GPB\252\002\032Google.Protobuf.Reflectio" + "n" }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { false, false, - 6212, + 6241, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, @@ -8017,6 +8021,9 @@ static void set_has_weak(HasBits* has_bits) { (*has_bits)[0] |= 64u; } + static void set_has_debug_redact(HasBits* has_bits) { + (*has_bits)[0] |= 128u; + } }; FieldOptions::FieldOptions(::PROTOBUF_NAMESPACE_ID::Arena* arena, @@ -8039,13 +8046,14 @@ , decltype(_impl_.lazy_){} , decltype(_impl_.unverified_lazy_){} , decltype(_impl_.deprecated_){} - , decltype(_impl_.weak_){}}; + , decltype(_impl_.weak_){} + , decltype(_impl_.debug_redact_){}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); ::memcpy(&_impl_.ctype_, &from._impl_.ctype_, - static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.weak_) - - reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.weak_)); + static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.debug_redact_) - + reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.debug_redact_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } @@ -8065,6 +8073,7 @@ , decltype(_impl_.unverified_lazy_){false} , decltype(_impl_.deprecated_){false} , decltype(_impl_.weak_){false} + , decltype(_impl_.debug_redact_){false} }; } @@ -8096,10 +8105,10 @@ _impl_._extensions_.Clear(); _impl_.uninterpreted_option_.Clear(); cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x000000ffu) { ::memset(&_impl_.ctype_, 0, static_cast<::size_t>( - reinterpret_cast<char*>(&_impl_.weak_) - - reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.weak_)); + reinterpret_cast<char*>(&_impl_.debug_redact_) - + reinterpret_cast<char*>(&_impl_.ctype_)) + sizeof(_impl_.debug_redact_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); @@ -8191,6 +8200,16 @@ goto handle_unusual; } continue; + // optional bool debug_redact = 16 [default = false]; + case 16: + if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 128)) { + _Internal::set_has_debug_redact(&has_bits); + _impl_.debug_redact_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else { + goto handle_unusual; + } + continue; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 58)) { @@ -8286,6 +8305,12 @@ target = ::_pbi::WireFormatLite::WriteBoolToArray(15, this->_internal_unverified_lazy(), target); } + // optional bool debug_redact = 16 [default = false]; + if (cached_has_bits & 0x00000080u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(16, this->_internal_debug_redact(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned i = 0, n = static_cast<unsigned>(this->_internal_uninterpreted_option_size()); i < n; i++) { @@ -8325,7 +8350,7 @@ } cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x000000ffu) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (cached_has_bits & 0x00000001u) { total_size += 1 + @@ -8363,6 +8388,11 @@ total_size += 1 + 1; } + // optional bool debug_redact = 16 [default = false]; + if (cached_has_bits & 0x00000080u) { + total_size += 2 + 1; + } + } return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } @@ -8385,7 +8415,7 @@ _this->_impl_.uninterpreted_option_.MergeFrom(from._impl_.uninterpreted_option_); cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { _this->_impl_.ctype_ = from._impl_.ctype_; } @@ -8407,6 +8437,9 @@ if (cached_has_bits & 0x00000040u) { _this->_impl_.weak_ = from._impl_.weak_; } + if (cached_has_bits & 0x00000080u) { + _this->_impl_.debug_redact_ = from._impl_.debug_redact_; + } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_impl_._extensions_.MergeFrom(internal_default_instance(), from._impl_._extensions_); @@ -8437,8 +8470,8 @@ swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); _impl_.uninterpreted_option_.InternalSwap(&other->_impl_.uninterpreted_option_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.weak_) - + sizeof(FieldOptions::_impl_.weak_) + PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.debug_redact_) + + sizeof(FieldOptions::_impl_.debug_redact_) - PROTOBUF_FIELD_OFFSET(FieldOptions, _impl_.ctype_)>( reinterpret_cast<char*>(&_impl_.ctype_), reinterpret_cast<char*>(&other->_impl_.ctype_));
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 40413f1..93a1f48 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h
@@ -4860,6 +4860,7 @@ kUnverifiedLazyFieldNumber = 15, kDeprecatedFieldNumber = 3, kWeakFieldNumber = 10, + kDebugRedactFieldNumber = 16, }; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; @@ -4949,6 +4950,16 @@ void _internal_set_weak(bool value); public: + // optional bool debug_redact = 16 [default = false]; + bool has_debug_redact() const; + void clear_debug_redact(); + bool debug_redact() const; + void set_debug_redact(bool value); + private: + bool _internal_debug_redact() const; + void _internal_set_debug_redact(bool value); + public: + template <typename _proto_TypeTraits, ::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, @@ -5159,6 +5170,7 @@ bool unverified_lazy_; bool deprecated_; bool weak_; + bool debug_redact_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; @@ -12851,6 +12863,31 @@ // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) } +// optional bool debug_redact = 16 [default = false]; +inline bool FieldOptions::has_debug_redact() const { + bool value = (_impl_._has_bits_[0] & 0x00000080u) != 0; + return value; +} +inline void FieldOptions::clear_debug_redact() { + _impl_.debug_redact_ = false; + _impl_._has_bits_[0] &= ~0x00000080u; +} +inline bool FieldOptions::_internal_debug_redact() const { + return _impl_.debug_redact_; +} +inline bool FieldOptions::debug_redact() const { + // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.debug_redact) + return _internal_debug_redact(); +} +inline void FieldOptions::_internal_set_debug_redact(bool value) { + _impl_._has_bits_[0] |= 0x00000080u; + _impl_.debug_redact_ = value; +} +inline void FieldOptions::set_debug_redact(bool value) { + _internal_set_debug_redact(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.debug_redact) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FieldOptions::_internal_uninterpreted_option_size() const { return _impl_.uninterpreted_option_.size();
diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 0636a87..7410042 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto
@@ -615,6 +615,10 @@ // For Google-internal migration only. Do not use. optional bool weak = 10 [default = false]; + // Indicate that the field value should not be printed out when using debug + // formats, e.g. when the field contains sensitive credentials. + optional bool debug_redact = 16 [default = false]; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999;
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index d6298c8..778e67a 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc
@@ -2123,12 +2123,6 @@ io::ZeroCopyOutputStream* output) const { TextGenerator generator(output, insert_silent_marker_, initial_indent_level_); -#ifndef PROTO2_OPENSOURCE -#ifdef SUPPORT_EXPLICIT_DEBUG_STRING - internal::PrintTextMarker(&generator, redact_debug_string_, - randomize_debug_string_, single_line_mode_); -#endif -#endif Print(message, &generator); @@ -2579,15 +2573,11 @@ << "Index must be -1 for non-repeated fields"; const FastFieldValuePrinter* printer = GetFieldPrinter(field); -#ifndef PROTO2_OPENSOURCE -#ifdef SUPPORT_EXPLICIT_DEBUG_STRING - if (redact_debug_string_ && internal::ShouldRedactField(field)) { - std::string redacted_value = "go/redact-debug-string"; - generator->PrintString(redacted_value); + if (redact_debug_string_ && field->options().debug_redact()) { + // TODO(b/258975650): Create OSS redaction documentation + generator->PrintString("[REDACTED]"); return; } -#endif -#endif switch (field->cpp_type()) { #define OUTPUT_FIELD(CPPTYPE, METHOD) \
diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 71dd756..d9c1b05 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc
@@ -2281,6 +2281,59 @@ EXPECT_FALSE(parser.ParseFromString("unknown_field: 1", &proto)); } +template <bool silent, bool redact, bool randomize> +class TextFormatBaseMarkerTest : public testing::Test { + public: + void SetUp() override { + saved_enable_debug_text_format_marker_ = + internal::enable_debug_text_format_marker; + saved_enable_debug_text_redaction_marker_ = + internal::enable_debug_text_redaction_marker; + saved_enable_debug_text_random_marker_ = + internal::enable_debug_text_random_marker; + + internal::enable_debug_text_format_marker = silent; + internal::enable_debug_text_redaction_marker = redact; + internal::enable_debug_text_random_marker = randomize; + } + + void TearDown() override { + internal::enable_debug_text_format_marker = + saved_enable_debug_text_format_marker_; + internal::enable_debug_text_redaction_marker = + saved_enable_debug_text_redaction_marker_; + internal::enable_debug_text_random_marker = + saved_enable_debug_text_random_marker_; + } + + private: + bool saved_enable_debug_text_format_marker_; + bool saved_enable_debug_text_redaction_marker_; + bool saved_enable_debug_text_random_marker_; +}; + +using TextFormatRedactionTest = TextFormatBaseMarkerTest<false, true, false>; + +TEST_F(TextFormatRedactionTest, TestRedactedField) { + unittest::RedactedFields proto; + proto.set_optional_redacted_string("foo"); + EXPECT_THAT( + proto.DebugString(), + testing::MatchesRegex("optional_redacted_string: \\[REDACTED\\]\n")); + EXPECT_THAT( + proto.ShortDebugString(), + testing::MatchesRegex("optional_redacted_string: \\[REDACTED\\]")); +} + +TEST_F(TextFormatRedactionTest, TestTextFormatIsNotRedacted) { + unittest::RedactedFields proto; + proto.set_optional_redacted_string("foo"); + + std::string text; + ASSERT_TRUE(TextFormat::PrintToString(proto, &text)); + EXPECT_EQ("optional_redacted_string: \"foo\"\n", text); +} + TEST(TextFormatFloatingPointTest, PreservesNegative0) { proto3_unittest::TestAllTypes in_message; in_message.set_optional_float(-0.0f);
diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index fa95bbd..ef09f8e 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto
@@ -1580,3 +1580,7 @@ optional int32 OptionalInt32 = 1; optional int32 for = 2; } + +message RedactedFields{ + optional string optional_redacted_string = 1 [debug_redact = true]; +}