-
Notifications
You must be signed in to change notification settings - Fork 1.7k
detect/sip: add sticky buffers to match headers v2 #10907
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e23913a
detect/sip: add stub file for headers keywords
glongo f8fc238
rust/sip: store response headers
glongo f9b7215
rust/sip: match on headers map
glongo e061f30
detect/sip: add sip.from sticky buffer
glongo f6ff049
detect/sip: add sip.to sticky buffer
glongo d087d4d
detect/sip: add sip.via sticky buffer
glongo 3dca93b
detect/sip: add sip.user_agent sticky buffer
glongo f5703d8
detect/sip: add sip.content_type sticky buffer
glongo a9808b8
detect/sip: add sip.content_length sticky buffer
glongo 52f3f7f
detect/sip: register headers sticky buffers
glongo 7f5570e
doc: update upgrade section
glongo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ pub struct Response { | |
| pub version: String, | ||
| pub code: String, | ||
| pub reason: String, | ||
| pub headers: HashMap<String, String>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if I have multiple
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value is updated and the old one is returned. |
||
|
|
||
| pub response_line_len: u16, | ||
| pub headers_len: u16, | ||
|
|
@@ -130,7 +131,7 @@ pub fn sip_parse_response(oi: &[u8]) -> IResult<&[u8], Response> { | |
| let (i, reason) = parse_reason(i)?; | ||
| let (hi, _) = crlf(i)?; | ||
| let response_line_len = oi.len() - hi.len(); | ||
| let (phi, _headers) = parse_headers(hi)?; | ||
| let (phi, headers) = parse_headers(hi)?; | ||
| let headers_len = hi.len() - phi.len(); | ||
| let (bi, _) = crlf(phi)?; | ||
| let body_offset = oi.len() - bi.len(); | ||
|
|
@@ -140,6 +141,7 @@ pub fn sip_parse_response(oi: &[u8]) -> IResult<&[u8], Response> { | |
| version, | ||
| code: code.into(), | ||
| reason: reason.into(), | ||
| headers, | ||
|
|
||
| response_line_len: response_line_len as u16, | ||
| headers_len: headers_len as u16, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* Copyright (C) 2024 Open Information Security Foundation | ||
| * | ||
| * You can copy, redistribute or modify this Program under the terms of | ||
| * the GNU General Public License version 2 as published by the Free | ||
| * Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * version 2 along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| * 02110-1301, USA. | ||
| */ | ||
|
|
||
| /** | ||
| * \file | ||
| * | ||
| * \author Giuseppe Longo <giuseppe@glongo.it> | ||
| * | ||
| * Implements the sip.content_length sticky buffer | ||
| */ | ||
|
|
||
| #define KEYWORD_NAME "sip.content_length" | ||
| #define KEYWORD_DOC "sip-keywords.html#sip-content-length" | ||
| #define BUFFER_NAME "sip.content_length" | ||
| #define BUFFER_DESC "sip content-length header" | ||
| #define HEADER_NAME "Content-Length" | ||
| #define KEYWORD_ID DETECT_AL_SIP_HEADER_CONTENT_LENGTH | ||
| #define KEYWORD_TOSERVER 1 | ||
| #define KEYWORD_TOCLIENT 1 | ||
|
|
||
| #include "detect-sip-headers-stub.h" | ||
| #include "detect-sip-content-length.h" | ||
|
|
||
| void RegisterSipHeadersContentLength(void) | ||
| { | ||
| DetectSipHeadersRegisterStub(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* Copyright (C) 2024 Open Information Security Foundation | ||
| * | ||
| * You can copy, redistribute or modify this Program under the terms of | ||
| * the GNU General Public License version 2 as published by the Free | ||
| * Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * version 2 along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| * 02110-1301, USA. | ||
| */ | ||
|
|
||
| #ifndef __DETECT_SIP_CONTENT_LENGTH_H__ | ||
| #define __DETECT_SIP_CONTENT_LENGTH_H__ | ||
|
|
||
| void RegisterSipHeadersContentLength(void); | ||
|
|
||
| #endif /* __DETECT_SIP_CONTENT_LENGTH_H__ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* Copyright (C) 2024 Open Information Security Foundation | ||
| * | ||
| * You can copy, redistribute or modify this Program under the terms of | ||
| * the GNU General Public License version 2 as published by the Free | ||
| * Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * version 2 along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| * 02110-1301, USA. | ||
| */ | ||
|
|
||
| /** | ||
| * \author Giuseppe Longo <giuseppe@glongo.it> | ||
| * | ||
| * Implements the sip.content_type sticky buffer | ||
| */ | ||
|
|
||
| #define KEYWORD_NAME "sip.content_type" | ||
| #define KEYWORD_DOC "sip-keywords.html#sip-content-type" | ||
| #define BUFFER_NAME "sip.content_type" | ||
| #define BUFFER_DESC "sip content-type header" | ||
| #define HEADER_NAME "Content-Type" | ||
| #define KEYWORD_ID DETECT_AL_SIP_HEADER_CONTENT_TYPE | ||
| #define KEYWORD_TOSERVER 1 | ||
| #define KEYWORD_TOCLIENT 1 | ||
|
|
||
| #include "detect-sip-headers-stub.h" | ||
| #include "detect-sip-content-type.h" | ||
|
|
||
| void RegisterSipHeadersContentType(void) | ||
| { | ||
| DetectSipHeadersRegisterStub(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* Copyright (C) 2024 Open Information Security Foundation | ||
| * | ||
| * You can copy, redistribute or modify this Program under the terms of | ||
| * the GNU General Public License version 2 as published by the Free | ||
| * Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * version 2 along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| * 02110-1301, USA. | ||
| */ | ||
|
|
||
| #ifndef __DETECT_SIP_CONTENT_TYPE_H__ | ||
| #define __DETECT_SIP_CONTENT_TYPE_H__ | ||
|
|
||
| void RegisterSipHeadersContentType(void); | ||
|
|
||
| #endif /* __DETECT_SIP_CONTENT_TYPE_H__ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* Copyright (C) 2024 Open Information Security Foundation | ||
| * | ||
| * You can copy, redistribute or modify this Program under the terms of | ||
| * the GNU General Public License version 2 as published by the Free | ||
| * Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * version 2 along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| * 02110-1301, USA. | ||
| */ | ||
|
|
||
| /** | ||
| * \author Giuseppe Longo <giuseppe@glongo.it> | ||
| * | ||
| * Implements the sip.from sticky buffer | ||
| */ | ||
|
|
||
| #define KEYWORD_NAME "sip.from" | ||
| #define KEYWORD_DOC "sip-keywords.html#sip-from" | ||
| #define BUFFER_NAME "sip.from" | ||
| #define BUFFER_DESC "sip from header" | ||
| #define HEADER_NAME "From" | ||
| #define KEYWORD_ID DETECT_AL_SIP_HEADER_FROM | ||
| #define KEYWORD_TOSERVER 1 | ||
| #define KEYWORD_TOCLIENT 1 | ||
|
|
||
| #include "detect-sip-headers-stub.h" | ||
| #include "detect-sip-from.h" | ||
|
|
||
| void RegisterSipHeadersFrom(void) | ||
| { | ||
| DetectSipHeadersRegisterStub(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* Copyright (C) 2023 Open Information Security Foundation | ||
| * | ||
| * You can copy, redistribute or modify this Program under the terms of | ||
| * the GNU General Public License version 2 as published by the Free | ||
| * Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * version 2 along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| * 02110-1301, USA. | ||
| */ | ||
|
|
||
| #ifndef __DETECT_SIP_FROM_H__ | ||
| #define __DETECT_SIP_FROM_H__ | ||
|
|
||
| void RegisterSipHeadersFrom(void); | ||
|
|
||
| #endif /* __DETECT_SIP_FROM_H__ */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like these miss in doc/userguide/rules/sip-keywords.rst ;-)