Skip to content

refactor: decouple foreign functions from WasmBase. #190

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

Merged
merged 4 commits into from
Aug 25, 2021

Conversation

mathetake
Copy link
Contributor

It seems unnecessary to have foreign functions managed by WasmBase because it's just using global lookup tables.

Signed-off-by: Takeshi Yoneda [email protected]

@mathetake mathetake requested a review from PiotrSikora as a code owner August 19, 2021 08:29
Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it works right now, but foreign functions must be coupled with WasmBase in order to enforce capability restrictions.

@mathetake
Copy link
Contributor Author

No I don't think so. The decoupled codes are only used in the "allowed" case - inside of exports::call_foreign_function which is replaced with the stub when capability not given: https://github.com/proxy-wasm/proxy-wasm-cpp-host/blob/master/src/wasm.cc#L109.

Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't think so. The decoupled codes are only used in the "allowed" case - inside of exports::call_foreign_function which is replaced with the stub when capability not given: https://github.com/proxy-wasm/proxy-wasm-cpp-host/blob/master/src/wasm.cc#L109.

Right, I guess there is some context missing. The end goal is to be able to allow/deny specific arguments, e.g. you should be able to allow only http_call(cluster="httpbin") or foreign_function(name="foo", args="bar") and deny everything else. The list of allowed arguments would be scoped to a given WasmBase, which is why the current code might work better.

Having said that, it's not implemented yet, so feel free to merge this if you need it.

@mathetake
Copy link
Contributor Author

The end goal is to be able to allow/deny specific arguments,

Oh I see. I think then we have to refactor around all the exports functions, not only this foreign function calls in order to couple with WasmBase. Thanks for letting me know the context.

The initial intent of this was I just wanted to reduce the complexity in the wasm.cc/wasm.h. I will go ahead and merge since I believe this could make them a bit less complex and readable (plus added doc!)🙂

@mathetake mathetake merged commit 860f36a into proxy-wasm:master Aug 25, 2021
@mathetake mathetake deleted the foreign-function-decouple branch August 25, 2021 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants