v1.0.54: fix 4 audit bugs — _client auto-detect, _find_uid by key, tracker_add before params, flock LOCK_NB

This commit is contained in:
2026-07-27 10:18:49 +04:00
parent f546f41f21
commit 338c080254
6 changed files with 126 additions and 33 deletions
+2 -20
View File
@@ -1,6 +1,6 @@
from flask import Blueprint, current_app, render_template, request, make_response, jsonify
from api.http_client import HttpClient
from api.http_client import HttpClient, detect_endpoint
from operations.get_instances import get_organization, get_instances
from operations.get_services import get_services, get_service_detail
from operations.tracker import list_all as tracker_list
@@ -8,24 +8,6 @@ from runner import load_config
bp = Blueprint("main", __name__)
STANDS = [
"https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc",
"https://lk-api-gateway-test.ngcloud.ru/api/v1/svc",
]
def _detect_endpoint(token):
"""Пробуем токен против dev и test стендов, возвращаем рабочий URL."""
for ep in STANDS:
try:
c = HttpClient(ep, token)
data = c.get("/instances", params={"pageSize": 1, "page": 1})
if data.get("results") is not None:
return ep
except Exception:
continue
return None
def _mask(s):
if not s or len(s) < 8:
@@ -113,7 +95,7 @@ def index():
instance_groups = {}
config = {}
if active_token:
endpoint = _detect_endpoint(active_token)
endpoint = detect_endpoint(active_token)
if endpoint:
try:
client = HttpClient(endpoint, active_token)