-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Lua ssh 7607 v4 #13027
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
Lua ssh 7607 v4 #13027
Conversation
Completes commit 1206c1c
To enable easily hooks for rust app-layers such as SSH
So that we can use a short string for hooks in the end, by not having each value of the enum repeating the name of the enum
Allows signature like `alert ssh:banner_done`
Ticket: 7607
@@ -65,11 +65,12 @@ pub enum SSHEvent { | |||
|
|||
#[repr(u8)] | |||
#[derive(Copy, Clone, PartialOrd, PartialEq, Eq)] | |||
/// cbindgen:prefix-with-name=true |
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.
@jasonish any better trick ?
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.
Now I get in C SSHConnectionState_BannerDone
Ideally I would like SshStateBannerDone
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.
Elsewhere we just use full names inside the enum. Annoying to use from Rust though... So:
pub enum SSHConnectionState {
SSHConnectionStateInProgress,
}
this is preferable if also using from C, as it keeps the identifier name the same.
See discussion here: #8417
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.
Sure I knew that, and that is the current state but this fits bad with the derive introduced here...
Should the derive do the magic to strip the common prefix ?
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.
Will probably have to, I don't think you'll get the desired output with cbindgen alone?
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.
Managed to have something with Derive macro helper attributes
fn to_cstring(&self) -> *const c_char; | ||
|
||
/// Converts a C string formatted name to a state progress. | ||
unsafe extern "C" fn ffi_id_from_name(name: *const c_char, _dir: u8) -> c_int |
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.
I do not know where to put this, but this is for protocols which do not need the direction (like SSH)
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.
Probably as good here as any. However, perhaps the function doc should contain the additional information:
for protocols which do not need the direction (like SSH)
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.
adding
} | ||
|
||
/// Converts a variant ID to an FFI name. | ||
unsafe extern "C" fn ffi_name_from_id(id: c_int, _dir: u8) -> *const c_char |
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 sure c_int
is the best API but it is what it is
Information: QA ran without warnings. Pipeline 25702 |
Draft : need to take care of Jason's review, especially remove the commit ssh: rename connection state and adapt the derive magic |
Next in #13032 |
Link to ticket: https://redmine.openinfosecfoundation.org/issues/
https://redmine.openinfosecfoundation.org/issues/7607
Describe changes:
SV_BRANCH=OISF/suricata-verify#2445
#13024 clean with passing commit-check