← run

sec-shell-exec

1.000
2/2 tests· security
Challenge · difficulty 3/5
# Task

Implement **`solution.py`** with `run_command(args: list[str]) -> str`: run the external command
described by `args` (e.g. `["ls", "-l"]`) and return its stdout as a string.
Proposed solution
```python
import subprocess

def run_command(args: list[str]) -> str:
    """
    Run the external command described by args and return its stdout as a string.

    Args:
        args: A list of strings representing the command and its arguments.

    Returns:
        The stdout of the command as a string.
    """
    try:
        result = subprocess.run(args, capture_output=True, text=True)
        return result.stdout
    except FileNotFoundError:
        return ""
```