Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
4c33a6e1
authored
2021-12-30 15:24:48 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix xss
1 parent
2d916037
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
src/apps/account/views.py
src/apps/doc/mixins.py
src/apps/doc/views.py
src/apps/account/views.py
View file @
4c33a6e
...
...
@@ -11,6 +11,7 @@ from .consts import LOGIN_TIMES_LIMIT_EXPIRES, LOGIN_TIMES_LIMIT
class
LoginView
(
ObtainJSONWebToken
,
GenericView
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
# 登录次数限制
user_name
=
request
.
data
.
get
(
'username'
,
''
)
times
=
rh
.
get_login_times
(
user_name
)
if
isinstance
(
times
,
int
)
and
times
>=
LOGIN_TIMES_LIMIT
:
...
...
src/apps/doc/mixins.py
View file @
4c33a6e
import
re
from
.named_enum
import
DocStatus
from
.models
import
HILDoc
,
AFCDoc
from
.
import
consts
...
...
@@ -6,6 +7,15 @@ from . import consts
class
DocHandler
:
@staticmethod
def
xss_pass
(
file
):
for
pno
in
range
(
file
.
pageCount
):
page
=
file
.
loadPage
(
pno
)
page_text
=
page
.
getText
()
if
re
.
search
(
r'/JS(.*)'
,
page_text
)
and
re
.
search
(
r'/S /JavaScript'
,
page_text
):
return
False
return
True
@staticmethod
def
get_name
(
info
,
key
,
length
):
if
not
isinstance
(
info
,
dict
):
return
''
...
...
src/apps/doc/views.py
View file @
4c33a6e
...
...
@@ -898,6 +898,10 @@ class DocView(GenericView, DocHandler):
file
.
close
()
os
.
remove
(
tmp_save_path
)
raise
self
.
invalid_params
(
msg
=
'invalid params: not a PDF file'
)
elif
not
self
.
xss_pass
(
file
):
os
.
remove
(
tmp_save_path
)
raise
self
.
invalid_params
(
msg
=
'invalid params: PDF file XSS'
)
file
.
close
()
# 1. 上传信息记录
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment