use serde::Deserialize;
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
#[non_exhaustive]
pub struct RuleConfig {
pub allowlist: Option<AllowlistConfig>,
pub rules: Vec<RuleSpec>,
}
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
#[non_exhaustive]
pub struct RuleSpec {
pub id: String,
pub regex: Option<String>,
pub keywords: Vec<String>,
pub entropy: Option<f64>,
pub path: Option<String>,
#[serde(rename = "secretGroup")]
pub secret_group: Option<usize>,
pub allowlists: Vec<AllowlistConfig>,
}
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
#[non_exhaustive]
pub struct AllowlistConfig {
pub regexes: Vec<String>,
pub stopwords: Vec<String>,
#[serde(rename = "regexTarget")]
pub regex_target: Option<String>,
pub condition: Option<String>,
pub paths: Vec<String>,
pub commits: Vec<String>,
}
pub const GITLEAKS: &str = include_str!("gitleaks.toml");
impl RuleConfig {
pub fn from_toml(text: &str) -> Result<Self, toml::de::Error> {
toml::from_str(text)
}
}