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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
feat: experimental security features
Louis Beaumont8ee00939deae
diff --git a/screenpipe-core/Cargo.toml b/screenpipe-core/Cargo.tomlindex 456ba3d10..7781e92f4 100644--- a/screenpipe-core/Cargo.toml+++ b/screenpipe-core/Cargo.toml@@ -27,9 +27,15 @@ tokio = { workspace = true }deno_core = { version = "0.283.0", optional = true }deno_ast = { version = "0.38.2", features = ["transpiling"], optional = true }+# Security+regex = { version = "1.10.6", features = ["std"], optional = true }+lazy_static = { version = "1.4.0", optional = true }+[features]pipes = ["dep:deno_core", "dep:deno_ast"]+security = ["dep:regex", "dep:lazy_static"]+[build-dependencies]# Move this under the same feature flagdeno_core = { version = "0.283.0", optional = true }diff --git a/screenpipe-core/src/lib.rs b/screenpipe-core/src/lib.rsindex 02d77aad0..8fb3e758e 100644--- a/screenpipe-core/src/lib.rs+++ b/screenpipe-core/src/lib.rs@@ -4,3 +4,5 @@ pub mod llm;pub use llm::*;pub mod pipes;pub use pipes::*;+#[cfg(feature = "security")]+mod pii_removal;diff --git a/screenpipe-core/src/pii_removal.rs b/screenpipe-core/src/pii_removal.rsnew file mode 100644index 000000000..251a7bc60--- /dev/null+++ b/screenpipe-core/src/pii_removal.rs@@ -0,0 +1,32 @@+use lazy_static::lazy_static;+use regex::Regex;++lazy_static! {+ static ref PII_PATTERNS: Vec<(Regex, &'static str)> = vec![+ (Regex::new(r"\b(?:\d{4}[-\s]?){3}\d{4}\b").unwrap(), "[CREDIT_CARD]"),+ (Regex::new(r"\b\d{3}-\d{2}-\d{4}\b").unwrap(), "[SSN]"),+ (Regex::new(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b").unwrap(), "[EMAIL]"),+ // add more patterns as needed+ ];+}++pub fn remove_pii(text: &str) -> String {+ let mut sanitized = text.to_string();+ for (pattern, replacement) in PII_PATTERNS.iter() {+ sanitized = pattern.replace_all(&sanitized, *replacement).to_string();+ }+ sanitized+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_remove_pii() {+ let input =+ "My card is 1234-5678-9012-3456 and SSN is 123-45-6789. Email: [email protected]";+ let expected = "My card is [CREDIT_CARD] and SSN is [SSN]. Email: [EMAIL]";+ assert_eq!(remove_pii(input), expected);+ }+}