strutils.mask_dict_password should accept collections.Mappings

Bug #1804528 reported by John Dennis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.utils
Fix Released
Medium
Ben Nemec

Bug Description

This test at the head of mask_dict_password:

    if not isinstance(dictionary, dict):
        raise TypeError("Expected a dictionary, got %s instead."
                        % type(dictionary))

Is too restrictive, it should accept any mapping object. It is not necessary for the dictionary to be mutable (unlike a dict) because mask_dict_password() copies the key/value pairs instead of modifying them. Thus the test should be:

    if not isinstance(dictionary, collections.Mapping):

Note, both of these statements below return True

isinstance({}, collections.Mapping) => True
isinstance({}, collections.MutableMapping) => True

Ben Nemec (bnemec)
Changed in oslo.utils:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.utils (master)

Fix proposed to branch: master
Review: https://review.openstack.org/620686

Changed in oslo.utils:
assignee: nobody → Ben Nemec (bnemec)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.utils (master)

Reviewed: https://review.openstack.org/620686
Committed: https://git.openstack.org/cgit/openstack/oslo.utils/commit/?id=ddc436925887b6ece4aba19a36e53ede0b22ae21
Submitter: Zuul
Branch: master

commit ddc436925887b6ece4aba19a36e53ede0b22ae21
Author: Ben Nemec <email address hidden>
Date: Wed Nov 28 19:38:48 2018 +0000

    Support non-dict mappings in mask_dict_password

    mask_dict_password doesn't actually have a dependency on the dict
    type specifically. It can work on any subclass of collections.Mapping.
    This changes the isinstance check to reflect that and adds a unit
    test using a collections.Mapping subclass.

    Change-Id: I28781acf027b9b34f8274196db5dd4d2a9adc9ba
    Closes-Bug: 1804528

Changed in oslo.utils:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.utils 3.40.0

This issue was fixed in the openstack/oslo.utils 3.40.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.