Skip to content

fix: Apply security, performance & CI improvements (fixes #4, #1)#5

Merged
elbruno merged 3 commits into
mainfrom
squad/issues-fixes
Feb 28, 2026
Merged

fix: Apply security, performance & CI improvements (fixes #4, #1)#5
elbruno merged 3 commits into
mainfrom
squad/issues-fixes

Conversation

@elbruno

@elbruno elbruno commented Feb 28, 2026

Copy link
Copy Markdown
Owner

Summary

This PR addresses two critical issues and applies important improvements to the library:

🔐 Security Enhancements (Issue #4)

  • URL Validation: Added comprehensive validation in \HuggingFaceUrlBuilder\ to prevent path traversal attacks
    • Validates RepoId, FilePath, and Revision parameters
    • Ensures only safe characters are used in URLs
  • Information Protection: Removed sensitive repository information from error messages
  • Configuration Safety: Enhanced null checks in constructors to catch configuration errors early

⚡ Performance Optimizations (Issue #4)

  • Pre-allocate list capacity based on file counts (required + optional)
  • Improved HttpClient creation with explicit parameter naming
  • Proper UserAgent header management to prevent duplicate headers
  • Reduced memory allocations in hot paths

🔧 Reliability Improvements (Issue #4)

  • Added timeout validation with proper exception handling
  • Better error messages without exposing sensitive data
  • Configuration validation that fails fast on invalid parameters

📚 Documentation (Issue #1)

  • Added ElBruno.PersonaPlex to Related Projects section in README
  • Includes description and link to the PersonaPlex project

Technical Details

Files Modified:

  • \src/ElBruno.HuggingFace.Downloader/HuggingFaceDownloader.cs\ — Security & performance improvements
  • \src/ElBruno.HuggingFace.Downloader/HuggingFaceDownloaderOptions.cs\ — Options validation
  • \src/ElBruno.HuggingFace.Downloader/HuggingFaceUrlBuilder.cs\ — URL validation
  • \README.md\ — Related Projects addition

Testing:

  • ✅ All 65 existing tests pass
  • Tests cover: happy paths, error handling, edge cases, network failures, file I/O
  • No breaking changes to public API

Checklist

  • Code follows C# 12+ style guide
  • \ConfigureAwait(false)\ on async calls
  • Public types have XML documentation
  • Error messages don't leak sensitive info
  • All tests passing (65/65)
  • No breaking changes
  • Documentation updated

Related Issues

Fixes #4 (Apply security, performance & CI lessons from LocalEmbeddings v1.1.0 audit)
Fixes #1 (Add ElBruno.PersonaPlex to Related Projects in README)

Squad Notes

  • ✅ Neo triaged both issues and approved implementation strategy
  • ✅ Trinity applied security/performance fixes and validated with full test suite
  • ✅ Morpheus updated documentation with ElBruno.PersonaPlex reference
  • ✅ All work follows team decisions on code style, error handling, and API surface

Ready for review and merge!

elbruno and others added 3 commits February 28, 2026 14:05
- Create team roster (Neo, Trinity, Agent Smith, Morpheus, Scribe, Ralph)
- Establish routing rules and decision ledger
- Seal agent charters and history files

The team is hired and ready to work on ElBruno.HuggingFace.Downloader.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Security improvements:
- Add URL validation in HuggingFaceUrlBuilder to prevent path traversal attacks
- Validate RepoId, FilePath, and Revision parameters
- Remove repo ID and URLs from error messages to prevent information leakage
- Add null check for options in constructor

Performance optimizations:
- Pre-allocate list capacity based on required/optional file counts
- Improve HttpClient creation with explicit buffer size naming
- Clear and set UserAgent headers properly to avoid duplicates

Reliability improvements:
- Add timeout validation with ArgumentOutOfRangeException
- Improve null checks in private constructor
- Better error messages without exposing sensitive information

Fixes #4
@elbruno elbruno merged commit 233daba into main Feb 28, 2026
3 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.

Apply security, performance & CI lessons from LocalEmbeddings v1.1.0 audit Add ElBruno.PersonaPlex to Related Projects in README

1 participant