Skip to content

fix(assembly): reject . and .. as extraction file names - #76

Merged
framinosona merged 1 commit into
mainfrom
fix/reject-dot-filenames
Nov 23, 2026
Merged

framinosona merged 1 commit into
mainfrom
fix/reject-dot-filenames

Conversation

@framinosona

Copy link
Copy Markdown
Member

Summary

MoveManifestResourceToDirectory and MoveManifestResourceToDirectoryAsync (and the cache variants that call them) now reject . and .. as the file name with an ArgumentException on filename, before any filesystem operation.

Follow-up to #70, whose plain file name check missed these two names.

Why

Path.GetFileName returns . and .. unchanged, so both passed the check. The output path then resolved to the target directory or its parent, the write failed with an IOException ("access denied") instead of an ArgumentException, and the target directory had already been created when it did not exist.

Change Type

  • Feature
  • Bug fix
  • Refactor
  • Docs only
  • CI/build/tooling

Affected Areas

  • String / Numeric / Enum extensions
  • Collection extensions (Dictionary / List / Enumerable / ConcurrentDictionary)
  • Temporal extensions (DateTime / DateOnly / TimeOnly / TimeSpan)
  • Reflection / Assembly extensions
  • Comparison extensions
  • Tests
  • Docs

Behavior And Compatibility

  • Public API changed
  • Exception behavior changed
  • No externally visible behavior change

Signatures are unchanged. A filename of . or .. used to end in an IOException after the target directory was created. It now throws ArgumentException and creates nothing. All other file names behave as before.

Tests

  • Unit tests added/updated
  • Not applicable (explain)

4 tests added: . and .. for the sync and the async method. Each uses a target directory that does not exist yet, and checks the ArgumentException on filename and that the directory was not created. All 4 failed before the change (the IOException above) and pass now. 502 tests pass locally (net9.0).

Documentation

  • README feature list updated
  • XML docs added/updated
  • Not applicable (explain)

Checklist

  • Commit messages follow Conventional Commits (type(scope): subject)
  • CI passes
  • Change is scoped to one logical unit of work

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.
Copilot AI balanced review requested due to automatic review settings November 23, 2026 01:03
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/coverlet

main 8ec5d16 fix/reject-dot-filen... 4d18b5d +/-
90% 90% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@github-actions

Copy link
Copy Markdown

Test Results

502 tests  +4   502 ✅ +4   2s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 4d18b5d. ± Comparison against base commit 8ec5d16.

@framinosona
framinosona merged commit fa5cf04 into main Nov 23, 2026
14 checks passed
@framinosona
framinosona deleted the fix/reject-dot-filenames branch November 23, 2026 01:32
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.

2 participants