Verify the whole release folder in core and rebuild packaged sources (#57)

Address the code review of the carried-over work:
- scripts/package extracts the snapshot with fresh mtimes, so the shared
  target never reuses a workspace crate built from other sources.
- core::verify_release owns the release-folder contract (file names, size
  limits, signature, identity, digest) and returns Error::InvalidUpdate; it is
  tested natively with real folders, oversized manifests and missing files.
- The app's --verify-release only adds the build identity and commit check.
- French script messages, clearer path helpers, accurate Velopack stub facts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-20 10:43:02 +01:00
1 parent f90ae109b9
commit 18e9db54fc
7 files changed
+134 -85

No files matched your search

+15 -26
View File
@@ -1,5 +1,3 @@
use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
use base64::prelude::{BASE64_STANDARD, Engine};
@@ -30,30 +28,21 @@ pub fn handle_command() {
}
}
fn verify_release(dir: &Path) -> io::Result<()> {
let missing = || io::Error::other("Executable built without release identity");
let channel = option_env!("ARENA_RELEASE_CHANNEL").ok_or_else(missing)?;
let version = option_env!("ARENA_RELEASE_VERSION").ok_or_else(missing)?;
let key = BASE64_STANDARD
.decode(option_env!("ARENA_RELEASE_PUBLIC_KEY").ok_or_else(missing)?)
.map_err(io::Error::other)?;
let mut manifest = Vec::new();
File::open(dir.join(format!("release-{channel}.json")))?
.take(4097)
.read_to_end(&mut manifest)?;
if manifest.len() > 4096 {
return Err(io::Error::other("Oversized release manifest"));
}
let mut signature = Vec::new();
File::open(dir.join(format!("release-{channel}.sig")))?
.take(65)
.read_to_end(&mut signature)?;
let package = File::open(dir.join(format!("ArenaTracker-{version}-{channel}-full.nupkg")))?;
let commit = arena_tracker_core::verify_update_package(
&key, channel, version, &manifest, &signature, package,
)?;
if Some(commit.as_str()) != option_env!("ARENA_RELEASE_COMMIT") {
return Err(io::Error::other("Unexpected release commit"));
/// Checks a release folder with the identity this executable was built with.
fn verify_release(dir: &Path) -> Result<(), String> {
let (Some(channel), Some(version), Some(key), Some(commit)) = (
option_env!("ARENA_RELEASE_CHANNEL"),
option_env!("ARENA_RELEASE_VERSION"),
option_env!("ARENA_RELEASE_PUBLIC_KEY"),
option_env!("ARENA_RELEASE_COMMIT"),
) else {
return Err("Exécutable construit sans identité de version.".into());
};
let key = BASE64_STANDARD.decode(key).map_err(|e| e.to_string())?;
let signed_commit = arena_tracker_core::verify_release(dir, &key, channel, version)
.map_err(|e| e.to_string())?;
if signed_commit != commit {
return Err("Commit de la version inattendu.".into());
}
Ok(())
}