mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-14 01:13:48 +00:00
Fixed a security issue in how AI Studio runs plugins (#1054)
This commit is contained in:
1 parent
57dda9ff8b
commit
b371b3d54f
6 files changed
+370
-16
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using Lua.IO;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem;
|
||||
|
||||
/// <summary>
|
||||
/// The file system of the Lua runtime of plugins, in which no file exists.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The Lua runtime reaches files through its file system: dofile and loadfile do, and so does require
|
||||
/// for every module the module loader does not know, which it then looks for along package.path,
|
||||
/// relative to the working directory of the app. Plugins are shared between users, and the assistant
|
||||
/// builder runs code a model wrote, so none of them may reach a file this way.<br/><br/>
|
||||
/// A plugin still loads the files of its own directory with require: the module loader, see
|
||||
/// PluginLoader, reads them without this file system.
|
||||
/// </remarks>
|
||||
public sealed class NoLuaFileSystem : ILuaFileSystem
|
||||
{
|
||||
private const string NO_FILES = "Plugins cannot reach files through the Lua runtime.";
|
||||
|
||||
#region Implementation of ILuaFileSystem
|
||||
|
||||
public bool IsReadable(string path) => false;
|
||||
|
||||
public ValueTask<ILuaStream> Open(string path, LuaFileOpenMode mode, CancellationToken cancellationToken) => throw new NotSupportedException(NO_FILES);
|
||||
|
||||
public ValueTask Rename(string oldName, string newName, CancellationToken cancellationToken) => throw new NotSupportedException(NO_FILES);
|
||||
|
||||
public ValueTask Remove(string path, CancellationToken cancellationToken) => throw new NotSupportedException(NO_FILES);
|
||||
|
||||
public string GetTempFileName() => throw new NotSupportedException(NO_FILES);
|
||||
|
||||
public ValueTask<ILuaStream> OpenTempFileStream(CancellationToken cancellationToken) => throw new NotSupportedException(NO_FILES);
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user