From 63b6fdb3e14d1093a9469f89764e08a8fd50ddd6 Mon Sep 17 00:00:00 2001 From: David Hagerty Date: Fri, 13 Feb 2026 02:52:11 +0000 Subject: [PATCH] chore(security): format SecurityScope implementation per project style Apply rustfmt formatting to src/security/scope.rs and tests/security_scope_test.rs to match project conventions. Co-Authored-By: Claude Opus 4.6 --- tests/security_scope_test.rs | 48 ++++++++++++++++++++++++++++++++++++------------ src/security/scope.rs | 23 ++++++++++++++++++----- 2 file(s) changed, 54 insertion(s)(+), 17 deletion(s)(-) diff --git a/tests/security_scope_test.rs b/tests/security_scope_test.rs --- a/tests/security_scope_test.rs +++ b/tests/security_scope_test.rs @@ -10,15 +10,21 @@ assert!(!profile.security.can_create_files); // Should deny writes - let result = profile.security.check_path("src/main.rs", FileOperation::Write); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Write); assert_eq!(result, ScopeCheck::Denied("read-only scope".to_string())); // Should allow reads - let result = profile.security.check_path("src/main.rs", FileOperation::Read); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Read); assert_eq!(result, ScopeCheck::Allowed); // Should deny file creation (read-only takes precedence) - let result = profile.security.check_path("src/newfile.rs", FileOperation::Create); + let result = profile + .security + .check_path("src/newfile.rs", FileOperation::Create); assert!(matches!(result, ScopeCheck::Denied(_))); } @@ -31,15 +37,21 @@ assert!(profile.security.can_create_files); // Should allow writes - let result = profile.security.check_path("src/main.rs", FileOperation::Write); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Write); assert_eq!(result, ScopeCheck::Allowed); // Should allow reads - let result = profile.security.check_path("src/main.rs", FileOperation::Read); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Read); assert_eq!(result, ScopeCheck::Allowed); // Should allow file creation - let result = profile.security.check_path("src/newfile.rs", FileOperation::Create); + let result = profile + .security + .check_path("src/newfile.rs", FileOperation::Create); assert_eq!(result, ScopeCheck::Allowed); } @@ -65,11 +77,15 @@ assert!(!profile.security.can_create_files); // Should deny writes - let result = profile.security.check_path("src/main.rs", FileOperation::Write); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Write); assert_eq!(result, ScopeCheck::Denied("read-only scope".to_string())); // Should allow reads - let result = profile.security.check_path("src/main.rs", FileOperation::Read); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Read); assert_eq!(result, ScopeCheck::Allowed); } @@ -82,11 +98,15 @@ assert!(!profile.security.can_create_files); // Should deny writes - let result = profile.security.check_path("src/main.rs", FileOperation::Write); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Write); assert_eq!(result, ScopeCheck::Denied("read-only scope".to_string())); // Should allow reads - let result = profile.security.check_path("src/main.rs", FileOperation::Read); + let result = profile + .security + .check_path("src/main.rs", FileOperation::Read); assert_eq!(result, ScopeCheck::Allowed); } @@ -99,11 +119,15 @@ assert!(profile.security.can_create_files); // Should allow writes - let result = profile.security.check_path("tests/test.rs", FileOperation::Write); + let result = profile + .security + .check_path("tests/test.rs", FileOperation::Write); assert_eq!(result, ScopeCheck::Allowed); // Should allow file creation - let result = profile.security.check_path("tests/newtest.rs", FileOperation::Create); + let result = profile + .security + .check_path("tests/newtest.rs", FileOperation::Create); assert_eq!(result, ScopeCheck::Allowed); } diff --git a/src/security/scope.rs b/src/security/scope.rs --- a/src/security/scope.rs +++ b/src/security/scope.rs @@ -81,7 +81,10 @@ for pattern_str in &self.denied_paths { if let Ok(pattern) = Pattern::new(pattern_str) { if pattern.matches_path_with(path_ref, opts) { - return ScopeCheck::Denied(format!("path matches denied pattern: {}", pattern_str)); + return ScopeCheck::Denied(format!( + "path matches denied pattern: {}", + pattern_str + )); } } } @@ -203,7 +206,10 @@ // Create operation should be blocked when can_create_files is false let result = scope.check_path("src/newfile.rs", FileOperation::Create); - assert_eq!(result, ScopeCheck::Denied("file creation not allowed".to_string())); + assert_eq!( + result, + ScopeCheck::Denied("file creation not allowed".to_string()) + ); } #[test] @@ -265,7 +271,9 @@ }; let result = scope.check_path("tests/something.rs", FileOperation::Read); - assert!(matches!(result, ScopeCheck::Denied(ref msg) if msg.contains("path not in allowed patterns"))); + assert!( + matches!(result, ScopeCheck::Denied(ref msg) if msg.contains("path not in allowed patterns")) + ); } // ============ check_command tests ============ @@ -297,7 +305,9 @@ }; let result = scope.check_command("rm -rf /"); - assert!(matches!(result, ScopeCheck::Denied(ref msg) if msg.contains("command not in allowed patterns"))); + assert!( + matches!(result, ScopeCheck::Denied(ref msg) if msg.contains("command not in allowed patterns")) + ); } #[test] @@ -360,6 +370,9 @@ }; let result = scope.check_network(); - assert_eq!(result, ScopeCheck::Denied("network access not allowed".to_string())); + assert_eq!( + result, + ScopeCheck::Denied("network access not allowed".to_string()) + ); } } -- tangled.sh