Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin Exposed:如何创建准备好的语句或避免SQL注入?_Kotlin_Kotlin Exposed - Fatal编程技术网

Kotlin Exposed:如何创建准备好的语句或避免SQL注入?

Kotlin Exposed:如何创建准备好的语句或避免SQL注入?,kotlin,kotlin-exposed,Kotlin,Kotlin Exposed,我使用Kotlin Exposed创建查询。但当我不得不使用从客户端接收的参数时,我遇到了一个问题: private fun accountInfo(msg: AccountInfoMsg) { transaction { val accountInfo = UserAccount.wrapRow(Account.innerJoin(Account_Banned).select { Account.email.eq(msg.

我使用Kotlin Exposed创建查询。但当我不得不使用从客户端接收的参数时,我遇到了一个问题:

private fun accountInfo(msg: AccountInfoMsg) {
        transaction {
            val accountInfo = UserAccount.wrapRow(Account.innerJoin(Account_Banned).select {
                Account.email.eq(msg.login.toLowerCase()) and (Account.id eq Account_Banned.accountId)
            }.single())
        }
    }

那么,如何创建一个准备好的语句,或者如何通过可能的SQL注入传递一个参数呢?

Exposed会在幕后为您做这件事。因为它将这项工作委托给一个预先准备好的语句,所以它是为您处理的。如果您想检查输入是否正常,那么出于业务原因,您应该这样做,而剩下的则由您自己决定


编辑:我相信这一点。委派给PreparedStatement是防止SQL注入攻击所需的一切。

Exposed在幕后为您做到这一点。因为它将这项工作委托给一个预先准备好的语句,所以它是为您处理的。如果您想检查输入是否正常,那么出于业务原因,您应该这样做,而剩下的则由您自己决定

编辑:我相信这一点。委派给PreparedStatement是您在此处防止SQL注入攻击所需的一切。

是的,我检查了105或1=1,在最后的查询中它看起来像是WHERE account.email='105或1=1',我检查了105或1=1,在最后的查询中它看起来像是WHERE account.email='105或1=1'