As stated earlier, V8 itself was never meant to be used this way, so there
is currently no way to specify a subset of JavaScript that V8 would allow.

As an alternative, you could run your scripts through an existing
JavaScript parser (acorn, esprima, etc), walk the resulting AST and throw
on all the language constructs you want to forbid. Before passing the
actual source along to V8.

On Fri, Jan 31, 2020 at 8:17 AM <[email protected]> wrote:

> Hi Thanks for the help. Currently i am using prebuilt v8 binaries from
> nuget package https://github.com/pmed/v8-nuget  in windows.
>  Is there any other way rather building the V8 and generating binaries.
>
> I already have  prebuilt v8 binaries and bin(snapshotblob and nativeblob)
> files from nuget package.
> can we do some thing in code to exclude those built-in functionality in V8
> engine?
>
> for eg:
> in js script, if i type
> 1) Date();    //V8 engine should show error rather than showing date.
>
> 2) var newarray = new Array();    var arr = [1,2,3,4,5];
>    // v8 engine should not allow creating dynamic elements.
>
> 3) var  newObject = {  "name"="xyz", "age"=5 };
>     var newObject = Object.create( Object.prototype );
>    // v8 engine should not allow  object oriented programming .
>
> 4) function add(a,b)
> {
>        return a+b;
> }
> var res = add(2,3);
>  // v8 engine should not allow users to create functions.
>
> My requirement is simple comparison and returning Boolean value
>
> 5 > 3 &&  4==10  ||   "abc" =="xyz;
>
> i am gonna register the callbackfunctions in c++ and get the value after
> running the script, evaluate and print the boolean result.
>
>
> Could you please help me how can i achieve this.
>
> On Friday, January 31, 2020 at 10:50:48 AM UTC+5:30, [email protected]
> wrote:
>>
>> I am trying to embed engine in c++ application. i don't want the
>> java-script  built-in Methods and functions.
>> I need it only for arithmetic and relational operators.
>>
>> after exploring much in internet ,i got to know built-ins functions are
>> de-serilized and put in from these native_blob.bin and snapshot_blob.bin .
>> I commented v8::V8::InitializeExternalStartupData(argv[0]); , but
>> throwing some run-time error.
>>
>> Could anyone please help me on this.
>>
>> Requirement : Embedding v8 engine without built-in functionality as i
>> need it only for arithmetic, relational operators.
>> I don't want these builts-in function gets de-serialized and put in heap
>> (
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
>> )
>>
>>
>> References:
>> 1) https://v8.dev/blog/embedded-builtins.
>> 2) https://v8.dev/blog/custom-startup-snapshots
>> 3) https://v8.dev/docs/builtin-functions
>> 4) https://v8.dev/blog/lazy-deserialization
>>
>> Thanks & Regards
>> Praveen N
>>
>>
> --
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/c7c63362-57b7-4840-b6e4-d193b96595d8%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-dev/c7c63362-57b7-4840-b6e4-d193b96595d8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CACswSC2V6_%3DCNjn_ouM9LS-ZvH9Huqu3hFVFrBSW-JLQRi03JQ%40mail.gmail.com.

Reply via email to