mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] re-put forbidding some chars in passwords
This commit is contained in:
parent
49b9146065
commit
2eb5f6b6da
2 changed files with 23 additions and 1 deletions
|
@ -2470,6 +2470,7 @@ class PasswordArgumentParser(YunoHostArgumentFormatParser):
|
|||
hide_user_input_in_prompt = True
|
||||
argument_type = "password"
|
||||
default_value = ""
|
||||
forbidden_chars = "{}"
|
||||
|
||||
def parse_question(self, question, user_answers):
|
||||
question = super(PasswordArgumentParser, self).parse_question(question, user_answers)
|
||||
|
@ -2479,6 +2480,12 @@ class PasswordArgumentParser(YunoHostArgumentFormatParser):
|
|||
|
||||
return question
|
||||
|
||||
def _post_parse_value(self, question):
|
||||
if any(char in question.value for char in self.forbidden_chars):
|
||||
raise YunohostError('pattern_password_app', forbidden_chars=self.forbidden_chars)
|
||||
|
||||
return super(PasswordArgumentParser, self)._post_parse_value(question)
|
||||
|
||||
|
||||
class PathArgumentParser(YunoHostArgumentFormatParser):
|
||||
argument_type = "path"
|
||||
|
|
|
@ -8,7 +8,7 @@ from collections import OrderedDict
|
|||
from moulinette import msignals
|
||||
|
||||
from yunohost import domain, user, app
|
||||
from yunohost.app import _parse_args_in_yunohost_format
|
||||
from yunohost.app import _parse_args_in_yunohost_format, PasswordArgumentParser
|
||||
from yunohost.utils.error import YunohostError
|
||||
|
||||
|
||||
|
@ -359,6 +359,21 @@ def test_parse_args_in_yunohost_format_password_input_test_ask_with_help():
|
|||
assert help_text in prompt.call_args[0][0]
|
||||
|
||||
|
||||
def test_parse_args_in_yunohost_format_password_bad_chars():
|
||||
questions = [
|
||||
{
|
||||
"name": "some_password",
|
||||
"type": "password",
|
||||
"ask": "some question",
|
||||
"example": "some_value",
|
||||
}
|
||||
]
|
||||
|
||||
for i in PasswordArgumentParser.forbidden_chars:
|
||||
with pytest.raises(YunohostError):
|
||||
_parse_args_in_yunohost_format({"some_password": i * 8}, questions)
|
||||
|
||||
|
||||
def test_parse_args_in_yunohost_format_path():
|
||||
questions = [{"name": "some_path", "type": "path",}]
|
||||
answers = {"some_path": "some_value"}
|
||||
|
|
Loading…
Add table
Reference in a new issue