mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
gitweb: Validate repository name also in actions script
This prevents writing to an arbitrary directory if running actions script as a root user. - Included tests for invalid names Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil@medhas.org Parametrize the test case] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
0b2d1265cb
commit
ba9869c030
3 files changed
+39
-5
No files matched your search
@@ -24,6 +24,7 @@ import pathlib
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from django.forms import ValidationError
|
||||
|
||||
|
||||
def _action_file():
|
||||
@@ -91,3 +92,15 @@ def test_actions(call_action):
|
||||
call_action(['delete-repo', '--name', repo_renamed])
|
||||
with pytest.raises(RuntimeError, match='Repository not found'):
|
||||
call_action(['repo-info', '--name', repo_renamed])
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'name',
|
||||
['.Test-repo', 'Test-repo.git.git', '/root/Test-repo', 'Test-repö'])
|
||||
def test_action_create_repo_with_invalid_names(call_action, name):
|
||||
"""Test that creating repository with invalid names fails."""
|
||||
with pytest.raises(ValidationError):
|
||||
call_action([
|
||||
'create-repo', '--name', name, '--description', '', '--owner', '',
|
||||
'--keep-ownership'
|
||||
])
|
||||
Reference in new issue
Block a user