fix(deploy): unauth health poll, validate-before-gate, fullmatch names, reload-only-on-ok
This commit is contained in:
@@ -16,7 +16,7 @@ def _path(name):
|
|||||||
"""Resolve a profile name to its directory. HTTP-supplied names are never
|
"""Resolve a profile name to its directory. HTTP-supplied names are never
|
||||||
trusted: reject anything but [A-Za-z0-9._-]{1,64} and explicitly refuse
|
trusted: reject anything but [A-Za-z0-9._-]{1,64} and explicitly refuse
|
||||||
'.'/'..' so traversal can never escape PROFILES_DIR."""
|
'.'/'..' so traversal can never escape PROFILES_DIR."""
|
||||||
if not isinstance(name, str) or not NAME_RE.match(name) \
|
if not isinstance(name, str) or not NAME_RE.fullmatch(name) \
|
||||||
or name in ('.', '..'):
|
or name in ('.', '..'):
|
||||||
raise ValueError('invalid profile name')
|
raise ValueError('invalid profile name')
|
||||||
return os.path.join(PROFILES_DIR, name)
|
return os.path.join(PROFILES_DIR, name)
|
||||||
|
|||||||
@@ -4899,13 +4899,15 @@ def h_profile_restore(ctx):
|
|||||||
name = (body.get('name') or '').strip()
|
name = (body.get('name') or '').strip()
|
||||||
if not name:
|
if not name:
|
||||||
return 400, {'error': 'profile name is required'}
|
return 400, {'error': 'profile name is required'}
|
||||||
mk8_gate.enter('restore_profile')
|
|
||||||
try:
|
try:
|
||||||
result = mk8_profiles.restore(name)
|
mk8_profiles._path(name)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
return 400, {'error': str(exc)}
|
return 400, {'error': str(exc)}
|
||||||
device_run(['wifi', 'reload'], timeout=45)
|
mk8_gate.enter('restore_profile')
|
||||||
|
result = mk8_profiles.restore(name)
|
||||||
ok = bool(result.get('ok'))
|
ok = bool(result.get('ok'))
|
||||||
|
if ok:
|
||||||
|
device_run(['wifi', 'reload'], timeout=45)
|
||||||
try:
|
try:
|
||||||
mk8_events.log_event('profile_restore',
|
mk8_events.log_event('profile_restore',
|
||||||
sev='info' if ok else 'warn',
|
sev='info' if ok else 'warn',
|
||||||
|
|||||||
+1
-1
@@ -247,7 +247,7 @@ chmod 755 /etc/init.d/mk8-guard
|
|||||||
i=0
|
i=0
|
||||||
HEALTH_OK=''
|
HEALTH_OK=''
|
||||||
while [ \$i -lt 60 ]; do
|
while [ \$i -lt 60 ]; do
|
||||||
if curl -fsS -m 3 http://127.0.0.1:8080/api/api_ping >/dev/null 2>&1; then
|
if curl -fsS -m 3 http://127.0.0.1:8080/ >/dev/null 2>&1; then
|
||||||
HEALTH_OK=1
|
HEALTH_OK=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user