新书报道
当前位置: 首页 >> 电类优秀教材 >> 正文
Java coding guidelines : 75 recommendations for reliable and secure programs
发布日期:2016-04-18  浏览

[内容简介]

全世界的各种组织都依赖Java代码执行关键任务,因此代码必须是可靠的、健壮的、快速的、可维护的、安全的。本书的主题就是如何编写安全可靠的Java代码。书中提供了更新的技术来防止蓄意攻击和其他意想不到的事件。书中给出了编写安全、可靠的Java代码的75条建议,每一条都非常一致和直观。对于每条编码指南都指定了一致性要求,对大多数编码指南还提供了违反这些原则的代码示例和合规的解决方案。读者不但可以在本书中找到改进代码可靠性和清晰性的实践,还能全面了解导致不佳代码的常见误解。
[目录]
Chapter 1 Security / 安全1
1. Limit the lifetime of sensitive data 2
限制敏感数据的生命周期
2. Do not store unencrypted sensitive information on the client side5
不要在客户端存储未经加密的敏感数据
3. Provide sensitive mutable classes with unmodifiable wrappers9
为敏感可变类提供不可修改的包装器
4. Ensure that security-sensitive methods are called with validated arguments11
确保安全敏感方法被调用时参数经过验证
5. Prevent arbitrary file upload13
防止任意文件上传
6. Properly encode or escape output16
正确地编码或转义输出
7. Prevent code injection20
防止代码注入
8. Prevent XPath injection23
防止XPath注入
9. Prevent LDAP injection27
防止LDAP注入
10. Do not use the clone() method to copy untrusted method parameters31
不要使用clone()方法来复制不可信的方法参数
11. Do not use Object.equals() to pare cryptographic keys34
不要使用Object.equals()来比较密钥
12. Do not use insecure or weak cryptographic algorithms36
不要使用不安全的弱加密算法
13. Store passwords using a hash function37
使用散列函数存储密码
14. Ensure that SecureRandom is properly seeded42
确保SecureRandom正确地选择随机数种子
15. Do not rely on methods that can be overridden by untrusted code44
不要依赖可以被不可信代码覆写的方法
16. Avoid granting excess privileges50
避免授予过多特权
17. Minimize privileged code54
*小化特权代码
18. Do not expose methods that use reduced-security checks to untrusted code56
不要将使用降低安全性检查的方法暴露给不可信代码
19. Define custom security permissions for fine-grained security64
对细粒度的安全定义自定义安全权限
20. Create a secure sandbox using a security manager67
使用安全管理器创建一个安全的沙盒
21. Do not let untrusted code misuse privileges of callback methods72
不要让不可信代码误用回调方法的特权
Chapter 2 Defensive Programming / 防御式编程79
22. Minimize the scope of variables80
*小化变量的作用域
23. Minimize the scope of the @SuppressWarnings annotation82
*小化@SuppressWarnings注解的作用域
24. Minimize the accessibility of classes and their members84
*小化类及其成员的可访问性
25. Document thread-safety and use annotations where applicable89
文档化代码的线程安全性
26. Always provide feedback about the resulting value of a method96
为方法的结果值提供反馈
27. Identify files using multiple file attributes99
使用多个文件属性识别文件
28. Do not attach significance to the ordinal associated with an enum106
不要赋予枚举常量的序号任何特殊意义
29. Be aware of numeric promotion behavior108
注意数字提升行为
30. Enable pile-time type checking of variable arity parameter types112
对可变参数的类型做编译时类型检查
31. Do not apply public final to constants whose value might change in later releases115
不要把其值在以后版本里可能会发生变化的常量设置为public final
32. Avoid cyclic dependencies between packages118
避免包之间的循环依赖
33. Prefer user-defined exceptions over more general exception types121
使用用户自定义的异常而非宽泛的异常类型
34. Try to gracefully recover from system errors123
尽量从系统错误中优雅恢复
35. Carefully design interfaces before releasing them125
布接口前请谨慎设计
36. Write garbage collection–friendly code128
编写对垃圾回收机制友好的代码
Chapter 3 Reliability / 可靠性131
37. Do not shadow or obscure identifiers in subscopes132
不要在子作用域里遮蔽或者掩盖标识符
38. Do not declare more than one variable per declaration134
不要在一个声明里声明多个变量
39. Use meaningful symbolic constantsto represent literal values in program logic138
在程序逻辑中用有意义的符号常量代表文字值
40. Properly encode relationships in constant definitions142
在常量定义中恰当地表示相互之间的关系
41. Return an empty array or collection instead of a null value for methods that return an array or collection143
对于返回数组或者集合的方法,用返回一个空数组或者集合来替代返回一个空值
42. Use exceptions only for exceptional conditions146
只在异常的情况下使用异常
43. Use a try-with-resources statement to safely handle closeable resources148
使用try-with-resources语句安全处理可关闭的资源
44. Do not use assertions to verify the absence of runtime errors151
不要使用断言来验证不存在的运行时错误
45. Use the same type for the second and third operands in conditional expressions153
在条件表达式中,第二和第三个操作数应使用相同类型
46. Do not serialize direct handles to system resources157
不要序列化直接指向系统资源的句柄
47. Prefer using iterators over enumerations159
更倾向于使用迭代器而不是枚举
48. Do not use direct buffers for short-lived, infrequently used objects162
对于短生存周期、不常用的对象不要使用直接缓冲区
49. Remove short-lived objects from long-lived containe

关闭


版权所有:西安交通大学图书馆      设计与制作:西安交通大学数据与信息中心  
地址:陕西省西安市碑林区咸宁西路28号     邮编710049

推荐使用IE9以上浏览器、谷歌、搜狗、360浏览器;推荐分辨率1360*768以上