Merging other languages

This commit is contained in:
James Miranda
2016-09-23 18:01:10 -03:00
parent 380a8ee74c
commit de3c5bdaa4
490 changed files with 24539 additions and 24588 deletions

View File

@@ -1,20 +1,19 @@
# 9 安全与加密
无论是开发Web应用的开发者还是企图利用Web应用漏洞的攻击者对于Web程序安全这个话题都给予了越来越多的关注。特别是最近CSDN密码泄露事件更是让我们对Web安全这个话题更加重视所有人都谈密码色变都开始检测自己的系统是否存在漏洞。那么我们作为一名Go程序的开发者一定也需要知道我们的应用程序随时会成为众多攻击者的目标并提前做好防范的准备。
很多Web应用程序中的安全问题都是由于轻信了第三方提供的数据造成的。比如对于用户的输入数据在对其进行验证之前都应该将其视为不安全的数据。如果直接把这些不安全的数据输出到客户端就可能造成跨站脚本攻击(XSS)的问题。如果把不安全的数据用于数据库查询那么就可能造成SQL注入问题我们将会在9.3、9.4小节介绍如何避免这些问题。
在使用第三方提供的数据包括用户提供的数据时首先检验这些数据的合法性非常重要这个过程叫做过滤我们将在9.2小节介绍如何保证对所有输入的数据进行过滤处理。
过滤输入和转义输出并不能解决所有的安全问题我们将会在9.1讲解的CSRF攻击会导致受骗者发送攻击者指定的请求从而造成一些破坏。
与安全加密相关的能够增强我们的Web应用程序的强大手段就是加密CSDN泄密事件就是因为密码保存的是明文使得攻击拿手库之后就可以直接实施一些破坏行为了。不过和其他工具一样加密手段也必须运用得当。我们将在9.5小节介绍如何存储密码,如何让密码存储的安全。
加密的本质就是扰乱数据某些不可恢复的数据扰乱我们称为单向加密或者散列算法。另外还有一种双向加密方式也就是可以对加密后的数据进行解密。我们将会在9.6小节介绍如何实现这种双向加密方式。
## 目录
![](images/navi9.png?raw=true)
## links
* [目录](<preface.md>)
* 上一章: [第八章总结](<08.5.md>)
* 下一节: [预防CSRF攻击](<09.1.md>)
# 9 Security and encryption
Security is an extremely important aspect of most web applications. This topic has been getting more and more attention lately, especially in light of the recent CSDN, Linkedin and Yahoo password leaks. As Go developers, we must be aware of vulnerabilities in our applications and take precautions in order to prevent attackers from taking over our systems.
Many of the security problems that arise in modern web applications originate from data provided by third-parties. For example, user input should always be validated and sanitized before being stored as secure data. If this isn't done, when the data is outputted to a client, it may cause a cross-site scripting attack (XSS). Similarly, if unsafe data is used directly as your application's database queries, then you may be vulnerable to SQL injection attacks. In sections 9.3 and 9.4, we'll look at how to avoid these problems.
When using third-party data (which includes user-supplied data), first verify the integrity of the data by filtering the input. Section 9.2 will describe how to filter input.
Unfortunately, filtering input and escaping output does not solve all security problems. In section 9.1, we will explain cross-site request forgery (CSRF) attacks.
This is a malicious exploit where unauthorized commands are transmitted from a user that the website trusts.
Keeping confidential data encrypted can also help you to secure your web applications. In section 9.5, we will describe how to store passwords safely using Go's encryption package.
A good hash function makes it hard to find two strings that would produce the same hash value, and this is one way with which we can encrypt our data. There is also two-way encryption, where you use a secret key to decrypt encrypted data. In section 9.6 we will describe how to perform both one-way and two-way encryption.
## Links
- [Directory](preface.md)
- Previous Chapter: [Chapter 8 Summary](08.5.md)
- Next section: [CSRF attacks](09.1.md)