{"record":{"id":"0885f2054f467123","repo":"abhigyanpatwari/GitNexus","slug":"benchmark-harness-checkout-must-contain-only-real","errorCode":null,"errorMessage":"benchmark harness checkout must contain only real directories","messagePattern":"benchmark harness checkout must contain only real directories","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/oracle_assets.py","lineNumber":307,"sourceCode":"    if not hidden_tree_result.ok:\n        raise ValueError(\"cannot inspect the clone for committed benchmark harness data\")\n    hidden_tree = hidden_tree_result.stdout_tail.strip()\n    if hidden_tree and (\n        len(hidden_tree) not in {40, 64} or any(character not in \"0123456789abcdefABCDEF\" for character in hidden_tree)\n    ):\n        raise ValueError(\"committed benchmark harness is not a single bounded tree\")\n\n    current = root.joinpath(*HIDDEN_HARNESS_PATH.parts)\n    if hidden_tree:\n        parent = root\n        for part in HIDDEN_HARNESS_PATH.parts:\n            parent /= part\n            try:\n                metadata = parent.lstat()\n            except OSError as exc:\n                raise ValueError(\"committed benchmark harness is missing from the clone checkout\") from exc\n            if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode):\n                raise ValueError(\"benchmark harness checkout must contain only real directories\")\n    elif current.exists() or current.is_symlink():\n        raise ValueError(\"untracked benchmark harness data blocks oracle sanitization\")\n\n    _git_checked(\n        root,\n        [\n            \"rm\",\n            \"-r\",\n            \"--force\",\n            \"--quiet\",\n            \"--ignore-unmatch\",\n            \"--\",\n            HIDDEN_HARNESS_PATH.as_posix(),\n        ],\n        timeout=120,\n    )\n    sanitized_tree = _git_checked(root, [\"write-tree\"], timeout=60)\n    deterministic_git_env = {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/oracle_assets.py#L289-L325","documentation":"Raised during the same worktree walk as [340]. A path component of eval/workflow_bench lstat'd successfully but is a symlink or not a directory. The guard prevents a symlink from redirecting the subsequent `git rm -r -- eval/workflow_bench` onto an unrelated location (path-substitution / TOCTOU attack).","triggerScenarios":"Triggered when eval/ or eval/workflow_bench/ in the clone worktree is a symbolic link or a regular file rather than a real directory, even though HEAD tracks it as a tree.","commonSituations":"A hand-modified clone where someone replaced the directory with a symlink; a crafted malicious clone; leftover artifact from a failed merge that left a file named 'workflow_bench'.","solutions":["Inspect `ls -la <clone>/eval` and `<clone>/eval/workflow_bench` for symlinks or files.","Remove the offending entry and restore from HEAD: `git -C <clone> checkout -- eval/workflow_bench` (after deleting the link/file).","Re-clone from a trusted source if the worktree looks crafted."],"exampleFix":"// before: eval/workflow_bench -> /etc/passwd (symlink)\nrm <clone>/eval/workflow_bench\ngit -C <clone> checkout HEAD -- eval/workflow_bench\n// after: real directory restored, lstat reports S_ISDIR\n","handlingStrategy":"validation","validationCode":"import stat\nfrom pathlib import Path\n\ndef harness_parts_are_real_dirs(clone: Path, parts=(\"eval\", \"workflow_bench\")) -> bool:\n    cur = clone\n    for part in parts:\n        cur = cur / part\n        try:\n            st = cur.lstat()\n        except OSError:\n            return False\n        if stat.S_ISLNK(st.st_mode) or not stat.S_ISDIR(st.st_mode):\n            return False\n    return True\n","typeGuard":"def is_unsafe_harness_dir(exc: BaseException) -> bool:\n    return isinstance(exc, ValueError) and \"must contain only real directories\" in str(exc)\n","tryCatchPattern":"try:\n    oracle_assets.sanitize_clone_for_hidden_oracles(clone)\nexcept ValueError as exc:\n    quarantine(clone)\n    raise AbortTask(str(exc)) from exc\n","preventionTips":["Never sanitize a clone whose worktree has been hand-edited; start from a fresh clone.","Document that the benchmark clone is disposable and must not be modified by setup scripts before sanitization."],"tags":["git","clone","symlink","toctou","path-traversal","oracle","sanitization","invariant"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}