类型: 安全缺陷
程序中采用硬编码方式处理银行卡号,一方面会降低系统安全性,另一方面不易于程序维护。
public class EmployeeDAO {private static Map<Integer, Employee> emps = new LinkedHashMap<Integer, Employee>();//...static {emps.put(1001, new Employee("330781198509075478", "韩信", 32, "18701608086", "6228482410842133810"));emps.put(1002, new Employee("330781198509075419", "张良", 40, "18610524666", "6221386102180111738"));emps.put(1003, new Employee("33078119850907853X", "萧何", 28, "13701155577", "6222801842821035763"));// ...}// 雇员信息的增删改查方法// ...}public class Employee {private String id; // 记录雇员的身份证号码private String name;private int age;private String tel; // 记录雇员的电话号码private String bankId; // 记录雇员的银行卡卡号public Employee() {}public Employee(String id, String name, int age, String tel, String bankId) {this.id = id;this.name = name;this.age = age;this.tel = tel;this.bankId = bankId;}// Getter and Setter// ...}
在上面的源码片段中,程序直接将员工的银行卡卡号等敏感信息以硬编码的方式进行存储,这样做会让数据与程序直接绑定,提高了系统的耦合性,使得系统和数据的维护变得困难。同时,如果对程序的执行文件做反编译操作,很容易就能够得到雇员的真实信息,导致敏感数据泄露,大大降低了系统的安全性。
