Repository navigation
fix(assembly): reject . and .. as extraction file names - #76
Merged
Merged
Conversation
Path.GetFileName returns . and .. unchanged, so both passed the plain file name check added earlier. The output path then resolved to the target directory or its parent, the write failed with an IOException, and the target directory could be created first. Reject both names with an ArgumentException before any filesystem operation.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the resource-extraction filename-validation change.
No open issues 🎉
What changed in this PR
Closes the filename-validation gap left by #70: assembly resource extraction now rejects . and .. with an ArgumentException on filename before filesystem operations. Public signatures remain unchanged.
Changes:
- Extends shared filename validation used by synchronous, asynchronous, and cache extraction methods.
- Updates XML exception documentation to describe the rejected names.
- Adds four regression cases verifying the exception and that no target directory is created.
| File | Description |
|---|---|
| Plugin.BaseTypeExtensions/AssemblyExtensions.cs | Rejects dot-segment filenames and documents the validation behavior. |
| Plugin.BaseTypeExtensions.Tests/AssemblyExtensionsTests.cs | Tests both names in synchronous and asynchronous extraction without directory creation. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MoveManifestResourceToDirectoryandMoveManifestResourceToDirectoryAsync(and the cache variants that call them) now reject.and..as the file name with anArgumentExceptiononfilename, before any filesystem operation.Follow-up to #70, whose plain file name check missed these two names.
Why
Path.GetFileNamereturns.and..unchanged, so both passed the check. The output path then resolved to the target directory or its parent, the write failed with anIOException("access denied") instead of anArgumentException, and the target directory had already been created when it did not exist.Change Type
Affected Areas
Behavior And Compatibility
Signatures are unchanged. A
filenameof.or..used to end in anIOExceptionafter the target directory was created. It now throwsArgumentExceptionand creates nothing. All other file names behave as before.Tests
4 tests added:
.and..for the sync and the async method. Each uses a target directory that does not exist yet, and checks theArgumentExceptiononfilenameand that the directory was not created. All 4 failed before the change (theIOExceptionabove) and pass now. 502 tests pass locally (net9.0).Documentation
Checklist
type(scope): subject)