{"record":{"id":"913723803b4dc764","repo":"abhigyanpatwari/GitNexus","slug":"oracle-parents-must-be-real-directories-relative","errorCode":null,"errorMessage":"oracle parents must be real directories: {relative}","messagePattern":"oracle parents must be real directories: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/oracle_assets.py","lineNumber":137,"sourceCode":"        metadata = lexical.lstat()\n        resolved = lexical.resolve(strict=True)\n    except OSError as exc:\n        raise ValueError(f\"oracle root is unavailable: {lexical}\") from exc\n    if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode) or resolved != lexical:\n        raise ValueError(f\"oracle root must be a real non-symlink directory: {lexical}\")\n    return lexical\n\n\ndef _read_oracle_file(root: Path, relative: PurePosixPath) -> bytes:\n    current = root\n    for part in relative.parts[:-1]:\n        current /= part\n        try:\n            metadata = current.lstat()\n        except OSError as exc:\n            raise ValueError(f\"oracle parent is unreadable: {relative}\") from exc\n        if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode):\n            raise ValueError(f\"oracle parents must be real directories: {relative}\")\n\n    path = root.joinpath(*relative.parts)\n    try:\n        before = path.lstat()\n        if stat.S_ISLNK(before.st_mode) or not stat.S_ISREG(before.st_mode):\n            raise ValueError(f\"oracle source must be a bounded regular non-symlink file: {relative}\")\n        descriptor = os.open(path, os.O_RDONLY | getattr(os, \"O_NOFOLLOW\", 0))\n    except ValueError:\n        raise\n    except OSError as exc:\n        raise ValueError(f\"oracle source is unreadable: {relative}\") from exc\n    try:\n        opened = os.fstat(descriptor)\n        if (\n            stat.S_ISLNK(before.st_mode)\n            or not stat.S_ISREG(before.st_mode)\n            or not stat.S_ISREG(opened.st_mode)\n            or before.st_dev != opened.st_dev","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/oracle_assets.py#L119-L155","documentation":"Raised by _read_oracle_file when an intermediate parent directory of an oracle source is a symlink or not a directory (e.g. a regular file). The harness walks every parent component with lstat to ensure the path is composed entirely of real directories, blocking symlink-based traversal and substitution attacks against the oracle store.","triggerScenarios":"An intermediate path component is a symbolic link; an intermediate component is a regular file or special device rather than a directory; the source path traverses through a symlinked directory.","commonSituations":"A symlink placed inside the oracle tree (intentional convenience or accidental); an oracle path like 'dir.txt/inner' where a non-directory sits mid-path; tampered or hand-edited oracle directory structure.","solutions":["Remove or replace any symlinks in the oracle source path's directory chain with real directories.","Ensure every component except the final file is a genuine directory.","Re-extract the oracle assets from a trusted source to eliminate tampering."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import stat\nfrom pathlib import Path\n\ndef assert_real_parents(root: Path, relative) -> None:\n    cur = root\n    for part in Path(relative).parts[:-1]:\n        cur /= part\n        md = cur.lstat()\n        if stat.S_ISLNK(md.st_mode) or not stat.S_ISDIR(md.st_mode):\n            raise ValueError(f\"{cur} is not a real directory\")","typeGuard":"def parents_all_real_dirs(root, relative) -> bool:\n    import stat\n    cur = Path(root)\n    for part in Path(relative).parts[:-1]:\n        cur /= part\n        try:\n            md = cur.lstat()\n        except OSError:\n            return False\n        if stat.S_ISLNK(md.st_mode) or not stat.S_ISDIR(md.st_mode):\n            return False\n    return True","tryCatchPattern":"try:\n    payload = _read_oracle_file(root, relative)\nexcept ValueError as exc:\n    if \"must be real directories\" in str(exc):\n        raise SystemExit(f\"Symlink/non-dir in oracle path: {relative}\") from exc\n    raise","preventionTips":["Keep the oracle tree free of symlinks; audit with `find <root> -type l`.","Materialize oracle assets from a tarball rather than a symlinked checkout."],"tags":["python","benchmark","oracle","security","symlink","filesystem"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}