-
Notifications
You must be signed in to change notification settings - Fork 1.6k
transform/subslice: Add subslice transform #14372
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
Conversation
The subslice transform creates a slice of the input buffer.
Specify the subslice desired -- nbytes is optional:
subslice: offset <,nbytes>
offset: Specifies the starting offset for the new subslice. When
negative, expresses how far from the end of the input buffer to begin.
When nbytes is *not* specified, start must be > 0.
nbytes: Specifies the size of the subslice. When negative, specifies the
byte count preceding the offset to include. Nbytes must be > 0.
When nbytes is not specified, the size of the subslice will be the size
of the input buffer - offset.
Examples:
subslice: 1; - The subslice will be a copy of the input
buffer but omits the input buffer's first byte
"This is Suricata" -> "his is Suricata"
subslice: 0, 13; - The slice is created from the first 13 bytes
of the input buffer
"This is Suricata" -> "This is Suric"
subslice: 10, -5; - The subslice is created starting at offset 10
and continues to 5 bytes before the end of the input buffer
"This is Suricata" -> "r"
subslice: -3; - The subslice will be the last 3 bytes of the
input buffer.
"This is Suricata" -> "ata"
Add documentation for the subslice transform. Issue: 7672
|
What is the behavior if offset > the end of the buffer? Will What is the behavior if offset+nbytes > end of buffer, so we get data but not nbytes? Can you update the SV tests to cover both scenarios? |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14372 +/- ##
==========================================
+ Coverage 84.19% 84.21% +0.02%
==========================================
Files 1012 1013 +1
Lines 261796 262056 +260
==========================================
+ Hits 220414 220687 +273
+ Misses 41382 41369 -13
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Information: QA ran without warnings. Pipeline = 28533 |
No --
Yes. |
With a buffer like Thoughts? |
There is a generic open ticket about transforms error (like base64) https://redmine.openinfosecfoundation.org/issues/7313 |
|
|
||
| When `nbytes` is not specified, the size of the subslice will be the size | ||
| of the input buffer minus the `offset` value. The value of ``offset`` must | ||
|
|
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.
Need to document the out of bounds cases behavior
catenacyber
left a comment
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.
As per Victor's point
|
Continued in #14428 |
I think I'd prefer to be a bit permissive, but I don't really have a use case in mind. |
Continuation of #14366
The subslice transform creates a slice of the input buffer.
Specify the subslice desired -- nbytes is optional:
subslice: offset <,nbytes>
offset: Specifies the starting offset for the new subslice. When negative, it expresses how far from the end of the input buffer to begin.
nbytes: Specifies the size of the subslice. When negative, specifies the byte count preceding the offset to include.
When nbytes is not specified, the size of the subslice will be the size of the input buffer - offset.
Examples:
subslice: 1; - The subslice will be a copy of the input
buffer but omit the input buffer's first byte
"This is Suricata" -> "his is Suricata"
subslice: 0, 13; - The slice is created from the first 13 bytes
of the input buffer
"This is Suricata" -> "This is Suric"
subslice: 10, -5; - This is the same as subslice[5, 5]
"This is Suricata" -> "is Su"
subslice: -3; - The subslice will be the last 3 bytes of the
input buffer.
"This is Suricata" -> "ata"
Link to ticket: https://redmine.openinfosecfoundation.org/issues/7672
Describe changes:
Updates:
[3],[3, 8]`DetectTransformSubsliceDatato be attributed withrepr(C)nbytevalues to mean "bytes from the end" .start=0is an error unlessnbytesis specifiedend=0is always an error.Provide values to any of the below to override the defaults.
link to the pull request in the respective
_BRANCHvariable.SV_REPO=
SV_BRANCH=OISF/suricata-verify#2749
SU_REPO=
SU_BRANCH=