在以下情况下我需要清理 Javascript 吗?
我的问题是关于消毒。 在以下情况下我需要清理 javascript 吗?
我通过 ajax 将 javascript 数组作为 Json 发送到 php。该数组将在 php 中进行操作,然后一些数据将发布到 mysql。 请注意,用户在任何时候都不会自己写入值。该数组是根据用户单击的按钮创建的。
进一步阅读
基于清理(单选按钮、复选框和< ;option>) 我假设我需要清理 JavaScript。如果这是正确的,您建议我做什么清理工作?
我使用的数组是一个多维数组,如 Array[5][3]=2。它应该只包含数值。
My question is about sanitization.Do I need to sanitize the javascript in the following situation?
I'm sending a javascript array as Json to php via ajax. The array will be manipulated in php then some of the data will be posted to mysql.
Please note that at no time does the user write values themselves. The array is created based on the buttons the user clicks.
On further reading
Based on Sanitize (radio buttons, checkboxes and <option>) I'm assuming that I need to sanitize the javascript. If this is correct, what sanitization would you recommend I do?
The array I'm using is a multidimensional array like Array[5][3]=2. It should only contains number values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于清理,您只需要了解一条简单的规则:
因此,遵循此规则意味着您是否清理客户端上的输入并不重要。您仍然需要在服务器上对其进行清理。
为了更深入地了解您的具体情况,仅信任 JavaScript 来完成这项工作是不够的,因为有些人可能没有启用 JavaScript。或者,怀有恶意的人可能会从浏览器环境外部进行这些 HTTP 调用,从而完全跳过 JavaScript。
There is only one simple rule you need to know about sanitization:
So, following this rule means that it does not matter whether you sanitize the input on the client or not. You still need to sanitize it on the server.
To dive deeper into your specific case, trusting JavaScript alone to do the job is not enough as some people may not have JavaScript enabled. Or, somebody with a malicious intent could make those HTTP calls from outside the browser environment skipping JavaScript altogether.
不要认为它是“清理 JavaScript”,您必须始终了解 SQL 查询中使用的所有输入或值,或者直接输出到屏幕。
它应该被隔离,而不是清理,但是您可以通过清理和检查最大长度等来相当接近“安全”。
请记住,大多数攻击并不是简单的“从废话中删除”,它们是复杂的攻击利用特定的向量,例如 Microsoft SQL Server 或 MYSQL 版本等;
它可能是十六进制/ASCII,也可能是西里尔字母,你永远不知道。
永远不要相信任何输入。
Don't think of it is 'sanitizing JavaScript' you have to always be aware of ALL input or values that you use in a SQL query, or output directly to the screen.
IT should be quarantined, not sanitized, however you can get fairly close to 'safe' by sanitizing and checking max length, etc.
Keep in mind most attacks don't come as simple "DROP FROM BLAH WHERE BLAH BLAH" they are complex attacks utilizing specific vectors for say Microsoft SQL Server or MYSQL versions, etc;
It might be hex/ASCII or it might be Cyrillic alphabet, you never know.
Never trust any input.