From 458989328e7a563d72928db9db6dd70301152477 Mon Sep 17 00:00:00 2001 From: GuangHongwei Date: Mon, 15 May 2017 23:39:54 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9bug=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8py3=E7=BC=96=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../templates/assets/user_asset_list.html | 2 -- apps/audits/views.py | 2 +- apps/common/utils.py | 19 +++-------- apps/ops/models.py | 5 +-- apps/perms/views.py | 1 + apps/static/css/plugins/inputTags.css | 4 +-- apps/static/css/style.css | 4 +-- .../plugins/highcharts/themes/dark-unica.js | 2 +- .../plugins/highcharts/themes/grid-light.js | 2 +- .../plugins/highcharts/themes/sand-signika.js | 2 +- apps/users/utils.py | 6 ++-- requirements/requirements.txt | 34 +++++++++---------- 13 files changed, 37 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 4861567b4..260775ff9 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ host_rsa_key *.bat tags tmp/* +jumpserver.iml diff --git a/apps/assets/templates/assets/user_asset_list.html b/apps/assets/templates/assets/user_asset_list.html index 20bc77623..27657564b 100644 --- a/apps/assets/templates/assets/user_asset_list.html +++ b/apps/assets/templates/assets/user_asset_list.html @@ -43,8 +43,6 @@ -{% include 'assets/_asset_import_modal.html' %} -{% include 'assets/_asset_bulk_update_modal.html' %} {% endblock %} {% block custom_foot_js %} diff --git a/apps/audits/views.py b/apps/audits/views.py index de7cc9421..9767b54bd 100644 --- a/apps/audits/views.py +++ b/apps/audits/views.py @@ -55,7 +55,7 @@ class ProxyLogListView(AdminUserRequiredMixin, ListView): if self.username: filter_kwargs['user'] = self.username if self.ip: - filter_kwargs['ip'] = self.ip + filter_kwargs['asset'] = self.ip if self.system_user: filter_kwargs['system_user'] = self.system_user if self.keyword: diff --git a/apps/common/utils.py b/apps/common/utils.py index 41de9bada..516b70987 100644 --- a/apps/common/utils.py +++ b/apps/common/utils.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # - from __future__ import unicode_literals + from collections import OrderedDict from six import string_types import base64 @@ -15,9 +15,9 @@ import hashlib from email.utils import formatdate import calendar import threading +from io import StringIO import paramiko -from passlib.hash import sha512_crypt import sshpubkeys from itsdangerous import TimedJSONWebSignatureSerializer, JSONWebSignatureSerializer, \ BadSignature, SignatureExpired @@ -25,10 +25,6 @@ from django.shortcuts import reverse as dj_reverse from django.conf import settings from django.utils import timezone -try: - from io import StringIO -except ImportError: - from StringIO import StringIO from .compat import to_bytes, to_string @@ -281,6 +277,7 @@ _ISO8601_FORMAT = "%Y-%m-%dT%H:%M:%S.000Z" def to_unixtime(time_string, format_string): + time_string = time_string.decode("ascii") with _STRPTIME_LOCK: return int(calendar.timegm(time.strptime(time_string, format_string))) @@ -305,15 +302,9 @@ def iso8601_to_unixtime(time_string): return to_unixtime(time_string, _ISO8601_FORMAT) -# def http_to_unixtime(time_string): -# """把HTTP Date格式的字符串转换为UNIX时间(自1970年1月1日UTC零点的秒数)。 -# -# HTTP Date形如 `Sat, 05 Dec 2015 11:10:29 GMT` 。 -# """ -# return to_unixtime(time_string, "%a, %d %b %Y %H:%M:%S GMT") - - def make_signature(access_key_secret, date=None): + if isinstance(date, bytes): + date = bytes.decode(date) if isinstance(date, int): date_gmt = http_date(date) elif date is None: diff --git a/apps/ops/models.py b/apps/ops/models.py index 6c9079014..b2c6cdece 100644 --- a/apps/ops/models.py +++ b/apps/ops/models.py @@ -40,10 +40,7 @@ class Task(models.Model): @property def assets_json(self): - from assets.models import Asset - return [Asset.objects.get(id=int(id_))._to_secret_json() - for id_ in self.total_assets - if Asset.objects.filter(id=int(id_))] + return [asset._to_secret_json() for asset in self.total_assets] @property def module_args(self): diff --git a/apps/perms/views.py b/apps/perms/views.py index 59db43067..57dde9cf0 100644 --- a/apps/perms/views.py +++ b/apps/perms/views.py @@ -105,6 +105,7 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView): success_message = _( 'Update asset permission {name} successfully.' ) + success_url = reverse_lazy("perms:asset-permission-list") def get_context_data(self, **kwargs): context = { diff --git a/apps/static/css/plugins/inputTags.css b/apps/static/css/plugins/inputTags.css index 36ac4543d..085ea19fa 100644 --- a/apps/static/css/plugins/inputTags.css +++ b/apps/static/css/plugins/inputTags.css @@ -1,5 +1,5 @@ -@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"); -@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700"); +@import url("https://fonts.css.network/css?family=Open+Sans:300,400,600,700"); +@import url("https://fonts.css.network/css?family=Roboto:400,300,500,700"); /** {*/ /*box-sizing: border-box;*/ /*}*/ diff --git a/apps/static/css/style.css b/apps/static/css/style.css index 609d1cffb..637517e34 100644 --- a/apps/static/css/style.css +++ b/apps/static/css/style.css @@ -1,5 +1,5 @@ -@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"); -@import url("https://fonts.googleapis.com/css?family=Roboto:400,300,500,700"); +@import url("https://fonts.css.network/css?family=Open+Sans:300,400,600,700"); +@import url("https://fonts.css.network/css?family=Roboto:400,300,500,700"); /* * * INSPINIA - Responsive Admin Theme diff --git a/apps/static/js/plugins/highcharts/themes/dark-unica.js b/apps/static/js/plugins/highcharts/themes/dark-unica.js index 4f1f8df5d..2a47201d0 100644 --- a/apps/static/js/plugins/highcharts/themes/dark-unica.js +++ b/apps/static/js/plugins/highcharts/themes/dark-unica.js @@ -5,7 +5,7 @@ // Load the fonts Highcharts.createElement('link', { - href: 'http://fonts.googleapis.com/css?family=Unica+One', + href: 'https://fonts.css.network/css?family=Unica+One', rel: 'stylesheet', type: 'text/css' }, null, document.getElementsByTagName('head')[0]); diff --git a/apps/static/js/plugins/highcharts/themes/grid-light.js b/apps/static/js/plugins/highcharts/themes/grid-light.js index acf53aece..eb3dd3686 100644 --- a/apps/static/js/plugins/highcharts/themes/grid-light.js +++ b/apps/static/js/plugins/highcharts/themes/grid-light.js @@ -5,7 +5,7 @@ // Load the fonts Highcharts.createElement('link', { - href: 'http://fonts.googleapis.com/css?family=Dosis:400,600', + href: 'https://fonts.css.network/css?family=Dosis:400,600', rel: 'stylesheet', type: 'text/css' }, null, document.getElementsByTagName('head')[0]); diff --git a/apps/static/js/plugins/highcharts/themes/sand-signika.js b/apps/static/js/plugins/highcharts/themes/sand-signika.js index 27198331f..bd153f934 100644 --- a/apps/static/js/plugins/highcharts/themes/sand-signika.js +++ b/apps/static/js/plugins/highcharts/themes/sand-signika.js @@ -5,7 +5,7 @@ // Load the fonts Highcharts.createElement('link', { - href: 'http://fonts.googleapis.com/css?family=Signika:400,700', + href: 'https://fonts.css.network/css?family=Signika:400,700', rel: 'stylesheet', type: 'text/css' }, null, document.getElementsByTagName('head')[0]); diff --git a/apps/users/utils.py b/apps/users/utils.py index 133929c3b..67e9b1d37 100644 --- a/apps/users/utils.py +++ b/apps/users/utils.py @@ -161,10 +161,12 @@ def refresh_token(token, user, expiration=3600): def generate_token(request, user): expiration = settings.CONFIG.TOKEN_EXPIRATION or 3600 remote_addr = request.META.get('REMOTE_ADDR', '') - remote_addr = base64.b16encode(remote_addr).replace('=', '') + if not isinstance(remote_addr, bytes): + remote_addr = remote_addr.encode("utf-8") + remote_addr = base64.b16encode(remote_addr) #.replace(b'=', '') token = cache.get('%s_%s' % (user.id, remote_addr)) if not token: - token = uuid.uuid4().get_hex() + token = uuid.uuid4().hex print('Set cache: %s' % token) cache.set(token, user.id, expiration) cache.set('%s_%s' % (user.id, remote_addr), token, expiration) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 541d794ee..e6158a949 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,19 +1,19 @@ -Django==1.11 -django-bootstrap3==8.2.2 -Pillow==4.1.0 -djangorestframework==3.6.2 +Django>=1.11 +django-bootstrap3>=8.2.2 +Pillow>=4.1.0 +djangorestframework>=3.6.2 ForgeryPy -openpyxl==2.4.0 -celery==4.0.2 -paramiko==2.1.2 -ansible==2.2.2.0 -django-simple-captcha==0.5.5 -django-formtools==2.0 -sshpubkeys==2.2.0 -djangorestframework-bulk==0.2.1 -django-redis-cache==1.7.1 -requests==2.13.0 -itsdangerous==0.24 +openpyxl>=2.4.0 +celery>=4.0.2 +paramiko>=2.1.2 +ansible>=2.2.2.0 +django-simple-captcha>=0.5.5 +django-formtools>=2.0 +sshpubkeys>=2.2.0 +djangorestframework-bulk>=0.2.1 +django-redis-cache>=1.7.1 +requests>=2.13.0 +itsdangerous>=0.24 eventlet -django-filter==1.0.2 -passlib==1.7.1 +django-filter>=1.0.2 +passlib>=1.7.1