Skip to content

Commit d036c5c

Browse files
committed
更新了第95天文档内容
1 parent b27a53f commit d036c5c

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

Day91-100/95.使用Django开发商业项目.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,7 @@ Celery是一个本身不提供队列服务,官方推荐使用RabbitMQ或Redis
16841684
pass
16851685

16861686

1687+
# 消息的生产者
16871688
send_email.delay('', [], [], '', '')
16881689
```
16891690

@@ -1700,7 +1701,7 @@ Celery是一个本身不提供队列服务,官方推荐使用RabbitMQ或Redis
17001701
beat_schedule={
17011702
'task1': {
17021703
'task': 'common.tasks.show_msg',
1703-
'schedule': crontab(),
1704+
'schedule': crontab('*', '*', '*', '*', '*'),
17041705
'args': ('刘强东,奶茶妹妹喊你回家喝奶啦', )
17051706
},
17061707
},
@@ -1759,13 +1760,13 @@ CORS_ORIGIN_ALLOW_ALL = True
17591760

17601761
### 安全保护
17611762

1762-
问题1:什么是跨站脚本攻击,如何防范?(对提交的内容进行消毒)
1763+
问题1:什么是跨站脚本攻击(XSS),如何防范?(对提交的内容进行消毒)
17631764

1764-
问题2:什么是跨站身份伪造,如何防范?(使用随机令牌)
1765+
问题2:什么是跨站身份伪造(CSRF),如何防范?(使用随机令牌)
17651766

1766-
问题3:什么是SQL注射攻击,如何防范?(不拼接SQL语句,避免使用单引号)
1767+
问题3:什么是SQL注射攻击(SQL Injection),如何防范?(不拼接SQL语句,避免使用单引号)
17671768

1768-
问题4:什么是点击劫持攻击,如何防范?(不允许`<iframe>`加载非同源站点内容)
1769+
问题4:什么是点击劫持攻击(Click-hacking),如何防范?(不允许`<iframe>`加载非同源站点内容)
17691770

17701771
#### Django提供的安全措施
17711772

@@ -1834,21 +1835,6 @@ CSRF令牌和小工具
18341835

18351836
2. 加密和解密(对称加密和非对称加密)
18361837

1837-
```Shell
1838-
pip install rsa
1839-
```
1840-
1841-
```Python
1842-
>>> pub_key, pri_key = rsa.newkeys(1024)
1843-
>>> message = 'hello, world!'
1844-
>>> crypto = rsa.encrypt(message.encode(), pub_key)
1845-
>>> crypto
1846-
b'Ou{gH\xa9\xa8}O\xe3\x1d\x052|M\x9d9?\xdc\xd8\xecF\xd3v\x9b\xde\x8e\x12\xe6M\xebvx\x08\x08\x8b\xe8\x86~\xe4^)w\xf2\xef\x9e\x9fOg\x15Q\xb7\x7f\x1d\xcfV\xf1\r\xbe^+\x8a\xbf }\x10\x01\xa4U9b\x97\xf5\xe0\x90T\'\xd4(\x9b\x00\xa5\x92\x17\xad4\xb0\xb0"\xd4\x16\x94*s\xe1r\xb7L\xe2\x98\xb7\x7f\x03\xd9\xf2\t\xee*\xe6\x93\xe6\xe1o\xfd\x18\x83L\x0cfL\xff\xe4\xdd%\xf2\xc0/\xfb'
1847-
>>> origin = rsa.decrypt(crypto, pri_key).decode()
1848-
>>> origin
1849-
'hello, world!'
1850-
```
1851-
18521838
```Shell
18531839
pip install pycrypto
18541840
```
@@ -1938,7 +1924,7 @@ CSRF令牌和小工具
19381924
- 测试套件(测试集)- 组合了多个测试用例而构成的集合。
19391925

19401926
```Python
1941-
class UtilTest(TestCase):
1927+
class UtilTest(unittest.TestCase):
19421928

19431929
def setUp(self):
19441930
self.pattern = re.compile(r'\d{6}')
@@ -2340,7 +2326,7 @@ TOTAL 267 176 34%
23402326
23412327
1. 用ID生成器代替自增主键(性能更好、适用于分布式环境)。
23422328
2343-
- 自定义ID生成器
2329+
- 自定义ID生成器 - snowflake
23442330
23452331
- UUID
23462332

0 commit comments

Comments
 (0)