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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ attacker with a kernel exploit can still escape it.
keys).
- **Syscalls**: a seccomp denylist refuses interfaces no extension needs, such as `ptrace` and
module loading. It is a denylist because the worker is Node, whose syscall use changes between
releases.
releases. It also refuses Unix-domain sockets (`socketpair` stays allowed for a child's pipes),
so a worker cannot reach the session bus, the engine's IPC socket or any other local service,
and the worker is started with a short allowlist of the engine's environment, without the bus,
display or agent addresses.
- **Memory**: each worker is capped at 256 MiB by `MemoryMax` in its own systemd scope, with
each JavaScript heap capped at 160 MiB below that. Where no systemd is reachable (inside the
Flatpak) `RLIMIT_DATA` holds it at 512 MiB of committed memory. The caps are not configurable
Expand Down
17 changes: 9 additions & 8 deletions crates/compass-core/src/onboarding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ impl Recommendation {
/// first command rendering. The Raycast ones come first, because running
/// Raycast store extensions on Linux is what Compass adds; none of them runs
/// AppleScript or needs Homebrew, so they work without the runtime's shim
/// having to stand in for macOS.
/// having to stand in for macOS. None talks to a local daemon over a unix
/// socket either (the system bus, Docker), which the sandbox refuses.
pub const RECOMMENDED_EXTENSIONS: &[Recommendation] = &[
Recommendation {
store: Store::Raycast,
Expand Down Expand Up @@ -315,20 +316,20 @@ pub const RECOMMENDED_EXTENSIONS: &[Recommendation] = &[
title: "Tailwind CSS",
description: "Search the Tailwind CSS documentation.",
},
Recommendation {
store: Store::Vicinae,
owner: "gelei",
name: "bluetooth",
title: "Bluetooth",
description: "Connect and manage Bluetooth devices.",
},
Recommendation {
store: Store::Vicinae,
owner: "dagimg-dot",
name: "wifi-commander",
title: "Wifi Commander",
description: "Connect to Wi-Fi networks and manage saved ones.",
},
Recommendation {
store: Store::Vicinae,
owner: "costeer",
name: "color-converter",
title: "Color Converter",
description: "Convert colors between hex, RGB and HSL.",
},
Recommendation {
store: Store::Vicinae,
owner: "fbosch",
Expand Down
19 changes: 17 additions & 2 deletions crates/compass-core/src/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,39 @@ pub fn prepare(

/// The Plasma script the KDE backend evaluates (`org.kde.PlasmaShell.evaluateScript`):
/// every desktop switched to the image plugin with this image and fill mode.
///
/// The path comes from an extension, and a file name may hold any byte but
/// `/` and NUL, so it never goes into the script as text: it becomes a
/// percent-encoded `file://` URI ([`kde_image_uri`]), and that URI a JSON
/// string, which is also a JavaScript string literal. A quote or a `)` in the
/// name stays inside the literal instead of ending it.
#[must_use]
pub fn kde_script(request: &WallpaperRequest) -> String {
let image =
serde_json::to_string(&kde_image_uri(&request.path)).unwrap_or_else(|_| "\"\"".to_owned());
format!(
r#"
var ds = desktops();
for (var i = 0; i < ds.length; i++) {{
var d = ds[i];
d.wallpaperPlugin = "org.kde.image";
d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
d.writeConfig("Image", "{}");
d.writeConfig("Image", {image});
d.writeConfig("FillMode", {});
}}
"#,
file_uri(&request.path),
kde_fill_mode(request.fit)
)
}

/// The image's URI for Plasma: percent-encoded by [`url::Url::from_file_path`]
/// for an absolute path, as the engine encodes paths elsewhere, and
/// [`file_uri`] otherwise.
#[must_use]
pub fn kde_image_uri(path: &str) -> String {
url::Url::from_file_path(path).map_or_else(|()| file_uri(path), String::from)
}

/// Whether the session is the desktop `backend` belongs to, read from
/// `$XDG_CURRENT_DESKTOP` (colon-separated) and `$GDMSESSION` as the C++
/// `Environment` helpers read them. `None` for the two daemons and KDE,
Expand Down
23 changes: 23 additions & 0 deletions crates/compass-core/tests/wallpaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,29 @@ fn the_kde_script_sets_the_image_plugin_image_and_fill_on_every_desktop() {
assert!(script.contains("for (var i = 0; i < ds.length; i++)"));
}

#[test]
fn a_kde_wallpaper_path_cannot_end_the_script_s_string() {
let path = r#"/tmp/a");evil();("b.png"#;
let script = compass_core::wallpaper::kde_script(&WallpaperRequest {
path: path.into(),
screen: None,
fit: WallpaperFit::Cover,
});
// `evil();` may appear inside the URI, but never right after a closed
// string, where Plasma would run it.
assert!(!script.contains(r#"");evil"#), "{script}");
assert_eq!(script.matches(r#"d.writeConfig("Image", "#).count(), 1);
let start =
script.find(r#"d.writeConfig("Image", "#).unwrap() + r#"d.writeConfig("Image", "#.len();
let rest = &script[start..];
let end = rest.find(");\n").unwrap();
let literal: String = serde_json::from_str(&rest[..end]).expect("one JSON string literal");
assert_eq!(
url::Url::parse(&literal).unwrap().to_file_path().unwrap(),
std::path::PathBuf::from(path)
);
}

#[test]
fn desktops_are_recognised_as_the_cpp_environment_helpers_do() {
use compass_core::wallpaper::desktop_matches;
Expand Down
2 changes: 2 additions & 0 deletions crates/compass-input-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ xkbcommon = { version = "0.8", default-features = false }
notify.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio = { workspace = true, features = ["rt"] }
zbus.workspace = true
7 changes: 6 additions & 1 deletion crates/compass-input-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//! * [`keymap`] — keycodes to text through xkbcommon (and a table for tests);
//! * [`device`] — `/dev/input` and `/dev/uinput` through `evdev`;
//! * [`server`] — the process and its loop;
//! * [`seat`] — serving only the user at the keyboard;
//! * [`recording`] — reading `evtest` logs, for replaying real typing.
//!
//! The wire is `compass_core::input_server`: figura's JSON-RPC in
Expand All @@ -23,13 +24,17 @@
//! Reading `/dev/input/event*` and writing `/dev/uinput` need either root
//! or `CAP_DAC_OVERRIDE`. The packages grant it with
//! `setcap cap_dac_override+ep` (Arch's `compass.install`) or the NixOS
//! module's `security.wrappers`; see `packaging/README.md`.
//! module's `security.wrappers`; see `packaging/README.md`. A file
//! capability goes to whoever runs the file, so a privileged helper reads
//! keys and injects only while its user has the active session on a seat
//! ([`seat`]).

#![deny(missing_docs)]

pub mod device;
pub mod keymap;
pub mod recording;
pub mod seat;
pub mod server;
pub mod service;
pub mod tracker;
Loading
Loading