grpc 1.55.0 → 1.56.0.pre3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (374) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +100 -68
  3. data/include/grpc/event_engine/event_engine.h +4 -3
  4. data/include/grpc/grpc_audit_logging.h +96 -0
  5. data/include/grpc/module.modulemap +2 -0
  6. data/include/grpc/support/json.h +218 -0
  7. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +5 -0
  8. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  9. data/src/core/ext/filters/client_channel/channel_connectivity.cc +4 -4
  10. data/src/core/ext/filters/client_channel/client_channel.cc +86 -104
  11. data/src/core/ext/filters/client_channel/client_channel.h +6 -0
  12. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +19 -18
  13. data/src/core/ext/filters/client_channel/client_channel_internal.h +16 -21
  14. data/src/core/ext/filters/client_channel/config_selector.h +9 -24
  15. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -0
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +5 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +455 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +54 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +186 -0
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +2 -7
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +52 -20
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +23 -2
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -6
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +1 -9
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +16 -7
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +18 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +12 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -4
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +36 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +76 -6
  31. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +32 -39
  32. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +4 -10
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +52 -47
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +1 -9
  35. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -16
  36. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +40 -43
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +7 -12
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -19
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +35 -33
  40. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +29 -4
  41. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/service_config_helper.cc +1 -1
  42. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +28 -27
  43. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +163 -46
  44. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +16 -1
  45. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -0
  46. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +10 -40
  47. data/src/core/ext/filters/client_channel/subchannel.cc +10 -196
  48. data/src/core/ext/filters/client_channel/subchannel.h +3 -43
  49. data/src/core/ext/filters/http/message_compress/compression_filter.cc +5 -5
  50. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +100 -6
  51. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +6 -8
  52. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -3
  53. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +16 -1
  54. data/src/core/ext/transport/chttp2/transport/flow_control.cc +46 -95
  55. data/src/core/ext/transport/chttp2/transport/internal.h +1 -15
  56. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +11 -2
  57. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -0
  58. data/src/core/ext/xds/certificate_provider_store.cc +4 -9
  59. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  60. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +30 -42
  61. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +14 -9
  62. data/src/core/ext/xds/xds_api.cc +9 -6
  63. data/src/core/ext/xds/xds_api.h +3 -2
  64. data/src/core/ext/xds/xds_audit_logger_registry.cc +122 -0
  65. data/src/core/ext/xds/xds_audit_logger_registry.h +68 -0
  66. data/src/core/ext/xds/xds_bootstrap_grpc.cc +21 -9
  67. data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -0
  68. data/src/core/ext/xds/xds_client.cc +5 -4
  69. data/src/core/ext/xds/xds_client_stats.h +1 -1
  70. data/src/core/ext/xds/xds_cluster.cc +20 -19
  71. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +11 -8
  72. data/src/core/ext/xds/xds_common_types.cc +3 -1
  73. data/src/core/ext/xds/xds_http_fault_filter.cc +16 -13
  74. data/src/core/ext/xds/xds_http_fault_filter.h +2 -1
  75. data/src/core/ext/xds/xds_http_filters.h +4 -2
  76. data/src/core/ext/xds/xds_http_rbac_filter.cc +154 -67
  77. data/src/core/ext/xds/xds_http_rbac_filter.h +2 -1
  78. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +15 -11
  79. data/src/core/ext/xds/xds_http_stateful_session_filter.h +2 -1
  80. data/src/core/ext/xds/xds_lb_policy_registry.cc +22 -16
  81. data/src/core/ext/xds/xds_listener.cc +1 -0
  82. data/src/core/ext/xds/xds_route_config.cc +40 -3
  83. data/src/core/ext/xds/xds_routing.cc +2 -2
  84. data/src/core/ext/xds/xds_transport_grpc.cc +3 -1
  85. data/src/core/lib/avl/avl.h +5 -0
  86. data/src/core/lib/channel/channel_args.cc +80 -22
  87. data/src/core/lib/channel/channel_args.h +34 -1
  88. data/src/core/lib/channel/channel_trace.cc +16 -12
  89. data/src/core/lib/channel/channelz.cc +159 -132
  90. data/src/core/lib/channel/channelz.h +42 -35
  91. data/src/core/lib/channel/channelz_registry.cc +23 -20
  92. data/src/core/lib/channel/connected_channel.cc +17 -6
  93. data/src/core/lib/channel/promise_based_filter.cc +0 -4
  94. data/src/core/lib/channel/promise_based_filter.h +2 -0
  95. data/src/core/lib/compression/compression_internal.cc +2 -5
  96. data/src/core/lib/config/config_vars.cc +20 -18
  97. data/src/core/lib/config/config_vars.h +4 -4
  98. data/src/core/lib/config/load_config.cc +13 -0
  99. data/src/core/lib/config/load_config.h +6 -0
  100. data/src/core/lib/debug/event_log.h +1 -1
  101. data/src/core/lib/debug/stats_data.h +1 -1
  102. data/src/core/lib/debug/trace.cc +24 -55
  103. data/src/core/lib/debug/trace.h +3 -1
  104. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +211 -0
  105. data/src/core/lib/event_engine/cf_engine/cf_engine.h +86 -0
  106. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +354 -0
  107. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +146 -0
  108. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +79 -0
  109. data/src/core/lib/event_engine/default_event_engine.cc +13 -1
  110. data/src/core/lib/event_engine/default_event_engine_factory.cc +14 -2
  111. data/src/core/lib/event_engine/poller.h +2 -2
  112. data/src/core/lib/event_engine/posix.h +4 -0
  113. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  114. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +7 -18
  115. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -0
  116. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +33 -19
  117. data/src/core/lib/event_engine/posix_engine/posix_engine.h +1 -1
  118. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +4 -4
  119. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +7 -8
  120. data/src/core/lib/event_engine/posix_engine/timer_manager.h +1 -1
  121. data/src/core/lib/event_engine/shim.cc +7 -1
  122. data/src/core/lib/event_engine/{thread_pool.cc → thread_pool/original_thread_pool.cc} +28 -25
  123. data/src/core/lib/event_engine/{thread_pool.h → thread_pool/original_thread_pool.h} +11 -15
  124. data/src/core/lib/event_engine/thread_pool/thread_pool.h +50 -0
  125. data/src/core/lib/event_engine/{executor/executor.h → thread_pool/thread_pool_factory.cc} +17 -15
  126. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +489 -0
  127. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +249 -0
  128. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +166 -0
  129. data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +108 -0
  130. data/src/core/lib/event_engine/windows/iocp.cc +4 -3
  131. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  132. data/src/core/lib/event_engine/windows/win_socket.cc +6 -6
  133. data/src/core/lib/event_engine/windows/win_socket.h +4 -4
  134. data/src/core/lib/event_engine/windows/windows_endpoint.cc +11 -10
  135. data/src/core/lib/event_engine/windows/windows_endpoint.h +3 -2
  136. data/src/core/lib/event_engine/windows/windows_engine.cc +19 -17
  137. data/src/core/lib/event_engine/windows/windows_engine.h +6 -6
  138. data/src/core/lib/event_engine/windows/windows_listener.cc +3 -3
  139. data/src/core/lib/event_engine/windows/windows_listener.h +3 -2
  140. data/src/core/lib/event_engine/work_queue/basic_work_queue.cc +63 -0
  141. data/src/core/lib/event_engine/work_queue/basic_work_queue.h +71 -0
  142. data/src/core/lib/event_engine/work_queue/work_queue.h +62 -0
  143. data/src/core/lib/experiments/config.cc +38 -7
  144. data/src/core/lib/experiments/config.h +16 -0
  145. data/src/core/lib/experiments/experiments.cc +67 -20
  146. data/src/core/lib/experiments/experiments.h +27 -21
  147. data/src/core/lib/gpr/log_internal.h +55 -0
  148. data/src/core/lib/gprpp/crash.cc +10 -0
  149. data/src/core/lib/gprpp/crash.h +3 -0
  150. data/src/core/lib/gprpp/per_cpu.cc +33 -0
  151. data/src/core/lib/gprpp/per_cpu.h +29 -6
  152. data/src/core/lib/gprpp/time.cc +1 -0
  153. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  154. data/src/core/lib/iomgr/endpoint_cfstream.cc +10 -8
  155. data/src/core/lib/iomgr/ev_apple.cc +12 -12
  156. data/src/core/lib/iomgr/ev_epoll1_linux.cc +10 -3
  157. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +15 -1
  158. data/src/core/lib/iomgr/iocp_windows.cc +24 -3
  159. data/src/core/lib/iomgr/iocp_windows.h +11 -0
  160. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +1 -1
  161. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -2
  162. data/src/core/lib/iomgr/socket_windows.cc +61 -7
  163. data/src/core/lib/iomgr/socket_windows.h +9 -2
  164. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -3
  165. data/src/core/lib/iomgr/tcp_server_posix.cc +148 -107
  166. data/src/core/lib/iomgr/tcp_server_utils_posix.h +1 -1
  167. data/src/core/lib/iomgr/tcp_server_windows.cc +1 -1
  168. data/src/core/lib/json/json.h +2 -166
  169. data/src/core/lib/json/json_object_loader.cc +8 -9
  170. data/src/core/lib/json/json_object_loader.h +25 -18
  171. data/src/core/lib/json/json_reader.cc +13 -6
  172. data/src/core/lib/json/json_util.cc +6 -11
  173. data/src/core/lib/json/json_writer.cc +7 -8
  174. data/src/core/lib/load_balancing/lb_policy.h +13 -0
  175. data/src/core/lib/load_balancing/lb_policy_registry.cc +2 -1
  176. data/src/core/lib/matchers/matchers.cc +3 -4
  177. data/src/core/lib/matchers/matchers.h +2 -1
  178. data/src/core/lib/promise/activity.cc +5 -0
  179. data/src/core/lib/promise/activity.h +10 -0
  180. data/src/core/lib/promise/detail/promise_factory.h +1 -1
  181. data/src/core/lib/promise/party.cc +31 -13
  182. data/src/core/lib/promise/party.h +11 -2
  183. data/src/core/lib/promise/pipe.h +9 -2
  184. data/src/core/lib/promise/prioritized_race.h +95 -0
  185. data/src/core/lib/promise/sleep.cc +2 -1
  186. data/src/core/lib/resolver/server_address.cc +0 -8
  187. data/src/core/lib/resolver/server_address.h +0 -6
  188. data/src/core/lib/resource_quota/memory_quota.cc +7 -7
  189. data/src/core/lib/resource_quota/memory_quota.h +1 -2
  190. data/src/core/lib/security/authorization/audit_logging.cc +98 -0
  191. data/src/core/lib/security/authorization/audit_logging.h +73 -0
  192. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +47 -2
  193. data/src/core/lib/security/authorization/grpc_authorization_engine.h +18 -1
  194. data/src/core/lib/security/authorization/rbac_policy.cc +36 -4
  195. data/src/core/lib/security/authorization/rbac_policy.h +19 -2
  196. data/src/core/lib/security/authorization/stdout_logger.cc +75 -0
  197. data/src/core/lib/security/authorization/stdout_logger.h +61 -0
  198. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +8 -4
  199. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +8 -18
  200. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +14 -8
  201. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +19 -12
  202. data/src/core/lib/security/credentials/external/external_account_credentials.cc +4 -2
  203. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +1 -0
  204. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  205. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  206. data/src/core/lib/security/credentials/jwt/json_token.cc +15 -14
  207. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -2
  208. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +1 -0
  209. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -0
  210. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -5
  211. data/src/core/lib/security/util/json_util.cc +1 -0
  212. data/src/core/lib/service_config/service_config_call_data.h +49 -20
  213. data/src/core/lib/service_config/service_config_impl.cc +2 -1
  214. data/src/core/lib/surface/call.cc +38 -23
  215. data/src/core/lib/surface/completion_queue.cc +6 -2
  216. data/src/core/lib/surface/version.cc +2 -2
  217. data/src/core/lib/transport/batch_builder.cc +15 -12
  218. data/src/core/lib/transport/batch_builder.h +39 -35
  219. data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -2
  220. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
  221. data/src/ruby/ext/grpc/extconf.rb +8 -9
  222. data/src/ruby/lib/grpc/version.rb +1 -1
  223. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +9 -8
  224. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +1 -1
  225. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +3 -3
  226. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +10 -6
  227. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +7 -4
  228. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +6 -4
  229. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -1
  230. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +5 -9
  231. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +4 -2
  232. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +31 -22
  233. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +29 -26
  234. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +8 -0
  235. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +189 -13
  236. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +62 -0
  237. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +31 -0
  238. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +6 -4
  239. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +795 -795
  240. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -5
  241. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +4 -0
  242. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +18 -6
  243. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +15 -7
  244. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +1 -1
  245. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +1 -1
  246. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -0
  247. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +3 -0
  248. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +24 -24
  249. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +1 -1
  250. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +7 -7
  251. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +74 -74
  252. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +1 -2
  253. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +11 -11
  254. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +12 -12
  255. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +14 -15
  256. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +1 -1
  257. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +10 -10
  258. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +23 -23
  259. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +13 -13
  260. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +1 -1
  261. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +2 -2
  262. data/third_party/boringssl-with-bazel/src/crypto/{hkdf → fipsmodule/hkdf}/hkdf.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +2 -10
  264. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +1 -4
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +115 -133
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +12 -14
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +57 -47
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -8
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +27 -28
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -23
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +21 -16
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +5 -288
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +143 -83
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +95 -183
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +71 -0
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +8 -0
  277. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +33 -0
  278. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +162 -6
  279. data/third_party/boringssl-with-bazel/src/crypto/internal.h +18 -0
  280. data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +18 -11
  281. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +6 -13
  282. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +18 -14
  283. data/third_party/boringssl-with-bazel/src/crypto/{refcount_lock.c → refcount_no_threads.c} +3 -13
  284. data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +89 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +77 -0
  286. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_crypt.c +568 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +62 -0
  288. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +218 -44
  289. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +35 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +588 -39
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +27 -18
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +1 -1
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +17 -39
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +39 -48
  295. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +0 -140
  296. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +72 -23
  297. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -14
  298. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +1 -1
  299. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  300. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +1 -1
  301. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +33 -46
  302. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +1 -0
  303. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +3 -5
  304. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +14 -46
  305. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -26
  306. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +17 -10
  307. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1 -1
  308. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +5 -7
  309. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +6 -4
  310. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +32 -1
  311. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +0 -4
  312. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +1 -4
  313. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +3 -3
  314. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +28 -0
  315. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +2 -11
  316. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -3
  317. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +91 -1
  318. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +5 -0
  319. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +149 -20
  320. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +4 -0
  321. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  322. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +8 -0
  323. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +774 -615
  324. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +42 -10
  325. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +11 -6
  326. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -4
  327. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +24 -16
  328. data/third_party/boringssl-with-bazel/src/ssl/internal.h +65 -18
  329. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +37 -18
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +187 -193
  331. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +13 -129
  332. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +85 -10
  333. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +17 -4
  334. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +27 -19
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1 -1
  336. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +5 -21
  337. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -2
  338. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_msvc.h +1281 -0
  339. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64_msvc.h +2002 -0
  340. data/third_party/cares/cares/include/ares.h +23 -1
  341. data/third_party/cares/cares/{src/lib → include}/ares_nameser.h +9 -7
  342. data/third_party/cares/cares/include/ares_rules.h +2 -2
  343. data/third_party/cares/cares/include/ares_version.h +3 -3
  344. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +266 -0
  345. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +240 -0
  346. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +49 -80
  347. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +37 -43
  348. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +12 -4
  349. data/third_party/cares/cares/src/lib/ares_data.c +16 -0
  350. data/third_party/cares/cares/src/lib/ares_data.h +7 -0
  351. data/third_party/cares/cares/src/lib/ares_destroy.c +8 -0
  352. data/third_party/cares/cares/src/lib/ares_expand_name.c +17 -6
  353. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +1 -0
  354. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +156 -78
  355. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +130 -326
  356. data/third_party/cares/cares/src/lib/ares_init.c +97 -485
  357. data/third_party/cares/cares/src/lib/ares_library_init.c +2 -89
  358. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +23 -142
  359. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +22 -142
  360. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +184 -0
  361. data/third_party/cares/cares/src/lib/ares_private.h +30 -16
  362. data/third_party/cares/cares/src/lib/ares_process.c +55 -16
  363. data/third_party/cares/cares/src/lib/ares_query.c +1 -35
  364. data/third_party/cares/cares/src/lib/ares_rand.c +279 -0
  365. data/third_party/cares/cares/src/lib/ares_send.c +5 -7
  366. data/third_party/cares/cares/src/lib/ares_strdup.c +12 -19
  367. data/third_party/cares/cares/src/lib/ares_strsplit.c +44 -128
  368. data/third_party/cares/cares/src/lib/ares_strsplit.h +9 -10
  369. data/third_party/cares/cares/src/lib/inet_net_pton.c +78 -116
  370. data/third_party/cares/cares/src/tools/ares_getopt.h +53 -0
  371. metadata +50 -14
  372. data/src/core/ext/filters/client_channel/health/health_check_client.cc +0 -175
  373. data/src/core/ext/filters/client_channel/health/health_check_client.h +0 -43
  374. data/third_party/cares/cares/src/lib/ares_library_init.h +0 -43
