Skip to content

test: create private fixture directories with an explicit mode - #215

Open
rohanpoudel2 wants to merge 3 commits into
openai:mainfrom
rohanpoudel2:fix/umask-fixtures
Open

test: create private fixture directories with an explicit mode#215
rohanpoudel2 wants to merge 3 commits into
openai:mainfrom
rohanpoudel2:fix/umask-fixtures

Conversation

@rohanpoudel2

Copy link
Copy Markdown

Fixes #207

Problem

The POSIX test suite silently depends on the ambient process umask being at least as restrictive as 0022. Several fixtures that stand in for private or trusted scan ancestors are created with a bare mkdir, so under the common collaborative umask 0002 they become mode 0775. The SDK's group-writable ancestor check then correctly rejects them, and six tests fail for a reason unrelated to what they assert:

OutputDirectoryError: Scan output parent must not be group- or world-writable
without the sticky bit: .../canonical-parent

Reproduced on macOS 15 (Darwin 25.5.0), Node 24.11.1, Bun 1.3.14, at a8fc009:

$ (umask 0002; bun test --timeout 30000 ./tests-ts)
 711 pass
 5 skip
 6 fail

The six failures match the ones reported in #207 exactly:

  • runtime directories and plugin Python boundary > validates explicit output directories and creates private temporary paths
  • canonical scan contract > accepts a scan directory beneath a symlinked parent
  • CLI authentication > keeps delegated credentials in the configured Codex home
  • CodexSecurity orchestration > preflights local inputs without initializing runtime or credentials
  • CodexSecurity orchestration > rejects output inside normal and linked Git worktrees before runtime initialization
  • CodexSecurity orchestration > keeps a private preflight snapshot isolated from persistent credentials

Change

Test-only. The production ancestry check is deliberately left alone, per the reporter's suggestion.

Each affected fixture is now created with an explicit mode: 0o700, matching the neighbouring mkdir calls that already do this in the same tests (for example caller-owned and scanDir a few lines away). mkdir applies the mode to every directory it creates, including with recursive: true, and 0o700 carries no group- or world-writable bits for a umask to strip, so the fixtures are now umask-independent.

One fixture needed a different treatment: the linked worktree in rejects output inside normal and linked Git worktrees is created by git worktree add, which honours the ambient umask and takes no mode argument, so the test restores the private mode with an explicit chmod afterwards.

Verification

Full suite, same commit, four umasks:

umask result
0002 717 pass / 5 skip / 0 fail
0022 717 pass / 5 skip / 0 fail
0007 717 pass / 5 skip / 0 fail
0077 717 pass / 5 skip / 0 fail

pnpm run types and pnpm run format are both clean.

Note on restricted-root

While fixing this I found a seventh fixture with the same defect that #207 does not list: restricted-root in runtime.test.ts. It only surfaces once the other fixtures in that test are fixed, because an earlier assertion in the same test aborted first. It is included here.

The POSIX test suite silently depended on the ambient process umask being
at least as restrictive as 0022. Several fixtures that stand in for private
or trusted scan ancestors were created with a bare `mkdir`, so under the
common collaborative umask 0002 they became mode 0775 and the SDK's
group-writable ancestor checks correctly rejected them. Six tests failed
for a reason unrelated to what they were asserting.

Create those fixtures with an explicit `mode: 0o700`, matching the
neighbouring `mkdir` calls in the same tests, and restore the private mode
on the linked Git worktree that `git worktree add` creates under the
ambient umask. The production ancestry check is deliberately unchanged.

Verified with the full suite under umask 0002, 0022, 0007 and 0077.

Fixes openai#207
@github-actions github-actions Bot added the skip-release-notes Omit internal changes from generated release notes label Aug 3, 2026
@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review exact head 08edbdc

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 08edbdc1c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 08edbdc1c5

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-release-notes Omit internal changes from generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POSIX test suite fails under umask 0002 because secure fixtures inherit mode 0775

2 participants