MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / _validate_command_list

Function _validate_command_list

security.py:482–511  ·  view source on GitHub ↗

Validate a list of command entries from a YAML config. Each entry must be a dict with a non-empty string 'name' field. Used by both load_org_config() and load_project_commands() to avoid duplicating the same validation logic. Args: commands: List of command entries to

(commands: list, config_path: Path, field_name: str)

Source from the content-addressed store, hash-verified

480
481
482def _validate_command_list(commands: list, config_path: Path, field_name: str) -> bool:
483 """
484 Validate a list of command entries from a YAML config.
485
486 Each entry must be a dict with a non-empty string 'name' field.
487 Used by both load_org_config() and load_project_commands() to avoid
488 duplicating the same validation logic.
489
490 Args:
491 commands: List of command entries to validate
492 config_path: Path to the config file (for log messages)
493 field_name: Name of the YAML field being validated (e.g., 'allowed_commands', 'commands')
494
495 Returns:
496 True if all entries are valid, False otherwise
497 """
498 if not isinstance(commands, list):
499 logger.warning(f"Config at {config_path}: '{field_name}' must be a list")
500 return False
501 for i, cmd in enumerate(commands):
502 if not isinstance(cmd, dict):
503 logger.warning(f"Config at {config_path}: {field_name}[{i}] must be a dict")
504 return False
505 if "name" not in cmd:
506 logger.warning(f"Config at {config_path}: {field_name}[{i}] missing 'name'")
507 return False
508 if not isinstance(cmd["name"], str) or cmd["name"].strip() == "":
509 logger.warning(f"Config at {config_path}: {field_name}[{i}] has invalid 'name'")
510 return False
511 return True
512
513
514def _validate_pkill_processes(config: dict, config_path: Path) -> Optional[list[str]]:

Callers 2

load_org_configFunction · 0.85
load_project_commandsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected