Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3a28d51
wasm: update Proxy-Wasm C++ Host to latest (2021-05-11).
PiotrSikora May 11, 2021
c838b2a
review: pass stripped bytecode and precompiled module.
PiotrSikora May 11, 2021
a07fff8
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora May 11, 2021
7258f94
review: fix format.
PiotrSikora May 11, 2021
77323eb
review: bump commit.
PiotrSikora May 11, 2021
af4d395
review: Kick CI.
PiotrSikora May 11, 2021
2dfe090
review: fix format.
PiotrSikora May 11, 2021
f8d0400
review: update commit.
PiotrSikora May 12, 2021
8558079
review: fix test on Linux-aarch64.
PiotrSikora May 12, 2021
b5963b6
review: fix test on Linux-aarch64 (take 2).
PiotrSikora May 12, 2021
e2d54da
review: update commit (signatures).
PiotrSikora May 12, 2021
fa8905b
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora May 14, 2021
074cef2
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora May 14, 2021
15e0d48
review: update commit.
PiotrSikora May 14, 2021
d7d550c
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora May 15, 2021
75e7698
review: update commit.
PiotrSikora May 15, 2021
10f0b74
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora May 16, 2021
9cabb6e
review: update commit.
PiotrSikora May 16, 2021
8c9b848
Merge remote-tracking branch 'origin/main' into wasm-bytecode
PiotrSikora May 28, 2021
0a2c02e
review: update commit.
PiotrSikora May 28, 2021
0f1b23c
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora Jun 3, 2021
b22ef87
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora Jun 3, 2021
ba48b89
review: update to the most recent commit.
PiotrSikora Jun 3, 2021
7e26bf2
Merge remote-tracking branch 'origin/main' into PiotrSikora/wasm-byte…
PiotrSikora Jun 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bazel/external/proxy_wasm_cpp_host.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ cc_library(
"src/*.h",
"src/*.cc",
"src/common/*.h",
"src/common/*.cc",
"src/third_party/*.h",
"src/third_party/*.cc",
]),
Expand Down
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "WebAssembly for Proxies (C++ host implementation)",
project_desc = "WebAssembly for Proxies (C++ host implementation)",
project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-host",
version = "e641ffa8893477cdb4720f572f50f003cd51a083",
sha256 = "20abaa0ff37b3765111fb81774bf4fa4630e23dc9c468b42016c4ebf4f27a38a",
version = "c3712617b28c69ff205e8302f70942c06e35f4e2",
sha256 = "60dd1a7f4b51e20ee1620a7106b09adf06763333c907076f884aeb37b741c17d",
strip_prefix = "proxy-wasm-cpp-host-{version}",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
Expand All @@ -982,7 +982,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
"envoy.wasm.runtime.wavm",
"envoy.wasm.runtime.wasmtime",
],
release_date = "2021-05-07",
release_date = "2021-06-01",
cpe = "N/A",
),
proxy_wasm_rust_sdk = dict(
Expand Down
3 changes: 2 additions & 1 deletion test/extensions/bootstrap/wasm/wasm_speed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ static void bmWasmSimpleCallSpeedTest(benchmark::State& state, std::string test,
TestEnvironment::runfilesPath("test/extensions/bootstrap/wasm/test_data/speed_cpp.wasm"));
}
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr,
[](Extensions::Common::Wasm::Wasm* wasm,
Expand Down
21 changes: 14 additions & 7 deletions test/extensions/bootstrap/wasm/wasm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class WasmNullTest : public WasmTestBase, public testing::TestWithParam<std::str
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/stats_cpp.wasm"))
: "WasmStatsCpp";
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->initialize(code, false));
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
}
};

