pub enum Filter {
And(Vec<Filter>),
Or(Vec<Filter>),
Not(Box<Filter>),
Equality {
attribute: String,
value: String,
},
GreaterOrEqual {
attribute: String,
value: String,
},
LessOrEqual {
attribute: String,
value: String,
},
Approximate {
attribute: String,
value: String,
},
Present {
attribute: String,
},
Substrings {
attribute: String,
initial: Option<String>,
any: Vec<String>,
last: Option<String>,
},
}Expand description
A search filter, built as a value rather than pasted together as a string.
This is the security-relevant type in the package. The classic LDAP
injection is a filter template — (&(objectClass=person)(uid=NAME)) — with
a username interpolated into it: a username of * turns the lookup into a
wildcard that matches every account, and one containing )(uid=admin re-
writes the filter outright.
A Filter cannot be injected into, because it never becomes a string on the
way to the directory. Filter::encode writes each assertion value as a
length-delimited BER octet string, where * and ) are just bytes with no
syntax of their own.
Display does produce RFC 4515 text — for logs, and
for anything that genuinely needs the string form — and escapes every value
on the way out.
Variants§
And(Vec<Filter>)
(&(a)(b)). An empty And is the absolute-true filter (&) of
RFC 4526, which is well defined and matches everything.
Or(Vec<Filter>)
(|(a)(b)). An empty Or is RFC 4526’s absolute-false filter (|).
Not(Box<Filter>)
Equality
(attribute=value)
GreaterOrEqual
(attribute>=value)
LessOrEqual
(attribute<=value)
Approximate
(attribute~=value)
Present
(attribute=*) — the entry has this attribute at all.
Substrings
(attribute=initial*any*any*last). RFC 4511 calls the trailing part
final, which is a Rust keyword, so it is last here.
Implementations§
Source§impl Filter
impl Filter
pub fn equals(attribute: impl Into<String>, value: impl Into<String>) -> Filter
pub fn greater_or_equal( attribute: impl Into<String>, value: impl Into<String>, ) -> Filter
pub fn less_or_equal( attribute: impl Into<String>, value: impl Into<String>, ) -> Filter
pub fn approximately( attribute: impl Into<String>, value: impl Into<String>, ) -> Filter
pub fn present(attribute: impl Into<String>) -> Filter
pub fn starts_with( attribute: impl Into<String>, prefix: impl Into<String>, ) -> Filter
pub fn ends_with( attribute: impl Into<String>, suffix: impl Into<String>, ) -> Filter
pub fn contains( attribute: impl Into<String>, fragment: impl Into<String>, ) -> Filter
pub fn and(filters: impl IntoIterator<Item = Filter>) -> Filter
pub fn or(filters: impl IntoIterator<Item = Filter>) -> Filter
Sourcepub fn negate(self) -> Filter
pub fn negate(self) -> Filter
(!(…)). Also spelled !filter, through std::ops::Not; this form
exists because it chains, and a filter is usually built left to right.
Trait Implementations§
impl Eq for Filter
Source§impl Not for Filter
!filter, for the times that reads better than Filter::negate.
impl Not for Filter
!filter, for the times that reads better than Filter::negate.