1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use super::schema_version::SCHEMA_VERSION;
/// Errors that can occur during TOML rule loading.
#[derive(Debug, thiserror::Error)]
pub enum LoaderError {
/// Underlying filesystem I/O error.
#[error("IO error at {path}: {source}")]
Io {
/// Path associated with the I/O error.
path: std::path::PathBuf,
/// Underlying I/O error.
#[source]
source: std::io::Error,
},
/// Failed to parse the TOML document.
#[error("TOML parse error: {0}")]
Parse(#[from] toml::de::Error),
/// A file was found outside the permitted directory boundary.
#[error("Path traversal detected: {0}")]
PathTraversal(std::path::PathBuf),
/// The document uses an unknown or missing schema version.
#[error("Unsupported schema version: {0} (expected {SCHEMA_VERSION})")]
UnsupportedVersion(String),
/// A TOML file exceeds the maximum permitted size.
#[error("TOML file too large: {bytes} bytes (max 1 MiB) at {path}")]
TomlTooLarge {
/// Path to the oversized file.
path: std::path::PathBuf,
/// Byte length of the file.
bytes: u64,
},
/// A witness count exceeds the maximum reasonable value.
#[error("Unreasonable witness count: {count} (max 1_000_000)")]
UnreasonableCount {
/// The unreasonable count.
count: usize,
},
/// A string field contains unsafe characters.
#[error("Unsafe string in field '{field}' at byte offset {byte_offset} in {path}")]
UnsafeString {
/// Field path where the unsafe string was found.
field: String,
/// Path to the file containing the unsafe string.
path: std::path::PathBuf,
/// Byte offset of the first unsafe byte.
byte_offset: usize,
},
}