Skip to content

Commit 06e7f4c

Browse files
CopilotBukeLy
andcommitted
chore: harden whitelist parsing
Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
1 parent d58812d commit 06e7f4c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

agent-sdk-client/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def extract_command(text: Optional[str]) -> Optional[str]:
1919
if not trimmed.startswith('/'):
2020
return None
2121

22-
command = trimmed.split()[0]
22+
parts = trimmed.split()
23+
if not parts:
24+
return None
25+
26+
command = parts[0]
2327
if '@' in command:
2428
command = command.split('@', 1)[0]
2529
return command or None
@@ -36,7 +40,7 @@ def load_command_whitelist(config_path: Path = DEFAULT_CONFIG_PATH) -> list[str]
3640
whitelist = data.get('white_list_commands', {}).get('whitelist', [])
3741
if isinstance(whitelist, list):
3842
return [cmd for cmd in whitelist if isinstance(cmd, str)]
39-
except Exception as exc: # pragma: no cover - defensive logging
43+
except (OSError, tomllib.TOMLDecodeError) as exc: # pragma: no cover - defensive logging
4044
logger.warning(f"Failed to load command whitelist: {exc}")
4145
return []
4246

0 commit comments

Comments
 (0)