Skip to content

Add self-extracting binary examples, use internal pathsafe and update README#8

Open
sanderhahn wants to merge 8 commits intomasterfrom
self-extracting-example
Open

Add self-extracting binary examples, use internal pathsafe and update README#8
sanderhahn wants to merge 8 commits intomasterfrom
self-extracting-example

Conversation

@sanderhahn
Copy link
Owner

  • Introduced examples for self-extracting binaries using both gozip and the Go standard library.
  • Added demo scripts and main programs demonstrating the creation and extraction of payload files.
  • Updated README with instructions and examples for building self-extracting binaries.

- Introduced examples for self-extracting binaries using both gozip and the Go standard library.
- Added demo scripts and main programs demonstrating the creation and extraction of payload files.
- Updated README with instructions and examples for building self-extracting binaries.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds documentation and runnable examples demonstrating “self-extracting” binaries where a zip payload is appended to an executable, and shows extraction both via gozip and via Go’s archive/zip.

Changes:

  • Expanded readme.md with self-extracting binary instructions and two example approaches (gozip + stdlib).
  • Added a gozip-based self-extracting example program and demo.sh.
  • Added a stdlib-only self-extracting example program and demo.sh.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
readme.md Adds build/run instructions and embedded-zip extraction examples (gozip + stdlib).
examples/selfextract/main.go Example self-extracting app using gozip.Unzip / UnzipList.
examples/selfextract/demo.sh Scripted demo for building/packing/running the gozip-based example.
examples/selfextract-stdlib/main.go Example extractor implemented with archive/zip (no gozip import).
examples/selfextract-stdlib/demo.sh Scripted demo for building/packing/running the stdlib-based example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add `sanitizePath` function to prevent path traversal attacks.
- Update `main.go` to use `zip.OpenReader` and sanitize paths during extraction.
- Refactor `Unzip` function in `gozip.go` to utilize `pathsafe.SafeJoin`.
- Remove dependency on `github.com/cyphar/filepath-securejoin`.
- Add tests for path sanitization in `gozip_test.go`.
- Update README with improved examples and warnings about path validation.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 11 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

go.mod:4

  • go.sum is now committed as an empty file (0 lines). If the module has no external dependencies after removing filepath-securejoin, it’s cleaner to delete go.sum entirely; otherwise, regenerate it via go mod tidy so it contains the expected sums.
module github.com/sanderhahn/gozip

go 1.22


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sanderhahn sanderhahn changed the title Add self-extracting binary examples and update README Add self-extracting binary examples and update README, use internal pathsafe instead of cyphar/filepath-securejoin Feb 13, 2026
@sanderhahn sanderhahn changed the title Add self-extracting binary examples and update README, use internal pathsafe instead of cyphar/filepath-securejoin Add self-extracting binary examples and update README, use internal pathsafe Feb 13, 2026
@sanderhahn sanderhahn changed the title Add self-extracting binary examples and update README, use internal pathsafe Add self-extracting binary examples, use internal pathsafe and update README Feb 13, 2026
@sanderhahn
Copy link
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link

Copilot AI commented Feb 13, 2026

@sanderhahn I've opened a new pull request, #9, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits February 13, 2026 11:02
Co-authored-by: sanderhahn <775103+sanderhahn@users.noreply.github.com>
Co-authored-by: sanderhahn <775103+sanderhahn@users.noreply.github.com>
Co-authored-by: sanderhahn <775103+sanderhahn@users.noreply.github.com>
Fix GOOS detection and document TOCTOU limitations in pathsafe
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