ActiveRecord/nHibernate SQL 生成“安全”吗?

发布于 2024-07-09 01:29:46 字数 260 浏览 6 评论 0原文

我正在做这个系统 Stacked 并且我正在创建搜索功能。 在这个过程中,我突然想到 AR/nHibernate Expression.Like(以及兄弟姐妹)可能不是 100%“安全”,因为您可以创建类似的东西; “\r\ndrop database xxx;---”和类似的东西......?

我希望他们是安全的,但我不确定......

I'm doing this system Stacked and I am creating the search function. And in that process it occurs to me that maybe AR/nHibernate Expression.Like (and siblings) might maybe not be 100% "safe" in that you can create stuff like;
"\r\ndrop database xxx;---" and similar things...?

I would expect them to be safe, but I am not sure...

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

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

发布评论

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

评论(2

蝶…霜飞 2024-07-16 01:29:46

NHibernate(以及扩展的 ActiveRecord)生成形如 sp_executesql 'select blah from table where column = @p1', '@p1 varchar(10)', @p1 = 'drop database xxx;--- 的参数化 SQL 语句' 用于查询。 这些类型的 SQL 语句可以安全地避免 SQL 注入,因为参数的内容不会被执行(与使用简单串联时的情况不同)。

所以是的,两者都是“安全的”。

NHibernate (and by extension ActiveRecord) generate parameterized SQL statements of the form sp_executesql 'select blah from table where column = @p1', '@p1 varchar(10)', @p1 = 'drop database xxx;---' for queries. These types of SQL statements are safe from SQL injection because the contents of the parameters are not executed (unlike they would be if simple concatenation was used).

So yes, both are "safe".

酒几许 2024-07-16 01:29:46

如果您发现安全错误,您一定应该将其归档。 许多人依赖这些东西。

If you find a security bug, you should definitely file it. Many rely on such things.

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