Commit d544f7f9 authored by ibuler's avatar ibuler

Merge branch 'dev' into 1.5.5

parents 0c1463bc fbe4f4c1
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
GENERAL_LIMIT_SPECIAL_CHARACTERS_HELP_TEXT = _( GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT = _(
'Only Numbers、letters、 chinese and characters ( {} ) are allowed' 'Cannot contain special characters: [ {} ]'
).format(" ".join(['.', '_', '@', '-'])) ).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") _("* The contains characters that are not allowed")
...@@ -7,7 +7,7 @@ from common.utils import get_logger ...@@ -7,7 +7,7 @@ from common.utils import get_logger
from orgs.mixins.forms import OrgModelForm from orgs.mixins.forms import OrgModelForm
from ..models import Asset, Node 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__) logger = get_logger(__file__)
...@@ -69,7 +69,7 @@ class AssetCreateForm(OrgModelForm): ...@@ -69,7 +69,7 @@ class AssetCreateForm(OrgModelForm):
'nodes': _("Node"), 'nodes': _("Node"),
} }
help_texts = { help_texts = {
'hostname': GENERAL_LIMIT_SPECIAL_CHARACTERS_HELP_TEXT, 'hostname': GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT,
'admin_user': _( 'admin_user': _(
'root or other NOPASSWD sudo privilege user existed in asset,' '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' 'If asset is windows or other set any one, more see admin user left menu'
...@@ -116,7 +116,7 @@ class AssetUpdateForm(OrgModelForm): ...@@ -116,7 +116,7 @@ class AssetUpdateForm(OrgModelForm):
'nodes': _("Node"), 'nodes': _("Node"),
} }
help_texts = { help_texts = {
'hostname': GENERAL_LIMIT_SPECIAL_CHARACTERS_HELP_TEXT, 'hostname': GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT,
'admin_user': _( 'admin_user': _(
'root or other NOPASSWD sudo privilege user existed in asset,' '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' 'If asset is windows or other set any one, more see admin user left menu'
......
...@@ -6,7 +6,7 @@ from django.utils.translation import gettext_lazy as _ ...@@ -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 common.utils import validate_ssh_private_key, ssh_pubkey_gen, get_logger
from orgs.mixins.forms import OrgModelForm from orgs.mixins.forms import OrgModelForm
from ..models import AdminUser, SystemUser 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__) logger = get_logger(__file__)
__all__ = [ __all__ = [
...@@ -99,7 +99,7 @@ class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm): ...@@ -99,7 +99,7 @@ class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm):
}), }),
} }
help_texts = { help_texts = {
'name': GENERAL_LIMIT_SPECIAL_CHARACTERS_HELP_TEXT, 'name': GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_HELP_TEXT,
'auto_push': _('Auto push system user to asset'), 'auto_push': _('Auto push system user to asset'),
'priority': _('1-100, High level will be using login asset as default, ' 'priority': _('1-100, High level will be using login asset as default, '
'if user was granted more than 2 system user'), 'if user was granted more than 2 system user'),
......
...@@ -9,8 +9,8 @@ from orgs.mixins.serializers import BulkOrgResourceModelSerializer ...@@ -9,8 +9,8 @@ from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from common.serializers import AdaptedBulkListSerializer from common.serializers import AdaptedBulkListSerializer
from ..models import Asset, Node, Label from ..models import Asset, Node, Label
from ..const import ( from ..const import (
GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN, GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN,
GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
) )
from .base import ConnectivitySerializer from .base import ConnectivitySerializer
...@@ -98,10 +98,10 @@ class AssetSerializer(BulkOrgResourceModelSerializer): ...@@ -98,10 +98,10 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
@staticmethod @staticmethod
def validate_hostname(hostname): def validate_hostname(hostname):
pattern = GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN pattern = GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
res = re.match(pattern, hostname) res = re.search(pattern, hostname)
if res is None: if res is not None:
msg = GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG msg = GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
raise serializers.ValidationError(msg) raise serializers.ValidationError(msg)
return hostname return hostname
......
...@@ -8,8 +8,8 @@ from common.utils import ssh_pubkey_gen ...@@ -8,8 +8,8 @@ from common.utils import ssh_pubkey_gen
from orgs.mixins.serializers import BulkOrgResourceModelSerializer from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from ..models import SystemUser from ..models import SystemUser
from ..const import ( from ..const import (
GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN, GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN,
GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
) )
from .base import AuthSerializer, AuthSerializerMixin from .base import AuthSerializer, AuthSerializerMixin
...@@ -41,10 +41,10 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer): ...@@ -41,10 +41,10 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
@staticmethod @staticmethod
def validate_name(name): def validate_name(name):
pattern = GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN pattern = GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
res = re.match(pattern, name) res = re.search(pattern, name)
if res is None: if res is not None:
msg = GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG msg = GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
raise serializers.ValidationError(msg) raise serializers.ValidationError(msg)
return name return name
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
VERSION = '1.5.3' VERSION = '1.5.4'
This diff is collapsed.
...@@ -5,8 +5,8 @@ from rest_framework import serializers ...@@ -5,8 +5,8 @@ from rest_framework import serializers
from users.models import User, UserGroup from users.models import User, UserGroup
from assets.models import Asset, Domain, AdminUser, SystemUser, Label from assets.models import Asset, Domain, AdminUser, SystemUser, Label
from assets.const import ( from assets.const import (
GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN, GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN,
GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
) )
from perms.models import AssetPermission from perms.models import AssetPermission
from common.serializers import AdaptedBulkListSerializer from common.serializers import AdaptedBulkListSerializer
...@@ -24,10 +24,10 @@ class OrgSerializer(ModelSerializer): ...@@ -24,10 +24,10 @@ class OrgSerializer(ModelSerializer):
@staticmethod @staticmethod
def validate_name(name): def validate_name(name):
pattern = GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN pattern = GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_PATTERN
res = re.match(pattern, name) res = re.search(pattern, name)
if res is None: if res is not None:
msg = GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG msg = GENERAL_FORBIDDEN_SPECIAL_CHARACTERS_ERROR_MSG
raise serializers.ValidationError(msg) raise serializers.ValidationError(msg)
return name return name
......
...@@ -20,6 +20,10 @@ class ActionField(forms.MultipleChoiceField): ...@@ -20,6 +20,10 @@ class ActionField(forms.MultipleChoiceField):
kwargs['initial'] = Action.ALL kwargs['initial'] = Action.ALL
kwargs['label'] = _("Action") kwargs['label'] = _("Action")
kwargs['widget'] = forms.CheckboxSelectMultiple() kwargs['widget'] = forms.CheckboxSelectMultiple()
kwargs['help_text'] = _(
'Tips: The RDP protocol does not support separate controls '
'for uploading or downloading files'
)
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def to_python(self, value): def to_python(self, value):
...@@ -89,10 +93,6 @@ class AssetPermissionForm(OrgModelForm): ...@@ -89,10 +93,6 @@ class AssetPermissionForm(OrgModelForm):
labels = { labels = {
'nodes': _("Node"), 'nodes': _("Node"),
} }
help_texts = {
'actions': _('Tips: The RDP protocol does not support separate '
'controls for uploading or downloading files')
}
def clean_user_groups(self): def clean_user_groups(self):
users = self.cleaned_data.get('users') users = self.cleaned_data.get('users')
......
...@@ -414,6 +414,44 @@ function makeLabel(data) { ...@@ -414,6 +414,44 @@ function makeLabel(data) {
return "<label class='detail-key'><b>" + data[0] + ": </b></label>" + data[1] + "</br>" return "<label class='detail-key'><b>" + data[0] + ": </b></label>" + data[1] + "</br>"
} }
function parseTableFilter(value) {
var cleanValues = [];
var valuesArray = value.split(':');
for (var i=0; i<valuesArray.length; i++) {
var v = valuesArray[i].trim();
if (!v) {
continue
}
// 如果是最后一个元素,直接push,不需要再处理了, 因为最后一个肯定不是key
if (i === valuesArray.length -1) {
cleanValues.push(v);
continue
}
v = v.split(' ');
// 如果长度是1,直接push上
// 如果长度不是1,根据空格分隔后,最后面的是key
if (v.length === 1) {
cleanValues.push(v[0]);
} else {
var leaveData = v.slice(0, -1).join(' ').trim();
cleanValues.push(leaveData);
cleanValues.push(v.slice(-1)[0]);
}
}
var filter = {};
var key = '';
for (i=0; i<cleanValues.length; i++) {
if (i%2 === 0) {
key = cleanValues[i]
} else {
value = cleanValues[i];
filter[key] = value
}
}
console.log(filter);
return filter;
}
var jumpserver = {}; var jumpserver = {};
jumpserver.checked = false; jumpserver.checked = false;
...@@ -611,24 +649,9 @@ jumpserver.initServerSideDataTable = function (options) { ...@@ -611,24 +649,9 @@ jumpserver.initServerSideDataTable = function (options) {
delete data.start; delete data.start;
} }
if (data.search !== null) { if (data.search !== null) {
var search_val = data.search.value; var searchValue = data.search.value;
var search_list = search_val.split(" "); var searchFilter = parseTableFilter(searchValue);
var search_attr = {}; $.each(searchFilter, function (k, v) {
var search_raw = [];
search_list.map(function (val, index) {
var kv = val.split(":");
if (kv.length === 2) {
var value = kv[1];
var key = kv[0].trim();
value = value.replace("+", " ").trim();
search_attr[key] = value
} else {
search_raw.push(kv)
}
});
data.search = search_raw.join("");
$.each(search_attr, function (k, v) {
data[k] = v data[k] = v
}) })
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script> <script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script>
<script src="{% static "js/inspinia.js" %}"></script> <script src="{% static "js/inspinia.js" %}"></script>
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script> <script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script src="{% static "js/jumpserver.js" %}?v=4"></script> <script src="{% static "js/jumpserver.js" %}?v=5"></script>
<script> <script>
activeNav("{{ FORCE_SCRIPT_NAME }}"); activeNav("{{ FORCE_SCRIPT_NAME }}");
$(document).ready(function(){ $(document).ready(function(){
......
amqp==2.1.4 amqp==2.1.4
ansible==2.8.0 ansible==2.8.2
asn1crypto==0.24.0 asn1crypto==0.24.0
bcrypt==3.1.4 bcrypt==3.1.4
billiard==3.5.0.3 billiard==3.5.0.3
...@@ -14,7 +14,7 @@ coreapi==2.3.3 ...@@ -14,7 +14,7 @@ coreapi==2.3.3
coreschema==0.0.4 coreschema==0.0.4
cryptography==2.3.1 cryptography==2.3.1
decorator==4.1.2 decorator==4.1.2
Django==2.1.7 Django==2.1.11
django-auth-ldap==1.7.0 django-auth-ldap==1.7.0
django-bootstrap3==9.1.0 django-bootstrap3==9.1.0
django-celery-beat==1.4.0 django-celery-beat==1.4.0
...@@ -27,7 +27,7 @@ django-simple-captcha==0.5.6 ...@@ -27,7 +27,7 @@ django-simple-captcha==0.5.6
djangorestframework==3.9.4 djangorestframework==3.9.4
djangorestframework-bulk==0.2.1 djangorestframework-bulk==0.2.1
docutils==0.14 docutils==0.14
ecdsa==0.13 ecdsa==0.13.3
enum-compat==0.0.2 enum-compat==0.0.2
ephem==3.7.6.0 ephem==3.7.6.0
eventlet==0.24.1 eventlet==0.24.1
...@@ -47,7 +47,7 @@ olefile==0.44 ...@@ -47,7 +47,7 @@ olefile==0.44
openapi-codec==1.3.2 openapi-codec==1.3.2
paramiko==2.4.2 paramiko==2.4.2
passlib==1.7.1 passlib==1.7.1
Pillow==4.3.0 Pillow==6.2.0
pyasn1==0.4.2 pyasn1==0.4.2
pycparser==2.19 pycparser==2.19
pycrypto==2.6.1 pycrypto==2.6.1
...@@ -68,7 +68,7 @@ uritemplate==3.0.0 ...@@ -68,7 +68,7 @@ uritemplate==3.0.0
urllib3==1.25.2 urllib3==1.25.2
vine==1.1.4 vine==1.1.4
drf-yasg==1.9.1 drf-yasg==1.9.1
Werkzeug==0.14.1 Werkzeug==0.15.3
drf-nested-routers==0.91 drf-nested-routers==0.91
aliyun-python-sdk-core-v3==2.9.1 aliyun-python-sdk-core-v3==2.9.1
aliyun-python-sdk-ecs==4.10.1 aliyun-python-sdk-ecs==4.10.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment