Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
a57df0e0
Commit
a57df0e0
authored
Oct 25, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改主机名/系统用户名称/组织名称的特殊字符限制(修改为特殊字符黑名单)[/ \]
parent
36d98a23
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
31 deletions
+31
-31
const.py
apps/assets/const.py
+5
-5
asset.py
apps/assets/forms/asset.py
+3
-3
user.py
apps/assets/forms/user.py
+2
-2
asset.py
apps/assets/serializers/asset.py
+6
-6
system_user.py
apps/assets/serializers/system_user.py
+6
-6
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+3
-3
serializers.py
apps/orgs/serializers.py
+6
-6
No files found.
apps/assets/const.py
View file @
a57df0e0
...
...
@@ -4,11 +4,11 @@
from
django.utils.translation
import
ugettext_lazy
as
_
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_HELP_TEXT
=
_
(
'
Only Numbers、letters、 chinese and characters ( {} ) are allowed
'
)
.
format
(
" "
.
join
([
'
.'
,
'_'
,
'@'
,
'-
'
]))
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_HELP_TEXT
=
_
(
'
Cannot contain special characters: [ {} ]
'
)
.
format
(
" "
.
join
([
'
/'
,
'
\\
'
]))
GENERAL_
LIMIT_SPECIAL_CHARACTERS_PATTERN
=
r"^[\._@\w-]+$
"
GENERAL_
FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
=
r"[/\\]
"
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
=
\
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
=
\
_
(
"* The contains characters that are not allowed"
)
apps/assets/forms/asset.py
View file @
a57df0e0
...
...
@@ -7,7 +7,7 @@ from common.utils import get_logger
from
orgs.mixins.forms
import
OrgModelForm
from
..models
import
Asset
,
Node
from
..const
import
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_HELP_TEXT
from
..const
import
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_HELP_TEXT
logger
=
get_logger
(
__file__
)
...
...
@@ -69,7 +69,7 @@ class AssetCreateForm(OrgModelForm):
'nodes'
:
_
(
"Node"
),
}
help_texts
=
{
'hostname'
:
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_HELP_TEXT
,
'hostname'
:
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_HELP_TEXT
,
'admin_user'
:
_
(
'root or other NOPASSWD sudo privilege user existed in asset,'
'If asset is windows or other set any one, more see admin user left menu'
...
...
@@ -116,7 +116,7 @@ class AssetUpdateForm(OrgModelForm):
'nodes'
:
_
(
"Node"
),
}
help_texts
=
{
'hostname'
:
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_HELP_TEXT
,
'hostname'
:
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_HELP_TEXT
,
'admin_user'
:
_
(
'root or other NOPASSWD sudo privilege user existed in asset,'
'If asset is windows or other set any one, more see admin user left menu'
...
...
apps/assets/forms/user.py
View file @
a57df0e0
...
...
@@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _
from
common.utils
import
validate_ssh_private_key
,
ssh_pubkey_gen
,
get_logger
from
orgs.mixins.forms
import
OrgModelForm
from
..models
import
AdminUser
,
SystemUser
from
..const
import
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_HELP_TEXT
from
..const
import
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_HELP_TEXT
logger
=
get_logger
(
__file__
)
__all__
=
[
...
...
@@ -99,7 +99,7 @@ class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm):
}),
}
help_texts
=
{
'name'
:
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_HELP_TEXT
,
'name'
:
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_HELP_TEXT
,
'auto_push'
:
_
(
'Auto push system user to asset'
),
'priority'
:
_
(
'1-100, High level will be using login asset as default, '
'if user was granted more than 2 system user'
),
...
...
apps/assets/serializers/asset.py
View file @
a57df0e0
...
...
@@ -9,8 +9,8 @@ from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from
common.serializers
import
AdaptedBulkListSerializer
from
..models
import
Asset
,
Node
,
Label
from
..const
import
(
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
)
from
.base
import
ConnectivitySerializer
...
...
@@ -98,10 +98,10 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
@staticmethod
def
validate_hostname
(
hostname
):
pattern
=
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
mat
ch
(
pattern
,
hostname
)
if
res
is
None
:
msg
=
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
pattern
=
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
sear
ch
(
pattern
,
hostname
)
if
res
is
not
None
:
msg
=
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
hostname
...
...
apps/assets/serializers/system_user.py
View file @
a57df0e0
...
...
@@ -8,8 +8,8 @@ from common.utils import ssh_pubkey_gen
from
orgs.mixins.serializers
import
BulkOrgResourceModelSerializer
from
..models
import
SystemUser
from
..const
import
(
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
)
from
.base
import
AuthSerializer
,
AuthSerializerMixin
...
...
@@ -41,10 +41,10 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
@staticmethod
def
validate_name
(
name
):
pattern
=
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
mat
ch
(
pattern
,
name
)
if
res
is
None
:
msg
=
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
pattern
=
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
sear
ch
(
pattern
,
name
)
if
res
is
not
None
:
msg
=
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
name
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
a57df0e0
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
a57df0e0
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-2
4 18:31
+0800\n"
"POT-Creation-Date: 2019-10-2
5 10:52
+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -583,8 +583,8 @@ msgid "Test if the assets under the node are connectable: {}"
msgstr "测试节点下资产是否可连接: {}"
#: assets/const.py:8
msgid "
Only Numbers、letters、 chinese and characters ( {} ) are allowed
"
msgstr "
只允许包含数字、字母、中文和特殊字符( {} )
"
msgid "
Cannot contain special characters: [ {} ]
"
msgstr "
不能包含特殊字符:[ {} ]
"
#: assets/const.py:14
msgid "* The contains characters that are not allowed"
...
...
apps/orgs/serializers.py
View file @
a57df0e0
...
...
@@ -5,8 +5,8 @@ from rest_framework import serializers
from
users.models
import
User
,
UserGroup
from
assets.models
import
Asset
,
Domain
,
AdminUser
,
SystemUser
,
Label
from
assets.const
import
(
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
)
from
perms.models
import
AssetPermission
from
common.serializers
import
AdaptedBulkListSerializer
...
...
@@ -24,10 +24,10 @@ class OrgSerializer(ModelSerializer):
@staticmethod
def
validate_name
(
name
):
pattern
=
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
mat
ch
(
pattern
,
name
)
if
res
is
None
:
msg
=
GENERAL_
LIMIT
_SPECIAL_CHARACTERS_ERROR_MSG
pattern
=
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
sear
ch
(
pattern
,
name
)
if
res
is
not
None
:
msg
=
GENERAL_
FORBIDDEN
_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment