-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm: capability restriction #13911
wasm: capability restriction #13911
Changes from 5 commits
f468a96
13b76e0
a62f952
4c0d583
a8e77dd
4dffd5e
15dacd1
cb0bce3
b988429
af695b1
f9cf17f
8c8b69f
e63f7ed
9edc973
caa4f68
486b68a
b5f793c
91067f6
f189898
1959a9c
f3f73d4
5b27bb2
12bd787
5798880
559f452
238bace
0b9099c
acc3e53
5c8f31b
372d335
eed3c43
452b91e
86c5c34
cc60e16
bb76300
0d0a6c2
af91df7
909b1fd
d6fa1c1
ac3f629
7101e0c
ee8a52b
38afe66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,10 +100,12 @@ void Wasm::initializeLifecycle(Server::ServerLifecycleNotifier& lifecycle_notifi | |
} | ||
|
||
Wasm::Wasm(absl::string_view runtime, absl::string_view vm_id, absl::string_view vm_configuration, | ||
absl::string_view vm_key, const Stats::ScopeSharedPtr& scope, | ||
Upstream::ClusterManager& cluster_manager, Event::Dispatcher& dispatcher) | ||
: WasmBase(createWasmVm(runtime, scope), vm_id, vm_configuration, vm_key), scope_(scope), | ||
cluster_manager_(cluster_manager), dispatcher_(dispatcher), | ||
absl::string_view vm_key, absl::flat_hash_set<std::string> allowed_abi_functions, | ||
const Stats::ScopeSharedPtr& scope, Upstream::ClusterManager& cluster_manager, | ||
Event::Dispatcher& dispatcher) | ||
: WasmBase(createWasmVm(runtime, scope), vm_id, vm_configuration, vm_key, | ||
allowed_abi_functions), | ||
scope_(scope), cluster_manager_(cluster_manager), dispatcher_(dispatcher), | ||
time_source_(dispatcher.timeSource()), | ||
wasm_stats_(WasmStats{ | ||
ALL_WASM_STATS(POOL_COUNTER_PREFIX(*scope_, absl::StrCat("wasm.", runtime, ".")), | ||
|
@@ -314,8 +316,9 @@ WasmEvent toWasmEvent(const std::shared_ptr<WasmHandleBase>& wasm) { | |
NOT_IMPLEMENTED_GCOVR_EXCL_LINE; | ||
} | ||
|
||
static bool createWasmInternal(const VmConfig& vm_config, const PluginSharedPtr& plugin, | ||
const Stats::ScopeSharedPtr& scope, | ||
static bool createWasmInternal(const VmConfig& vm_config, | ||
const CapabilityRestrictionConfig& cr_config, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, changed to capabiility_restriction_config for consistency with type name and proto. Can change to capabilities_config if too long. |
||
const PluginSharedPtr& plugin, const Stats::ScopeSharedPtr& scope, | ||
Upstream::ClusterManager& cluster_manager, | ||
Init::Manager& init_manager, Event::Dispatcher& dispatcher, | ||
Api::Api& api, Server::ServerLifecycleNotifier& lifecycle_notifier, | ||
|
@@ -382,7 +385,7 @@ static bool createWasmInternal(const VmConfig& vm_config, const PluginSharedPtr& | |
.value_or(code.empty() ? EMPTY_STRING : INLINE_STRING); | ||
} | ||
|
||
auto complete_cb = [cb, vm_config, plugin, scope, &cluster_manager, &dispatcher, | ||
auto complete_cb = [cb, vm_config, cr_config, plugin, scope, &cluster_manager, &dispatcher, | ||
&lifecycle_notifier, create_root_context_for_testing, | ||
wasm_extension](std::string code) -> bool { | ||
if (code.empty()) { | ||
|
@@ -393,10 +396,10 @@ static bool createWasmInternal(const VmConfig& vm_config, const PluginSharedPtr& | |
proxy_wasm::makeVmKey(vm_config.vm_id(), anyToBytes(vm_config.configuration()), code); | ||
auto wasm_factory = wasm_extension->wasmFactory(); | ||
proxy_wasm::WasmHandleFactory proxy_wasm_factory = | ||
[&vm_config, scope, &cluster_manager, &dispatcher, &lifecycle_notifier, | ||
[&vm_config, &cr_config, scope, &cluster_manager, &dispatcher, &lifecycle_notifier, | ||
wasm_factory](absl::string_view vm_key) -> WasmHandleBaseSharedPtr { | ||
return wasm_factory(vm_config, scope, cluster_manager, dispatcher, lifecycle_notifier, | ||
vm_key); | ||
return wasm_factory(vm_config, cr_config, scope, cluster_manager, dispatcher, | ||
lifecycle_notifier, vm_key); | ||
}; | ||
auto wasm = proxy_wasm::createWasm( | ||
vm_key, code, plugin, proxy_wasm_factory, | ||
|
@@ -471,15 +474,16 @@ static bool createWasmInternal(const VmConfig& vm_config, const PluginSharedPtr& | |
return true; | ||
} | ||
|
||
bool createWasm(const VmConfig& vm_config, const PluginSharedPtr& plugin, | ||
const Stats::ScopeSharedPtr& scope, Upstream::ClusterManager& cluster_manager, | ||
Init::Manager& init_manager, Event::Dispatcher& dispatcher, Api::Api& api, | ||
bool createWasm(const VmConfig& vm_config, const CapabilityRestrictionConfig& cr_config, | ||
const PluginSharedPtr& plugin, const Stats::ScopeSharedPtr& scope, | ||
Upstream::ClusterManager& cluster_manager, Init::Manager& init_manager, | ||
Event::Dispatcher& dispatcher, Api::Api& api, | ||
Envoy::Server::ServerLifecycleNotifier& lifecycle_notifier, | ||
Config::DataSource::RemoteAsyncDataProviderPtr& remote_data_provider, | ||
CreateWasmCallback&& cb, CreateContextFn create_root_context_for_testing) { | ||
return createWasmInternal(vm_config, plugin, scope, cluster_manager, init_manager, dispatcher, | ||
api, lifecycle_notifier, remote_data_provider, std::move(cb), | ||
create_root_context_for_testing); | ||
return createWasmInternal(vm_config, cr_config, plugin, scope, cluster_manager, init_manager, | ||
dispatcher, api, lifecycle_notifier, remote_data_provider, | ||
std::move(cb), create_root_context_for_testing); | ||
} | ||
|
||
PluginHandleSharedPtr | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a reference to where the capabilities are defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a reference and updated the docs.