diff options
author | 2023-02-06 23:15:23 -0800 | |
---|---|---|
committer | 2023-02-06 23:15:23 -0800 | |
commit | 153834cf5c98fb1bda1a679154200fed9bbda4b7 (patch) | |
tree | 063acf8621a3828fa5b00b50217847e67c57e4b8 /src | |
parent | 6aea31f4fcb7b0b1cfbe1aac43145c87cb09f775 (diff) | |
download | bun-153834cf5c98fb1bda1a679154200fed9bbda4b7.tar.gz bun-153834cf5c98fb1bda1a679154200fed9bbda4b7.tar.zst bun-153834cf5c98fb1bda1a679154200fed9bbda4b7.zip |
Throw on process.binding
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/bindings/Process.cpp | 12 | ||||
-rw-r--r-- | src/bun.js/crypto.exports.js | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index bce4db8a6..7b9154211 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -308,6 +308,15 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUptime, return JSC::JSValue::encode(JSC::jsNumber(result)); } +JSC_DEFINE_HOST_FUNCTION(Process_functionBinding, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + auto& vm = globalObject->vm(); + throwTypeError(globalObject, scope, "process.binding is not supported in Bun. If this breaks a library you're using, please file an issue at https://bun.sh/issues and include a reproducible code sample."_s); + return JSC::JSValue::encode(JSC::JSValue {}); +} + JSC_DEFINE_HOST_FUNCTION(Process_functionExit, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { @@ -724,6 +733,9 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "umask"_s), 1, Process_functionUmask, ImplementationVisibility::Public, NoIntrinsic, 0); + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "binding"_s), + 1, Process_functionBinding, ImplementationVisibility::Public, NoIntrinsic, PropertyAttribute::DontEnum | 0); + // target_defaults: // { cflags: [], // default_configuration: 'Release', diff --git a/src/bun.js/crypto.exports.js b/src/bun.js/crypto.exports.js index 6f9e82b5d..4001179e8 100644 --- a/src/bun.js/crypto.exports.js +++ b/src/bun.js/crypto.exports.js @@ -5,6 +5,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; +const MAX_STRING_LENGTH = 536870888; + var __require = id => import.meta.require(id); const crypto = globalThis.crypto; const globalCrypto = crypto; @@ -17405,7 +17407,7 @@ var require_safer = __commonJS({ }); if (!safer.kStringMaxLength) try { - safer.kStringMaxLength = process.binding("buffer").kStringMaxLength; + safer.kStringMaxLength = MAX_STRING_LENGTH; } catch {} safer.constants || ((safer.constants = { |