@@ -19,9 +19,9 @@
19
19
  #include "src/core/ext/xds/xds_http_rbac_filter.h"
20
20
 
21
21
  #include <stddef.h>
22
+ #include <stdint.h>
22
23
 
23
24
  #include <algorithm>
24
- #include <cstdint>
25
25
  #include <string>
26
26
  #include <utility>
27
27
 
@@ -42,10 +42,17 @@
42
42
  #include "google/protobuf/wrappers.upb.h"
43
43
  #include "upb/collections/map.h"
44
44
 
45
+ #include <grpc/support/json.h>
46
+
45
47
  #include "src/core/ext/filters/rbac/rbac_filter.h"
46
48
  #include "src/core/ext/filters/rbac/rbac_service_config_parser.h"
47
49
  #include "src/core/ext/xds/upb_utils.h"
50
+ #include "src/core/ext/xds/xds_audit_logger_registry.h"
51
+ #include "src/core/ext/xds/xds_bootstrap_grpc.h"
52
+ #include "src/core/ext/xds/xds_client.h"
48
53
  #include "src/core/lib/channel/channel_args.h"
54
+ #include "src/core/lib/gpr/string.h"
55
+ #include "src/core/lib/gprpp/env.h"
49
56
  #include "src/core/lib/json/json.h"
