Skip to content

FEATURE: Redesign Writer API with entry type methods and placeholders#9

Open
gschlager wants to merge 2 commits into
mainfrom
improvements
Open

FEATURE: Redesign Writer API with entry type methods and placeholders#9
gschlager wants to merge 2 commits into
mainfrom
improvements

Conversation

@gschlager

@gschlager gschlager commented Jan 27, 2026

Copy link
Copy Markdown
Member

Replaces the low-level add_file_from_source/add_file_from_stream API with
intuitive methods for each entry type: file(), directory(), symlink(),
hardlink(), and placeholder().

New features:

  • file() supports from:, content:, or streaming block
  • directory() for directory entries
  • symlink() and hardlink() for links with path traversal protection
  • placeholder() reserves space to fill later (useful for manifests)
  • Path validation rejects traversal attacks by default
  • Automatic username/groupname lookup from uid/gid

Architecture improvements:

  • Extract ContentWriter for file content handling
  • Extract PlaceholderManager for placeholder lifecycle
  • Extract EntryAttributes value object for tar metadata
  • Extract PathValidator and SourceValidator for input validation
  • Simplify Header to receive EntryAttributes directly
  • Reorganize specs into unit/ and integration/ directories
  • Add integration tests with real tar extractors (GNU tar, bsdtar)

This change is Reviewable

@gschlager gschlager force-pushed the improvements branch 11 times, most recently from ce2ab27 to 0911faa Compare January 29, 2026 17:22
@gschlager gschlager changed the title FEATURE: Add Reader class and security hardening FEATURE: Improve Writer with directories, symlinks, and path validation Jan 29, 2026
@gschlager gschlager force-pushed the improvements branch 6 times, most recently from 7e255ea to ebdf291 Compare February 2, 2026 20:41
Replaces the low-level add_file_from_source/add_file_from_stream API with
intuitive methods for each entry type: file(), directory(), symlink(),
hardlink(), and placeholder().

New features:
- file() supports from:, content:, or streaming block
- directory() for directory entries
- symlink() and hardlink() for links with path traversal protection
- placeholder() reserves space to fill later (useful for manifests)
- Path validation rejects traversal attacks by default
- Automatic username/groupname lookup from uid/gid

Architecture improvements:
- Extract ContentWriter for file content handling
- Extract PlaceholderManager for placeholder lifecycle
- Extract EntryAttributes value object for tar metadata
- Extract PathValidator and SourceValidator for input validation
- Simplify Header to receive EntryAttributes directly
- Reorganize specs into unit/ and integration/ directories
- Add integration tests with real tar extractors (GNU tar, bsdtar)

@gschlager gschlager left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@gschlager partially reviewed 94 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @gschlager).

@gschlager gschlager changed the title FEATURE: Improve Writer with directories, symlinks, and path validation FEATURE: Redesign Writer API with entry type methods and placeholders Feb 3, 2026
@gschlager gschlager marked this pull request as ready for review February 3, 2026 16:52
Organize files into logical subdirectories:

lib/mini_tarball/
- headers/: header.rb, header_fields.rb, header_formatter.rb,
            header_writer.rb, user_group_lookup.rb
- validators/: path_validator.rb, source_validator.rb
- writers/: writer.rb, content_writer.rb, null_writer.rb,
            placeholder.rb, placeholder_manager.rb, entry_attributes.rb
- streams/: (unchanged)
- errors.rb, version.rb (top-level)

Specs mirror the lib structure. Integration tests moved to writers/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant