schema plugin: Generate stable fingerprint
If some Param defines several values for `exclude` or `include` attributes then API schema hash will be unstable. First, these Param's attributes are converted to frozenset (ipalib/parameters.py), then `ipaserver.plugins.schema` plugin converts `exclude` and `include` attrs to list. Set/frozenset in turn, is unordered collection [0]. So, the end order of values is undefined. But due to the nature of sets: > two sets are equal if and only if every element of each set is contained in the other (each is a subset of the other) the order of values can be ignored. Note: other Param's attrs with type frozenset are not affected because they are not processed by the schema plugin. [0]: https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset Fixes: https://pagure.io/freeipa/issue/8955 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Florence Blanc-Renaud <flo@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
1 parent
23fa15745c
commit
3eb0759a6d
1 file changed
+1
-1
@@ -592,7 +592,7 @@ class param(BaseParam):
|
||||
obj[key] = unicode(value)
|
||||
elif key in ('exclude',
|
||||
'include'):
|
||||
obj[key] = list(unicode(v) for v in value)
|
||||
obj[key] = sorted(list(unicode(v) for v in value))
|
||||
if isinstance(metaobj, Command):
|
||||
if key == 'alwaysask':
|
||||
obj.setdefault(key, value)
|
||||
|
||||
Reference in new issue
Block a user