Skip to content

Commit

Permalink
feat(helper.py): Better allow/deny list debug
Browse files Browse the repository at this point in the history
In some situations we need better debug on allow/deny list

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Jan 13, 2025
1 parent 71538f8 commit 14d371f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions kernelci/api/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _is_allowed(self, rules, key, node, parent):

for item in base[key]:
if item in deny:
print(f"rules: {key.capitalize()} {item} not allowed")
print(f"rules{key}: {key.capitalize()} {item} not allowed due {deny}")
return False
if item in allow:
found = True
Expand All @@ -187,7 +187,7 @@ def _is_allowed(self, rules, key, node, parent):

else:
if base[key] in deny or (len(allow) > 0 and base[key] not in allow):
print(f"rules: {key.capitalize()} {base[key]} not allowed")
print(f"rule[{key}]: {key.capitalize()} {base[key]} not allowed due {deny}")
return False

return True
Expand Down Expand Up @@ -273,10 +273,15 @@ def _is_tree_branch_allowed(self, node, rules):
return False

# Get back to regular allow/deny list processing
if (node[key] in deny or
(len(allow) == 0 and len(allow_combos) > 0) or
(len(allow) > 0 and node[key] not in allow)):
print(f"{key.capitalize()} {node[key]} not allowed")
if (node[key] in deny):
print(f"{key.capitalize()} {node[key]} not allowed due {deny}")
return False
if (len(allow) == 0 and len(allow_combos) > 0):
print(f"{key.capitalize()} {node[key]} not allowed due"
f" to tree/branch rules")
return False
if (len(allow) > 0 and node[key] not in allow):
print(f"{key.capitalize()} {node[key]} not allowed due {allow}")
return False

return True
Expand Down

0 comments on commit 14d371f

Please sign in to comment.