Initial project import
This commit is contained in:
@@ -49,7 +49,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._json(404, {"status": "not_found"})
|
||||
|
||||
def do_POST(self) -> None: # noqa: N802
|
||||
if self.path != "/repository/execute":
|
||||
if self.path not in {"/repository/execute", "/configuration/activation/debug"}:
|
||||
self._json(404, {"status": "not_found"})
|
||||
return
|
||||
if not authorized(self.headers.get("Authorization", "")):
|
||||
@@ -66,6 +66,61 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._json(400, {"status": "invalid_request", "message": str(exc)})
|
||||
return
|
||||
base_id = str(payload.get("base_id") or "").strip()
|
||||
if self.path == "/configuration/activation/debug":
|
||||
layer = str(payload.get("layer") or "all").strip()
|
||||
mode = str(payload.get("mode") or "debug").strip().casefold()
|
||||
request_id = str(payload.get("request_id") or "").strip()
|
||||
fingerprint = str(payload.get("fingerprint") or "").strip().casefold()
|
||||
if not base_id or layer not in {"all", "base_saved_state", "extension_saved_state"} or mode != "debug":
|
||||
self._json(
|
||||
400,
|
||||
{
|
||||
"status": "invalid_request",
|
||||
"message": "base_id, a supported layer, and mode=debug are required",
|
||||
},
|
||||
)
|
||||
return
|
||||
if bool(request_id) != bool(fingerprint) or (
|
||||
request_id
|
||||
and (
|
||||
not request_id.startswith("actreq-")
|
||||
or len(request_id) != len("actreq-") + 32
|
||||
or any(char not in "0123456789abcdef" for char in request_id[len("actreq-"):].casefold())
|
||||
or len(fingerprint) != 64
|
||||
or any(char not in "0123456789abcdef" for char in fingerprint)
|
||||
)
|
||||
):
|
||||
self._json(
|
||||
400,
|
||||
{
|
||||
"status": "invalid_request",
|
||||
"message": "request_id and a 64-hex fingerprint must be supplied together",
|
||||
},
|
||||
)
|
||||
return
|
||||
config, error = repository_control.repository_config(base_id)
|
||||
if error:
|
||||
self._json(400, error)
|
||||
return
|
||||
if (config.get("runner") or {}).get("kind") != "local":
|
||||
self._json(
|
||||
400,
|
||||
{
|
||||
"status": "invalid_config",
|
||||
"message": "Windows runner base configuration must use runner.kind=local",
|
||||
},
|
||||
)
|
||||
return
|
||||
result = repository_control.activation_debug_probe(
|
||||
base_id,
|
||||
config,
|
||||
layer=layer,
|
||||
timeout_seconds=10,
|
||||
request_id=request_id,
|
||||
fingerprint=fingerprint,
|
||||
)
|
||||
self._json(200 if result.get("status") in {"ready", "not_ready"} else 409, result)
|
||||
return
|
||||
action = str(payload.get("action") or "").strip().casefold()
|
||||
objects = payload.get("objects") or []
|
||||
if not base_id or action not in {"report", "lock", "unlock", "commit"}:
|
||||
|
||||
Reference in New Issue
Block a user