Skip to main content

ldap_parser/
lib.rs

1//! # LDAP Parser
2//!
3//! A Lightweight Directory Access Protocol (LDAP) ([RFC4511]) parser, implemented with the
4//! [nom](https://github.com/Geal/nom) parser combinator framework.
5//!
6//! It is written in pure Rust, fast, and makes extensive use of zero-copy. A lot of care is taken
7//! to ensure security and safety of this crate, including design (recursion limit, defensive
8//! programming), tests, and fuzzing. It also aims to be panic-free.
9//!
10//! The code is available on [Github](https://github.com/rusticata/ldap-parser)
11//! and is part of the [Rusticata](https://github.com/rusticata) project.
12//!
13//! # Examples
14//!
15//! Parsing an LDAP message (in BER format):
16//!
17//! ```rust
18//! use ldap_parser::FromBer;
19//! use ldap_parser::ldap::{LdapMessage, MessageID, ProtocolOp, ProtocolOpTag};
20//!
21//! static DATA: &[u8] = include_bytes!("../assets/message-search-request-01.bin");
22//!
23//! # fn main() {
24//! let res = LdapMessage::from_ber(DATA);
25//! match res {
26//!     Ok((rem, msg)) => {
27//!         assert!(rem.is_empty());
28//!         //
29//!         assert_eq!(msg.message_id, MessageID(4));
30//!         assert_eq!(msg.protocol_op.tag(), ProtocolOpTag::SearchRequest);
31//!         match msg.protocol_op {
32//!             ProtocolOp::SearchRequest(req) => {
33//!                 assert_eq!(req.base_object.0, "dc=rccad,dc=net");
34//!             },
35//!             _ => panic!("Unexpected message type"),
36//!         }
37//!     },
38//!     _ => panic!("LDAP parsing failed: {:?}", res),
39//! }
40//! # }
41//! ```
42//!
43//! [RFC4511]: https://tools.ietf.org/html/rfc4511
44
45#![deny(/*missing_docs,*/
46        unstable_features,
47        unused_import_braces, unused_qualifications)]
48#![warn(
49    missing_debug_implementations,
50    /* missing_docs,
51    rust_2018_idioms,*/
52    unreachable_pub
53)]
54#![forbid(unsafe_code)]
55#![deny(rustdoc::broken_intra_doc_links)]
56#![doc(test(
57    no_crate_inject,
58    attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
59))]
60#![cfg_attr(docsrs, feature(doc_cfg))]
61
62pub mod error;
63pub mod filter;
64mod filter_parser;
65pub mod ldap;
66mod parser;
67
68pub use parser::*;
69
70pub use asn1_rs;
71pub use asn1_rs::nom::{Err, IResult};
72pub use asn1_rs::FromBer;