diff --git a/app/funct.py b/app/funct.py index a1f5bea5..56e64b20 100644 --- a/app/funct.py +++ b/app/funct.py @@ -272,7 +272,10 @@ def check_login(**kwargs): import sql import http.cookies cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) - user_uuid = cookie.get('uuid') + try: + user_uuid = cookie.get('uuid') + except Exception: + print('') ref = os.environ.get("REQUEST_URI") sql.delete_old_uuid() @@ -492,7 +495,6 @@ def get_remote_sections(server_ip: str, service: str) -> str: elif service == 'apache': section_name = 'ServerName' commands = ['sudo grep {} {}* -R |grep -v \'$server_name\|#\'|awk \'{{print $1, $3}}\''.format(section_name, config_dir)] - backends = ssh_command(server_ip, commands) return backends @@ -1526,18 +1528,17 @@ def get_users_params(**kwargs): import http.cookies import sql cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) - user_uuid = cookie.get('uuid') + try: + user_uuid = cookie.get('uuid') user = sql.get_user_name_by_uuid(user_uuid.value) role = sql.get_user_role_by_uuid(user_uuid.value) user_id = sql.get_user_id_by_uuid(user_uuid.value) user_services = sql.select_user_services(user_id) token = sql.get_token(user_uuid.value) except: - user = '' - role = '' - user_services = '' - token = '' + print('') + if kwargs.get('virt') and kwargs.get('haproxy'): servers = sql.get_dick_permit(virt=1, haproxy=1) elif kwargs.get('virt'): diff --git a/app/sql.py b/app/sql.py index 7cf50765..fc84cd89 100644 --- a/app/sql.py +++ b/app/sql.py @@ -135,7 +135,7 @@ def add_setting_for_new_group(group_id): {'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main', 'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. The path must be valid', 'group': group_id}, - {'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/access.log', 'section': 'haproxy', + {'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/', 'section': 'haproxy', 'desc': 'The default local path for saving logs', 'group': group_id}, {'param': 'syslog_server_enable', 'value': '0', 'section': 'logs', 'desc': 'Enable getting logs from a syslog server; (0 - no, 1 - yes)', 'group': group_id}, @@ -159,7 +159,7 @@ def add_setting_for_new_group(group_id): 'desc': 'Path to the HAProxy sock file', 'group': group_id}, {'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'Socket port for HAProxy', 'group': group_id}, - {'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx', + {'param': 'nginx_path_logs', 'value': '/var/log/nginx/', 'section': 'nginx', 'desc': 'Nginx error log', 'group': group_id}, {'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for accessing Nginx stats page', 'group': group_id}, @@ -169,7 +169,7 @@ def add_setting_for_new_group(group_id): 'group': group_id}, {'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx', 'group': group_id}, - {'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx', + {'param': 'nginx_dir', 'value': '/etc/nginx/', 'section': 'nginx', 'desc': 'Path to the Nginx directory with config files', 'group': group_id}, {'param': 'nginx_config_path', 'value': '/etc/nginx/nginx.conf', 'section': 'nginx', 'desc': 'Path to the main Nginx configuration file', 'group': group_id}, @@ -738,18 +738,19 @@ def get_slack_by_id(slack_id): def get_dick_permit(**kwargs): - import http.cookies import os if kwargs.get('username'): grp = kwargs.get('group_id') else: try: + import http.cookies cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) group = cookie.get('group') grp = group.value except Exception as e: - print('error: ' + str(e)) + print('') + return if kwargs.get('token'): token = kwargs.get('token') else: @@ -779,11 +780,14 @@ def get_dick_permit(**kwargs): if funct.check_user_group(token=token): cursor = conn.cursor() - if grp == '1' and not only_group: - sql = """ select * from servers where {} {} {} {} {} {} order by pos""" .format(disable, type_ip, nginx, haproxy, keepalived, ip) - else: - sql = """ select * from servers where groups = '{group}' and ({disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos - """.format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived) + try: + if grp == '1' and not only_group: + sql = """ select * from servers where {} {} {} {} {} {} order by pos""" .format(disable, type_ip, nginx, haproxy, keepalived, ip) + else: + sql = """ select * from servers where groups = '{group}' and ({disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos + """.format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived) + except Exception: + print('') try: cursor.execute(sql) except Exception as e: diff --git a/app/templates/ajax/overivewWaf.html b/app/templates/ajax/overivewWaf.html index 2db67569..c40c442f 100644 --- a/app/templates/ajax/overivewWaf.html +++ b/app/templates/ajax/overivewWaf.html @@ -58,10 +58,13 @@ Open {% endif %} + + View + {% else %} {% if role <= 2 %} - + {% endif %}