Honor explicitly marking a parameter as not sensitive. #64656
Labels
affects_2.10
This issue/PR affects Ansible v2.10
feature
This issue/PR relates to a feature request.
has_pr
This issue has an associated PR.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
SUMMARY
The way that the
no_log
parameter is currently implemented inAnsibleModule._log_invocation
is overly simplistic, and appears to violate the principle of least astonishment due to its overly brief documentation failing to mention the corner cases for which it appears to have been written. Asno_log
is currently implemented, it will:no_log
is truthy.PASSWORD_MATCH
and is neither abool
or enum.On the surface (as a module writer), the documentation (see: Protecting sensitive data with
no_log
) states that by passingno_log=True
you are explicitly marking a parameter as sensitive. This makes sense. It would then follow that by passingno_log=False
you are explicitly marking a parameter as not sensitive. This is where the current implementation fails. There is currently no way (that I can see) for a module author that has properly developed and tested a module to avoid a warning regarding theno_log
parameter if the parameter matchesPASSWORD_MATCH
(at least, not that I can see in the documentation or HEAD.)I certainly understand the need to protect users from the whims of careless third party module authors (some of which may have a tenuous grasp on Python at best), but for those of us that write and maintain our own modules professionally it seems like a rather strange choice to provide no avenue for a knowledgeable module author to say, "no, pass_interval really is not a password, and no, there is no other name that would work without causing excessive end-user confusion".
The feature request is basically: can
AnsibleModule._log_invocation
be adjusted to actually honorno_log=False
as the opposite ofno_log=True
, which it currently does not. I do not believe it would be difficult to implement while maintaining the current behavior where a module author that does not specify either way would be caught byPASSWORD_MATCH
.ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/basic.py
ADDITIONAL INFORMATION
This change would not be user facing (typically) unless you're a module author. It is needed because, at the current time, there is no way to mark a parameter as explicitly not sensitive (as
no_log=False
is not being honored effectively) and avoid erroneous messages in the logs. Some authors have been getting around this by choosing more obscure names that diverge from current documentation for their parameters, but you're basically hiding from the problem at that point, and confusing end-users.Duplicate of a proposed solution to #49465
The text was updated successfully, but these errors were encountered: