Commit dd076c21 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add safety check on job dependency/TIsLength



If TIsLength is applied to a non-container item, it will fail (type
error) due to invalid application of len(). Since this can happen on
user-supplied data, we add an explicit TList/TTuple check (the TTuple
test is a new one).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 4a826364
......@@ -259,6 +259,14 @@ def TList(val):
return isinstance(val, list)
@WithDesc("Tuple")
def TTuple(val):
"""Checks if the given value is a tuple.
"""
return isinstance(val, tuple)
@WithDesc("Dictionary")
def TDict(val):
"""Checks if the given value is a dictionary.
......
......@@ -554,7 +554,8 @@ def _BuildJobDepCheck(relative):
job_id = ht.TJobId
job_dep = \
ht.TAnd(ht.TIsLength(2),
ht.TAnd(ht.TOr(ht.TList, ht.TTuple),
ht.TIsLength(2),
ht.TItems([job_id,
ht.TListOf(ht.TElemOf(constants.JOBS_FINALIZED))]))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment