| 1 | // Aseprite |
| 2 | // Copyright (C) 2021 Igara Studio S.A. |
| 3 | // Copyright (C) 2018 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifndef APP_SCRIPT_SECURITY_H_INCLUDED |
| 9 | #define APP_SCRIPT_SECURITY_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #ifndef ENABLE_SCRIPTING |
| 13 | #error ENABLE_SCRIPTING must be defined |
| 14 | #endif |
| 15 | |
| 16 | #include "app/script/engine.h" |
| 17 | |
| 18 | namespace app { |
| 19 | namespace script { |
| 20 | |
| 21 | enum class FileAccessMode { |
| 22 | Execute = 1, |
| 23 | Write = 2, |
| 24 | Read = 4, |
| 25 | OpenSocket = 8, |
| 26 | Full = Execute | Write | Read | OpenSocket, |
| 27 | }; |
| 28 | |
| 29 | enum class ResourceType { |
| 30 | File, |
| 31 | Command, |
| 32 | WebSocket, |
| 33 | }; |
| 34 | |
| 35 | int secure_io_open(lua_State* L); |
| 36 | int secure_os_execute(lua_State* L); |
| 37 | |
| 38 | bool ask_access(lua_State* L, |
| 39 | const char* filename, |
| 40 | const FileAccessMode mode, |
| 41 | const ResourceType resourceType); |
| 42 | |
| 43 | } // namespace script |
| 44 | } // namespace app |
| 45 | |
| 46 | #endif |
| 47 | |