Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: pipe Api() endpoint permissions + bump app v2.2.198, CLI v0.3.198

Louis Beaumont282b825b8f6e
diff --git a/Cargo.lock b/Cargo.lock
index f428c95f4..66e3ce7f1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6513,7 +6513,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"anyhow",
"audiopipe",
@@ -6572,7 +6572,7 @@ dependencies = [
[[package]]
name = "screenpipe-config"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"dirs 6.0.0",
"serde",
@@ -6585,7 +6585,7 @@ dependencies = [
[[package]]
name = "screenpipe-connect"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"anyhow",
"async-trait",
@@ -6611,7 +6611,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -6654,7 +6654,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"anyhow",
"chrono",
@@ -6679,7 +6679,7 @@ dependencies = [
[[package]]
name = "screenpipe-engine"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"anyhow",
"async-trait",
@@ -6747,7 +6747,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"anyhow",
"chrono",
@@ -6765,7 +6765,7 @@ dependencies = [
[[package]]
name = "screenpipe-screen"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"accessibility-sys",
"anyhow",
@@ -6805,7 +6805,7 @@ dependencies = [
[[package]]
name = "screenpipe-vault"
-version = "0.3.196"
+version = "0.3.197"
dependencies = [
"argon2",
"chacha20poly1305",
diff --git a/Cargo.toml b/Cargo.toml
index f68ab09bd..a7f709187 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ exclude = ["apps/screenpipe-app-tauri/src-tauri", "crates/screenpipe-integration
resolver = "2"
[workspace.package]
-version = "0.3.197"
+version = "0.3.198"
authors = ["louis030195 <[email protected]>"]
description = ""
repository = "https://github.com/screenpipe/screenpipe"
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 5eaebcb5f..3257e9f86 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.2.197"
+version = "2.2.198"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rs
index a0d82afab..c83ee6c8e 100644
--- a/crates/screenpipe-core/src/pipes/mod.rs
+++ b/crates/screenpipe-core/src/pipes/mod.rs
@@ -237,14 +237,14 @@ pub enum PipePermissionsConfig {
impl Default for PipePermissionsConfig {
fn default() -> Self {
- // No permissions block = safe defaults (reader preset)
- PipePermissionsConfig::Preset("reader".to_string())
+ // No permissions block = full access, no restrictions
+ PipePermissionsConfig::Preset("none".to_string())
}
}
impl PipePermissionsConfig {
pub fn is_default(&self) -> bool {
- matches!(self, PipePermissionsConfig::Preset(s) if s == "reader")
+ matches!(self, PipePermissionsConfig::Preset(s) if s == "none")
}
}
@@ -740,30 +740,36 @@ async fn setup_pipe_permissions(
let mut perms = permissions::PipePermissions::from_config(config);
- // All pipes get a token — endpoint enforcement is always active.
- use rand::Rng;
- let suffix: u64 = rand::thread_rng().gen();
- let t = format!("sp_pipe_{:016x}", suffix);
- perms.pipe_token = Some(t.clone());
-
- // Register with server middleware — must complete before Pi starts
- // to avoid race where Pi's first API call arrives before token is registered
- if let Some(registry) = token_registry {
- registry.register_token(t.clone(), perms.clone()).await;
- }
-
- // Write permissions JSON for the extension to read
- let perms_path = pipe_dir.join(".screenpipe-permissions.json");
- match serde_json::to_string(&perms) {
- Ok(json) => {
- if let Err(e) = std::fs::write(&perms_path, &json) {
- warn!("failed to write permissions file: {}", e);
+ if perms.has_any_restrictions() {
+ // Generate a unique pipe token for server-side enforcement
+ use rand::Rng;
+ let suffix: u64 = rand::thread_rng().gen();
+ let t = format!("sp_pipe_{:016x}", suffix);
+ perms.pipe_token = Some(t.clone());
+
+ // Register with server middleware — must complete before Pi starts
+ // to avoid race where Pi's first API call arrives before token is registered
+ if let Some(registry) = token_registry {
+ registry.register_token(t.clone(), perms.clone()).await;
+ }
+
+ // Write permissions JSON for the extension to read
+ let perms_path = pipe_dir.join(".screenpipe-permissions.json");
+ match serde_json::to_string(&perms) {
+ Ok(json) => {
+ if let Err(e) = std::fs::write(&perms_path, &json) {
+ warn!("failed to write permissions file: {}", e);
+ }
}
+ Err(e) => warn!("failed to serialize permissions: {}", e),
}
- Err(e) => warn!("failed to serialize permissions: {}", e),
- }
- Some(t)
+ Some(t)
+ } else {
+ // No restrictions — clean up any stale permissions file
+ let _ = std::fs::remove_file(pipe_dir.join(".screenpipe-permissions.json"));
+ None
+ }
}
/// Remove a pipe token from the server registry.
diff --git a/crates/screenpipe-core/src/pipes/permissions.rs b/crates/screenpipe-core/src/pipes/permissions.rs
index 24ed9e0b2..e92762e70 100644
--- a/crates/screenpipe-core/src/pipes/permissions.rs
+++ b/crates/screenpipe-core/src/pipes/permissions.rs
@@ -39,12 +39,12 @@ pub trait PipeTokenRegistry: Send + Sync {
}
// ---------------------------------------------------------------------------
-// Default allowlist — safe endpoints that any pipe can call without opt-in.
-// Everything NOT on this list is denied by default.
+// Default allowlist — safe endpoints used by the `reader` preset.
+// Only applied when a pipe explicitly opts in via `permissions: reader`.
+// Pipes with no `permissions` block have full access (no restrictions).
// ---------------------------------------------------------------------------
-/// Default allowed endpoints for the `reader` preset (and pipes with no
-/// explicit `permissions` block). Format: `"METHOD /path"` with glob support.
+/// Allowed endpoints for the `reader` preset. Format: `"METHOD /path"` with glob support.
pub const DEFAULT_ALLOWED_ENDPOINTS: &[&str] = &[
"GET /search",
"GET /activity-summary",
@@ -193,16 +193,31 @@ impl PipePermissions {
|| self.days.is_some()
}
- /// All pipes now get tokens for endpoint enforcement. This always returns
- /// true since every pipe needs at least the default allowlist enforced.
+ /// Returns true if any permission field differs from the fully-open default.
+ /// Used to decide whether to generate a token and install the permissions
+ /// extension. Pipes with no restrictions run with full API access.
pub fn has_any_restrictions(&self) -> bool {
- true
+ self.has_filter_rules()
+ || !self.allow_raw_sql
+ || !self.allow_frames
+ || !self.allow_endpoints.is_empty()
+ || !self.deny_endpoints.is_empty()
+ || self.use_default_allowlist // true = restricted to defaults
}
/// Check if an HTTP request (method + path) is allowed for this pipe.
///
- /// Evaluation order: **deny → explicit allow → default allowlist → reject**.
+ /// - No endpoint rules and no default allowlist → **allow everything** (full access)
+ /// - Otherwise: **deny → explicit allow → default allowlist → reject**
pub fn is_endpoint_allowed(&self, method: &str, path: &str) -> bool {
+ // No endpoint restrictions at all → full access
+ if self.allow_endpoints.is_empty()
+ && self.deny_endpoints.is_empty()
+ && !self.use_default_allowlist
+ {
+ return true;
+ }
+
let method_upper = method.to_uppercase();
// Step 1: deny rules always win
@@ -228,7 +243,6 @@ impl PipePermissions {
if self.use_default_allowlist {
for pattern in DEFAULT_ALLOWED_ENDPOINTS {
if let Some(rule) = parse_endpoint_rule(pattern) {
- // Respect allow_frames and allow_raw_sql overrides
if rule.path.starts_with("/frames") && !self.allow_frames {
continue;
}
@@ -394,8 +408,12 @@ fn resolve_endpoint_rules(
}
(allow, vec![], true) // use_default_allowlist = true
}
- // "reader" or anything else → safe defaults only
- _ => (vec![], vec![], true),
+ "reader" => {
+ // Reader: only safe read endpoints via default allowlist
+ (vec![], vec![], true)
+ }
+ // "none" or anything unrecognized → no restrictions
+ _ => (vec![], vec![], false),
}
}
PipePermissionsConfig::Rules { allow, deny } => {
@@ -508,6 +526,7 @@ mod tests {
use super::*;
fn make_perms() -> PipePermissions {
+ // Fully-open pipe — no restrictions (default when no permissions block)
PipePermissions {
pipe_name: "test".to_string(),
allow_apps: vec![],
@@ -522,7 +541,7 @@ mod tests {
allow_frames: true,
allow_endpoints: vec![],
deny_endpoints: vec![],
- use_default_allowlist: true,
+ use_default_allowlist: false,
pipe_token: None,
}
}
@@ -691,8 +710,19 @@ mod tests {
// -- Endpoint permission tests -------------------------------------------
#[test]
- fn default_allowlist_permits_search() {
- let p = make_perms();
+ fn no_permissions_allows_everything() {
+ let p = make_perms(); // fully open, no restrictions
+ assert!(p.is_endpoint_allowed("GET", "/search"));
+ assert!(p.is_endpoint_allowed("POST", "/meetings/start"));
+ assert!(p.is_endpoint_allowed("POST", "/meetings/stop"));
+ assert!(p.is_endpoint_allowed("DELETE", "/data/delete-range"));
+ assert!(p.is_endpoint_allowed("POST", "/raw_sql"));
+ }
+
+ #[test]
+ fn reader_preset_permits_search() {
+ let mut p = make_perms();
+ p.use_default_allowlist = true; // reader preset
assert!(p.is_endpoint_allowed("GET", "/search"));
assert!(p.is_endpoint_allowed("GET", "/activity-summary"));
assert!(p.is_endpoint_allowed("GET", "/meetings"));
@@ -701,8 +731,9 @@ mod tests {
}
#[test]
- fn default_allowlist_blocks_mutations() {
- let p = make_perms();
+ fn reader_preset_blocks_mutations() {
+ let mut p = make_perms();
+ p.use_default_allowlist = true; // reader preset
assert!(!p.is_endpoint_allowed("POST", "/meetings/start"));
assert!(!p.is_endpoint_allowed("POST", "/meetings/stop"));
assert!(!p.is_endpoint_allowed("DELETE", "/meetings/42"));
@@ -712,8 +743,9 @@ mod tests {
}
#[test]
- fn default_allowlist_respects_allow_frames() {
+ fn reader_preset_respects_allow_frames() {
let mut p = make_perms();
+ p.use_default_allowlist = true;
assert!(p.is_endpoint_allowed("GET", "/frames/123"));
p.allow_frames = false;
@@ -753,6 +785,7 @@ mod tests {
#[test]
fn deny_wins_over_default_allowlist() {
let mut p = make_perms();
+ p.use_default_allowlist = true; // reader preset
// Deny search even though it's in the default allowlist
p.deny_endpoints = vec![
parse_endpoint_rule("GET /search").unwrap(),
@@ -869,7 +902,7 @@ mod tests {
days: None,
allow_raw_sql: true,
allow_frames: true,
- permissions: PipePermissionsConfig::default(), // reader
+ permissions: PipePermissionsConfig::Preset("reader".to_string()),
connections: vec![],
timeout: None,
source_slug: None,
@@ -884,8 +917,59 @@ mod tests {
}
#[test]
- fn has_any_restrictions_always_true() {
+ fn from_config_no_permissions_allows_everything() {
+ let config = PipeConfig {
+ name: "test".to_string(),
+ schedule: "manual".to_string(),
+ enabled: true,
+ agent: "pi".to_string(),
+ model: "claude-haiku-4-5".to_string(),
+ provider: None,
+ preset: vec![],
+ config: std::collections::HashMap::new(),
+ allow_apps: vec![],
+ deny_apps: vec![],
+ allow_windows: vec![],
+ deny_windows: vec![],
+ allow_content_types: vec![],
+ deny_content_types: vec![],
+ time_range: None,
+ days: None,
+ allow_raw_sql: true,
+ allow_frames: true,
+ permissions: PipePermissionsConfig::default(), // "none" → full access
+ connections: vec![],
+ timeout: None,
+ source_slug: None,
+ installed_version: None,
+ source_hash: None,
+ };
+ let perms = PipePermissions::from_config(&config);
+ assert!(!perms.use_default_allowlist);
+ assert!(!perms.has_any_restrictions());
+ assert!(perms.is_endpoint_allowed("GET", "/search"));
+ assert!(perms.is_endpoint_allowed("POST", "/meetings/stop"));
+ assert!(perms.is_endpoint_allowed("DELETE", "/data/delete-range"));
+ }
+
+ #[test]
+ fn no_restrictions_when_fully_open() {
let p = make_perms();
+ // Default perms (no endpoint rules, use_default_allowlist=false) → no restrictions
+ assert!(!p.has_any_restrictions());
+ }
+
+ #[test]
+ fn has_restrictions_with_endpoint_rules() {
+ let mut p = make_perms();
+ p.deny_endpoints = vec![parse_endpoint_rule("* /meetings/stop").unwrap()];
+ assert!(p.has_any_restrictions());
+ }
+
+ #[test]
+ fn has_restrictions_with_default_allowlist() {
+ let mut p = make_perms();
+ p.use_default_allowlist = true;
assert!(p.has_any_restrictions());
}
}