50
57
  #include "src/core/lib/json/json_writer.h"
51
58
 
@@ -53,16 +60,27 @@ namespace grpc_core {
53
60
 
54
61
  namespace {
55
62
 
63
+ // TODO(lwge): Remove once the feature is stable.
64
+ bool XdsRbacAuditLoggingEnabled() {
65
+ auto value = GetEnv("GRPC_EXPERIMENTAL_XDS_RBAC_AUDIT_LOGGING");
66
+ if (!value.has_value()) return false;
67
+ bool parsed_value;
68
+ bool parse_succeeded = gpr_parse_bool_value(value->c_str(), &parsed_value);
69
+ return parse_succeeded && parsed_value;
70
+ }
71
+
56
72
  Json ParseRegexMatcherToJson(
57
73
  const envoy_type_matcher_v3_RegexMatcher* regex_matcher) {
58
- return Json::Object(
59
- {{"regex", UpbStringToStdString(envoy_type_matcher_v3_RegexMatcher_regex(
60
- regex_matcher))}});
74
+ return Json::FromObject(
75
+ {{"regex",
76
+ Json::FromString(UpbStringToStdString(
77
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)))}});
61
78
  }
62
79
 
63
80
  Json ParseInt64RangeToJson(const envoy_type_v3_Int64Range* range) {
64
- return Json::Object{{"start", envoy_type_v3_Int64Range_start(range)},
65
- {"end", envoy_type_v3_Int64Range_end(range)}};
81
+ return Json::FromObject(
82
+ {{"start", Json::FromNumber(envoy_type_v3_Int64Range_start(range))},
83
+ {"end", Json::FromNumber(envoy_type_v3_Int64Range_end(range))}});
66
84
  }
67
85
 
68
86
  Json ParseHeaderMatcherToJson(const envoy_config_route_v3_HeaderMatcher* header,
@@ -77,13 +95,13 @@ Json ParseHeaderMatcherToJson(const envoy_config_route_v3_HeaderMatcher* header,
77
95
  } else if (absl::StartsWith(name, "grpc-")) {
78
96
  errors->AddError("'grpc-' prefixes not allowed in header");
79
97
  }
80
- header_json.emplace("name", std::move(name));
98
+ header_json.emplace("name", Json::FromString(std::move(name)));
81
99
  }
82
100
  if (envoy_config_route_v3_HeaderMatcher_has_exact_match(header)) {
83
101
  header_json.emplace(
84
102
  "exactMatch",
85
- UpbStringToStdString(
86
- envoy_config_route_v3_HeaderMatcher_exact_match(header)));
103
+ Json::FromString(UpbStringToStdString(
104
+ envoy_config_route_v3_HeaderMatcher_exact_match(header))));
87
105
  } else if (envoy_config_route_v3_HeaderMatcher_has_safe_regex_match(header)) {
88
106
  header_json.emplace(
89
107
  "safeRegexMatch",
@@ -97,28 +115,30 @@ Json ParseHeaderMatcherToJson(const envoy_config_route_v3_HeaderMatcher* header,
97
115
  } else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
98
116
  header_json.emplace(
99
117
  "presentMatch",
100
- envoy_config_route_v3_HeaderMatcher_present_match(header));
118
+ Json::FromBool(
119
+ envoy_config_route_v3_HeaderMatcher_present_match(header)));
101
120
  } else if (envoy_config_route_v3_HeaderMatcher_has_prefix_match(header)) {
102
121
  header_json.emplace(
103
122
  "prefixMatch",
104
- UpbStringToStdString(
105
- envoy_config_route_v3_HeaderMatcher_prefix_match(header)));
123
+ Json::FromString(UpbStringToStdString(
124
+ envoy_config_route_v3_HeaderMatcher_prefix_match(header))));
106
125
  } else if (envoy_config_route_v3_HeaderMatcher_has_suffix_match(header)) {
107
126
  header_json.emplace(
108
127
  "suffixMatch",
109
- UpbStringToStdString(
110
- envoy_config_route_v3_HeaderMatcher_suffix_match(header)));
128
+ Json::FromString(UpbStringToStdString(
129
+ envoy_config_route_v3_HeaderMatcher_suffix_match(header))));
111
130
  } else if (envoy_config_route_v3_HeaderMatcher_has_contains_match(header)) {
112
131
  header_json.emplace(
113
132
  "containsMatch",
114
- UpbStringToStdString(
115
- envoy_config_route_v3_HeaderMatcher_contains_match(header)));
133
+ Json::FromString(UpbStringToStdString(
134
+ envoy_config_route_v3_HeaderMatcher_contains_match(header))));
116
135
  } else {
117
136
  errors->AddError("invalid route header matcher specified");
118
137
  }
119
- header_json.emplace("invertMatch",
120
- envoy_config_route_v3_HeaderMatcher_invert_match(header));
121
- return header_json;
138
+ header_json.emplace(
139
+ "invertMatch",
140
+ Json::FromBool(envoy_config_route_v3_HeaderMatcher_invert_match(header)));
141
+ return Json::FromObject(std::move(header_json));
122
142
  }
123
143
 
124
144
  Json ParseStringMatcherToJson(
@@ -127,30 +147,31 @@ Json ParseStringMatcherToJson(
127
147
  Json::Object json;
128
148
  if (envoy_type_matcher_v3_StringMatcher_has_exact(matcher)) {
129
149
  json.emplace("exact",
130
- UpbStringToStdString(
131
- envoy_type_matcher_v3_StringMatcher_exact(matcher)));
150
+ Json::FromString(UpbStringToStdString(
151
+ envoy_type_matcher_v3_StringMatcher_exact(matcher))));
132
152
  } else if (envoy_type_matcher_v3_StringMatcher_has_prefix(matcher)) {
133
153
  json.emplace("prefix",
134
- UpbStringToStdString(
135
- envoy_type_matcher_v3_StringMatcher_prefix(matcher)));
154
+ Json::FromString(UpbStringToStdString(
155
+ envoy_type_matcher_v3_StringMatcher_prefix(matcher))));
136
156
  } else if (envoy_type_matcher_v3_StringMatcher_has_suffix(matcher)) {
137
157
  json.emplace("suffix",
138
- UpbStringToStdString(
139
- envoy_type_matcher_v3_StringMatcher_suffix(matcher)));
158
+ Json::FromString(UpbStringToStdString(
159
+ envoy_type_matcher_v3_StringMatcher_suffix(matcher))));
140
160
  } else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(matcher)) {
141
161
  json.emplace("safeRegex",
142
162
  ParseRegexMatcherToJson(
143
163
  envoy_type_matcher_v3_StringMatcher_safe_regex(matcher)));
144
164
  } else if (envoy_type_matcher_v3_StringMatcher_has_contains(matcher)) {
145
165
  json.emplace("contains",
146
- UpbStringToStdString(
147
- envoy_type_matcher_v3_StringMatcher_contains(matcher)));
166
+ Json::FromString(UpbStringToStdString(
167
+ envoy_type_matcher_v3_StringMatcher_contains(matcher))));
148
168
  } else {
149
169
  errors->AddError("invalid match pattern");
150
170
  }
151
- json.emplace("ignoreCase",
152
- envoy_type_matcher_v3_StringMatcher_ignore_case(matcher));
153
- return json;
171
+ json.emplace(
172
+ "ignoreCase",
173
+ Json::FromBool(envoy_type_matcher_v3_StringMatcher_ignore_case(matcher)));
174
+ return Json::FromObject(std::move(json));
154
175
  }
155
176
 
156
177
  Json ParsePathMatcherToJson(const envoy_type_matcher_v3_PathMatcher* matcher,
@@ -162,30 +183,32 @@ Json ParsePathMatcherToJson(const envoy_type_matcher_v3_PathMatcher* matcher,
162
183
  return Json();
163
184
  }
164
185
  Json path_json = ParseStringMatcherToJson(path, errors);
165
- return Json::Object{{"path", std::move(path_json)}};
186
+ return Json::FromObject({{"path", std::move(path_json)}});
166
187
  }
167
188
 
168
189
  Json ParseCidrRangeToJson(const envoy_config_core_v3_CidrRange* range) {
169
190
  Json::Object json;
170
191
  json.emplace("addressPrefix",
171
- UpbStringToStdString(
172
- envoy_config_core_v3_CidrRange_address_prefix(range)));
192
+ Json::FromString(UpbStringToStdString(
193
+ envoy_config_core_v3_CidrRange_address_prefix(range))));
173
194
  const auto* prefix_len = envoy_config_core_v3_CidrRange_prefix_len(range);
174
195
  if (prefix_len != nullptr) {
175
- json.emplace("prefixLen", google_protobuf_UInt32Value_value(prefix_len));
196
+ json.emplace(
197
+ "prefixLen",
198
+ Json::FromNumber(google_protobuf_UInt32Value_value(prefix_len)));
176
199
  }
177
- return json;
200
+ return Json::FromObject(std::move(json));
178
201
  }
179
202
 
180
203
  Json ParseMetadataMatcherToJson(
181
204
  const envoy_type_matcher_v3_MetadataMatcher* metadata_matcher) {
182
- Json::Object json;
183
205
  // The fields "filter", "path" and "value" are irrelevant to gRPC as per
184
206
  // https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md and are not
185
207
  // being parsed.
186
- json.emplace("invert",
187
- envoy_type_matcher_v3_MetadataMatcher_invert(metadata_matcher));
188
- return json;
208
+ return Json::FromObject({
209
+ {"invert", Json::FromBool(envoy_type_matcher_v3_MetadataMatcher_invert(
210
+ metadata_matcher))},
211
+ });
189
212
  }
190
213
 
191
214
  Json ParsePermissionToJson(const envoy_config_rbac_v3_Permission* permission,
@@ -205,7 +228,8 @@ Json ParsePermissionToJson(const envoy_config_rbac_v3_Permission* permission,
205
228
  Json permission_json = ParsePermissionToJson(rules[i], errors);
206
229
  rules_json.emplace_back(std::move(permission_json));
207
230
  }
208
- return Json::Object({{"rules", std::move(rules_json)}});
231
+ return Json::FromObject(
232
+ {{"rules", Json::FromArray(std::move(rules_json))}});
209
233
  };
