如何在安全解释器中加载sqlite3包

时间:2018-04-01 23:19:14

标签: sqlite tcl

由于我无法在安全解释器中正常加载包,因此我将package命令别名为安全解释器,如下所示:

Imports System.ComponentModel

Public Class MyUserControl
    Private Image_ As Image = My.Resources.MyImage

    Public Sub New()
        InitializeComponent()
        ResetImage() ' set default
    End Sub

    <Category("Appearance")> <DisplayName("Image")> <Description("...")>
    Public Property Image As Image
        Get
            Return NestedControl.Image
        End Get
        Set(ByVal value As Image)
            NestedControl.Image = value
        End Set
    End Property

    Public Sub ResetImage()
        If Image IsNot Nothing Then Image.Dispose()
        Image = Image_
    End Sub

    Public Function ShouldSerializeImage() As Boolean
        Return (Image IsNot Image_)
    End Function
End Class

我想知道是否有任何方法可以正常加载sqlite3包并在安全解释器中创建连接,这样我就不需要为主解释器中的每个命令设置别名。

1 个答案:

答案 0 :(得分:1)

tclsqlite包故意不会定义SafeInit入口点,如源代码中所述。当在安全解释器中加载包以提供更安全的命令子集时,使用_SafeInit()代替_Init()。

/* Because it accesses the file-system and uses persistent state, SQLite
 ** is not considered appropriate for safe interpreters.  Hence, we cause
 ** the _SafeInit() interfaces return TCL_ERROR.
 */
EXTERN int Sqlite3_SafeInit(Tcl_Interp *interp){ return TCL_ERROR; }
EXTERN int Sqlite3_SafeUnload(Tcl_Interp *interp, int flags){return TCL_ERROR;}

(来自https://www.sqlite.org/src/artifact/916a92de77ec5cbe

简单地将sqlite命令别名化为安全解释器可能会使其不安全,特别是如果某些额外选项可用,如可加载模块。

所以不,不可能只是在没有别名的情况下加载它。为了确保安全,您应该添加一些策略包装程序来清理命令并限制可用选项,具体取决于您的安全需求。

相关问题