mirror of https://github.com/razor-ai/soup.git
fix: validate model name before ollama rm (security review finding)
Add validate_model_name() check in deploy --remove path to prevent passing unsanitized names to ollama rm subprocess. Adds test coverage.
This commit is contained in:
parent
f98519ef87
commit
ba7a6b1ee1
|
|
@ -99,6 +99,11 @@ def ollama(
|
|||
|
||||
# --- Remove mode ---
|
||||
if remove:
|
||||
valid_name, name_err = validate_model_name(remove)
|
||||
if not valid_name:
|
||||
console.print(f"[red]Invalid model name:[/] {name_err}")
|
||||
raise typer.Exit(1)
|
||||
|
||||
version = detect_ollama()
|
||||
if not version:
|
||||
console.print("[red]Ollama not found.[/] Install from https://ollama.com")
|
||||
|
|
|
|||
|
|
@ -469,6 +469,14 @@ def test_deploy_remove_failure(mock_rm, mock_detect):
|
|||
assert "not found" in result.output.lower()
|
||||
|
||||
|
||||
def test_deploy_remove_invalid_name():
|
||||
result = runner.invoke(
|
||||
app, ["deploy", "ollama", "--remove", "bad/name", "--yes"]
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
assert "invalid" in result.output.lower()
|
||||
|
||||
|
||||
@patch(f"{_OLLAMA}.detect_ollama", return_value=None)
|
||||
def test_deploy_remove_no_ollama(mock_detect):
|
||||
result = runner.invoke(app, ["deploy", "ollama", "--remove", "soup-test", "--yes"])
|
||||
|
|
|
|||
Loading…
Reference in New Issue