Skip to content

Commit

Permalink
Fix the checksum type check
Browse files Browse the repository at this point in the history
It incorrectly returned valid for a `list` of alternative checksums
while it must be a `tuple`. The `None` case was missed and due to the
unrestricted `tuple` elem_type it may return valid for actually invalid
entries. So restrict to tuples of strings which are valid at that point
but that may wrongly return invalid. But in that case the conversion
function will be called which does more elaborate verification for those
cases.
  • Loading branch information
Flamefire committed Jan 6, 2023
1 parent 6adfa5d commit 8cec17f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions easybuild/framework/easyconfig/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,28 @@ def ensure_iterable_license_specs(specs):
}))
# checksums is a list of checksums, one entry per file (source/patch)
# each entry can be:
# None
# a single checksum value (string)
# a single checksum value of a specified type (2-tuple, 1st element is checksum type, 2nd element is checksum)
# a list of checksums (of different types, perhaps different formats), which should *all* be valid
# a dictionary with a mapping from filename to checksum value
CHECKSUM_LIST = (list, as_hashable({'elem_types': [str, tuple, STRING_DICT]}))
CHECKSUMS = (list, as_hashable({'elem_types': [str, tuple, STRING_DICT, CHECKSUM_LIST]}))
# a tuple of checksums (of different types, perhaps different formats), which should *all* be valid
# a dictionary with a mapping from filename to checksum (None, value, type&value, alternatives)
#
# For simplicity we only allow the case(s) where the tuple consists only of strings
# and leave further verification to the to_checksums function
CHECKSUM_DICT = (dict, as_hashable(
{
'elem_types': [type(None), str, TUPLE_OF_STRINGS],
'key_types': [str],
}
))
CHECKSUMS = (list, as_hashable({'elem_types': [type(None), str, TUPLE_OF_STRINGS, CHECKSUM_DICT]}))

CHECKABLE_TYPES = [CHECKSUM_LIST, CHECKSUMS, DEPENDENCIES, DEPENDENCY_DICT, LIST_OF_STRINGS,
CHECKABLE_TYPES = [CHECKSUM_DICT, CHECKSUMS, DEPENDENCIES, DEPENDENCY_DICT, LIST_OF_STRINGS,
SANITY_CHECK_PATHS_DICT, STRING_DICT, STRING_OR_TUPLE_LIST, STRING_OR_TUPLE_OR_DICT_LIST,
TOOLCHAIN_DICT, TUPLE_OF_STRINGS]

# easy types, that can be verified with isinstance
EASY_TYPES = [string_type, bool, dict, int, list, str, tuple]
EASY_TYPES = [string_type, bool, dict, int, list, str, tuple, type(None)]

# type checking is skipped for easyconfig parameters names not listed in PARAMETER_TYPES
PARAMETER_TYPES = {
Expand Down

0 comments on commit 8cec17f

Please sign in to comment.