210
234
  if (envoy_config_rbac_v3_Permission_has_and_rules(permission)) {
211
235
  ValidationErrors::ScopedField field(errors, ".and_permission");
@@ -219,8 +243,8 @@ Json ParsePermissionToJson(const envoy_config_rbac_v3_Permission* permission,
219
243
  Json permission_set_json = parse_permission_set_to_json(or_rules);
220
244
  permission_json.emplace("orRules", std::move(permission_set_json));
221
245
  } else if (envoy_config_rbac_v3_Permission_has_any(permission)) {
222
- permission_json.emplace("any",
223
- envoy_config_rbac_v3_Permission_any(permission));
246
+ permission_json.emplace(
247
+ "any", Json::FromBool(envoy_config_rbac_v3_Permission_any(permission)));
224
248
  } else if (envoy_config_rbac_v3_Permission_has_header(permission)) {
225
249
  ValidationErrors::ScopedField field(errors, ".header");
226
250
  Json header_json = ParseHeaderMatcherToJson(
@@ -239,7 +263,8 @@ Json ParsePermissionToJson(const envoy_config_rbac_v3_Permission* permission,
239
263
  } else if (envoy_config_rbac_v3_Permission_has_destination_port(permission)) {
240
264
  permission_json.emplace(
241
265
  "destinationPort",
242
- envoy_config_rbac_v3_Permission_destination_port(permission));
266
+ Json::FromNumber(
267
+ envoy_config_rbac_v3_Permission_destination_port(permission)));
243
268
  } else if (envoy_config_rbac_v3_Permission_has_metadata(permission)) {
244
269
  permission_json.emplace(
245
270
  "metadata", ParseMetadataMatcherToJson(
@@ -260,7 +285,7 @@ Json ParsePermissionToJson(const envoy_config_rbac_v3_Permission* permission,
260
285
  } else {
261
286
  errors->AddError("invalid rule");
262
287
  }
263
- return permission_json;
288
+ return Json::FromObject(std::move(permission_json));
264
289
  }
265
290
 
266
291
  Json ParsePrincipalToJson(const envoy_config_rbac_v3_Principal* principal,
@@ -280,7 +305,7 @@ Json ParsePrincipalToJson(const envoy_config_rbac_v3_Principal* principal,
280
305
  Json principal_json = ParsePrincipalToJson(ids[i], errors);
281
306
  ids_json.emplace_back(std::move(principal_json));
282
307
  }
283
- return Json::Object({{"ids", std::move(ids_json)}});
308
+ return Json::FromObject({{"ids", Json::FromArray(std::move(ids_json))}});
284
309
  };
285
310
  if (envoy_config_rbac_v3_Principal_has_and_ids(principal)) {
286
311
  ValidationErrors::ScopedField field(errors, ".and_ids");
@@ -293,8 +318,8 @@ Json ParsePrincipalToJson(const envoy_config_rbac_v3_Principal* principal,
293
318
  Json principal_set_json = parse_principal_set_to_json(or_rules);
294
319
  principal_json.emplace("orIds", std::move(principal_set_json));
295
320
  } else if (envoy_config_rbac_v3_Principal_has_any(principal)) {
296
- principal_json.emplace("any",
297
- envoy_config_rbac_v3_Principal_any(principal));
321
+ principal_json.emplace(
322
+ "any", Json::FromBool(envoy_config_rbac_v3_Principal_any(principal)));
298
323
  } else if (envoy_config_rbac_v3_Principal_has_authenticated(principal)) {
299
324
  Json::Object authenticated_json;
300
325
  const auto* principal_name =
@@ -307,7 +332,8 @@ Json ParsePrincipalToJson(const envoy_config_rbac_v3_Principal* principal,
307
332
  ParseStringMatcherToJson(principal_name, errors);
308
333
  authenticated_json["principalName"] = std::move(principal_name_json);
309
334
  }
310
- principal_json["authenticated"] = std::move(authenticated_json);
335
+ principal_json["authenticated"] =
336
+ Json::FromObject(std::move(authenticated_json));
311
337
  } else if (envoy_config_rbac_v3_Principal_has_source_ip(principal)) {
312
338
  principal_json.emplace(
313
339
  "sourceIp", ParseCidrRangeToJson(
@@ -343,7 +369,7 @@ Json ParsePrincipalToJson(const envoy_config_rbac_v3_Principal* principal,
343
369
  } else {
344
370
  errors->AddError("invalid rule");
345
371
  }
346
- return principal_json;
372
+ return Json::FromObject(std::move(principal_json));
347
373
  }
348
374
 
349
375
  Json ParsePolicyToJson(const envoy_config_rbac_v3_Policy* policy,
@@ -359,7 +385,8 @@ Json ParsePolicyToJson(const envoy_config_rbac_v3_Policy* policy,
359
385
  Json permission_json = ParsePermissionToJson(permissions[i], errors);
360
386
  permissions_json.emplace_back(std::move(permission_json));
361
387
  }
362
- policy_json.emplace("permissions", std::move(permissions_json));
388
+ policy_json.emplace("permissions",
389
+ Json::FromArray(std::move(permissions_json)));
363
390
  Json::Array principals_json;
364
391
  const envoy_config_rbac_v3_Principal* const* principals =
365
392
  envoy_config_rbac_v3_Policy_principals(policy, &size);
@@ -369,7 +396,8 @@ Json ParsePolicyToJson(const envoy_config_rbac_v3_Policy* policy,
369
396
  Json principal_json = ParsePrincipalToJson(principals[i], errors);
370
397
  principals_json.emplace_back(std::move(principal_json));
371
398
  }
372
- policy_json.emplace("principals", std::move(principals_json));
399
+ policy_json.emplace("principals",
400
+ Json::FromArray(std::move(principals_json)));
373
401
  if (envoy_config_rbac_v3_Policy_has_condition(policy)) {
374
402
  ValidationErrors::ScopedField field(errors, ".condition");
375
403
  errors->AddError("condition not supported");
@@ -378,10 +406,33 @@ Json ParsePolicyToJson(const envoy_config_rbac_v3_Policy* policy,
378
406
  ValidationErrors::ScopedField field(errors, ".checked_condition");
379
407
  errors->AddError("checked condition not supported");
380
408
  }
381
- return policy_json;
409
+ return Json::FromObject(std::move(policy_json));
410
+ }
411
+
412
+ Json ParseAuditLoggerConfigsToJson(
413
+ const XdsResourceType::DecodeContext& context,
414
+ const envoy_config_rbac_v3_RBAC_AuditLoggingOptions* audit_logging_options,
415
+ ValidationErrors* errors) {
416
+ Json::Array logger_configs_json;
417
+ size_t size;
418
+ const auto& registry =
419
+ static_cast<const GrpcXdsBootstrap&>(context.client->bootstrap())
420
+ .audit_logger_registry();
421
+ const envoy_config_rbac_v3_RBAC_AuditLoggingOptions_AuditLoggerConfig* const*
422
+ logger_configs =
423
+ envoy_config_rbac_v3_RBAC_AuditLoggingOptions_logger_configs(
424
+ audit_logging_options, &size);
425
+ for (size_t i = 0; i < size; ++i) {
426
+ ValidationErrors::ScopedField field(
427
+ errors, absl::StrCat(".logger_configs[", i, "]"));
428
+ logger_configs_json.emplace_back(registry.ConvertXdsAuditLoggerConfig(
429
+ context, logger_configs[i], errors));
430
+ }
431
+ return Json::FromArray(logger_configs_json);
382
432
  }
383
433
 
384
- Json ParseHttpRbacToJson(const envoy_extensions_filters_http_rbac_v3_RBAC* rbac,
434
+ Json ParseHttpRbacToJson(const XdsResourceType::DecodeContext& context,
435
+ const envoy_extensions_filters_http_rbac_v3_RBAC* rbac,
385
436
  ValidationErrors* errors) {
386
437
  Json::Object rbac_json;
387
438
  const auto* rules = envoy_extensions_filters_http_rbac_v3_RBAC_rules(rbac);
@@ -390,10 +441,11 @@ Json ParseHttpRbacToJson(const envoy_extensions_filters_http_rbac_v3_RBAC* rbac,
390
441
  int action = envoy_config_rbac_v3_RBAC_action(rules);
391
442
  // Treat Log action as RBAC being absent
392
443
  if (action == envoy_config_rbac_v3_RBAC_LOG) {
393
- return rbac_json;
444
+ return Json::FromObject({});
394
445
  }
395
446
  Json::Object inner_rbac_json;
396
- inner_rbac_json.emplace("action", envoy_config_rbac_v3_RBAC_action(rules));
447
+ inner_rbac_json.emplace(
448
+ "action", Json::FromNumber(envoy_config_rbac_v3_RBAC_action(rules)));
397
449
  if (envoy_config_rbac_v3_RBAC_policies_size(rules) != 0) {
398
450
  Json::Object policies_object;
399
451
  size_t iter = kUpb_Map_Begin;
@@ -410,11 +462,40 @@ Json ParseHttpRbacToJson(const envoy_extensions_filters_http_rbac_v3_RBAC* rbac,
410
462
  envoy_config_rbac_v3_RBAC_PoliciesEntry_value(entry), errors);
411
463
  policies_object.emplace(std::string(key), std::move(policy));
412
464
  }
413
- inner_rbac_json.emplace("policies", std::move(policies_object));
465
+ inner_rbac_json.emplace("policies",
466
+ Json::FromObject(std::move(policies_object)));
467
+ }
468
+ // Flatten the nested messages defined in rbac.proto
469
+ if (XdsRbacAuditLoggingEnabled() &&
470
+ envoy_config_rbac_v3_RBAC_has_audit_logging_options(rules)) {
471
+ ValidationErrors::ScopedField field(errors, ".audit_logging_options");
472
+ const auto* audit_logging_options =
473
+ envoy_config_rbac_v3_RBAC_audit_logging_options(rules);
474
+ int32_t audit_condition =
475
+ envoy_config_rbac_v3_RBAC_AuditLoggingOptions_audit_condition(
476
+ audit_logging_options);
477
+ switch (audit_condition) {
478
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_NONE:
479
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_ON_DENY:
480
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_ON_ALLOW:
481
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_ON_DENY_AND_ALLOW:
482
+ inner_rbac_json.emplace("audit_condition",
483
+ Json::FromNumber(audit_condition));
484
+ break;
485
+ default:
486
+ ValidationErrors::ScopedField field(errors, ".audit_condition");
487
+ errors->AddError("invalid audit condition");
488
+ }
489
+ if (envoy_config_rbac_v3_RBAC_AuditLoggingOptions_has_logger_configs(
490
+ audit_logging_options)) {
491
+ inner_rbac_json.emplace("audit_loggers",
492
+ ParseAuditLoggerConfigsToJson(
493
+ context, audit_logging_options, errors));
494
+ }
414
495
  }
415
- rbac_json.emplace("rules", std::move(inner_rbac_json));
496
+ rbac_json.emplace("rules", Json::FromObject(std::move(inner_rbac_json)));
416
497
  }
417
- return rbac_json;
498
+ return Json::FromObject(std::move(rbac_json));
418
499
  }
419
500
 
420
501
  } // namespace
@@ -448,7 +529,8 @@ XdsHttpRbacFilter::GenerateFilterConfig(
448
529
  errors->AddError("could not parse HTTP RBAC filter config");
449
530
  return absl::nullopt;
450
531
  }
451
- return FilterConfig{ConfigProtoName(), ParseHttpRbacToJson(rbac, errors)};
532
+ return FilterConfig{ConfigProtoName(),
533
+ ParseHttpRbacToJson(context, rbac, errors)};
452
534
  }
453
535
 
454
536
  absl::optional<XdsHttpFilterImpl::FilterConfig>
@@ -473,10 +555,10 @@ XdsHttpRbacFilter::GenerateFilterConfigOverride(
473
555
  const auto* rbac =
474
556
  envoy_extensions_filters_http_rbac_v3_RBACPerRoute_rbac(rbac_per_route);
475
557
  if (rbac == nullptr) {
476
- rbac_json = Json::Object();
558
+ rbac_json = Json::FromObject({});
477
559
  } else {
478
560
  ValidationErrors::ScopedField field(errors, ".rbac");
479
- rbac_json = ParseHttpRbacToJson(rbac, errors);
561
+ rbac_json = ParseHttpRbacToJson(context, rbac, errors);
480
562
  }
481
563
  return FilterConfig{OverrideConfigProtoName(), std::move(rbac_json)};
482
564
  }
@@ -493,12 +575,17 @@ ChannelArgs XdsHttpRbacFilter::ModifyChannelArgs(
493
575
  absl::StatusOr<XdsHttpFilterImpl::ServiceConfigJsonEntry>
494
576
  XdsHttpRbacFilter::GenerateServiceConfig(
495
577
  const FilterConfig& hcm_filter_config,
496
- const FilterConfig* filter_config_override) const {
497
- Json policy_json = filter_config_override != nullptr
498
- ? filter_config_override->config
499
- : hcm_filter_config.config;
500
- // The policy JSON may be empty, that's allowed.
501
- return ServiceConfigJsonEntry{"rbacPolicy", JsonDump(policy_json)};
578
+ const FilterConfig* filter_config_override,
579
+ absl::string_view filter_name) const {
580
+ const Json& policy_json = filter_config_override != nullptr
581
+ ? filter_config_override->config
582
+ : hcm_filter_config.config;
583
+ auto json_object = policy_json.object();
584
+ json_object.emplace("filter_name",
585
+ Json::FromString(std::string(filter_name)));
586
+ // The policy JSON may be empty other than the filter name, that's allowed.
587
+ return ServiceConfigJsonEntry{"rbacPolicy",
588
+ JsonDump(Json::FromObject(json_object))};
502
589
  }
503
590
 
504
591
  } // namespace grpc_core
@@ -48,7 +48,8 @@ class XdsHttpRbacFilter : public XdsHttpFilterImpl {
48
48
  ChannelArgs ModifyChannelArgs(const ChannelArgs& args) const override;
49
49
  absl::StatusOr<ServiceConfigJsonEntry> GenerateServiceConfig(
50
50
  const FilterConfig& hcm_filter_config,
51
- const FilterConfig* filter_config_override) const override;
51
+ const FilterConfig* filter_config_override,
52
+ absl::string_view filter_name) const override;
52
53
  bool IsSupportedOnClients() const override { return false; }
53
54
  bool IsSupportedOnServers() const override { return true; }
54
55
  };
@@ -31,6 +31,8 @@
31
31
  #include "envoy/extensions/http/stateful_session/cookie/v3/cookie.upbdefs.h"
32
32
  #include "envoy/type/http/v3/cookie.upb.h"
33
33
 
34
+ #include <grpc/support/json.h>
35
+
34
36
  #include "src/core/ext/filters/stateful_session/stateful_session_filter.h"
35
37
  #include "src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h"
36
38
  #include "src/core/ext/xds/upb_utils.h"
@@ -119,20 +121,20 @@ Json::Object ValidateStatefulSession(
119
121
  ValidationErrors::ScopedField field(errors, ".name");
120
122
  errors->AddError("field not present");
121
123
  }
122
- cookie_config["name"] = std::move(cookie_name);
124
+ cookie_config["name"] = Json::FromString(std::move(cookie_name));
123
125
  // ttl
124
126
  {
125
127
  ValidationErrors::ScopedField field(errors, ".ttl");
126
128
  const auto* duration = envoy_type_http_v3_Cookie_ttl(cookie);
127
129
  if (duration != nullptr) {
128
130
  Duration ttl = ParseDuration(duration, errors);
129
- cookie_config["ttl"] = ttl.ToJsonString();
131
+ cookie_config["ttl"] = Json::FromString(ttl.ToJsonString());
130
132
  }
131
133
  }
132
134
  // path
133
135
  std::string path =
134
136
  UpbStringToStdString(envoy_type_http_v3_Cookie_path(cookie));
135
- if (!path.empty()) cookie_config["path"] = std::move(path);
137
+ if (!path.empty()) cookie_config["path"] = Json::FromString(std::move(path));
136
138
  return cookie_config;
137
139
  }
138
140
 
@@ -156,9 +158,9 @@ XdsHttpStatefulSessionFilter::GenerateFilterConfig(
156
158
  errors->AddError("could not parse stateful session filter config");
157
159
  return absl::nullopt;
158
160
  }
159
- return FilterConfig{
160
- ConfigProtoName(),
161
- ValidateStatefulSession(context, stateful_session, errors)};
161
+ return FilterConfig{ConfigProtoName(),
162
+ Json::FromObject(ValidateStatefulSession(
163
+ context, stateful_session, errors))};
162
164
  }
163
165
 
164
166
  absl::optional<XdsHttpFilterImpl::FilterConfig>
@@ -192,7 +194,8 @@ XdsHttpStatefulSessionFilter::GenerateFilterConfigOverride(
192
194
  config = ValidateStatefulSession(context, stateful_session, errors);
193
195
  }
194
196
  }
195
- return FilterConfig{OverrideConfigProtoName(), Json(std::move(config))};
197
+ return FilterConfig{OverrideConfigProtoName(),
198
+ Json::FromObject(std::move(config))};
196
199
  }
197
200
 
198
201
  const grpc_channel_filter* XdsHttpStatefulSessionFilter::channel_filter()
@@ -208,10 +211,11 @@ ChannelArgs XdsHttpStatefulSessionFilter::ModifyChannelArgs(
208
211
  absl::StatusOr<XdsHttpFilterImpl::ServiceConfigJsonEntry>
209
212
  XdsHttpStatefulSessionFilter::GenerateServiceConfig(
210
213
  const FilterConfig& hcm_filter_config,
211
- const FilterConfig* filter_config_override) const {
212
- Json config = filter_config_override != nullptr
213
- ? filter_config_override->config
214
- : hcm_filter_config.config;
214
+ const FilterConfig* filter_config_override,
215
+ absl::string_view /*filter_name*/) const {
216
+ const Json& config = filter_config_override != nullptr
217
+ ? filter_config_override->config
218
+ : hcm_filter_config.config;
215
219
  return ServiceConfigJsonEntry{"stateful_session", JsonDump(config)};
216
220
  }
217
221
 
@@ -48,7 +48,8 @@ class XdsHttpStatefulSessionFilter : public XdsHttpFilterImpl {
48
48
  ChannelArgs ModifyChannelArgs(const ChannelArgs& args) const override;
49
49
  absl::StatusOr<ServiceConfigJsonEntry> GenerateServiceConfig(
50
50
  const FilterConfig& hcm_filter_config,
51
- const FilterConfig* filter_config_override) const override;
51
+ const FilterConfig* filter_config_override,
52
+ absl::string_view filter_name) const override;
52
53
  bool IsSupportedOnClients() const override { return true; }
53
54
  bool IsSupportedOnServers() const override { return false; }
54
55
  };
@@ -33,6 +33,8 @@
33
33
  #include "envoy/extensions/load_balancing_policies/wrr_locality/v3/wrr_locality.upb.h"
34
34
  #include "google/protobuf/wrappers.upb.h"
35
35
 
36
+ #include <grpc/support/json.h>
37
+
36
38
  #include "src/core/ext/xds/xds_common_types.h"
37
39
  #include "src/core/lib/config/core_configuration.h"
38
40
  #include "src/core/lib/gprpp/time.h"
@@ -51,7 +53,7 @@ class RoundRobinLbPolicyConfigFactory
51
53
  const XdsResourceType::DecodeContext& /*context*/,
52
54
  absl::string_view /*configuration*/, ValidationErrors* /*errors*/,
53
55
  int /*recursion_depth*/) override {
54
- return Json::Object{{"round_robin", Json::Object()}};
56
+ return Json::Object{{"round_robin", Json::FromObject({})}};
55
57
  }
