Increase security and reformat
This commit is contained in:
@@ -40,13 +40,21 @@ class ClaudeCLITaskProvider(TaskProvider):
|
||||
return True
|
||||
if "unrecognized subcommand 'create'" in text and "usage: claude" in text:
|
||||
return True
|
||||
if "unrecognized subcommand 'append_update'" in text and "usage: claude" in text:
|
||||
if (
|
||||
"unrecognized subcommand 'append_update'" in text
|
||||
and "usage: claude" in text
|
||||
):
|
||||
return True
|
||||
if "unrecognized subcommand 'mark_complete'" in text and "usage: claude" in text:
|
||||
if (
|
||||
"unrecognized subcommand 'mark_complete'" in text
|
||||
and "usage: claude" in text
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _builtin_stub_result(self, op: str, payload: dict, stderr: str) -> ProviderResult:
|
||||
def _builtin_stub_result(
|
||||
self, op: str, payload: dict, stderr: str
|
||||
) -> ProviderResult:
|
||||
mode = str(payload.get("mode") or "default").strip().lower()
|
||||
external_key = (
|
||||
str(payload.get("external_key") or "").strip()
|
||||
@@ -117,7 +125,10 @@ class ClaudeCLITaskProvider(TaskProvider):
|
||||
cwd=workspace if workspace else None,
|
||||
)
|
||||
stderr_probe = str(completed.stderr or "").lower()
|
||||
if completed.returncode != 0 and "unexpected argument '--op'" in stderr_probe:
|
||||
if (
|
||||
completed.returncode != 0
|
||||
and "unexpected argument '--op'" in stderr_probe
|
||||
):
|
||||
completed = subprocess.run(
|
||||
fallback_cmd,
|
||||
capture_output=True,
|
||||
@@ -133,7 +144,9 @@ class ClaudeCLITaskProvider(TaskProvider):
|
||||
payload={"op": op, "timeout_seconds": command_timeout},
|
||||
)
|
||||
except Exception as exc:
|
||||
return ProviderResult(ok=False, error=f"claude_cli_exec_error:{exc}", payload={"op": op})
|
||||
return ProviderResult(
|
||||
ok=False, error=f"claude_cli_exec_error:{exc}", payload={"op": op}
|
||||
)
|
||||
|
||||
stdout = str(completed.stdout or "").strip()
|
||||
stderr = str(completed.stderr or "").strip()
|
||||
@@ -172,7 +185,12 @@ class ClaudeCLITaskProvider(TaskProvider):
|
||||
out_payload.update(parsed)
|
||||
if (not ok) and self._is_task_sync_contract_mismatch(stderr):
|
||||
return self._builtin_stub_result(op, dict(payload or {}), stderr)
|
||||
return ProviderResult(ok=ok, external_key=ext, error=("" if ok else stderr[:4000]), payload=out_payload)
|
||||
return ProviderResult(
|
||||
ok=ok,
|
||||
external_key=ext,
|
||||
error=("" if ok else stderr[:4000]),
|
||||
payload=out_payload,
|
||||
)
|
||||
|
||||
def healthcheck(self, config: dict) -> ProviderResult:
|
||||
command = self._command(config)
|
||||
@@ -193,7 +211,11 @@ class ClaudeCLITaskProvider(TaskProvider):
|
||||
"stdout": str(completed.stdout or "").strip()[:1000],
|
||||
"stderr": str(completed.stderr or "").strip()[:1000],
|
||||
},
|
||||
error=("" if completed.returncode == 0 else str(completed.stderr or "").strip()[:1000]),
|
||||
error=(
|
||||
""
|
||||
if completed.returncode == 0
|
||||
else str(completed.stderr or "").strip()[:1000]
|
||||
),
|
||||
)
|
||||
|
||||
def create_task(self, config: dict, payload: dict) -> ProviderResult:
|
||||
|
||||
Reference in New Issue
Block a user