Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module_params_get*: Fail on empty string in string list parameters #779

Conversation

t-woerner
Copy link
Member

So far it is possible to pass list parameters with empty strings to the
modules. The use of empty strings in list does not make a lot of sense,
though. The simple solution is to add a check to module_params_get for
empty strings in returned lists.

module_params_get_lowercase has been changed to use module_params_get to
have one place to add the check.

@t-woerner t-woerner force-pushed the module_params_get_fail_empty_str_in_list branch 2 times, most recently from efebe5a to e5dfb4e Compare February 22, 2022 14:11
Copy link
Collaborator

@varunmylaraiah varunmylaraiah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triggered Downstream tests with this PR pipelines#1722057

@varunmylaraiah
Copy link
Collaborator

varunmylaraiah commented Feb 23, 2022

@t-woerner
Changes are required in the downstream tests for the below modules.

  1. Config Module : pac_type and auth_type
  2. Service Module: pac_type
  3. User Module : sshpubkey
  4. Automount Module : empty description.
    I will fix those.

@rjeffman
Copy link
Member

rjeffman commented Feb 23, 2022

This PR would not fix this issue:

4. Automount Module : empty description.

See PR #754 which is a draft that aims to fix this specific issue.

@t-woerner t-woerner force-pushed the module_params_get_fail_empty_str_in_list branch from fc1d5c5 to 0f2965b Compare February 23, 2022 19:04
So far it is possible to pass list parameters with empty strings to the
modules. The use of empty strings in list does not make a lot of sense,
though. The simple solution is to add a check to module_params_get for
empty strings in returned lists.

The option allow_empty_string can be set to True to allow an empty string
in the list with a list len of 1. The option defaults to False. It is
needed for some parameters the modules, like for example userauthtype in
the user module. It is using "" to reset to the default value.

module_params_get_lowercase has been changed to use module_params_get to
have one place to add the check.

Due to an issue in Ansible it is possible to use the empty string "" for
lists with choices, even if the empty list is not part of the choices.
Ansible issue ansible/ansible#77108
The parameters userauthtype and sshpubkey allowing to use "" to reset to
the default value.

The new check in params_get is not allowing to use empty strings in lists,
therefore allow_empty_string=True had to be added to the call.

A test has been added to verify that the empty strings are supported and
working. An idempotency issue with sshpubkey has been found with the test
and fixed additionally.
@t-woerner t-woerner force-pushed the module_params_get_fail_empty_str_in_list branch from 0f2965b to 7219161 Compare February 24, 2022 12:05
@t-woerner t-woerner force-pushed the module_params_get_fail_empty_str_in_list branch 2 times, most recently from df552e5 to 1317701 Compare February 24, 2022 13:14
The parameters auth_ind and pac_type are allowing to use "" to reset to
the default value.

The new check in params_get is not allowing to use empty strings in lists,
therefore allow_empty_string=True had to be added to the call.

A test has been added to verify that the empty strings are supported and
working. An idempotency issue with pac_type has been found with the test
and fixed additionally.
The parameter auth_ind is allowing to use "" to reset to the default
value.

The new check in params_get is not allowing to use empty strings in lists,
therefore allow_empty_string=True had to be added to the call.

A test has been added to verify that the empty strings are supported and
working.
@t-woerner t-woerner force-pushed the module_params_get_fail_empty_str_in_list branch from 1317701 to 3a342b8 Compare February 25, 2022 17:42
…gstring

The parameters user_auth_type, pac_type and configstring are allowing to
use "" to reset to the default value or for configstring to set an empty
list.

The new check in params_get is not allowing to use empty strings in lists,
therefore allow_empty_string=True had to be added to the call.

A test has been added to verify that the empty strings are supported and
working.

Additionally empty pac_type, user_auth_type and domain_resolution_order
have been added to exit_args as if they have not been set.
@t-woerner t-woerner force-pushed the module_params_get_fail_empty_str_in_list branch from 3a342b8 to e30bcfd Compare February 28, 2022 12:13
Copy link
Member

@rjeffman rjeffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@varunmylaraiah
Copy link
Collaborator

LGTM

@varunmylaraiah varunmylaraiah merged commit f0a71ed into freeipa:master Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants