grpc 1.43.1 → 1.44.0.pre2

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 (382) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +84 -64
  3. data/include/grpc/grpc_security.h +10 -0
  4. data/include/grpc/impl/codegen/compression_types.h +0 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  6. data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
  7. data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
  8. data/src/core/ext/filters/client_channel/client_channel.h +8 -8
  9. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  10. data/src/core/ext/filters/client_channel/config_selector.h +4 -4
  11. data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
  13. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  14. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
  26. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
  27. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
  28. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
  29. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
  35. data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
  36. data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
  37. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  45. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
  46. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
  47. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
  48. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
  49. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
  50. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
  51. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
  52. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
  53. data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
  54. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
  55. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  56. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
  57. data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
  58. data/src/core/ext/filters/client_channel/subchannel.h +2 -3
  59. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
  60. data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
  61. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  62. data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
  63. data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
  64. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
  65. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
  66. data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
  67. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
  68. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  69. data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
  70. data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
  71. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
  72. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
  73. data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
  74. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
  75. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
  76. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
  78. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
  80. data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
  81. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
  84. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
  86. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
  87. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
  88. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
  89. data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
  90. data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
  91. data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
  92. data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
  93. data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
  94. data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
  95. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
  96. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
  97. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
  99. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
  100. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
  101. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
  102. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
  103. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
  104. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
  105. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
  106. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
  107. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
  108. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
  109. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
  110. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
  111. data/src/core/ext/xds/upb_utils.h +65 -0
  112. data/src/core/ext/xds/xds_api.cc +81 -3458
  113. data/src/core/ext/xds/xds_api.h +56 -611
  114. data/src/core/ext/xds/xds_bootstrap.cc +189 -125
  115. data/src/core/ext/xds/xds_bootstrap.h +20 -15
  116. data/src/core/ext/xds/xds_certificate_provider.h +1 -0
  117. data/src/core/ext/xds/xds_channel_creds.cc +108 -0
  118. data/src/core/ext/xds/xds_channel_creds.h +50 -0
  119. data/src/core/ext/xds/xds_client.cc +584 -994
  120. data/src/core/ext/xds/xds_client.h +78 -135
  121. data/src/core/ext/xds/xds_cluster.cc +451 -0
  122. data/src/core/ext/xds/xds_cluster.h +111 -0
  123. data/src/core/ext/xds/xds_common_types.cc +388 -0
  124. data/src/core/ext/xds/xds_common_types.h +110 -0
  125. data/src/core/ext/xds/xds_endpoint.cc +364 -0
  126. data/src/core/ext/xds/xds_endpoint.h +135 -0
  127. data/src/core/ext/xds/xds_http_filters.cc +5 -0
  128. data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
  129. data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
  130. data/src/core/ext/xds/xds_listener.cc +1036 -0
  131. data/src/core/ext/xds/xds_listener.h +220 -0
  132. data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
  133. data/src/core/ext/xds/xds_resource_type.h +98 -0
  134. data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
  135. data/src/core/ext/xds/xds_route_config.cc +993 -0
  136. data/src/core/ext/xds/xds_route_config.h +215 -0
  137. data/src/core/ext/xds/xds_routing.cc +11 -8
  138. data/src/core/ext/xds/xds_routing.h +8 -5
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
  140. data/src/core/lib/address_utils/parse_address.cc +20 -0
  141. data/src/core/lib/address_utils/parse_address.h +5 -0
  142. data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
  143. data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
  144. data/src/core/lib/backoff/backoff.cc +4 -30
  145. data/src/core/lib/backoff/backoff.h +3 -3
  146. data/src/core/lib/channel/channel_args.cc +0 -1
  147. data/src/core/lib/channel/channel_stack.cc +8 -0
  148. data/src/core/lib/channel/channel_stack.h +1 -1
  149. data/src/core/lib/channel/channel_stack_builder.cc +5 -9
  150. data/src/core/lib/channel/channel_stack_builder.h +4 -7
  151. data/src/core/lib/channel/channelz.cc +1 -0
  152. data/src/core/lib/compression/compression.cc +19 -111
  153. data/src/core/lib/compression/compression_internal.cc +142 -202
  154. data/src/core/lib/compression/compression_internal.h +64 -69
  155. data/src/core/lib/compression/message_compress.cc +11 -11
  156. data/src/core/lib/compression/message_compress.h +2 -2
  157. data/src/core/lib/gpr/useful.h +4 -0
  158. data/src/core/lib/gprpp/bitset.h +7 -0
  159. data/src/core/lib/gprpp/chunked_vector.h +45 -3
  160. data/src/core/lib/gprpp/status_helper.cc +20 -28
  161. data/src/core/lib/gprpp/status_helper.h +6 -19
  162. data/src/core/lib/gprpp/table.h +11 -0
  163. data/src/core/lib/http/httpcli.cc +37 -46
  164. data/src/core/lib/http/httpcli.h +3 -15
  165. data/src/core/lib/iomgr/call_combiner.cc +15 -4
  166. data/src/core/lib/iomgr/closure.h +29 -9
  167. data/src/core/lib/iomgr/combiner.cc +25 -3
  168. data/src/core/lib/iomgr/error.cc +2 -0
  169. data/src/core/lib/iomgr/error.h +3 -0
  170. data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
  171. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
  172. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
  173. data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
  174. data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
  175. data/src/core/lib/iomgr/exec_ctx.cc +22 -9
  176. data/src/core/lib/iomgr/executor.cc +10 -1
  177. data/src/core/lib/iomgr/fork_posix.cc +3 -2
  178. data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
  179. data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
  180. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  181. data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
  182. data/src/core/lib/iomgr/port.h +2 -2
  183. data/src/core/lib/iomgr/resolve_address.cc +5 -24
  184. data/src/core/lib/iomgr/resolve_address.h +47 -44
  185. data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
  186. data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
  187. data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
  188. data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
  189. data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
  190. data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
  191. data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
  192. data/src/core/lib/iomgr/resolved_address.h +39 -0
  193. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
  194. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
  195. data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
  196. data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
  197. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
  198. data/src/core/lib/matchers/matchers.cc +1 -1
  199. data/src/core/lib/promise/activity.h +49 -20
  200. data/src/core/lib/promise/detail/status.h +5 -0
  201. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
  202. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
  203. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
  204. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
  205. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
  206. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
  207. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
  208. data/src/core/lib/resource_quota/api.h +0 -1
  209. data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
  210. data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
  211. data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
  212. data/src/core/lib/security/authorization/evaluate_args.h +1 -0
  213. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
  214. data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
  215. data/src/core/lib/security/authorization/matchers.cc +227 -0
  216. data/src/core/lib/security/authorization/matchers.h +211 -0
  217. data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
  218. data/src/core/lib/security/authorization/rbac_policy.h +170 -0
  219. data/src/core/lib/security/context/security_context.cc +4 -2
  220. data/src/core/lib/security/context/security_context.h +1 -1
  221. data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
  222. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
  223. data/src/core/lib/security/credentials/credentials.h +10 -20
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
  226. data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
  227. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
  228. data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
  229. data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
  230. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
  231. data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
  232. data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
  233. data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
  234. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
  235. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
  236. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
  237. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
  238. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
  239. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
  240. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
  241. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
  242. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
  243. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
  244. data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
  245. data/src/core/lib/security/security_connector/security_connector.cc +0 -4
  246. data/src/core/lib/security/security_connector/security_connector.h +5 -1
  247. data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
  248. data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
  249. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
  250. data/src/core/lib/security/transport/auth_filters.h +7 -0
  251. data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
  252. data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
  253. data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
  254. data/src/core/{ext → lib}/service_config/service_config.h +4 -4
  255. data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
  256. data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
  257. data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
  258. data/src/core/lib/slice/slice.cc +3 -1
  259. data/src/core/lib/slice/slice.h +43 -13
  260. data/src/core/lib/slice/slice_intern.cc +3 -101
  261. data/src/core/lib/slice/slice_internal.h +1 -2
  262. data/src/core/lib/slice/slice_refcount.h +4 -13
  263. data/src/core/lib/slice/slice_refcount_base.h +0 -16
  264. data/src/core/lib/surface/call.cc +140 -382
  265. data/src/core/lib/surface/call.h +4 -4
  266. data/src/core/lib/surface/channel.cc +42 -44
  267. data/src/core/lib/surface/channel.h +4 -4
  268. data/src/core/lib/surface/init.cc +0 -2
  269. data/src/core/lib/surface/lame_client.cc +0 -1
  270. data/src/core/lib/surface/server.cc +12 -29
  271. data/src/core/lib/surface/server.h +2 -2
  272. data/src/core/lib/surface/version.cc +2 -2
  273. data/src/core/lib/transport/error_utils.h +14 -0
  274. data/src/core/lib/transport/metadata_batch.h +799 -717
  275. data/src/core/lib/transport/parsed_metadata.cc +2 -0
  276. data/src/core/lib/transport/parsed_metadata.h +95 -92
  277. data/src/core/lib/transport/timeout_encoding.cc +200 -66
  278. data/src/core/lib/transport/timeout_encoding.h +40 -10
  279. data/src/core/lib/transport/transport.h +1 -1
  280. data/src/core/lib/transport/transport_op_string.cc +6 -39
  281. data/src/core/lib/uri/uri_parser.cc +223 -53
  282. data/src/core/lib/uri/uri_parser.h +36 -23
  283. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
  284. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  285. data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
  286. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
  287. data/src/core/tsi/ssl_transport_security.cc +53 -13
  288. data/src/core/tsi/ssl_transport_security.h +18 -6
  289. data/src/ruby/ext/grpc/extconf.rb +10 -3
  290. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  291. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  292. data/src/ruby/lib/grpc/version.rb +1 -1
  293. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
  294. data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
  295. data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
  296. data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
  297. data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
  298. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
  299. data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
  300. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
  301. data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
  302. data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
  303. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
  304. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
  305. data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
  306. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
  307. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
  308. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
  309. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
  310. data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
  311. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
  312. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
  313. data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
  314. data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
  315. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
  316. data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
  317. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
  318. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
  319. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
  320. data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
  321. data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
  322. data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
  323. data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
  324. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
  325. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
  326. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
  327. data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
  328. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
  329. data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
  330. data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
  331. data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
  332. data/third_party/abseil-cpp/absl/random/random.h +189 -0
  333. data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
  334. data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
  335. data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
  336. data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
  337. data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
  338. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
  339. data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
  340. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
  341. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
  342. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
  343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
  344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
  345. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
  346. data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
  347. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
  348. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
  349. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
  350. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  351. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
  352. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
  353. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
  354. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
  355. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
  356. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
  357. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
  358. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
  359. data/third_party/xxhash/xxhash.h +607 -352
  360. metadata +149 -77
  361. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
  362. data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
  363. data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
  364. data/src/core/lib/compression/algorithm_metadata.h +0 -62
  365. data/src/core/lib/compression/compression_args.cc +0 -140
  366. data/src/core/lib/compression/compression_args.h +0 -58
  367. data/src/core/lib/compression/stream_compression.cc +0 -81
  368. data/src/core/lib/compression/stream_compression.h +0 -117
  369. data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
  370. data/src/core/lib/compression/stream_compression_gzip.h +0 -28
  371. data/src/core/lib/compression/stream_compression_identity.cc +0 -91
  372. data/src/core/lib/compression/stream_compression_identity.h +0 -29
  373. data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
  374. data/src/core/lib/slice/static_slice.cc +0 -377
  375. data/src/core/lib/slice/static_slice.h +0 -300
  376. data/src/core/lib/transport/metadata.cc +0 -714
  377. data/src/core/lib/transport/metadata.h +0 -449
  378. data/src/core/lib/transport/metadata_batch.cc +0 -99
  379. data/src/core/lib/transport/static_metadata.cc +0 -1032
  380. data/src/core/lib/transport/static_metadata.h +0 -322
  381. data/src/core/lib/transport/status_metadata.cc +0 -63
  382. data/src/core/lib/transport/status_metadata.h +0 -48