56
58
 
57
59
  absl::string_view type() override { return Type(); }
@@ -84,7 +86,7 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory
84
86
  resource);
85
87
  if (enable_oob_load_report != nullptr &&
86
88
  google_protobuf_BoolValue_value(enable_oob_load_report)) {
87
- config["enableOobLoadReport"] = true;
89
+ config["enableOobLoadReport"] = Json::FromBool(true);
88
90
  }
89
91
  // oob_reporting_period
90
92
  auto* duration_proto =
@@ -93,7 +95,7 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory
93
95
  if (duration_proto != nullptr) {
94
96
  ValidationErrors::ScopedField field(errors, ".oob_reporting_period");
95
97
  Duration duration = ParseDuration(duration_proto, errors);
96
- config["oobReportingPeriod"] = duration.ToJsonString();
98
+ config["oobReportingPeriod"] = Json::FromString(duration.ToJsonString());
97
99
  }
98
100
  // blackout_period
99
101
  duration_proto =
@@ -102,7 +104,7 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory
102
104
  if (duration_proto != nullptr) {
103
105
  ValidationErrors::ScopedField field(errors, ".blackout_period");
104
106
  Duration duration = ParseDuration(duration_proto, errors);
105
- config["blackoutPeriod"] = duration.ToJsonString();
107
+ config["blackoutPeriod"] = Json::FromString(duration.ToJsonString());
106
108
  }
