-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust plugins: provide bindings to register eve filetype plugins - v1 #12446
base: master
Are you sure you want to change the base?
Conversation
With the recent refactor, the log level as seen by plugins was not being updated when being set through the C interface, so just set it directly upon plugin initialization.
This allow for an EVE file type plugin written in Rust to register itself without needing to provide its own Rust bindings.
// Get a child node of this node by name. | ||
// | ||
// Wrapper around ConfNodeLookupChild. | ||
// | ||
// Returns None if the child is not found. | ||
pub fn get_child(&self, name: &str) -> Option<ConfNode> { | ||
unsafe { | ||
let name = CString::new(name).unwrap(); | ||
let child = ConfNodeLookupChild(self.conf, name.as_ptr()); | ||
if child.is_null() { | ||
None | ||
} else { | ||
Some(ConfNode { conf: child }) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used by our Rust, but still an existing conf function that was never exposed to Rust. But useful to have.
#[repr(C)] | ||
pub struct EveFileType { | ||
name: *const c_char, | ||
open: EveFileInitFn, | ||
thread_init: EveFileThreadInitFn, | ||
write: EveFileWriteFn, | ||
thread_deinit: EveFileThreadDeinitFn, | ||
close: EveFileDeinitFn, | ||
pad: [usize; 2], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its kind of painful to have to duplicate this, yet I don't want to cbindgen
it from Rust to C, because this is functionality owned by C. The other alternative is bindgen
to generate Rust from C, but has some extra developer overhead like requiring clang.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12446 +/- ##
==========================================
- Coverage 80.63% 80.62% -0.01%
==========================================
Files 920 921 +1
Lines 258704 258740 +36
==========================================
+ Hits 208595 208606 +11
- Misses 50109 50134 +25
Flags with carried forward coverage won't be shown. Click here to find out more. |
Information: QA ran without warnings. Pipeline 24312 |
First, fix some breaking changes done in the visibility cleanups with respect to Rust plugins and using our log macros.
But primarily, add Rust bindings to our C EVE filetype registration. For 7.0 my Redis example plugin provided its own bindings, (see https://github.com/jasonish/suricata-redis-output/blob/main/src/ffi.rs), but ideally those should be provided by Suricata.
This patch brings enough bindings over to register EVE filetypes such as a Redis output without having to provide any custom C bindings itself.