Skip to content
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

Applayer plugin 5053 v11 #12471

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

catenacyber
Copy link
Contributor

Link to ticket: https://redmine.openinfosecfoundation.org/issues/
https://redmine.openinfosecfoundation.org/issues/4102 with all 6 subtickets

Describe changes:

  • add app-layer plugin example with template protocol
  • document app-layer plugins

@jufajardini what do you think about the doc ?

#12467 rebased to get green CI

There are also #12470 and #12466 which will require a rebase of this PR if they get merged first (or the other way around)

cc @jasonish

and use generic logger callback prototype with later cast

and do some other small modifications so that the plugin
has less diff
so that it can be used by plugins

Avoid export by cbindgen as this constant is also defined in C
so that it can be used by plugins that want to call SCLogError
and such
Comment on lines +31 to +39
// Struct definitions
#[repr(C)]
#[allow(non_snake_case)]
pub struct SCPlugin {
pub name: *const libc::c_char,
pub license: *const libc::c_char,
pub author: *const libc::c_char,
pub Init: extern "C" fn(),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good example of a data structure that should remain in C, and be provided to Rust via bindgen instead of continuing the pattern of creating C data structure in Rust for the convenience of write once.

@@ -83,7 +83,7 @@ extern crate suricata_derive;
pub mod core;

#[macro_use]
pub(crate) mod debug;
pub mod debug;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you also need 8b12670

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I broke out the fixes from my previous PR to expose SCPlugin to Rust to just a minimal one to fix logging from plugins:

#12472

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 84.09091% with 7 lines in your changes missing coverage. Please review.

Project coverage is 80.55%. Comparing base (d63ad75) to head (b35cd6d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12471      +/-   ##
==========================================
+ Coverage   80.52%   80.55%   +0.02%     
==========================================
  Files         923      923              
  Lines      259176   259543     +367     
==========================================
+ Hits       208708   209067     +359     
- Misses      50468    50476       +8     
Flag Coverage Δ
fuzzcorpus 56.16% <79.54%> (+0.09%) ⬆️
livemode 19.36% <4.54%> (-0.05%) ⬇️
pcap 44.27% <43.18%> (+0.07%) ⬆️
suricata-verify 63.34% <83.33%> (+0.01%) ⬆️
unittests 58.37% <29.54%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24348

jasonish and others added 6 commits January 25, 2025 08:23
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.
so that they can be used by rust plugins
Ticket: 7151
Ticket: 7152
Ticket: 7154
Ticket: 7149
Ticket: 7150
Ticket: 7153
@catenacyber catenacyber force-pushed the applayer-plugin-5053-v11 branch from d08fb5c to b35cd6d Compare January 25, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants