Project

General

Profile

Actions

Feature #7666

open
PA PA

rust: zero-dependency crate suricata-ffi

Feature #7666: rust: zero-dependency crate suricata-ffi

Added by Philippe Antoine 12 months ago. Updated about 2 months ago.

Status:
In Progress
Priority:
Normal
Target version:
Effort:
Difficulty:
Label:

Description

To be used by plugins so that they do not need to pull and compile +200 dependencies to know the value ok ALPROTO_UNKNOWN and such


Related issues 6 (4 open2 closed)

Related to Suricata - Task #8445: rust: provide bindings to thread storageIn ProgressJason IshActions
Related to Suricata - Task #8446: rust: provide callbacks to flow life cycleIn ProgressJason IshActions
Related to Suricata - Task #8447: rust: provide bindings to flow storageIn ProgressJason IshActions
Blocks Suricata - Task #7501: rust/plugins: first class support for app-layer pluginsNewOISF DevActions
Blocked by Suricata - Bug #7667: rust: move extern C definitions to suricata_sys and bindgenClosedPhilippe AntoineActions
Blocked by Suricata - Optimization #7762: rust: finish moving extern C definitions to suricata_sys and bindgenClosedPhilippe AntoineActions

PA Updated by Philippe Antoine 12 months ago Actions #1

  • Blocks Task #7501: rust/plugins: first class support for app-layer plugins added

PA Updated by Philippe Antoine 12 months ago Actions #2

  • Subtask #7667 added

VJ Updated by Victor Julien 11 months ago Actions #3

  • Subtask deleted (#7667)

PA Updated by Philippe Antoine 11 months ago Actions #4

  • Blocked by Bug #7667: rust: move extern C definitions to suricata_sys and bindgen added

PA Updated by Philippe Antoine 10 months ago Actions #5

  • Blocked by Optimization #7762: rust: finish moving extern C definitions to suricata_sys and bindgen added

PA Updated by Philippe Antoine 9 months ago Actions #6

  • Tracker changed from Bug to Feature

PA Updated by Philippe Antoine 6 months ago Actions #7

  • Status changed from New to Assigned

PA Updated by Philippe Antoine 5 months ago Actions #8

Also, A plugin and Suricata should at runtime check their compile (C ifdef, rust cfg) options : like

#ifdef HAVE_MAGIC
    char *magic;
#endif

in File structure

JI Updated by Jason Ish 5 months ago Actions #9

Philippe Antoine wrote in #note-8:

Also, A plugin and Suricata should at runtime check their compile (C ifdef, rust cfg) options : like
[...]

in File structure

Ideally, we'd get rid of any of these for 9. I wonder if moving any compile-time options like this to the end of the structure would help. Of course, no plugin/lib could use them without explicit checking.

JI Updated by Jason Ish 5 months ago ยท Edited Actions #10

What do you think about naming? "core" doesn't work, as it does not contain the core of Suricata. I do want to get some binding code out of one of my plugins, and this crate is where it will go:

- suricata-ffi: Somewhat makes sense as it's Rust code for working with the Rust API via C interfaces
- suricata-api

But it's also kind of an odd API crate. As it's wrapping/bridging/adapting as its Rust bindings to C bindings to Rust: suricata-rcr? ;)

PA Updated by Philippe Antoine 5 months ago Actions #11

suricata-basics ?

JI Updated by Jason Ish 5 months ago Actions #12

Philippe Antoine wrote in #note-11:

suricata-basics ?

That would imply it contains Suricata's basic functionality, but it doesn't. It contains an interface to Suricata functionality, much of which is not "basic" at all.

JI Updated by Jason Ish 5 months ago Actions #13

How much of this stuff we need from plugins could ripple into the -sys crate if we bindgen'd it to C, then cbindgen'd it back to Rust? Did you try that before?

PA Updated by Philippe Antoine 5 months ago Actions #14

if we bindgen'd it to C, then cbindgen'd it back to Rust? Did you try that before?

Like I did for jsonbuilder ?

I think you were against filling Suricata-sys with other such stuff...

JI Updated by Jason Ish 5 months ago Actions #15

Philippe Antoine wrote in #note-14:

if we bindgen'd it to C, then cbindgen'd it back to Rust? Did you try that before?

Like I did for jsonbuilder ?

I think you were against filling Suricata-sys with other such stuff...

I was, somewhat.. But I think its making sense.

`-sys` for all C bindings, whether they be to Rust or C code. I wasn't liking the idea of putting C bindings to Rust code there before, but I'm seeing the light.

Then `-ffi` style crate with some nicer wrappers around those raw bindings? Maybe even name it `-wrapper`? Then many plugins would need only require `suricata-sys` and `suricata-wrapper` right?

PA Updated by Philippe Antoine about 2 months ago Actions #16

  • Status changed from Assigned to In Progress

https://github.com/OISF/suricata/pull/14797 has done a big share of the work

PA Updated by Philippe Antoine about 2 months ago Actions #17

  • Subject changed from rust: zero-dependency crate suricata-core to rust: zero-dependency crate suricata-ffi

JI Updated by Jason Ish 13 days ago Actions #19

  • Related to Task #8445: rust: provide bindings to thread storage added

JI Updated by Jason Ish 13 days ago Actions #20

  • Related to Task #8446: rust: provide callbacks to flow life cycle added

JI Updated by Jason Ish 13 days ago Actions #21

  • Related to Task #8447: rust: provide bindings to flow storage added
Actions

Also available in: PDF Atom