Compare commits

...
Author SHA1 Message Date
spark 24ec8095f6 Desktop 0.3.4: allow ftp_check for the web app, and a test that every command is allowed
ci / typescript (push) Failing after 21m10s
ci / rust (push) Successful in 22m51s
desktop-release / build (deb,appimage, linux-x86_64, ubuntu-latest) (push) Successful in 1h19m4s
Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 14:13:22 +01:00
7 changed files with 53 additions and 3 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@photoreport/desktop",
"version": "0.3.3",
"version": "0.3.4",
"private": true,
"type": "module",
"scripts": {
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "photoreport-desktop"
version = "0.3.3"
version = "0.3.4"
edition = "2024"
publish = false
description = "PhotoReport desktop: the web app in a native shell, with keychain sign-in and (later) local FTP and the native engine."
+1
View File
@@ -9,6 +9,7 @@ fn main() {
"ftp_start",
"ftp_stop",
"ftp_status",
"ftp_check",
"ftp_take",
"ftp_retry",
"ftp_read",
@@ -24,6 +24,7 @@
"allow-ftp-start",
"allow-ftp-stop",
"allow-ftp-status",
"allow-ftp-check",
"allow-ftp-take",
"allow-ftp-retry",
"allow-ftp-read",
@@ -0,0 +1,11 @@
# Automatically generated - DO NOT EDIT!
[[permission]]
identifier = "allow-ftp-check"
description = "Enables the ftp_check command without any pre-configured scope."
commands.allow = ["ftp_check"]
[[permission]]
identifier = "deny-ftp-check"
description = "Denies the ftp_check command without any pre-configured scope."
commands.deny = ["ftp_check"]
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "PhotoReport",
"version": "0.3.3",
"version": "0.3.4",
"identifier": "pt.photoreport.desktop",
"build": {
"devUrl": "http://localhost:5173",
@@ -0,0 +1,37 @@
//! The web app is loaded from the server (a remote origin), so every command it calls must be listed in build.rs
//! (to get an ACL permission) and allowed in capabilities/default.json. A command registered in lib.rs but missing
//! from either is refused at runtime and looks like "this desktop app is too old" in the web app.
use std::path::Path;
fn read(rel: &str) -> String {
std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join(rel)).unwrap()
}
#[test]
fn every_registered_command_is_allowed_for_the_web_app() {
let lib = read("src/lib.rs");
let start =
lib.find("generate_handler![").expect("generate_handler") + "generate_handler![".len();
let end = start + lib[start..].find(']').unwrap();
let commands: Vec<String> = lib[start..end]
.split(',')
.map(|c| c.trim().rsplit("::").next().unwrap_or("").to_string())
.filter(|c| !c.is_empty())
.collect();
assert!(commands.len() > 10, "{commands:?}");
let build = read("build.rs");
let capabilities = read("capabilities/default.json");
for c in &commands {
assert!(
build.contains(&format!("\"{c}\"")),
"{c} is not listed in build.rs"
);
let permission = format!("\"allow-{}\"", c.replace('_', "-"));
assert!(
capabilities.contains(&permission),
"{permission} is missing from capabilities/default.json"
);
}
}