mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Validate client_config path expression
This commit is contained in:
parent
b567f565d9
commit
95ad90063b
@ -1,4 +1,5 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
def configs():
|
def configs():
|
||||||
#ignore symlinks, because wg0.conf is in production the main config, but in insiders it is a symlink
|
#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])
|
return(active_config[1])
|
||||||
|
|
||||||
def client_config_list(client_config):
|
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}"
|
config_path = f"/etc/wireguard/{client_config}"
|
||||||
try:
|
try:
|
||||||
with open(config_path, 'r') as f:
|
with open(config_path, 'r') as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user