Expand Down Expand Up @@ -141,7 +142,8 @@ TEST_P(WasmTestMatrix, LoggingWithEnvVars) {
auto wasm_weak = std::weak_ptr<Extensions::Common::Wasm::Wasm>(wasm_);
auto wasm_handler = std::make_unique<Extensions::Common::Wasm::WasmHandle>(std::move(wasm_));

EXPECT_TRUE(wasm_weak.lock()->initialize(code_, false));
EXPECT_TRUE(wasm_weak.lock()->load(code_, false));
EXPECT_TRUE(wasm_weak.lock()->initialize());
auto context = static_cast<TestContext*>(wasm_weak.lock()->start(plugin_));
if (std::get<1>(GetParam()) == "cpp") {
EXPECT_CALL(*context, log_(spdlog::level::info, Eq("printf stdout test")));
Expand Down Expand Up @@ -178,7 +180,8 @@ TEST_P(WasmTest, BadSignature) {
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/bad_signature_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_FALSE(wasm_->initialize(code, false));
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_FALSE(wasm_->initialize());
EXPECT_TRUE(wasm_->isFailed());
}

Expand All @@ -193,7 +196,8 @@ TEST_P(WasmTest, Segv) {
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->initialize(code, false));
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
auto context = static_cast<TestContext*>(wasm_->start(plugin_));
EXPECT_CALL(*context, log_(spdlog::level::err, Eq("before badptr")));
EXPECT_FALSE(wasm_->configure(context, plugin_));
Expand All @@ -211,7 +215,8 @@ TEST_P(WasmTest, DivByZero) {
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->initialize(code, false));
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
auto context = static_cast<TestContext*>(wasm_->start(plugin_));
EXPECT_CALL(*context, log_(spdlog::level::err, Eq("before div by zero")));
context->onLog();
Expand All @@ -229,7 +234,8 @@ TEST_P(WasmTest, IntrinsicGlobals) {
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/emscripten_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->initialize(code, false));
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
auto context = static_cast<TestContext*>(wasm_->start(plugin_));
EXPECT_CALL(*context, log_(spdlog::level::info, Eq("NaN nan")));
EXPECT_CALL(*context, log_(spdlog::level::warn, Eq("inf inf"))).Times(3);
Expand All @@ -253,7 +259,8 @@ TEST_P(WasmTest, Asm2Wasm) {
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/asm2wasm_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->initialize(code, false));
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
auto context = static_cast<TestContext*>(wasm_->start(plugin_));
EXPECT_CALL(*context, log_(spdlog::level::info, Eq("out 0 0 0")));
EXPECT_TRUE(wasm_->configure(context, plugin_));
Expand Down
50 changes: 33 additions & 17 deletions test/extensions/common/wasm/wasm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ TEST_P(WasmCommonTest, Logging) {
EXPECT_EQ(std::unique_ptr<ContextBase>(wasm->createContext(plugin)), nullptr);
auto wasm_weak = std::weak_ptr<Extensions::Common::Wasm::Wasm>(wasm);
auto wasm_handle = std::make_shared<Extensions::Common::Wasm::WasmHandle>(std::move(wasm));
EXPECT_TRUE(wasm_weak.lock()->initialize(code, false));
EXPECT_TRUE(wasm_weak.lock()->load(code, false));
EXPECT_TRUE(wasm_weak.lock()->initialize());
auto thread_local_wasm = std::make_shared<Wasm>(wasm_handle, *dispatcher);
thread_local_wasm.reset();

Expand Down Expand Up @@ -268,7 +269,8 @@ TEST_P(WasmCommonTest, BadSignature) {
auto wasm = std::make_unique<Extensions::Common::Wasm::Wasm>(plugin->wasmConfig(), vm_key, scope,
cluster_manager, *dispatcher);

EXPECT_FALSE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_FALSE(wasm->initialize());
EXPECT_TRUE(wasm->isFailed());
}

Expand Down Expand Up @@ -302,7 +304,8 @@ TEST_P(WasmCommonTest, Segv) {
auto vm_key = proxy_wasm::makeVmKey("", vm_configuration, code);
auto wasm = std::make_unique<Extensions::Common::Wasm::Wasm>(plugin->wasmConfig(), vm_key, scope,
cluster_manager, *dispatcher);
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
TestContext* root_context = nullptr;
wasm->setCreateContextForTesting(
nullptr, [&root_context](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
Expand Down Expand Up @@ -353,7 +356,8 @@ TEST_P(WasmCommonTest, DivByZero) {
cluster_manager, *dispatcher);
EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
auto root_context = new TestContext(wasm, plugin);
Expand Down Expand Up @@ -397,7 +401,8 @@ TEST_P(WasmCommonTest, IntrinsicGlobals) {
cluster_manager, *dispatcher);

EXPECT_NE(wasm, nullptr);
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
auto root_context = new TestContext(wasm, plugin);
Expand Down Expand Up @@ -442,7 +447,8 @@ TEST_P(WasmCommonTest, Utilities) {
cluster_manager, *dispatcher);

EXPECT_NE(wasm, nullptr);
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
auto root_context = new TestContext(wasm, plugin);
Expand Down Expand Up @@ -515,7 +521,8 @@ TEST_P(WasmCommonTest, Stats) {
cluster_manager, *dispatcher);

EXPECT_NE(wasm, nullptr);
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
auto root_context = new TestContext(wasm, plugin);
Expand Down Expand Up @@ -563,7 +570,8 @@ TEST_P(WasmCommonTest, Foreign) {
code = "CommonWasmTestCpp";
}
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
auto root_context = new TestContext(wasm, plugin);
Expand Down Expand Up @@ -612,7 +620,8 @@ TEST_P(WasmCommonTest, OnForeign) {
code = "CommonWasmTestCpp";
}
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
TestContext* test_context = nullptr;
wasm->setCreateContextForTesting(
nullptr, [&test_context](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
Expand Down Expand Up @@ -663,7 +672,8 @@ TEST_P(WasmCommonTest, WASI) {
code = "CommonWasmTestCpp";
}
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());
wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
auto root_context = new TestContext(wasm, plugin);
Expand Down Expand Up @@ -1056,7 +1066,8 @@ TEST_P(WasmCommonTest, RestrictCapabilities) {

EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());

// expect no call because proxy_on_vm_start is restricted
wasm->setCreateContextForTesting(
Expand Down Expand Up @@ -1113,7 +1124,8 @@ TEST_P(WasmCommonTest, AllowOnVmStart) {

EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());

// proxy_on_vm_start will trigger proxy_log and fd_write, but expect no call because both are
// restricted
Expand Down Expand Up @@ -1176,7 +1188,8 @@ TEST_P(WasmCommonTest, AllowLog) {

EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());

// Expect proxy_log since allowed, but no call to WASI since restricted
wasm->setCreateContextForTesting(
Expand Down Expand Up @@ -1234,7 +1247,8 @@ TEST_P(WasmCommonTest, AllowWASI) {

EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());

wasm->setCreateContextForTesting(
nullptr, [](Wasm* wasm, const std::shared_ptr<Plugin>& plugin) -> ContextBase* {
Expand Down Expand Up @@ -1293,7 +1307,8 @@ TEST_P(WasmCommonTest, AllowOnContextCreate) {

EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());

// Expect two calls to proxy_log, from proxy_on_vm_start and from proxy_on_context_create
wasm->setCreateContextForTesting(
Expand Down Expand Up @@ -1352,14 +1367,15 @@ TEST_P(WasmCommonTest, ThreadLocalCopyRetainsEnforcement) {

EXPECT_NE(wasm, nullptr);
auto context = std::make_unique<TestContext>(wasm.get());
EXPECT_TRUE(wasm->initialize(code, false));
EXPECT_TRUE(wasm->load(code, false));
EXPECT_TRUE(wasm->initialize());

auto wasm_handle = std::make_shared<Extensions::Common::Wasm::WasmHandle>(std::move(wasm));
auto thread_local_wasm = std::make_shared<Wasm>(wasm_handle, *dispatcher);

EXPECT_NE(thread_local_wasm, nullptr);
context = std::make_unique<TestContext>(thread_local_wasm.get());
EXPECT_TRUE(thread_local_wasm->initialize(code, false));
EXPECT_TRUE(thread_local_wasm->initialize());

EXPECT_TRUE(thread_local_wasm->capabilityAllowed("proxy_on_vm_start"));
EXPECT_FALSE(thread_local_wasm->capabilityAllowed("proxy_log"));
Expand Down
Loading