ruvector_security/
error.rs1use std::path::PathBuf;
4
5pub type SecurityResult<T> = std::result::Result<T, SecurityError>;
7
8#[derive(Debug, thiserror::Error)]
10pub enum SecurityError {
11 #[error("Invalid path: {0}")]
13 InvalidPath(PathBuf),
14
15 #[error("Path traversal attempt detected: {0}")]
17 PathTraversal(PathBuf),
18
19 #[error("Path {path} is outside allowed directories")]
21 PathOutsideAllowed {
22 path: PathBuf,
23 allowed: Vec<PathBuf>,
24 },
25
26 #[error("Path contains invalid characters: {0}")]
28 InvalidPathCharacters(PathBuf),
29
30 #[error("Symlink detected: {0}")]
32 SymlinkDetected(PathBuf),
33
34 #[error("Authentication required")]
36 AuthenticationRequired,
37
38 #[error("Invalid authentication token")]
40 InvalidToken,
41
42 #[error("Token has expired")]
44 TokenExpired,
45
46 #[error("Rate limit exceeded, retry after {retry_after_secs} seconds")]
48 RateLimitExceeded { retry_after_secs: u64 },
49
50 #[error("Null pointer passed to FFI function")]
52 NullPointer,
53
54 #[error("Misaligned pointer: address {ptr:#x} requires {required_alignment}-byte alignment")]
56 MisalignedPointer { ptr: usize, required_alignment: usize },
57
58 #[error("Size overflow in FFI operation")]
60 SizeOverflow,
61
62 #[error("Buffer too large: {0} bytes exceeds maximum")]
64 BufferTooLarge(usize),
65
66 #[error("Memory allocation failed")]
68 AllocationFailed,
69
70 #[error("IO error: {0}")]
72 Io(#[from] std::io::Error),
73
74 #[error("Configuration error: {0}")]
76 Config(String),
77}