in antlir/compiler/items/common.py [0:0]
def is_path_protected(path: Path, protected_paths: Set[Path]) -> bool:
# NB: The O-complexity could obviously be lots better, if needed.
for prot_path in protected_paths:
# Handle both protected files and directories. This test is written
# to return True even if `prot_path` is `/path/to/file` while `path`
# is `/path/to/file/oops`.
if (path + b"/").startswith(
prot_path + (b"" if prot_path.endswith(b"/") else b"/")
):
return True
return False