Refactor: modular layout, security hardening, CI, and off-target tests#6
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/Marcogn/3ds-zip-extractor/sessions/b66ae80f-ffda-423c-b45c-5fe9e2243879 Co-authored-by: Marcogn <54799180+Marcogn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Marcogn/3ds-zip-extractor/sessions/b66ae80f-ffda-423c-b45c-5fe9e2243879 Co-authored-by: Marcogn <54799180+Marcogn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Marcogn/3ds-zip-extractor/sessions/b66ae80f-ffda-423c-b45c-5fe9e2243879 Co-authored-by: Marcogn <54799180+Marcogn@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Marcogn
April 30, 2026 14:14
View session
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.
The ~1.5k-line
source/main.cmixed UI, networking, archive handling, and config parsing, with a duplicated hand-rolled ZIP path, no CI, no tests, and.3dsx/.smdhchecked in. This PR delivers phases 1, 2, 4, and 5 of the planned refactor; phase 3 (UX/GUI overhaul) is deferred to a follow-up since it can't be validated outside hardware/emulator.Module split (Phase 1)
source/main.creduced to ~470 lines (state machine + lifecycle only). New modules with headers ininclude/:led,gdrive,config,download,file_browser,queue,integrity, plus a purearchive_extractor_detectcarved out so detection is host-testable without libarchive.extract_zip_file, manual inflate,mkdir_recursive,ZIP_LOCAL_SIGNATURE); all formats now go throughextract_archive_libarchive.SECURE_SYMLINKS | SECURE_NOABSOLUTEPATHSon top of the existingSECURE_NODOTDOT.umask/getpwnam/getgrnam/LZ4_*stubs warn once on first use instead of failing silently..3dsx/.smdhremoved from tracking and gitignored. Fixed a latent Makefile bug (ICONunset → empty path passed tosmdhtool) that the untracking exposed.Security & reliability (Phase 2)
sdmc:/3ds/zip-extractor/tmp/run_<ts>_<n>.partwith orphan sweep at startup and shutdown.200to aRangerequest and restarts from zero.URL sha256:<64-hex>syntax — mbedtls on target, vendored pure-C SHA-256 on host so tests stay dependency-free. Backwards compatible (lines without the suffix work as before).max_urls,download_buffer_kb,connect_timeout_s(defaults 100 / 128 / 30, clamped to safe ranges).CI (Phase 1.6)
.github/workflows/build.yml:build-3ds(devkitpro/devkitarm container, uploads.3dsx/.smdhartifacts) andhost-tests(ASan+UBSan) jobs, both required. Release-on-tag job publishes the artifacts onv*tags.GITHUB_TOKENpermissions pinned tocontents: read(write only on the release job).Off-target test suite (Phase 5)
tests/Makefile.hostwithtest,test-asan,coverage,clean. Vendored Unity 2.6.0 (unity.{c,h}, internals inlined).tests/3ds_stubs.hcovers the few libctru types the pure modules need; sources guard<3ds.h>with#ifndef HOST_BUILD.test_gdrive(incl. small-buffer/NULL/folder-URL edge cases),test_config(BOM, overlong-line truncation, clamping, sha256 split,max_urlscap),test_archive_detect(every magic, too-short, missing, NULL),test_sha256(NIST vectors, file hashing, case-insensitive verify).tests/make_fixtures.shgenerates archive and config fixtures deterministically — nozip/tar/zstdtools required on the host.Docs (Phase 4)
sha256:example.docs/ARCHITECTURE.md(module map + per-URL data flow + threading model).CHANGELOG.md[Unreleased]section.CLAUDE.mdrealigned:[post-refactor]markers and "Stato attuale" notice updated to reflect the new layout.Deferred (Phase 3)
Bottom-screen interactive queue, swkbd URL entry, extraction progress bar, MB/s+ETA, local archive picker. These are UI changes that need on-device iteration; tracking for a separate PR.