fix: validate ls special permission bits by position#3420
Conversation
eb16c7e to
e13755c
Compare
seratch
left a comment
There was a problem hiding this comment.
Thanks for fixing this. One small tightening suggestion: can we make the special execute-column handling position-aware?
ls -l only emits s/S in the owner and group execute columns, and t/T in the other execute column. The current generic triplet parser accepts t/T for owner/group and s/S for other, which should not appear in real ls output.
I think the behavior would be easier to defend if we kept the current rwx-only model but validated the special characters by position:
- owner: allow
x,s,S,- - group: allow
x,s,S,- - other: allow
x,t,T,-
Could you also add regression coverage for rejecting the invalid cross-position cases?
Validate special execute-column markers according to their ls position. Owner and group now accept setuid/setgid markers `s` and `S`, while other accepts sticky markers `t` and `T`. Lowercase markers preserve the modeled execute bit, uppercase markers parse without execute, and cross-position markers are rejected. Add parse_ls_la regression coverage for valid special-bit entries and invalid cross-position `s`/`S`/`t`/`T` cases.
e13755c to
a649a4d
Compare
|
@seratch thanks for the catch. I pushed an update that makes this validation position-aware now. Owner and group accept I also added regression coverage through |
Summary
Permissions.from_str()to parse validls -lspecial execute-column markers:s/Sfor owner and group, andt/Tfor other.s/t; ignore the special bit itself becausePermissionscurrently stores only rwx bits.tin owner/group orsin other, are rejected.parse_ls_la()for sticky directories, setuid/setgid-style entries, and invalid special-bit positions.Test plan
UV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 uv run pytest tests/sandbox/test_parse_utils.pyUV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 uv run ruff check src/agents/sandbox tests/sandboxUV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 uv run pyrightUV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 make formatUV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 make lintUV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 make typecheckUV_CACHE_DIR=/tmp/uv-cache UV_PROJECT_ENVIRONMENT=/tmp/openai-pr3420-venv UV_PYTHON=3.12.13 make testsIssue number
N/A
Checks
make format,make lint,make typecheck, andmake tests