@@ -33,8 +33,6 @@
33
33
 
34
34
  #include "src/core/ext/filters/message_size/message_size_filter.h"
35
35
  #include "src/core/lib/channel/channel_args.h"
36
- #include "src/core/lib/compression/algorithm_metadata.h"
37
- #include "src/core/lib/compression/compression_args.h"
38
36
  #include "src/core/lib/compression/compression_internal.h"
39
37
  #include "src/core/lib/compression/message_compress.h"
40
38
  #include "src/core/lib/gpr/string.h"
@@ -114,7 +112,7 @@ class CallData {
114
112
  // Fields for handling recv_message_ready callback
115
113
  bool seen_recv_message_ready_ = false;
116
114
  int max_recv_message_length_;
117
- grpc_message_compression_algorithm algorithm_ = GRPC_MESSAGE_COMPRESS_NONE;
115
+ grpc_compression_algorithm algorithm_ = GRPC_COMPRESS_NONE;
118
116
  grpc_closure on_recv_message_ready_;
119
117
  grpc_closure* original_recv_message_ready_ = nullptr;
120
118
  grpc_closure on_recv_message_next_done_;
@@ -133,30 +131,12 @@ class CallData {
133
131
  grpc_error_handle on_recv_trailing_metadata_ready_error_ = GRPC_ERROR_NONE;
134
132
  };
135
133
 
136
- grpc_message_compression_algorithm DecodeMessageCompressionAlgorithm(
137
- grpc_mdelem md) {
138
- grpc_message_compression_algorithm algorithm =
139
- grpc_message_compression_algorithm_from_slice(GRPC_MDVALUE(md));
140
- if (algorithm == GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT) {
141
- char* md_c_str = grpc_slice_to_c_string(GRPC_MDVALUE(md));
142
- gpr_log(GPR_ERROR,
143
- "Invalid incoming message compression algorithm: '%s'. "
144
- "Interpreting incoming data as uncompressed.",
145
- md_c_str);
146
- gpr_free(md_c_str);
147
- return GRPC_MESSAGE_COMPRESS_NONE;
148
- }
149
- return algorithm;
150
- }
151
-
152
134
  void CallData::OnRecvInitialMetadataReady(void* arg, grpc_error_handle error) {
153
135
  CallData* calld = static_cast<CallData*>(arg);
154
136
  if (error == GRPC_ERROR_NONE) {
155
- grpc_linked_mdelem* grpc_encoding =
156
- calld->recv_initial_metadata_->legacy_index()->named.grpc_encoding;
157
- if (grpc_encoding != nullptr) {
158
- calld->algorithm_ = DecodeMessageCompressionAlgorithm(grpc_encoding->md);
159
- }
137
+ calld->algorithm_ =
138
+ calld->recv_initial_metadata_->get(GrpcEncodingMetadata())
139
+ .value_or(GRPC_COMPRESS_NONE);
160
140
  }
161
141
  calld->MaybeResumeOnRecvMessageReady();
162
142
  calld->MaybeResumeOnRecvTrailingMetadataReady();
@@ -184,7 +164,7 @@ void CallData::OnRecvMessageReady(void* arg, grpc_error_handle error) {
184
164
  "OnRecvInitialMetadataReady");
185
165
  return;
186
166
  }
187
- if (calld->algorithm_ != GRPC_MESSAGE_COMPRESS_NONE) {
167
+ if (calld->algorithm_ != GRPC_COMPRESS_NONE) {
188
168
  // recv_message can be NULL if trailing metadata is received instead of
189
169
  // message, or it's possible that the message was not compressed.
190
170
  if (*calld->recv_message_ == nullptr ||
@@ -32,10 +32,6 @@
32
32
  #include "src/core/lib/slice/percent_encoding.h"
33
33
  #include "src/core/lib/slice/slice_internal.h"
34
34
  #include "src/core/lib/slice/slice_string_helpers.h"
35
- #include "src/core/lib/transport/static_metadata.h"
36
-
37
- #define EXPECTED_CONTENT_TYPE "application/grpc"
38
- #define EXPECTED_CONTENT_TYPE_LENGTH (sizeof(EXPECTED_CONTENT_TYPE) - 1)
39
35
 
40
36
  static void hs_recv_initial_metadata_ready(void* user_data,
41
37
  grpc_error_handle err);
@@ -67,10 +63,6 @@ struct call_data {
67
63
 
68
64
  grpc_core::CallCombiner* call_combiner;
69
65
 
70
- // Outgoing headers to add to send_initial_metadata.
71
- grpc_linked_mdelem status;
72
- grpc_linked_mdelem content_type;
73
-
74
66
  // If we see the recv_message contents in the GET query string, we
75
67
  // store it here.
76
68
  grpc_core::ManualConstructor<grpc_core::SliceBufferByteStream> read_stream;
@@ -121,63 +113,37 @@ static void hs_add_error(const char* error_name, grpc_error_handle* cumulative,
121
113
  *cumulative = grpc_error_add_child(*cumulative, new_err);
122
114
  }
123
115
 
124
- // Metadata equality within this filter leverages the fact that the sender was
125
- // likely using the gRPC chttp2 transport, in which case the encoder would emit
126
- // indexed values, in which case the local hpack parser would intern the
127
- // relevant metadata, allowing a simple pointer comparison.
128
- //
129
- // That said, if the header was transmitted sans indexing/encoding, we still
130
- // need to do the right thing.
131
- //
132
- // Assumptions:
133
- // 1) The keys for a and b_static must match
134
- // 2) b_static must be a statically allocated metadata object.
135
- // 3) It is assumed that the remote end is indexing, but not necessary.
136
- // TODO(arjunroy): Revisit this method when grpc_mdelem is strongly typed.
137
- static bool md_strict_equal(grpc_mdelem a, grpc_mdelem b_static) {
138
- // Hpack encoder on the remote side should emit indexed values, in which case
139
- // hpack parser on this end should pick up interned values, in which case the
140
- // pointer comparison alone is enough.
141
- //
142
- if (GPR_LIKELY(GRPC_MDELEM_IS_INTERNED(a))) {
143
- return a.payload == b_static.payload;
144
- } else {
145
- return grpc_slice_eq_static_interned(GRPC_MDVALUE(a),
146
- GRPC_MDVALUE(b_static));
147
- }
148
- }
149
-
150
116
  static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem,
151
117
  grpc_metadata_batch* b) {
152
118
  call_data* calld = static_cast<call_data*>(elem->call_data);
153
119
  grpc_error_handle error = GRPC_ERROR_NONE;
154
120
  static const char* error_name = "Failed processing incoming headers";
155
121
 
156
- if (b->legacy_index()->named.method != nullptr) {
157
- if (md_strict_equal(b->legacy_index()->named.method->md,
158
- GRPC_MDELEM_METHOD_POST)) {
159
- *calld->recv_initial_metadata_flags &=
160
- ~(GRPC_INITIAL_METADATA_CACHEABLE_REQUEST |
161
- GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST);
162
- } else if (md_strict_equal(b->legacy_index()->named.method->md,
163
- GRPC_MDELEM_METHOD_PUT)) {
164
- *calld->recv_initial_metadata_flags &=
165
- ~GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
166
- *calld->recv_initial_metadata_flags |=
167
- GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
168
- } else if (md_strict_equal(b->legacy_index()->named.method->md,
169
- GRPC_MDELEM_METHOD_GET)) {
170
- *calld->recv_initial_metadata_flags |=
171
- GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
172
- *calld->recv_initial_metadata_flags &=
173
- ~GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
174
- } else {
175
- hs_add_error(error_name, &error,
176
- grpc_attach_md_to_error(
177
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
178
- b->legacy_index()->named.method->md));
122
+ auto method = b->get(grpc_core::HttpMethodMetadata());
123
+ if (method.has_value()) {
124
+ switch (*method) {
125
+ case grpc_core::HttpMethodMetadata::kPost:
126
+ *calld->recv_initial_metadata_flags &=
127
+ ~(GRPC_INITIAL_METADATA_CACHEABLE_REQUEST |
128
+ GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST);
129
+ break;
130
+ case grpc_core::HttpMethodMetadata::kPut:
131
+ *calld->recv_initial_metadata_flags &=
132
+ ~GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
133
+ *calld->recv_initial_metadata_flags |=
134
+ GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
135
+ break;
136
+ case grpc_core::HttpMethodMetadata::kGet:
137
+ *calld->recv_initial_metadata_flags |=
138
+ GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
139
+ *calld->recv_initial_metadata_flags &=
140
+ ~GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
141
+ break;
142
+ case grpc_core::HttpMethodMetadata::kInvalid:
143
+ hs_add_error(error_name, &error,
144
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad method header"));
145
+ break;
179
146
  }
180
- b->Remove(GRPC_BATCH_METHOD);
181
147
  } else {
182
148
  hs_add_error(error_name, &error,
183
149
  grpc_error_set_str(
@@ -198,19 +164,12 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem,
198
164
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad te header"));
199
165
  }
200
166
 
201
- if (b->legacy_index()->named.scheme != nullptr) {
202
- if (!md_strict_equal(b->legacy_index()->named.scheme->md,
203
- GRPC_MDELEM_SCHEME_HTTP) &&
204
- !md_strict_equal(b->legacy_index()->named.scheme->md,
205
- GRPC_MDELEM_SCHEME_HTTPS) &&
206
- !grpc_mdelem_static_value_eq(b->legacy_index()->named.scheme->md,
207
- GRPC_MDELEM_SCHEME_GRPC)) {
167
+ auto scheme = b->Take(grpc_core::HttpSchemeMetadata());
168
+ if (scheme.has_value()) {
169
+ if (*scheme == grpc_core::HttpSchemeMetadata::kInvalid) {
208
170
  hs_add_error(error_name, &error,
209
- grpc_attach_md_to_error(
210
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
211
- b->legacy_index()->named.scheme->md));
171
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad :scheme header"));
212
172
  }
213
- b->Remove(GRPC_BATCH_SCHEME);
214
173
  } else {
215
174
  hs_add_error(error_name, &error,
216
175
  grpc_error_set_str(
@@ -218,40 +177,10 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem,
218
177
  GRPC_ERROR_STR_KEY, ":scheme"));
219
178
  }
220
179
 
221
- if (b->legacy_index()->named.content_type != nullptr) {
222
- if (!grpc_mdelem_static_value_eq(
223
- b->legacy_index()->named.content_type->md,
224
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) {
225
- if (grpc_slice_buf_start_eq(
226
- GRPC_MDVALUE(b->legacy_index()->named.content_type->md),
227
- EXPECTED_CONTENT_TYPE, EXPECTED_CONTENT_TYPE_LENGTH) &&
228
- (GRPC_SLICE_START_PTR(GRPC_MDVALUE(
229
- b->legacy_index()
230
- ->named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] ==
231
- '+' ||
232
- GRPC_SLICE_START_PTR(GRPC_MDVALUE(
233
- b->legacy_index()
234
- ->named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] ==
235
- ';')) {
236
- /* Although the C implementation doesn't (currently) generate them,
237
- any custom +-suffix is explicitly valid. */
238
- /* TODO(klempner): We should consider preallocating common values such
239
- as +proto or +json, or at least stashing them if we see them. */
240
- /* TODO(klempner): Should we be surfacing this to application code? */
241
- } else {
242
- /* TODO(klempner): We're currently allowing this, but we shouldn't
243
- see it without a proxy so log for now. */
244
- char* val = grpc_dump_slice(
245
- GRPC_MDVALUE(b->legacy_index()->named.content_type->md),
246
- GPR_DUMP_ASCII);
247
- gpr_log(GPR_INFO, "Unexpected content-type '%s'", val);
248
- gpr_free(val);
249
- }
250
- }
251
- b->Remove(GRPC_BATCH_CONTENT_TYPE);
252
- }
180
+ b->Remove(grpc_core::ContentTypeMetadata());
253
181
 
254
- if (b->legacy_index()->named.path == nullptr) {
182
+ grpc_core::Slice* path_slice = b->get_pointer(grpc_core::HttpPathMetadata());
183
+ if (path_slice == nullptr) {
255
184
  hs_add_error(error_name, &error,
256
185
  grpc_error_set_str(
257
186
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"),
@@ -260,25 +189,18 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem,
260
189
  GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) {
261
190
  /* We have a cacheable request made with GET verb. The path contains the
262
191
  * query parameter which is base64 encoded request payload. */
263
- const char k_query_separator = '?';
264
- grpc_slice path_slice = GRPC_MDVALUE(b->legacy_index()->named.path->md);
265
- uint8_t* path_ptr = GRPC_SLICE_START_PTR(path_slice);
266
- size_t path_length = GRPC_SLICE_LENGTH(path_slice);
192
+ static const char kQuerySeparator = '?';
267
193
  /* offset of the character '?' */
268
- size_t offset = 0;
269
- for (offset = 0; offset < path_length && *path_ptr != k_query_separator;
270
- path_ptr++, offset++) {
271
- }
272
- if (offset < path_length) {
273
- grpc_slice query_slice =
274
- grpc_slice_sub(path_slice, offset + 1, path_length);
194
+ auto it =
195
+ std::find(path_slice->begin(), path_slice->end(), kQuerySeparator);
196
+ if (it != path_slice->end()) {
197
+ const auto query_start = it - path_slice->begin() + 1;
198
+ auto query_slice = path_slice->RefSubSlice(
199
+ query_start, path_slice->size() - query_start);
275
200
 
276
201
  /* substitute path metadata with just the path (not query) */
277
- grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices(
278
- GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset));
279
-
280
- (void)b->Substitute(b->legacy_index()->named.path,
281
- mdelem_path_without_query);
202
+ auto path_without_query = path_slice->TakeSubSlice(0, query_start - 1);
203
+ *path_slice = std::move(path_without_query);
282
204
 
283
205
  /* decode payload from query and add to the slice buffer to be returned */
284
206
  const int k_url_safe = 1;
@@ -287,25 +209,24 @@ static grpc_error_handle hs_filter_incoming_metadata(grpc_call_element* elem,
287
209
  grpc_slice_buffer_add(
288
210
  &read_slice_buffer,
289
211
  grpc_base64_decode_with_len(
290
- reinterpret_cast<const char*> GRPC_SLICE_START_PTR(query_slice),
291
- GRPC_SLICE_LENGTH(query_slice), k_url_safe));
212
+ reinterpret_cast<const char*>(query_slice.begin()),
213
+ query_slice.size(), k_url_safe));
292
214
  calld->read_stream.Init(&read_slice_buffer, 0);
293
215
  grpc_slice_buffer_destroy_internal(&read_slice_buffer);
294
216
  calld->have_read_stream = true;
295
- grpc_slice_unref_internal(query_slice);
296
217
  } else {
297
218
  gpr_log(GPR_ERROR, "GET request without QUERY");
298
219
  }
299
220
  }
300
221
 
301
- if (b->legacy_index()->named.authority == nullptr) {
222
+ if (b->get_pointer(grpc_core::HttpAuthorityMetadata()) == nullptr) {
302
223
  absl::optional<grpc_core::Slice> host = b->Take(grpc_core::HostMetadata());
303
224
  if (host.has_value()) {
304
- b->Append(":authority", std::move(*host));
225
+ b->Set(grpc_core::HttpAuthorityMetadata(), std::move(*host));
305
226
  }
306
227
  }
307
228
 
308
- if (b->legacy_index()->named.authority == nullptr) {
229
+ if (b->get_pointer(grpc_core::HttpAuthorityMetadata()) == nullptr) {
309
230
  hs_add_error(error_name, &error,
310
231
  grpc_error_set_str(
311
232
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"),
@@ -410,17 +331,11 @@ static grpc_error_handle hs_mutate_op(grpc_call_element* elem,
410
331
  if (op->send_initial_metadata) {
411
332
  grpc_error_handle error = GRPC_ERROR_NONE;
412
333
  static const char* error_name = "Failed sending initial metadata";
413
- hs_add_error(
414
- error_name, &error,
415
- grpc_metadata_batch_add_head(
416
- op->payload->send_initial_metadata.send_initial_metadata,
417
- &calld->status, GRPC_MDELEM_STATUS_200, GRPC_BATCH_STATUS));
418
- hs_add_error(error_name, &error,
419
- grpc_metadata_batch_add_tail(
420
- op->payload->send_initial_metadata.send_initial_metadata,
421
- &calld->content_type,
422
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
423
- GRPC_BATCH_CONTENT_TYPE));
334
+ op->payload->send_initial_metadata.send_initial_metadata->Set(
335
+ grpc_core::HttpStatusMetadata(), 200);
336
+ op->payload->send_initial_metadata.send_initial_metadata->Set(
337
+ grpc_core::ContentTypeMetadata(),
338
+ grpc_core::ContentTypeMetadata::kApplicationGrpc);
424
339
  hs_add_error(error_name, &error,
425
340
  hs_filter_outgoing_metadata(
426
341
  op->payload->send_initial_metadata.send_initial_metadata));
@@ -27,13 +27,13 @@
27
27
  #include <grpc/support/alloc.h>
28
28
  #include <grpc/support/log.h>
29
29
 
30
- #include "src/core/ext/service_config/service_config_call_data.h"
31
30
  #include "src/core/lib/channel/channel_args.h"
32
31
  #include "src/core/lib/channel/channel_stack_builder.h"
33
32
  #include "src/core/lib/config/core_configuration.h"
34
33
  #include "src/core/lib/gpr/string.h"
35
34
  #include "src/core/lib/gprpp/ref_counted.h"
36
35
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
36
+ #include "src/core/lib/service_config/service_config_call_data.h"
37
37
  #include "src/core/lib/surface/call.h"
38
38
 
39
39
  static void recv_message_ready(void* user_data, grpc_error_handle error);
@@ -19,8 +19,8 @@
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
22
- #include "src/core/ext/service_config/service_config_parser.h"
23
22
  #include "src/core/lib/channel/channel_stack.h"
23
+ #include "src/core/lib/service_config/service_config_parser.h"
24
24
 
25
25
  extern const grpc_channel_filter grpc_message_size_filter;
26
26
 
@@ -0,0 +1,157 @@
1
+ //
2
+ // Copyright 2021 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+
17
+ #include <grpc/support/port_platform.h>
18
+
19
+ #include "src/core/ext/filters/rbac/rbac_filter.h"
20
+
21
+ #include "src/core/ext/filters/rbac/rbac_service_config_parser.h"
22
+ #include "src/core/lib/security/authorization/grpc_authorization_engine.h"
23
+ #include "src/core/lib/service_config/service_config_call_data.h"
24
+ #include "src/core/lib/transport/metadata_batch.h"
25
+
26
+ namespace grpc_core {
27
+
28
+ //
29
+ // RbacFilter::CallData
30
+ //
31
+
32
+ // CallData
33
+
34
+ grpc_error_handle RbacFilter::CallData::Init(
35
+ grpc_call_element* elem, const grpc_call_element_args* args) {
36
+ new (elem->call_data) CallData(elem, *args);
37
+ return GRPC_ERROR_NONE;
38
+ }
39
+
40
+ void RbacFilter::CallData::Destroy(grpc_call_element* elem,
41
+ const grpc_call_final_info* /*final_info*/,
42
+ grpc_closure* /*then_schedule_closure*/) {
43
+ auto* calld = static_cast<CallData*>(elem->call_data);
44
+ calld->~CallData();
45
+ }
46
+
47
+ void RbacFilter::CallData::StartTransportStreamOpBatch(
48
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
49
+ CallData* calld = static_cast<CallData*>(elem->call_data);
50
+ if (op->recv_initial_metadata) {
51
+ calld->recv_initial_metadata_ =
52
+ op->payload->recv_initial_metadata.recv_initial_metadata;
53
+ calld->original_recv_initial_metadata_ready_ =
54
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready;
55
+ op->payload->recv_initial_metadata.recv_initial_metadata_ready =
56
+ &calld->recv_initial_metadata_ready_;
57
+ }
58
+ // Chain to the next filter.
59
+ grpc_call_next_op(elem, op);
60
+ }
61
+
62
+ RbacFilter::CallData::CallData(grpc_call_element* elem,
63
+ const grpc_call_element_args& args)
64
+ : call_context_(args.context) {
65
+ GRPC_CLOSURE_INIT(&recv_initial_metadata_ready_, RecvInitialMetadataReady,
66
+ elem, grpc_schedule_on_exec_ctx);
67
+ }
68
+
69
+ void RbacFilter::CallData::RecvInitialMetadataReady(void* user_data,
70
+ grpc_error_handle error) {
71
+ grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
72
+ CallData* calld = static_cast<CallData*>(elem->call_data);
73
+ if (error == GRPC_ERROR_NONE) {
74
+ // Fetch and apply the rbac policy from the service config.
75
+ auto* service_config_call_data = static_cast<ServiceConfigCallData*>(
76
+ calld->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
77
+ auto* method_params = static_cast<RbacMethodParsedConfig*>(
78
+ service_config_call_data->GetMethodParsedConfig(
79
+ RbacServiceConfigParser::ParserIndex()));
80
+ if (method_params == nullptr) {
81
+ error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("No RBAC policy found.");
82
+ } else {
83
+ RbacFilter* chand = static_cast<RbacFilter*>(elem->channel_data);
84
+ auto* authorization_engine =
85
+ method_params->authorization_engine(chand->index_);
86
+ if (authorization_engine
87
+ ->Evaluate(EvaluateArgs(calld->recv_initial_metadata_,
88
+ &chand->per_channel_evaluate_args_))
89
+ .type == AuthorizationEngine::Decision::Type::kDeny) {
90
+ error =
91
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unauthorized RPC rejected");
92
+ }
93
+ }
94
+ if (error != GRPC_ERROR_NONE) {
95
+ error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
96
+ GRPC_STATUS_PERMISSION_DENIED);
97
+ }
98
+ } else {
99
+ GRPC_ERROR_REF(error);
100
+ }
101
+ grpc_closure* closure = calld->original_recv_initial_metadata_ready_;
102
+ calld->original_recv_initial_metadata_ready_ = nullptr;
103
+ Closure::Run(DEBUG_LOCATION, closure, error);
104
+ }
105
+
106
+ //
107
+ // RbacFilter
108
+ //
109
+
110
+ const grpc_channel_filter RbacFilter::kFilterVtable = {
111
+ RbacFilter::CallData::StartTransportStreamOpBatch,
112
+ grpc_channel_next_op,
113
+ sizeof(RbacFilter::CallData),
114
+ RbacFilter::CallData::Init,
115
+ grpc_call_stack_ignore_set_pollset_or_pollset_set,
116
+ RbacFilter::CallData::Destroy,
117
+ sizeof(RbacFilter),
118
+ RbacFilter::Init,
119
+ RbacFilter::Destroy,
120
+ grpc_channel_next_get_info,
121
+ "rbac_filter",
122
+ };
123
+
124
+ RbacFilter::RbacFilter(size_t index,
125
+ EvaluateArgs::PerChannelArgs per_channel_evaluate_args)
126
+ : index_(index),
127
+ per_channel_evaluate_args_(std::move(per_channel_evaluate_args)) {}
128
+
129
+ grpc_error_handle RbacFilter::Init(grpc_channel_element* elem,
130
+ grpc_channel_element_args* args) {
131
+ GPR_ASSERT(elem->filter == &kFilterVtable);
132
+ auto* auth_context = grpc_find_auth_context_in_args(args->channel_args);
133
+ if (auth_context == nullptr) {
134
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No auth context found");
135
+ }
136
+ if (args->optional_transport == nullptr) {
137
+ // This should never happen since the transport is always set on the server
138
+ // side.
139
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No transport configured");
140
+ }
141
+ new (elem->channel_data) RbacFilter(
142
+ grpc_channel_stack_filter_instance_number(args->channel_stack, elem),
143
+ EvaluateArgs::PerChannelArgs(
144
+ auth_context, grpc_transport_get_endpoint(args->optional_transport)));
145
+ return GRPC_ERROR_NONE;
146
+ }
147
+
148
+ void RbacFilter::Destroy(grpc_channel_element* elem) {
149
+ auto* chand = static_cast<RbacFilter*>(elem->channel_data);
150
+ chand->~RbacFilter();
151
+ }
152
+
153
+ void RbacFilterInit(void) { RbacServiceConfigParser::Register(); }
154
+
155
+ void RbacFilterShutdown(void) {}
156
+
157
+ } // namespace grpc_core
@@ -0,0 +1,74 @@
1
+ //
2
+ // Copyright 2021 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+
17
+ #ifndef GRPC_CORE_EXT_FILTERS_RBAC_RBAC_FILTER_H
18
+ #define GRPC_CORE_EXT_FILTERS_RBAC_RBAC_FILTER_H
19
+
20
+ #include <grpc/support/port_platform.h>
21
+
22
+ #include "src/core/lib/channel/channel_stack.h"
23
+ #include "src/core/lib/security/authorization/evaluate_args.h"
24
+
25
+ namespace grpc_core {
26
+
27
+ // Filter used when xDS server config fetcher provides a configuration with an
28
+ // HTTP RBAC filter. Also serves as the type for channel data for the filter.
29
+ class RbacFilter {
30
+ public:
31
+ // This channel filter is intended to be used by connections on xDS enabled
32
+ // servers configured with RBAC. The RBAC filter fetches the RBAC policy from
33
+ // the method config of service config returned by the ServerConfigSelector,
34
+ // and enforces the RBAC policy.
35
+ static const grpc_channel_filter kFilterVtable;
36
+
37
+ private:
38
+ class CallData {
39
+ public:
40
+ static grpc_error_handle Init(grpc_call_element* elem,
41
+ const grpc_call_element_args* args);
42
+ static void Destroy(grpc_call_element* elem,
43
+ const grpc_call_final_info* /* final_info */,
44
+ grpc_closure* /* then_schedule_closure */);
45
+ static void StartTransportStreamOpBatch(grpc_call_element* elem,
46
+ grpc_transport_stream_op_batch* op);
47
+
48
+ private:
49
+ CallData(grpc_call_element* elem, const grpc_call_element_args& args);
50
+ static void RecvInitialMetadataReady(void* user_data,
51
+ grpc_error_handle error);
52
+
53
+ grpc_call_context_element* call_context_;
54
+ // State for keeping track of recv_initial_metadata
55
+ grpc_metadata_batch* recv_initial_metadata_ = nullptr;
56
+ grpc_closure* original_recv_initial_metadata_ready_ = nullptr;
57
+ grpc_closure recv_initial_metadata_ready_;
58
+ };
59
+
60
+ RbacFilter(size_t index,
61
+ EvaluateArgs::PerChannelArgs per_channel_evaluate_args);
62
+ static grpc_error_handle Init(grpc_channel_element* elem,
63
+ grpc_channel_element_args* args);
64
+ static void Destroy(grpc_channel_element* elem);
65
+
66
+ // The index of this filter instance among instances of the same filter.
67
+ size_t index_;
68
+ // Per channel args used for authorization.
69
+ EvaluateArgs::PerChannelArgs per_channel_evaluate_args_;
70
+ };
71
+
72
+ } // namespace grpc_core
73
+
74
+ #endif // GRPC_CORE_EXT_FILTERS_RBAC_RBAC_FILTER_H