PMD规则之Security Code Guidelines
来源:互联网 发布:最好拆卸软件 编辑:程序博客网 时间:2023/09/26 11:34
· MethodReturnsInternalArray: Exposing internal arrays directly allows the user to modify some code that could be critical. It is safer to return a copy of the array.
翻译 方法返回内部数组:暴露内部数组直接允许用户修改的代码会是非常危险的,返回一个数组的copy是安全的做法
代码示例:
public class SecureSystem {
UserData [] ud;
public UserData [] getUserData() {
// Don't return directly the internal array, return a copy
return ud;
}
}
· ArrayIsStoredDirectly: Constructors and methods receiving arrays should clone objects and store the copy. This prevents that future changes from the user affect the internal functionality.
翻译 数组被直接存储:构造器和方法接收数组应该clone对象并保存副本,这会阻止用户将来的改变影响内部的功能。
代码示例:
public class Foo {
private String [] x;
public void foo (String [] param) {
// Don't do this, make a copy of the array at least
this.x=param;
}
}
- PMD规则之Security Code Guidelines
- PMD规则之Code Size Rules
- PMD规则之Unused Code Rules
- PMD规则之Basic Rules
- PMD规则之Braces Rules
- PMD规则之Controversial Rules
- PMD规则之Coupling Rules
- PMD规则之Design Rules
- PMD规则之Finalizer Rules
- PMD规则之J2EE Rules
- PMD规则之JavaBean Rules
- PMD规则之Junit Rules
- PMD规则之Migration Rules
- PMD规则之Naming Rules
- PMD规则之Optimization Rules
- PMD规则之Controversial Rules
- PMD规则之Basic Rules
- PMD规则之Braces Rules
- Writing Loadable Kernel Modules using netfilter hooks (in-depth HOWTO) – Part 1
- PMD规则之Strict Exception Rules
- SDL编译 omap3530
- 調用標準FORM打印(SE71)
- PMD规则之String and StringBuffer Rules
- PMD规则之Security Code Guidelines
- 一个简单的makefile示例及其注释
- 有关Android线程的学习
- 关于ireport脚本的我自己的一部分总结
- OneNote and Autohotkey – Useful Scripts
- PMD规则之Type Resolution Rules
- 用Nohup命令让Linux下的程序在后台执行
- PMD规则之Unused Code Rules
- PHP变量的变量——可变变量