当前位置:网站首页>field.setAccessible(true);代码扫描有安全漏洞,解决方案
field.setAccessible(true);代码扫描有安全漏洞,解决方案
2022-06-22 00:13:00 【优雅的开发】
AccessibleObject类是Field、Method和Constructor对象的基类,能够允许反射对象修改访问权限修饰符,绕过由Java访问修饰符提供的访问控制检查。它让程序员能够更改私有字段或调用私有方法,这在通常情况下是不允许的。
例如:以下代码片段中,将Field将accessible标记设置为true。
Class clazz = User.class;
Field field = clazz.getField("name");
field.setAccessible(true);
...
如果为false,则试题中的私有字段不能够被访问到的,所以不可以注掉。
ReflectionUtils.makeAccessible(field);
用这个取代。
边栏推荐
- Pat (a) - 1001 a+b format
- 活动窗口(active),焦点窗口(focused),前台窗口(foreground)的区别
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- 合理选择液压滑环密封间隙的重要性
- pytorch学习12:自动求导
- pytorch学习02:手写数字识别
- 让人无法喜爱的STL
- English grammar_ Adverb_ fairly / rather
- 0x00007ffff3d3ecd0 in _IO_vfprintf_internal (s=0x7ffff40b5620 <_IO_2_1_stdout_>
- Enterprises can improve database security in four ways
猜你喜欢

Mendix公司新任CFO Tom Ellison通过领导团队转型推动公司下一阶段高速增长
![[examination skills] memory method and simple derivation of Green formula](/img/26/f28a9f4abaca94988845b3fdaaf571.png)
[examination skills] memory method and simple derivation of Green formula

手写数据库连接池
![[Environmental stepping pit] pycharm reports an error when using QT](/img/ac/665d4052919a1783ba6ac8edcb06ba.png)
[Environmental stepping pit] pycharm reports an error when using QT

聚宽 - 简单策略试验

Pytorch learning 12: automatic derivation

合理选择液压滑环密封间隙的重要性

【环境踩坑】pycharm使用qt时报错

pytorch学习07:Broadcast广播——自动扩展

12 initialization of beautifulsoup class
随机推荐
pytorch学习05:索引和切片
【Redis】事件驱动框架源码分析(单线程)
[其他] 浅析ELF中的GOT与PLT
4274. 后缀表达式
The importance of rational selection of seal clearance of hydraulic slip ring
调试中的虚变量和格式化字符
Pytorch learning 10: statistical operations
2. 两数相加
Xshell比SecureCRT差吗?
52类110 个常用的组件和框架
[environment stepping on pit] error occurs when uploading files using fastdfs test
香橙派orangepi4b上安装tensorflow与transformer
【DailyFresh】课程记录3--商品搜索相关
12 initialization of beautifulsoup class
Leetcode content
03 FastJson 解决循环引用
【DailyFresh】发送激活邮件遇到的问题
Tom Ellison, the new CFO of mendix, promoted the next stage of rapid growth of the company through the transformation of the leadership team
4273. 链表合并
单点登录SSO与OAuth2 方案