mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Validate client_config path expression
This commit is contained in:
parent
b567f565d9
commit
95ad90063b
1 changed files with 5 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
import subprocess
|
||||
import re
|
||||
|
||||
def configs():
|
||||
#ignore symlinks, because wg0.conf is in production the main config, but in insiders it is a symlink
|
||||
|
@ -19,6 +20,10 @@ def client_config_active():
|
|||
return(active_config[1])
|
||||
|
||||
def client_config_list(client_config):
|
||||
pattern = r'^[a-zA-Z0-9_-]+$'
|
||||
if not re.match(pattern, client_config):
|
||||
raise ValueError("Invalid client_config")
|
||||
|
||||
config_path = f"/etc/wireguard/{client_config}"
|
||||
try:
|
||||
with open(config_path, 'r') as f:
|
||||
|
|
Loading…
Reference in a new issue