优化页面

dependabot/npm_and_yarn/fir_admin/async-2.6.4
nineven 3 years ago
parent fe880b27b7
commit df38944eab
  1. 12
      fir_client/src/components/FirDownload.vue
  2. 12
      fir_client/src/components/ShortDownload.vue
  3. 5
      fir_client/src/components/apps/FirAppInfossecurity.vue
  4. 8
      fir_ser/api/models.py
  5. 2
      fir_ser/api/utils/apputils.py
  6. 4
      fir_ser/api/utils/utils.py
  7. 4
      fir_ser/api/views/apps.py
  8. 8
      fir_ser/api/views/login.py
  9. 2
      fir_ser/api/views/report.py
  10. 7
      fir_ser/common/base/baseutils.py
  11. 6
      fir_ser/common/base/magic.py
  12. 2
      fir_ser/common/libs/pay/wx.py
  13. 4
      fir_ser/config.py
  14. 2
      fir_ser/tests/postudid.py
  15. 10
      fir_ser/xsign/models.py
  16. 2
      fir_ser/xsign/tasks.py
  17. 7
      fir_ser/xsign/utils/iossignapi.py
  18. 7
      fir_ser/xsign/utils/supersignutils.py
  19. 2
      fir_ser/xsign/views/appinfo.py
  20. 6
      fir_ser/xsign/views/download.py
  21. 26
      fir_ser/xsign/views/receiveudids.py

