oliver-zehentleitner / maity

runner: one no-follow descriptor walk, one bounded read, one capability check (scratchop, worktree, inclone, limitread, pointer, clonecheck)

Sign in to report

tsk-zzjc91gq8ar1 Open

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication. Paths under cli/src/maity/.

What is wrong: every module has its own "open each directory from the one before without following a link" loop, each mapping errors differently (OnTheWay, Refused, None, ("blocked", None), plain OSError):

  • runner/scratchop.py: _step :104, _opened :119, _open_below :228, _open_nofollow :412.
  • runner/worktree.py: _worktrees_scope :198, _descend :221, _is_real_dir :237, _child_prunable :167.
  • inclone.py: _open_at :83, _walk :102.
  • runner/limitread.py: _open :57.
  • pointer.py: _Root :72.
  • clonecheck.py: _read_regular :622; runner_record :820-849 repeats _read_regular in the same file, and worktree._admin_working_tree :140-164 repeats it again.
  • The "can this system do it" check five times: inclone.WALKS :33, clonecheck._walks :766, pointer._DIR_FD :25, scratchop.supported :79, worktree.supported :53; ghpr.WALKS :59 is an alias.
  • Also dead in production: ghpr.py:29-32 PULL_REQUESTS_PATH (only reader cli/tests/test_ghpr.py:552; its comment says the path is for Codex, which is never granted pull requests).

Proposal: one stdlib-only module (e.g. fdwalk) importable by the cli and the -I runner modules, holding supported(), descend(root, names, make=None), open_dir_nofollow, read_regular(dir_fd, name, limit) and one tree removal (see the worktree-prune card from the same round). Callers keep only their error wording. Drop PULL_REQUESTS_PATH and the ghpr.WALKS alias.

Effort / risk: M. Medium risk (security-relevant paths; each copy has its own tests to catch a regression).

Notes

  1. Lotse · Nov 21, 2026, 01:59 UTC

    Audit round 4 (tsk-hgnbapyw7hnh, read at 0a1b832e): #2053 added a second O_PATH constant. inclone.PASS (cli/src/maity/inclone.py:42) and scratchop._PATH_FD (cli/src/maity/runner/scratchop.py:70) both stand for opening a directory to pass through; inclone.FOLDER (inclone.py:35) has no O_CLOEXEC while scratchop._FOLDER (scratchop.py:64) has it. One set of flags in the shared walk.