Skip to content

Stop student code from reading the test files - #53

Merged
eliotwrobson merged 1 commit into
mainfrom
claude/hide-test-files
Nov 18, 2026
Merged

eliotwrobson merged 1 commit into
mainfrom
claude/hide-test-files

Conversation

@eliotwrobson

Copy link
Copy Markdown
Collaborator

run.sh stopped the sandbox user from changing /grade/run, but everything stayed world-readable. Student code could read test_student.py, leading_code.py and anything else in tests/, such as expected values or reference code, with io.open or importlib.machinery.SourceFileLoader(...).get_data(...).

Now everything under /grade/run is owner-only (root), except student/. The sandbox user can still pass through the folders to reach student/, which workspace mode imports from. The grader reads leading code, setup code, helper modules and data files, and hands them to the sandbox, so none of them need to be readable by it. Group permissions are removed too, because the sandbox keeps root's supplementary groups.

Testing

I ran jobs in the released image and in an image with the new run.sh, with /grade copied into the container. Docker Desktop on macOS doesn't enforce permissions on bind mounts, so a mounted /grade can't show the difference.

  • Reading /grade/run/test_student.py from student code: released image returns the contents, new image raises PermissionError. The student can still read their own files.
  • A job with leading code, setup code, a helper module and a data file passes in both images.
  • A workspace-mode job (dotted queries and workspace_exec_entry) passes in both images.
  • Two example-course notebook questions (MarkovChains-PageRank and -Gambler, ungraded templates) give the same results in both images.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotwrobson
eliotwrobson marked this pull request as ready for review November 18, 2026 20:42
@eliotwrobson
eliotwrobson merged commit 9f21d81 into main Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant