modsecurity

Crates.iomodsecurity
lib.rsmodsecurity
version
sourcesrc
created_at2024-05-05 00:22:43.392644
updated_at2024-12-04 02:39:34.298766
descriptionA high-level Rust interface to libmodsecurity
homepage
repositoryhttps://github.com/rkrishn7/rust-modsecurity
max_upload_size
id1229946
Cargo.toml error:TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Rohan Krishnaswamy (rkrishn7)

documentation

README

modsecurity

Crates.io MSRV Codecov Check Safety Test Contributions

A Rust-interface to the ModSecurity library.

If you're looking for low-level FFI bindings to libmodsecurity, check out modsecurity-sys.

Example

Block requests with admin in the path

use modsecurity::{ModSecurity, Rules};

let ms = ModSecurity::default();

let mut rules = Rules::new();
rules.add_plain(r#"
    SecRuleEngine On

    SecRule REQUEST_URI "@rx admin" "id:1,phase:1,deny,status:401"
"#).expect("Failed to add rules");

let mut transaction = ms
    .transaction_builder()
    .with_rules(&rules)
    .build()
    .expect("Error building transaction");

transaction.process_uri("http://example.com/admin", "GET", "1.1").expect("Error processing URI");
transaction.process_request_headers().expect("Error processing request headers");

let intervention = transaction.intervention().expect("Expected intervention");

assert_eq!(intervention.status(), 401);

More examples can be found in the examples directory.

Documentation

Information regarding the ModSecurity language can be found in the ModSecurity Reference Manual.

Documentation for this crate can be found on docs.rs.

Requirements

This crate requires libmodsecurity >= 3.0.13 to be installed on your system.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 50

cargo fmt