Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/smart-ssh-community/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ tauri-build = { version = "2", features = [] }
[dependencies]
app-shell = { workspace = true }
tauri = { workspace = true }
# Issue #1607: `generate_context!` expands to `serde_json::json!` once
# `tauri.conf.json` has a `plugins` section.
serde_json = { workspace = true }
# `tauri-build`'s ACL-/Capability-Auflösung (in `build.rs`, läuft für dieses
# Binary-Crate) scannt nur die eigenen, direkten Abhängigkeiten dieser
# Crate nach Plugin-Berechtigungen — eine rein transitive Abhängigkeit über
Expand Down Expand Up @@ -59,6 +62,12 @@ tauri-plugin-android-host = { workspace = true }
# Dieselbe Fassung, die `app-shell` ohnehin nutzt, keine neue Crate im Baum.
serde_json = { workspace = true }
toml = { workspace = true }
# Issue #1607: `tests/opener_dotfile_scope.rs` builds a `tauri::fs::Scope`
# against the mock runtime. Unix only: the literal-leading-dot rule exists only
# there, and a Windows test binary linking tauri's webview needs an app
# manifest and aborts at load (0xc0000139).
[target.'cfg(unix)'.dev-dependencies]
tauri = { workspace = true, features = ["test"] }

[lints]
workspace = true
5 changes: 5 additions & 0 deletions apps/smart-ssh-community/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' tauri-plugin-decoration: http://tauri-plugin-decoration.localhost https://tauri-plugin-decoration.localhost; img-src 'self' data:; connect-src 'self' ipc:;"
}
},
"plugins": {
"opener": {
"requireLiteralLeadingDot": false
}
},
"bundle": {
"license": "GPL-3.0-only",
"android": {
Expand Down
112 changes: 112 additions & 0 deletions apps/smart-ssh-community/tests/opener_dotfile_scope.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//! Issue #1607: "Open locally" must work for dotfile edit copies
//! (`.env.local`). The opener plugin builds a `tauri::fs::Scope` whose
//! `require_literal_leading_dot` defaults to `true` on Unix, so `**` never
//! matches a component starting with `.`. `tauri.conf.json` switches that off
//! for the opener plugin; the scope itself stays the edit-session folder.

#![allow(clippy::unwrap_used)]

fn conf() -> serde_json::Value {
let raw = include_str!("../tauri.conf.json");
serde_json::from_str(raw).expect("tauri.conf.json is valid JSON")
}

fn capability() -> serde_json::Value {
let raw = include_str!("../capabilities/default.json");
serde_json::from_str(raw).expect("default.json is valid JSON")
}

#[test]
fn config_disables_literal_leading_dot_for_opener() {
assert_eq!(
conf()["plugins"]["opener"]["requireLiteralLeadingDot"],
serde_json::Value::Bool(false),
"plugins.opener.requireLiteralLeadingDot must be false (issue #1607)"
);
}

#[test]
fn capability_scope_stays_the_edit_session_folder() {
let cap = capability();
let entry = cap["permissions"]
.as_array()
.unwrap()
.iter()
.find(|p| p["identifier"] == "opener:allow-open-path")
.expect("opener:allow-open-path entry");
let allow = entry["allow"].as_array().unwrap();
assert_eq!(allow.len(), 1);
assert_eq!(allow[0]["path"], "$CACHE/smart-ssh/edit-sessions/**");
assert_eq!(allow[0]["app"], true);
}

#[cfg(unix)]
mod scope {
use std::fs;
use std::path::{Path, PathBuf};
use tauri::test::{mock_builder, mock_context, noop_assets};
use tauri::utils::config::FsScope;

fn touch(path: &Path) {
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, b"x").unwrap();
}

/// Builds a scope with the same pattern shape as the capability, rooted in a
/// fresh temp dir, and checks `paths` against it.
fn check(require_dot: Option<bool>, check: impl FnOnce(&dyn Fn(&Path) -> bool, &Path)) {
let root: PathBuf = std::env::temp_dir().join(format!(
"smart-ssh-1607-{}-{:?}",
std::process::id(),
require_dot
));
let _ = fs::remove_dir_all(&root);
fs::create_dir_all(&root).unwrap();
let root = root.canonicalize().unwrap();
let app = mock_builder()
.build(mock_context(noop_assets()))
.expect("mock app");
let pattern = root.join("smart-ssh/edit-sessions/**");
let scope = tauri::fs::Scope::new(
&app,
&FsScope::Scope {
allow: vec![pattern],
deny: vec![],
require_literal_leading_dot: require_dot,
},
)
.unwrap();
check(&|p| scope.is_allowed(p), &root);
let _ = fs::remove_dir_all(&root);
}

#[test]
fn dotfile_edit_copy_allowed_and_everything_else_rejected() {
check(Some(false), |allowed, root| {
let ok = root.join("smart-ssh/edit-sessions/data-1/abc/.env.local");
touch(&ok);
assert!(allowed(&ok), "dotfile edit copy must be allowed");
let plain = root.join("smart-ssh/edit-sessions/data-1/abc/readme.txt");
touch(&plain);
assert!(allowed(&plain));

let ssh = root.join(".ssh/id_ed25519");
touch(&ssh);
assert!(!allowed(&ssh), "dotfile outside edit-sessions");
let other = root.join("smart-ssh/other/.env");
touch(&other);
assert!(!allowed(&other));
let traversal = root.join("smart-ssh/edit-sessions/../../.ssh/id_ed25519");
assert!(!allowed(&traversal), "traversal");
});
}

#[test]
fn counter_proof_literal_leading_dot_rejects_dotfile() {
check(Some(true), |allowed, root| {
let ok = root.join("smart-ssh/edit-sessions/data-1/abc/.env.local");
touch(&ok);
assert!(!allowed(&ok));
});
}
}
2 changes: 2 additions & 0 deletions changelog.d/issue-1607-open-locally-dotfiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Fixed
- "Open locally" now works for remote files whose name starts with a dot, such as `.env.local`, on macOS and Linux.
8 changes: 8 additions & 0 deletions docs/specs/0054-sftp-browser-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ Zeile in der Übertragungsliste. Ein erneuter Versuch ersetzt die Meldung,
statt eine weitere hinzuzufügen. Ein erfolgreicher Upload meldet sich wie
bisher.

**Dateien mit führendem Punkt** (`.env.local`, `.bashrc`, `.gitignore`) lassen
sich auf macOS, Linux und Windows gleich lokal öffnen. Die Freigabe zum Öffnen
gilt weiter nur für den Ordner der Bearbeitungskopien; die Einstellung
`requireLiteralLeadingDot: false` des Opener-Plugins sorgt nur dafür, dass
Punkt-Dateien *innerhalb* dieses Ordners passen. Pfade außerhalb (auch
Punkt-Dateien wie `~/.ssh/id_ed25519`) und Pfade mit `..` bleiben abgelehnt.
Die Bearbeitungskopie behält den Originalnamen.

## Teil 5: Standardprogramme je Dateityp

- In den Einstellungen legt der Nutzer je Dateiendung ein Programm fest
Expand Down
Loading