-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
FFI support #5566
FFI support #5566
Conversation
|
The JS API is complete but not implemented. Anyone to vet this? I feel that putting all of those functions under |
Regarding the permission, I feel like it would be better to use |
|
That's not true. Using native code and the FFI, I can do anything I want, without the user even being able to necessarily inspect the code easily, as can be done with some JS/TS code (I could ship the code compiled and obfuscated, which means the user now needs expert knowledge to inspect what my extension may do). The point of the permission system is not to guard agains my own buggy code (although that's a nice side-effect), but mainly to guard agains some random code I downloaded from the internet, e.g. to do a specific calculation for me. |
It definitely is true, but perhaps you understand "less restrictive" differently than I do? Let me try to explain what I mean:
Even if protection against buggy code is not a primary goal of the permission system, it seems we both agree that it is at least "a nice side-effect". In that case, wouldn't it be better to further explore how |
I think a seperate Putting that aside, some functionality like make |
ping for update and merge or any help need? |
@buckle2000 I'm very sorry for the slow response. I think you sent this PR right after the 1.0 release, and it got buried amongst the other issues. I would like to get some FFI working - but it seems like this is just a sketch of the API so far. Looks reasonable as far as I can see. I think what we need to do is get some demo working - dlopen a DLL, call a function from it, etc. Also I think we should just require |
@buckle2000 this branch is very out of date, please rebase to latest |
Closing as stale. I'm still interested in further development of this feature so don't hesitate to reopen if updated. |
The foreign function interface of Deno should allow code to call functions from shared library with native ABI. The Deno runtime should not segfault the program by itself, but the external library may.
FFI is inherently unsafe.
Capability:
--allow-ffi
.We also need https://tootallnate.github.io/ref/ to manage memory addresses and pointers.
Prior Art
Python:
Go:
Node (thrid-party node-ffi):
LuaJIT:
Rust:
extern
keywordQuestions
number
?dlclose
can run code. ShouldLibrary.close
require--allow-ffi
?--allow-ffi=path
actually useful.--allow-ffi
whitelist certain paths even if allowing the program to load any external executable means arbitrary code execution?Related issues
#5551