@ -602,6 +602,15 @@ export default {
window.location.href = this.mobileprovision;
},
check_msg() {
if(this.agent === 'wxandroid' || this.agent === 'wxapple'){
return
}
if (this.$route.query.msg) {
this.wrong = true;
this.show_err_msg(this.$route.query.msg);
this.currentappinfo.need_password=false;
return;
}
if (this.currentappinfo.need_password) {
if (this.currentappinfo.issupersign && !this.$route.query.udid) {
this.currentappinfo.need_password = false
@ -642,6 +651,7 @@ export default {
this.wrong = false;
this.err_password = true
this.currentappinfo.need_password = true
this.password=''
} else {
this.show_err_msg(data.msg);
// eslint-disable-next-line no-unused-vars
@ -682,7 +692,7 @@ export default {
if (this.agent !== '') {
this.downloadurl = res.data.download_url;
let pwd = ''
if(res.data.password && res.data.password.length>4){
if (res.data.password && res.data.password.length > 4) {
pwd = '&password=' + encodeURIComponent(res.data.password)
}
window.location.href = this.downloadurl + pwd;

@ -567,6 +567,15 @@ export default {
window.location.href = this.mobileprovision;
},
check_msg() {
if(this.agent === 'wxandroid' || this.agent === 'wxapple'){
return
}
if (this.$route.query.msg) {
this.wrong = true;
this.show_err_msg(this.$route.query.msg);
this.currentappinfo.need_password=false;
return;
}
if (this.currentappinfo.need_password) {
if (this.currentappinfo.issupersign && !this.$route.query.udid) {
this.currentappinfo.need_password = false
@ -607,6 +616,7 @@ export default {
this.wrong = false;
this.err_password = true;
this.currentappinfo.need_password = true;
this.password=''
} else {
this.show_err_msg(data.msg);
// eslint-disable-next-line no-unused-vars
@ -647,7 +657,7 @@ export default {
if (this.agent !== '') {
this.downloadurl = res.data.download_url;
let pwd = ''
if(res.data.password && res.data.password.length>4){
if (res.data.password && res.data.password.length > 4) {
pwd = '&password=' + encodeURIComponent(res.data.password)
}
window.location.href = this.downloadurl + pwd;

@ -324,8 +324,7 @@ export default {
},
methods: {
format_copy_text(token) {
let short_full_url = this.currentapp.preview_url + "/" + this.currentapp.short;
return short_full_url + "?password=" + token
return this.currentapp.preview_url + "/" + this.currentapp.short + "?password=" + token
},
copy_success() {
this.$message.success('复制剪切板成功');
@ -417,7 +416,7 @@ export default {
},
tokenHandleSizeChange(val) {
this.pagination.pagesize = val;
this.pagination.currentPage=1;
this.pagination.currentPage = 1;
this.showDownloadBase();
},
tokenHandleCurrentChange(val) {

@ -54,7 +54,7 @@ class UserInfo(AbstractUser):
verbose_name_plural = "账户信息"
def __str__(self):
return "%s_%s_%s(%s)" % (self.uid, self.email, self.mobile, self.get_role_display())
return f"{self.uid}-{self.email}-{self.mobile}-{self.get_role_display()}"
def save(self, *args, **kwargs):
if len(self.uid) < 8:
@ -175,7 +175,7 @@ class Apps(models.Model):
indexes = [models.Index(fields=['app_id']), models.Index(fields=['id', 'user_id', 'type'])]
def __str__(self):
return "%s %s-%s %s" % (self.name, self.get_type_display(), self.short, self.issupersign)
return f"{self.name}-{self.get_type_display()}-{self.short}-{self.issupersign}"
class AppBundleIdBlackList(models.Model):
@ -196,7 +196,7 @@ class AppBundleIdBlackList(models.Model):
unique_together = ('user_uid', 'bundle_id')
def __str__(self):
return "%s-%s-%s" % (self.user_uid, self.bundle_id, self.enable)
return f"{self.user_uid}-{self.bundle_id}-{self.enable}"
class AppScreenShot(models.Model):
@ -210,7 +210,7 @@ class AppScreenShot(models.Model):
indexes = [models.Index(fields=['app_id'])]
def __str__(self):
return "%s-%s" % (self.app_id, self.screenshot_url)
return f"{self.app_id}-{self.screenshot_url}"
class AppReleaseInfo(models.Model):

@ -25,7 +25,7 @@ def bytes2human(n):
if float(n) >= prefix[s]:
value = float(n) / prefix[s]
return '%.1f%s' % (value, s)
return '%sB' % n
return f'{n}B'
def get_release_type(app_file_name, app_info):

@ -82,7 +82,7 @@ def change_storage_and_change_advert_img(user_obj, new_storage_obj, clean_old_da
def download_files_form_oss(storage_obj, org_file, force=False):
with cache.lock("%s_%s" % ('download_files_form_oss', org_file), timeout=60 * 30):
with cache.lock(f"download_files_form_oss_{org_file}", timeout=60 * 30):
if os.path.isfile(org_file) and not force:
return True
if storage_obj.download_file(os.path.basename(org_file), org_file + ".check.tmp"):
@ -142,7 +142,7 @@ def migrating_storage_file_data(user_obj, filename, new_storage_obj, clean_old_d
def migrating_storage_data(user_obj, new_storage_obj, clean_old_data):
with cache.lock("%s_%s" % ('migrating_storage_data', user_obj.uid), timeout=60 * 60 * 24):
with cache.lock(f"migrating_storage_data_{user_obj.uid}", timeout=60 * 60 * 24):
auth_status = False
certification = getattr(user_obj, 'certification', None)

@ -172,7 +172,7 @@ class AppInfoView(APIView):
else:
try:
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
logger.info("app_id:%s update old data:%s" % (app_id, app_obj.__dict__))
logger.info(f"app_id:{app_id} update old data:{app_obj.__dict__}")
app_obj.description = data.get("description", app_obj.description)
app_obj.short = data.get("short", app_obj.short)
app_obj.name = data.get("name", app_obj.name)
@ -299,7 +299,7 @@ class AppReleaseInfoView(APIView):
if binary_url != '':
if binary_url:
if not binary_url.startswith('http'):
binary_url = 'http://%s' % binary_url
binary_url = f'http://{binary_url}'
else:
binary_url = app_release_objs.first().binary_url

@ -56,7 +56,7 @@ def get_authenticate(target, password, act, allow_type):
def check_register_userinfo(target, act, key, ftype=None):
res = BaseResponse()
res.data = {}
times_key = "%s_%s_%s" % (key, act, target)
times_key = f"{key}_{act}_{target}"
if key == "register":
if not get_register_type()[act]:
@ -137,7 +137,7 @@ def check_change_userinfo(target, act, key, user, ftype=None):
res.code = 1002
res.msg = "暂不允许该类型修改"
return res
times_key = "%s_%s_%s" % (user.uid, act, target)
times_key = f"{user.uid}_{act}_{target}"
if act == "sms":
if is_valid_phone(target) and str(user.mobile) != str(target):
if login_auth_failed("get", times_key):
@ -429,7 +429,7 @@ class RegistView(APIView):
response.msg = "密码不一致"
else:
response.code = 1006
logger.error("username:%s failed too try , locked" % (username,))
logger.error(f"username:{username} failed too try , locked")
response.msg = "用户注册失败次数过多,已被锁定,请1小时之后再次尝试"
else:
response.code = 1001
@ -668,7 +668,7 @@ class CertificationView(APIView):
res.data["usercert"] = {
'name': user_certification_obj.name,
'addr': user_certification_obj.addr,
'card': "%s%s%s" % (card[:4], '*' * (len(card) - 8), card[-4:]),
'card': f"{card[:4]}{'*' * (len(card) - 8)}{card[-4:]}",
'mobile': user_certification_obj.mobile,
'status': user_certification_obj.status,
'msg': user_certification_obj.msg,

@ -66,7 +66,7 @@ class ReportView(APIView):
res.code = 1005
else:
res.code = 1006
logger.error("email:%s failed too try , locked" % (email,))
logger.error(f"email:{email} failed too try , locked")
res.msg = "失败次数过多,已被锁定,请1小时之后再次尝试"
else:
res.code = 1001

@ -86,9 +86,8 @@ def make_from_user_uuid(uid):
def make_app_uuid(userinfo, bundleid):
user_id = userinfo.uid
app_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, "%s" % (user_id + bundleid)).__str__().split("-")
fapp_uuid = "".join(app_uuid)
return fapp_uuid
app_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, f"{user_id + bundleid}").__str__().split("-")
return "".join(app_uuid)
def make_random_uuid():
@ -254,7 +253,7 @@ def get_server_domain_from_request(request, server_domain):
protocol = 'https'
if server_protocol == 'HTTP/1.1':
protocol = 'http'
server_domain = "%s://%s" % (protocol, http_host)
server_domain = f"{protocol}://{http_host}"
return server_domain

@ -126,13 +126,11 @@ def import_from_string(dotted_path):
try:
module_path, class_name = dotted_path.rsplit('.', 1)
except ValueError as err:
raise ImportError("%s doesn't look like a module path" % dotted_path) from err
raise ImportError(f"{dotted_path} doesn't look like a module path") from err
module = import_module(module_path)
try:
return getattr(module, class_name)
except AttributeError as err:
raise ImportError('Module "%s" does not define a "%s" attribute/class' % (
module_path, class_name)
) from err
raise ImportError(f'Module "{module_path}" does not define a "{class_name}" attribute/class') from err

@ -27,7 +27,7 @@ class Weixinpay(object):
parivate_key=self.wx_config.get('APP_PRIVATE_KEY'),
cert_serial_no=self.wx_config.get('SERIAL_NO'),
appid=self.wx_config.get('APP_ID'),
notify_url="%s/%s" % (self.wx_config.get('APP_NOTIFY_URL'), self.name),
notify_url=f"{self.wx_config.get('APP_NOTIFY_URL')}/{self.name}",
apiv3_key=self.wx_config.get('API_V3_KEY')
)

@ -294,8 +294,8 @@ class IPACONF(object):
MOBILE_CONFIG_SIGN_SSL = {
# 描述文件是否签名,默认是关闭状态;如果开启,并且ssl_key_path 和 ssl_pem_path 正常,则使用填写的ssl进行签名,否则默认不签名
'open': True,
'ssl_key_path': '/data/cert/%s.key' % API_DOMAIN.split("://")[1],
'ssl_pem_path': '/data/cert/%s.pem' % API_DOMAIN.split("://")[1]
'ssl_key_path': f'/data/cert/{API_DOMAIN.split("://")[1]}.key',
'ssl_pem_path': f'/data/cert/{API_DOMAIN.split("://")[1]}.pem'
}
DEFAULT_MOBILEPROVISION = {
# 默认描述文件路径或者下载路径,用户企业签名或者超级签名 跳转 [设置 - 通用 - 描述文件|设备管理] 页面

@ -52,7 +52,7 @@ short_list = [
def postudid(short=short_list[0], udid=udid_lists[0]):
data = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n\t<key>PRODUCT</key>\n\t<string>iPhone9,1</string>\n\t<key>SERIAL</key>\n\t<string>F71YD58GHG74</string>\n\t<key>UDID</key>\n\t<string>%s</string>\n\t<key>VERSION</key>\n\t<string>17E262</string>\n</dict>\n</plist>\n' % (
udid)
uri = "https://app.hehelucky.cn/api/v1/fir/xsign/udid/%s" % (short)
uri = f"https://app.hehelucky.cn/api/v1/fir/xsign/udid/{short}"
req = requests.post(uri, data=data)
print(req.status_code, req.text)

@ -57,7 +57,7 @@ class AppIOSDeveloperInfo(models.Model):
return super(AppIOSDeveloperInfo, self).save(*args, **kwargs)
def __str__(self):
return "%s-%s" % (self.user_id, self.issuer_id)
return f"{self.user_id}-{self.issuer_id}"
class UDIDsyncDeveloper(models.Model):
@ -80,7 +80,7 @@ class UDIDsyncDeveloper(models.Model):
unique_together = ('udid', 'developerid',)
def __str__(self):
return "%s-%s-%s-%s" % (self.product, self.udid, self.developerid, self.status)
return f"{self.product}-{self.udid}-{self.developerid}-{self.status}"
class AppUDID(models.Model):
@ -111,7 +111,7 @@ class AppUDID(models.Model):
unique_together = ('app_id', 'udid',)
def __str__(self):
return "%s-%s" % (self.app_id.name, self.udid)
return f"{self.app_id.name}-{self.udid}"
class APPSuperSignUsedInfo(models.Model):
@ -130,7 +130,7 @@ class APPSuperSignUsedInfo(models.Model):
verbose_name_plural = "设备使用统计"
def __str__(self):
return "%s-%s-%s" % (self.user_id, self.app_id, self.udid)
return f"{self.user_id}-{self.app_id}-{self.udid}"
class APPToDeveloper(models.Model):
@ -148,7 +148,7 @@ class APPToDeveloper(models.Model):
verbose_name_plural = "应用开发者绑定"
def __str__(self):
return "%s-%s-%s" % (self.developerid, self.app_id, self.binary_file)
return f"{self.developerid}-{self.app_id}-{self.binary_file}"
class DeveloperAppID(models.Model):

@ -64,7 +64,7 @@ def run_resign_task(app_id, need_download_profile=True, force=True, developers_f
if developers_filter:
developer_app_id_queryset = developer_app_id_queryset.filter(developerid__in=developers_filter)
with cache.lock("%s_%s" % ('task_resign', app_obj.app_id), timeout=60 * 60):
with cache.lock(f"task_resign_{app_obj.app_id}", timeout=60 * 60):
task_list = []
for developer_app_id_obj in developer_app_id_queryset.all():
c_task = run_resign_task_do.apply_async((app_id, developer_app_id_obj.developerid.pk,

@ -72,7 +72,7 @@ class ResignApp(object):
self.my_local_key = my_local_key
self.app_dev_pem = app_dev_pem
self.app_dev_p12 = app_dev_p12
self.cmd = "zsign -c '%s' -k '%s' " % (self.app_dev_pem, self.my_local_key)
self.cmd = f"zsign -c '{self.app_dev_pem}' -k '{self.my_local_key}' "
@staticmethod
def sign_mobile_config(sign_data, ssl_pem_path, ssl_key_path, ssl_pem_data=None, ssl_key_data=None):
@ -192,9 +192,8 @@ class ResignApp(object):
info_plist_properties = {}
properties = ""
for k, v in info_plist_properties.items():
properties += " %s '%s' " % (k, v)
self.cmd = self.cmd + " %s -m '%s' -o '%s' -z 9 '%s'" % (properties, new_profile, new_ipa, org_ipa)
return exec_shell(self.cmd)
properties = f"{properties} {k} '{v}' "
return exec_shell(f"{self.cmd} {properties} -m '{new_profile}' -o '{new_ipa}' -z 9 '{org_ipa}'")
def make_csr_content(csr_file_path, private_key_path):

@ -71,8 +71,7 @@ def resign_by_app_id_and_developer(app_id, developer_id, developer_app_id, need_
return False, '清理执行中,请等待'
d_time = time.time()
if need_download_profile:
with cache.lock("%s_%s_%s" % ('make_and_download_profile', developer_obj.issuer_id, app_obj.app_id),
timeout=60):
with cache.lock(f"make_and_download_profile_{developer_obj.issuer_id}_{app_obj.app_id}", timeout=60):
IosUtils.modify_capability(developer_obj, app_obj, developer_app_id)
status, download_profile_result = IosUtils.make_and_download_profile(app_obj,
developer_obj,
@ -524,8 +523,8 @@ class IosUtils(object):
state, used_num = check_app_sign_limit(self.app_obj)
if not state:
d_result['code'] = 1003
d_result['msg'] = "app_id %s used over limit.now %s limit: %s" % (
self.app_obj, used_num, self.app_obj.supersign_limit_number)
d_result[
'msg'] = f"app_id {self.app_obj} used over limit.now {used_num} limit: {self.app_obj.supersign_limit_number}"
logger.error(d_result)
add_sign_message(self.user_obj, self.developer_obj, self.app_obj, '签名余额不足', d_result['msg'], False)
sign_app_over_limit_notify(self.app_obj.user_id, self.app_obj, used_num,

@ -57,7 +57,7 @@ class AppSignInfoView(APIView):
try:
do_sign_flag = 0
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
logger.info("app_id:%s update old data:%s" % (app_id, app_obj.__dict__))
logger.info(f"app_id:{app_id} update old data:{app_obj.__dict__}")
update_fields = []
if app_obj.issupersign:
app_obj.supersign_limit_number = data.get("supersign_limit_number",

@ -7,6 +7,7 @@
import logging
import os
import random
from urllib.parse import quote
from django.urls import reverse
from rest_framework.views import APIView
@ -28,8 +29,9 @@ def get_post_udid_url(request, app_obj, pwd):
server_domain = get_server_domain_from_request(request, Config.POST_UDID_DOMAIN)
p_token = make_token(app_obj.app_id, time_limit=120, key='post_udid', force_new=True)
token = f'{p_token}{"".join(random.sample(p_token, 3))}{app_obj.app_id}{"".join(random.sample(p_token, 3))}{pwd}'
logger.info(f'p_token:{p_token} app_id:{app_obj.app_id} pwd:{pwd}')
logger.info(f'token:{token}')
logger.info(f'make udid: p_token:{p_token} app_id:{app_obj.app_id} pwd:{pwd}')
logger.info(f'make udid: token:{token}')
token = quote(token, safe='/', encoding=None, errors=None)
return f'{server_domain}{reverse("xudid", kwargs={"short": app_obj.short})}?p={token}'

@ -5,7 +5,7 @@
# date: 2020/3/6
import json
import logging
from urllib.parse import quote
from urllib.parse import quote, unquote
from celery.exceptions import TimeoutError
from django.http import HttpResponsePermanentRedirect, FileResponse, HttpResponse
@ -40,10 +40,17 @@ class IosUDIDView(APIView):
p_token = app_id = pwd = ''
token_length = 52
app_id_length = 32
try:
if p_info:
p_token = p_info[:token_length]
app_id = p_info[token_length + 3:token_length + 3 + app_id_length]
pwd = p_info[token_length + app_id_length + 3 + 3:]
logger.info(f'get udid: p_token:{p_token} app_id:{app_id} pwd:{pwd}')
logger.info(f'get udid: p_info:{p_info}')
except Exception as e:
logger.error(f'token app_id check failed Exception:{e}')
return HttpResponsePermanentRedirect(Config.WEB_DOMAIN)
if not p_token or not app_id:
return HttpResponsePermanentRedirect(Config.WEB_DOMAIN)
stream_f = str(request.body)
@ -58,7 +65,7 @@ class IosUDIDView(APIView):
if app_obj.issupersign and app_obj.user_id.supersign_active:
res = check_app_permission(app_obj, BaseResponse())
if res.code != 1000:
msg = "&msg=%s" % res.msg
msg = f"&msg={res.msg}"
else:
client_ip = get_real_ip_address(request)
logger.info(f"client_ip {client_ip} short {short} app_info {app_obj}")
@ -72,16 +79,16 @@ class IosUDIDView(APIView):
'short': short,
'app_id': app_id,
'client_ip': client_ip,
'r_token': make_token(app_obj.app_id, time_limit=30, key='receive_udid', force_new=True)
'r_token': make_token(app_obj.app_id, time_limit=60, key='receive_udid', force_new=True)
}
encrypt_data = AesBaseCrypt().get_encrypt_uid(json.dumps(data))
msg = "&task_token=%s" % quote(encrypt_data, safe='/', encoding=None, errors=None)
msg = f"&task_token={quote(encrypt_data, safe='/', encoding=None, errors=None)}"
token_obj = AppDownloadToken.objects.filter(app_id__app_id=app_id,
bind_udid=format_udid_info.get('udid')).first()
if token_obj:
msg = f"{msg}&password={token_obj.token}"
elif pwd:
msg = f"{msg}&password={AesBaseCrypt().get_decrypt_uid(pwd)}"
msg = f"{msg}&password={AesBaseCrypt().get_decrypt_uid(unquote(pwd))}"
logger.info(f"msg:{msg}")
else:
return HttpResponsePermanentRedirect(f"{server_domain}/{short}")
@ -90,7 +97,7 @@ class IosUDIDView(APIView):
else:
return HttpResponsePermanentRedirect(f"{server_domain}/{short}")
except Exception as e:
msg = "&msg=系统内部错误"
msg = "&msg=系统内部错误,请重试"
logger.error(f"short {short} receive udid Exception:{e}")
return HttpResponsePermanentRedirect(f"{server_domain}/{short}?udid={format_udid_info.get('udid')}{msg}")
@ -175,7 +182,7 @@ class TaskView(APIView):
if not check_app_download_token(app_obj.need_password, False, app_obj.app_id, password, False, udid):
res.code = 1006
res.msg = '下载授权码有误'
res.msg = '下载授权码失效或有误'
if res.code != 1000:
return Response(res.dict)
@ -205,7 +212,7 @@ class ShowUdidView(View):
def get(self, request):
udid = request.GET.get("udid")
if udid:
return HttpResponse("udid: %s" % udid)
return HttpResponse(f"udid:{udid}")
server_domain = get_server_domain_from_request(request, Config.POST_UDID_DOMAIN)
path_info_lists = [server_domain, "show_udid"]
udid_url = "/".join(path_info_lists)
@ -220,5 +227,4 @@ class ShowUdidView(View):
format_udid_info = udid_bytes_to_dict(stream_f)
logger.info(f"show_udid receive new udid {format_udid_info}")
server_domain = get_server_domain_from_request(request, Config.POST_UDID_DOMAIN)
return HttpResponsePermanentRedirect(
"%s/show_udid?udid=%s" % (server_domain, format_udid_info.get("udid")))
return HttpResponsePermanentRedirect(f"{server_domain}/show_udid?udid={format_udid_info.get('udid')}")

Loading…
Cancel
Save