diff --git a/Cargo.toml b/Cargo.toml index b521b1c..170bdd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modsecurity-rs" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Quang Luong "] description = "Safe wrapper around libmodsecurity" @@ -21,5 +21,4 @@ libc = "0.2.152" [build-dependencies] autocxx-build = "0.26" -cc = "1.0.83" miette = { version = "5.10", features = ["fancy"] } diff --git a/src/lib.rs b/src/lib.rs index 3ba3e52..47b16dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -138,26 +138,22 @@ impl<'m, 'r> Transaction<'m, 'r> { Ok(()) } - pub fn add_request_body(&mut self, body: &str) -> anyhow::Result<()> { - let len = body.len(); - let body = CString::new(body)?; + pub fn add_request_body(&mut self, body: &[u8]) -> anyhow::Result<()> { // # Safety: libmodsecurity must not reassign inner pointer unsafe { self.inner .as_mut() - .appendRequestBody(body.as_ptr() as _, len); + .appendRequestBody(body.as_ptr(), body.len()); } Ok(()) } - pub fn add_response_body(&mut self, body: &str) -> anyhow::Result<()> { - let len = body.len(); - let body = CString::new(body)?; + pub fn add_response_body(&mut self, body: &[u8]) -> anyhow::Result<()> { // # Safety: libmodsecurity must not reassign inner pointer unsafe { self.inner .as_mut() - .appendResponseBody(body.as_ptr() as _, len); + .appendResponseBody(body.as_ptr(), body.len()); } Ok(()) } diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}