Skip to content

Skip tar-symlink extraction test when symlinks are unavailable - #8628

Open
iam-kira wants to merge 1 commit into
huggingface:mainfrom
iam-kira:test/skip-tar-symlink-test-without-privilege
Open

iam-kira wants to merge 1 commit into
huggingface:mainfrom
iam-kira:test/skip-tar-symlink-test-without-privilege

Conversation

@iam-kira

Copy link
Copy Markdown

What

tests/test_extract.py::test_tar_extract_insecure_files errors in setup on an
unprivileged Windows machine:

OSError: [WinError 1314] A required privilege is not held by the client

The tar_file_with_sym_link fixture calls os.symlink(...) unconditionally, and
the test requests all three tar fixtures eagerly — so on Windows every
parametrization (dot-dot, symlink, sibling-prefix) errors, not just the symlink one.

CI stays green because GitHub's Windows runner can create symlinks; a normal
Windows contributor (no elevation, Developer Mode off) cannot, so the suite is red
for them and has been silently.

Fix

  • Guard the fixture with pytest.skip when os.symlink fails — the same intent as
    the @pytest.mark.skipif(os.name == "nt", ...) guard already used in
    tests/test_data_files.py::test_resolve_pattern_locally_does_not_resolve_symbolic_links.
  • Resolve the parametrized fixture lazily via request.getfixturevalue(...), so only
    the symlink case skips on Windows — the dot-dot and sibling-prefix security cases
    still run there
    , which they didn't before this PR (they were collateral of the
    eager fixture).

Behaviour is unchanged everywhere symlinks are available (all current CI, and any
elevated / Developer-Mode machine): all three cases run exactly as today.

Note

Verified with py_compile and by inspection; I don't have an unprivileged-Windows
runner to execute the skip path in CI, so a maintainer confirming it there (skips
only the symlink case, still runs the other two) would be welcome.

🤖 Generated with Claude Code

The tar_file_with_sym_link fixture calls os.symlink unconditionally, which raises OSError (WinError 1314) on unprivileged Windows and errors the whole test_tar_extract_insecure_files parametrization in setup. CI stays green because GitHub's Windows runner can create symlinks.

Guard the fixture with pytest.skip (matching the skipif(os.name=='nt') guard already used in test_data_files.py) and resolve fixtures lazily so the dot-dot and sibling-prefix security cases still run on Windows.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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