Files
aaPanel/class/panelSafeController.py
Jack ed55fa708d Update to 7.7.0
Since version 7.7.0, we recommend yours update python to 3.12.

[+] Using nginx technology to load static files improves access speed
[+] Refactor homepage, website, FTP, and database using vue3
[+] Table loading changed to skeleton screen
[+] Add Website statistics-v2 professional plug-in
[+] Add Home page - top 5 resource occupancy
[+] Add protection for Files management (requires Tamper-proof for Enterprise 3.7)
[+] Website, FTP, Databases page add program status
[+] Add FTP log analysis (only supports Centos)
[+] Add password-free login to phpMyAdmin
[+] Add Proxy Project in Website (Supported when web service uses Nginx)
[+] Add WP Toolkit (Pro version only)
[+] Redesigned Docker module
[+] Add WP Toolkit Protection
[+] Add WP Toolkit Backup and Restore
[+] Add WP Toolkit Migrated
[+] Add WP Toolkit Clone site (supports new domain and subdomain)
[+] Add WP Toolkit Create site from backup of other panel
[+] Add WP Toolkit support for Cron automatic backup (only save Local disk)
[+] Add WP Toolkit operation log
[+] Add Integrity check for WP Toolkit
[+] Add WP Toolkit plug-in management and themes management

[*] Optimize phpMyAdmin formula access method
[*] Optimize Home page PHP display problem
[*] Optimize jump to the login interface after the login expires
[*] Optimize automatic renewal of SSL at some times
[*] Optimize Let's Encrypt to increase application success rate

[-] Fix Logs Audit cannot be opened
[-] Fix apache URL rewrite issue
[-] Fix phpmyadmin installation problem
[-] Fix the problem that some servers cannot install software
[-] Fix upload file error
[-] Fix left menu hiding problem
[-] Fix aaPanel Mobile QR code display problem
[-] Fix problem that third-party plug-ins are not displayed in the App Store
[-] Fix issue where the menu bar is blank when opening new tabs
[-] Fixed panel not being accessible in some cases
[-] Fix the issue where Curl warning caused the inability to apply for SSL
[-] Fix Quota issues for Website, FTP, Databases
[-] Fix file interface display problem on mobile terminal
2024-07-19 11:25:10 +08:00

94 lines
3.7 KiB
Python

#coding: utf-8
#-------------------------------------------------------------------
# aaPanel
#-------------------------------------------------------------------
# Copyright (c) 2015-2017 aaPanel(www.aapanel.com) All rights reserved.
#-------------------------------------------------------------------
# Author: hwliang <hwl@aapanel.com>
#-------------------------------------------------------------------
#------------------------------
# 系统安全管理控制器
#------------------------------
import os,sys,public,json,re
class SafeController:
def __init__(self):
pass
def model(self,args):
'''
@name 调用指定项目模型
@author hwliang<2021-12-31>
@param args<dict_obj> {
mod_name: string<模型名称>
def_name: string<方法名称>
data: JSON
}
'''
try: # 表单验证
if args['mod_name'] in ['base']: return public.return_status_code(1000,'wrong call!')
public.exists_args('def_name,mod_name',args)
if args['def_name'].find('__') != -1: return public.return_status_code(1000,'The called method name cannot contain the "__" character')
if not re.match(r"^\w+$",args['mod_name']): return public.return_status_code(1000,r'The called module name cannot contain characters other than \w')
if not re.match(r"^\w+$",args['def_name']): return public.return_status_code(1000,r'The called module name cannot contain characters other than \w')
except:
return public.get_error_object()
# 参数处理
module_name = args['mod_name'].strip()
mod_name = "{}Model".format(args['mod_name'].strip())
def_name = args['def_name'].strip()
if not hasattr(args,'data'): args.data = {}
if args.data:
if isinstance(args.data,str):
try: # 解析为dict_obj
pdata = public.to_dict_obj(json.loads(args.data))
except:
return public.get_error_object()
elif isinstance(args.data,dict):
pdata = public.to_dict_obj(args.data)
else:
pdata = args.data
else:
pdata = public.dict_obj()
if isinstance(pdata,dict): pdata = public.to_dict_obj(pdata)
pdata.model_index = 'safe'
# 前置HOOK
hook_index = '{}_{}_LAST'.format(mod_name.upper(),def_name.upper())
hook_result = public.exec_hook(hook_index,pdata)
if isinstance(hook_result,public.dict_obj):
pdata = hook_result # 桥接
elif isinstance(hook_result,dict):
return hook_result # 响应具体错误信息
elif isinstance(hook_result,bool):
if not hook_result: # 直接中断操作
return public.return_data(False,{},error_msg='前置HOOK中断操作')
# 调用处理方法
# result = run_object(pdata)
import PluginLoader
result = PluginLoader.module_run(module_name,def_name,pdata)
if isinstance(result,dict):
if 'status' in result and result['status'] == False and 'msg' in result:
if isinstance(result['msg'],str):
if result['msg'].find('Traceback ') != -1:
raise public.PanelError(result['msg'])
# 后置HOOK
hook_index = '{}_{}_END'.format(mod_name.upper(),def_name.upper())
hook_data = public.to_dict_obj({
'args': pdata,
'result': result
})
hook_result = public.exec_hook(hook_index,hook_data)
if isinstance(hook_result,dict):
result = hook_result['result']
return result