107
109
  // weight_update_period
108
110
  duration_proto =
@@ -111,7 +113,7 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory
111
113
  if (duration_proto != nullptr) {
112
114
  ValidationErrors::ScopedField field(errors, ".weight_update_period");
113
115
  Duration duration = ParseDuration(duration_proto, errors);
114
- config["weightUpdatePeriod"] = duration.ToJsonString();
116
+ config["weightUpdatePeriod"] = Json::FromString(duration.ToJsonString());
115
117
  }
116
118
  // weight_expiration_period
117
119
  duration_proto =
@@ -120,7 +122,8 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory
120
122
  if (duration_proto != nullptr) {
121
123
  ValidationErrors::ScopedField field(errors, ".weight_expiration_period");
122
124
  Duration duration = ParseDuration(duration_proto, errors);
123
- config["weightExpirationPeriod"] = duration.ToJsonString();
125
+ config["weightExpirationPeriod"] =
126
+ Json::FromString(duration.ToJsonString());
124
127
  }
125
128
  // error_utilization_penalty
126
129
  auto* error_utilization_penalty =
@@ -133,9 +136,10 @@ class ClientSideWeightedRoundRobinLbPolicyConfigFactory
133
136
  if (value < 0.0) {
134
137
  errors->AddError("value must be non-negative");
135
138
  }
136
- config["errorUtilizationPenalty"] = value;
139
+ config["errorUtilizationPenalty"] = Json::FromNumber(value);
137
140
  }
138
- return Json::Object{{"weighted_round_robin", std::move(config)}};
141
+ return Json::Object{
142
+ {"weighted_round_robin", Json::FromObject(std::move(config))}};
139
143
  }
140
144
 
141
145
  absl::string_view type() override { return Type(); }
@@ -197,10 +201,10 @@ class RingHashLbPolicyConfigFactory
197
201
  }
198
202
  return Json::Object{
199
203
  {"ring_hash_experimental",
200
- Json::Object{
201
- {"minRingSize", min_ring_size},
202
- {"maxRingSize", max_ring_size},
203
- }},
204
+ Json::FromObject({
205
+ {"minRingSize", Json::FromNumber(min_ring_size)},
206
+ {"maxRingSize", Json::FromNumber(max_ring_size)},
207
+ })},
204
208
  };
205
209
  }
206
210
 
@@ -238,7 +242,8 @@ class WrrLocalityLbPolicyConfigFactory
238
242
  context, endpoint_picking_policy, errors, recursion_depth + 1);
239
243
  return Json::Object{
240
244
  {"xds_wrr_locality_experimental",
241
- Json::Object{{"childPolicy", std::move(child_policy)}}}};
245
+ Json::FromObject(
246
+ {{"childPolicy", Json::FromArray(std::move(child_policy))}})}};
242
247
  }
243
248
 
244
249
  absl::string_view type() override { return Type(); }
@@ -306,8 +311,9 @@ Json::Array XdsLbPolicyRegistry::ConvertXdsLbPolicyConfig(
306
311
  if (serialized_value != nullptr) {
307
312
  auto config_factory_it = policy_config_factories_.find(extension->type);
308
313
  if (config_factory_it != policy_config_factories_.end()) {
309
- return Json::Array{config_factory_it->second->ConvertXdsLbPolicyConfig(
310
- this, context, *serialized_value, errors, recursion_depth)};
314
+ return Json::Array{Json::FromObject(
315
+ config_factory_it->second->ConvertXdsLbPolicyConfig(
316
+ this, context, *serialized_value, errors, recursion_depth))};
311
317
  }
312
318
  }
313
319
  // Check for custom LB policy type.
@@ -316,7 +322,7 @@ Json::Array XdsLbPolicyRegistry::ConvertXdsLbPolicyConfig(
316
322
  CoreConfiguration::Get().lb_policy_registry().LoadBalancingPolicyExists(
317
323
  extension->type, nullptr)) {
318
324
  return Json::Array{
319
- Json::Object{{std::string(extension->type), std::move(*json)}}};
325
+ Json::FromObject({{std::string(extension->type), std::move(*json)}})};
320
326
  }
321
327
  // Unsupported type. Continue to next entry.
322
328
  }
@@ -37,6 +37,7 @@
37
37
  #include "envoy/config/listener/v3/listener.upb.h"
38
38
  #include "envoy/config/listener/v3/listener.upbdefs.h"
39
39
  #include "envoy/config/listener/v3/listener_components.upb.h"
40
+ #include "envoy/config/rbac/v3/rbac.upb.h"
40
41
  #include "envoy/config/route/v3/route.upb.h"
41
42
  #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
42
43
  #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h"