避免 SQL 注入

发布于 2024-12-15 00:13:29 字数 46 浏览 1 评论 0原文

如果我确保在查询中只使用字母数字字符,我应该不会受到任何 SQL 注入,对吗?

If I make sure only alpha-numerical characters are used in queries I should be free of any SQL injections, right?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒浓于脸红 2024-12-22 00:13:29

SQL 注入预防 CheatSheet

要点:

  • 防御选项 1:准备好的语句(参数化查询)
    • ...首先应该教会所有开发人员如何编写数据库查询。
  • 防御选项 2:存储过程
    • ...安全实施时。
  • 防御选项 3:转义所有用户提供的输入
    • ...与使用参数化查询相比,脆弱。

SQL Injection Prevention CheatSheet

Bullet points:

  • Defense Option 1: Prepared Statements (Parameterized Queries)
    • ...how all developers should first be taught how to write database queries.
  • Defense Option 2: Stored Procedures
    • ...when implemented safely.
  • Defense Option 3: Escaping All User Supplied Input
    • ...frail compared to using parameterized queries.
黯然#的苍凉 2024-12-22 00:13:29

仅使用字母数字字符编写有用的查询非常困难。使用参数化查询,不要寻找非快捷方式。

It's pretty difficult to write a useful query with only alpha-numeric characters. Use paramterized queries, don't look for a non-shortcut shortcut.

时光沙漏 2024-12-22 00:13:29

从技术上讲,这可能是正确的,因为它会阻止使用 - 或类似的技巧。然而,如今大多数平台都有更强大的方法来正确转义输入并防止其以意想不到的方式影响数据库。

Technically, that's probably correct, since it would block using -- or similar trickery. Most platforms these days have much more robust methods for properly escaping input and keeping it from affecting the database in unintended ways, however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文