Lua Standard Library and Lua-lib Support List¶
- Version: 1.0.7-7-g251eead
- Release Date: 2023-04-06 11:17:57
- OS Support: windows/amd64, windows/386, linux/arm, linux/arm64, linux/386, linux/amd64
Description¶
Scheck aims to provide a fully functional, easy-to-integrate Lua sandbox environment for Golang, adapting to different user requirements and environments.
Therefore, we reference an excellent open-source Lua VM: gopher-lua. The Lua sandbox environment it uses is Lua 5.1.
For security reasons, we have disabled some functions of the IO and OS modules in the Lua standard library, and made corresponding supplements and extensions in lua-lib and go-openlib.
This document focuses on the usage and considerations of various libraries during Lua script development.
In Lua script development, libraries can be referenced from three sources:
- Standard Library: Most libraries and functions are supported.
- lua-lib: Encapsulates some commonly used Lua function libraries for developers to call.
- go-openlib: Developed in Golang and provides
file,system,net,utils, etc. See: Function List
Standard Library¶
Disabled functions:
- All IO module functions are completely prohibited.
- Disabled functions in the OS library:
exit,execute,remove,rename,setenv,setlocale - Available functions in the OS library:
clock,difftime,date,getenv,time,tmpname
Using lua-lib in Scheck¶
File location: under the ruls.d/libs directory in the installation directory. For specific function methods, refer to the corresponding files.
Function list:
- common
- watcher(path, enum, func)
- directorymonitor
- change(dir)
- add(dir)
- del(dir)
- priv_change(dir)
- filemonitor
- check(file)
- exist(file)
- priv_change(file)
- priv_fixedchange(file, mode)
- priv_limit(file, mode_bits)
- priv_root_ownership(file)
- priv_ownership(file, user)
- kernelmonitor
- module_isinstall(module_name, isInstalled)
- mountflagmonitor
- check(mountpath, mountflag, value)
- rpmmonitor
- check(pck_name, switch)
- sysctlmonitor
- check(param, switch)
- check_many(params, switch)
Example:¶
Using methods from lua-lib: