Sobes.tech
Junior — Senior

Validation of nested path in the file system

livecode

Task condition

Describe exactly what check the conditional operator performs and under what variable values the condition will be true.

# model.path: pathlib.Path
# model.path = pathlib.Path("/home/user/app/")
# PERMITTED_SUBPATH = "dir1/dir2"

if model.path / PERMITTED_SUBPATH not in model.path.parents:
    raise django.core.exceptions.PermissionDenied()