PHP 安全:将连接详细信息存储在常量或私有属性中?
我想知道将连接变量存储为常量(因为它们无法更改)或私有属性(因为无法查看它们)是否更好。我向所有因我缺乏安全感而感到恐惧的人道歉......
I was wondering if it's better to store connection variables as constants (because they can't be changed) or as private properties (because they can't be viewed). My apologies to all those who reel in horror at my lack of security nous...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的想法是,这真的不重要(从安全角度来看)。如果有人掌握了你的代码,那么无论哪种方式你都会被搞砸。如果某人没有您的代码,那么没关系,因为如果没有代码,他们就无法执行它,这将成为一个问题(如果您有远程代码执行漏洞,那么您遇到的问题比您的连接字符串更大)。
从设计的角度来看,我可能会使用私有常量。
My thoughts are that it really doesn't matter (from a security point of view). If someone has your code, then you are equally screwed either way. If someone doesn't have your code, then it doesn't matter because they can't execute it without the code for it to be an issue (if you have remote code execution vulnerabilities, you have larger issues than your connection strings).
From a design point of view, I'd probably use a private constant.
我认为这并不重要;您的代码应该受到保护,免受代码注入和查看。如果有人能够以某种方式将代码注入到您的系统中,那么访问连接字符串似乎是一个较小的问题。
I think it doesn't matter; your code should be protected both from code injection and viewing. If someone will have access to somehow inject code into your system accessing connection strings seems like a smaller problem then that.