nll*_*dfx 1 kotlin kotlin-exposed
我使用 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())
}
}
Run Code Online (Sandbox Code Playgroud)
那么如何创建一个准备好的语句或者如何通过可能的 SQL 注入传递参数呢?
Exposed 在幕后为你做这件事。因为它将这项工作委托给 a PreparedStatement
,所以它会为您处理。如果您想对您的输入进行健全性检查,您应该出于业务原因这样做,其余的交给 Exposed。
编辑:我相信in Exposed的来源Statement
显示了这一点。委派给PreparedStatement
是您在此处防止 SQL 注入攻击所需的全部内容。
归档时间: |
|
查看次数: |
2860 次 |
最近记录: |