feat: add zip archive support for bun-based server resources#385
Open
shadowfax92 wants to merge 1 commit intomainfrom
Open
feat: add zip archive support for bun-based server resources#385shadowfax92 wants to merge 1 commit intomainfrom
shadowfax92 wants to merge 1 commit intomainfrom
Conversation
The new bun-based server uploads zip archives to R2 containing
resources/bin/bun, resources/index.js, and resources/index.js.map.
This updates the build pipeline to download and extract these zips
instead of individual server binaries.
- Add zip archive download + extraction support to download.py
- Add {server_version} placeholder substitution in R2 keys
- Update download_resources.yaml for zip archive downloads
- Update copy_resources.yaml to copy extracted resource directories
- Add BROWSEROS_SERVER_VERSION file for version tracking
- Update validate_resources.py patch for new resource layout
- Add resources/server/ to .gitignore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryAdds zip archive support to the build pipeline for downloading and extracting bun-based server resources from R2. Key Changes:
Issues Found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Build Pipeline Starts] --> B[Read BROWSEROS_SERVER_VERSION]
B --> C{Resolve r2_key with version}
C --> D[Download zip from R2]
D --> E[Clear existing extract_dir]
E --> F[Extract zip to extract_dir]
F --> G{Set executable perms}
G --> H[Copy resources to Chromium tree]
H --> I[Validate resources]
I --> J{bin/bun + index.js exist?}
J -->|Yes| K[Build continues]
J -->|No| L[Build fails]
style D fill:#e1f5ff
style F fill:#e1f5ff
style I fill:#fff3cd
style J fill:#fff3cd
Last reviewed commit: a166c7e |
Comment on lines
+152
to
+153
| with zipfile.ZipFile(tmp_zip, "r") as zf: | ||
| zf.extractall(extract_dir) |
There was a problem hiding this comment.
extractall() vulnerable to zip slip attacks (malicious zips with ../ paths could write outside extract_dir)
Suggested change
| with zipfile.ZipFile(tmp_zip, "r") as zf: | |
| zf.extractall(extract_dir) | |
| with zipfile.ZipFile(tmp_zip, "r") as zf: | |
| for member in zf.namelist(): | |
| # Validate each member to prevent path traversal | |
| member_path = (extract_dir / member).resolve() | |
| if not member_path.is_relative_to(extract_dir.resolve()): | |
| raise RuntimeError(f"Unsafe zip entry: {member}") | |
| zf.extractall(extract_dir) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/browseros/build/modules/storage/download.py
Line: 152-153
Comment:
`extractall()` vulnerable to zip slip attacks (malicious zips with `../` paths could write outside `extract_dir`)
```suggestion
with zipfile.ZipFile(tmp_zip, "r") as zf:
for member in zf.namelist():
# Validate each member to prevent path traversal
member_path = (extract_dir / member).resolve()
if not member_path.is_relative_to(extract_dir.resolve()):
raise RuntimeError(f"Unsafe zip entry: {member}")
zf.extractall(extract_dir)
```
How can I resolve this? If you propose a fix, please make it concise.
Comment on lines
+160
to
+163
| exe_path = extract_dir / rel_path | ||
| if exe_path.exists(): | ||
| exe_path.chmod(exe_path.stat().st_mode | 0o755) | ||
| log_info(f" Set executable: {rel_path}") |
There was a problem hiding this comment.
silently continues if executable doesn't exist after extraction - should fail loudly to catch misconfigured archives
Suggested change
| exe_path = extract_dir / rel_path | |
| if exe_path.exists(): | |
| exe_path.chmod(exe_path.stat().st_mode | 0o755) | |
| log_info(f" Set executable: {rel_path}") | |
| for rel_path in executable_paths: | |
| exe_path = extract_dir / rel_path | |
| if not exe_path.exists(): | |
| raise RuntimeError(f"Expected executable not found after extraction: {rel_path}") | |
| exe_path.chmod(exe_path.stat().st_mode | 0o755) | |
| log_info(f" Set executable: {rel_path}") |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/browseros/build/modules/storage/download.py
Line: 160-163
Comment:
silently continues if executable doesn't exist after extraction - should fail loudly to catch misconfigured archives
```suggestion
for rel_path in executable_paths:
exe_path = extract_dir / rel_path
if not exe_path.exists():
raise RuntimeError(f"Expected executable not found after extraction: {rel_path}")
exe_path.chmod(exe_path.stat().st_mode | 0o755)
log_info(f" Set executable: {rel_path}")
```
How can I resolve this? If you propose a fix, please make it concise.
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
download.py)download_resources.yamlto download versioned server zip archives from R2 (server/v{version}/browseros-server-{platform}.zip)copy_resources.yamlto copy extracted resource directories (containingbin/bun,index.js,index.js.map) instead of individual server binariesBROWSEROS_SERVER_VERSIONfile for version tracking with{server_version}placeholder substitution in R2 keysvalidate_resources.pypatch to validate new resource layout (bin/bun+index.js)Context
The new bun-based server (from the
new-bun-runtimefeature) uploads zip archives to R2 containing aresources/directory with the Bun runtime, bundled server JS, and source maps. This PR updates the Chromium build pipeline to support downloading and extracting these archives.Test plan
download.pycorrectly downloads and extracts zip archives from R2{server_version}substitution reads fromBROWSEROS_SERVER_VERSIONcopy_resources.yamlcopies the extractedresources/directory tochrome/browser/browseros/server/resources/resources/server/is properly gitignoredserver/v0.0.57/browseros-server-darwin-arm64.zip🤖 Generated with Claude Code