kotlin - Kotlin Exposed:如何创建准备好的语句或避免 SQL 注入?
问题描述
我使用 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 在幕后为您做到这一点。因为它将这项工作委托给 a PreparedStatement
,所以它会为您处理。如果您想彻底检查您的输入,您应该出于商业原因这样做,而将其余部分留给 Exposed。
编辑:我相信Exposed的来源显示了这一点。Statement
在这里,您需要委托来PreparedStatement
防止 SQL 注入攻击。
推荐阅读
- r - Rmarkdown pdf的自定义表格
- javascript - 使用 javaScript 查找在表中选择值的次数
- firebase - Flutter:获取 Cloud Firestore 数据但没有结果
- html - 在模板中显示 shopify 变体选项 2 个位置
- python - 使用 Python 从文本文件中提取一行中两个字符之间的特定文本
- regex - 我需要一个相当基本的 Regex.Match 语法——用 2 个空格分隔的 2 个数字来识别文本行
- typeorm - 使 TypeORM 仅修改已更改的字段
- arrays - 在 JSON 路径中获得 +1 元素
- vb.net - 读取 NCR 7878 秤/扫描仪的称重和条形码扫描仪,
- javascript - OneTrust CCPA Opt Out Builder 按钮未在 React 中编译