wasm.proto 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. syntax = "proto3";
  2. package envoy.extensions.wasm.v3;
  3. import "envoy/config/core/v3/base.proto";
  4. import "google/protobuf/any.proto";
  5. import "udpa/annotations/status.proto";
  6. import "validate/validate.proto";
  7. option java_package = "io.envoyproxy.envoy.extensions.wasm.v3";
  8. option java_outer_classname = "WasmProto";
  9. option java_multiple_files = true;
  10. option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/wasm/v3;wasmv3";
  11. option (udpa.annotations.file_status).package_version_status = ACTIVE;
  12. // [#protodoc-title: Wasm]
  13. // [#extension: envoy.bootstrap.wasm]
  14. // Configuration for restricting Proxy-Wasm capabilities available to modules.
  15. message CapabilityRestrictionConfig {
  16. // The Proxy-Wasm capabilities which will be allowed. Capabilities are mapped by
  17. // name. The *SanitizationConfig* which each capability maps to is currently unimplemented and ignored,
  18. // and so should be left empty.
  19. //
  20. // The capability names are given in the
  21. // `Proxy-Wasm ABI <https://github.com/proxy-wasm/spec/tree/master/abi-versions/vNEXT>`_.
  22. // Additionally, the following WASI capabilities from
  23. // `this list <https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#modules>`_
  24. // are implemented and can be allowed:
  25. // *fd_write*, *fd_read*, *fd_seek*, *fd_close*, *fd_fdstat_get*, *environ_get*, *environ_sizes_get*,
  26. // *args_get*, *args_sizes_get*, *proc_exit*, *clock_time_get*, *random_get*.
  27. map<string, SanitizationConfig> allowed_capabilities = 1;
  28. }
  29. // Configuration for sanitization of inputs to an allowed capability.
  30. //
  31. // NOTE: This is currently unimplemented.
  32. message SanitizationConfig {
  33. }
  34. // Configuration for a Wasm VM.
  35. // [#next-free-field: 8]
  36. message VmConfig {
  37. // An ID which will be used along with a hash of the wasm code (or the name of the registered Null
  38. // VM plugin) to determine which VM will be used for the plugin. All plugins which use the same
  39. // *vm_id* and code will use the same VM. May be left blank. Sharing a VM between plugins can
  40. // reduce memory utilization and make sharing of data easier which may have security implications.
  41. // [#comment: TODO: add ref for details.]
  42. string vm_id = 1;
  43. // The Wasm runtime type.
  44. // Available Wasm runtime types are registered as extensions. The following runtimes are included
  45. // in Envoy code base:
  46. //
  47. // .. _extension_envoy.wasm.runtime.null:
  48. //
  49. // **envoy.wasm.runtime.null**: Null sandbox, the Wasm module must be compiled and linked into the
  50. // Envoy binary. The registered name is given in the *code* field as *inline_string*.
  51. //
  52. // .. _extension_envoy.wasm.runtime.v8:
  53. //
  54. // **envoy.wasm.runtime.v8**: `V8 <https://v8.dev/>`_-based WebAssembly runtime.
  55. //
  56. // .. _extension_envoy.wasm.runtime.wamr:
  57. //
  58. // **envoy.wasm.runtime.wamr**: `WAMR <https://github.com/bytecodealliance/wasm-micro-runtime/>`_-based WebAssembly runtime.
  59. // This runtime is not enabled in the official build.
  60. //
  61. // .. _extension_envoy.wasm.runtime.wavm:
  62. //
  63. // **envoy.wasm.runtime.wavm**: `WAVM <https://wavm.github.io/>`_-based WebAssembly runtime.
  64. // This runtime is not enabled in the official build.
  65. //
  66. // .. _extension_envoy.wasm.runtime.wasmtime:
  67. //
  68. // **envoy.wasm.runtime.wasmtime**: `Wasmtime <https://wasmtime.dev/>`_-based WebAssembly runtime.
  69. // This runtime is not enabled in the official build.
  70. //
  71. // [#extension-category: envoy.wasm.runtime]
  72. string runtime = 2 [(validate.rules).string = {min_len: 1}];
  73. // The Wasm code that Envoy will execute.
  74. config.core.v3.AsyncDataSource code = 3;
  75. // The Wasm configuration used in initialization of a new VM
  76. // (proxy_on_start). `google.protobuf.Struct` is serialized as JSON before
  77. // passing it to the plugin. `google.protobuf.BytesValue` and
  78. // `google.protobuf.StringValue` are passed directly without the wrapper.
  79. google.protobuf.Any configuration = 4;
  80. // Allow the wasm file to include pre-compiled code on VMs which support it.
  81. // Warning: this should only be enable for trusted sources as the precompiled code is not
  82. // verified.
  83. bool allow_precompiled = 5;
  84. // If true and the code needs to be remotely fetched and it is not in the cache then NACK the configuration
  85. // update and do a background fetch to fill the cache, otherwise fetch the code asynchronously and enter
  86. // warming state.
  87. bool nack_on_code_cache_miss = 6;
  88. // Specifies environment variables to be injected to this VM which will be available through
  89. // WASI's ``environ_get`` and ``environ_get_sizes`` system calls. Note that these functions are mostly implicitly
  90. // called in your language's standard library, so you do not need to call them directly and you can access to env
  91. // vars just like when you do on native platforms.
  92. // Warning: Envoy rejects the configuration if there's conflict of key space.
  93. EnvironmentVariables environment_variables = 7;
  94. }
  95. message EnvironmentVariables {
  96. // The keys of *Envoy's* environment variables exposed to this VM. In other words, if a key exists in Envoy's environment
  97. // variables, then that key-value pair will be injected. Note that if a key does not exist, it will be ignored.
  98. repeated string host_env_keys = 1;
  99. // Explicitly given key-value pairs to be injected to this VM in the form of "KEY=VALUE".
  100. map<string, string> key_values = 2;
  101. }
  102. // Base Configuration for Wasm Plugins e.g. filters and services.
  103. // [#next-free-field: 7]
  104. message PluginConfig {
  105. // A unique name for a filters/services in a VM for use in identifying the filter/service if
  106. // multiple filters/services are handled by the same *vm_id* and *root_id* and for
  107. // logging/debugging.
  108. string name = 1;
  109. // A unique ID for a set of filters/services in a VM which will share a RootContext and Contexts
  110. // if applicable (e.g. an Wasm HttpFilter and an Wasm AccessLog). If left blank, all
  111. // filters/services with a blank root_id with the same *vm_id* will share Context(s).
  112. string root_id = 2;
  113. // Configuration for finding or starting VM.
  114. oneof vm {
  115. VmConfig vm_config = 3;
  116. // TODO: add referential VM configurations.
  117. }
  118. // Filter/service configuration used to configure or reconfigure a plugin
  119. // (proxy_on_configuration).
  120. // `google.protobuf.Struct` is serialized as JSON before
  121. // passing it to the plugin. `google.protobuf.BytesValue` and
  122. // `google.protobuf.StringValue` are passed directly without the wrapper.
  123. google.protobuf.Any configuration = 4;
  124. // If there is a fatal error on the VM (e.g. exception, abort(), on_start or on_configure return false),
  125. // then all plugins associated with the VM will either fail closed (by default), e.g. by returning an HTTP 503 error,
  126. // or fail open (if 'fail_open' is set to true) by bypassing the filter. Note: when on_start or on_configure return false
  127. // during xDS updates the xDS configuration will be rejected and when on_start or on_configuration return false on initial
  128. // startup the proxy will not start.
  129. bool fail_open = 5;
  130. // Configuration for restricting Proxy-Wasm capabilities available to modules.
  131. CapabilityRestrictionConfig capability_restriction_config = 6;
  132. }
  133. // WasmService is configured as a built-in *envoy.wasm_service* :ref:`WasmService
  134. // <config_wasm_service>` This opaque configuration will be used to create a Wasm Service.
  135. message WasmService {
  136. // General plugin configuration.
  137. PluginConfig config = 1;
  138. // If true, create a single VM rather than creating one VM per worker. Such a singleton can
  139. // not be used with filters.
  140. bool singleton = 2;
  141. }