[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Protect global table from any changes
- From: Meir Shpilraien <meir@...>
- Date: Wed, 19 Jan 2022 15:35:37 +0200
I was wondering what is the recommended way to disallow script changing the global table. The problem I am facing, assuming I provide for example an api to the users, A1, another user can do: 'A1=function ... end', and override my implementation of A1 and cause all other users to run his code.
I can think of multiple ways:
1. Create a lua vm per script - this requires a lot of memory
2. Different environments per script - also might require a lot of memory
3. Make the global table a Readonly tables as described here: http://lua-users.org/wiki/ReadOnlyTables
, though in this way user can use rawset to bypass it, and I can not use a userdata to avoid it because I can not set a usedata as a global table (and I do not want to disallow rawset).
Is there any other way to lock the global table from any changes?
I am using lua 5.1.5.
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.