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

Feature/http range/v29 #6355

Closed
wants to merge 18 commits into from

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/1576

Describe changes:

  • Uses a generic container (a thread-safe hash table whose key is the url/filename) to store file parts with HTTP Range header
  • handles reassembly of these parts, while enforcing a global memcap

suricata-verify-pr: 531
OISF/suricata-verify#531

Continues #6354 with

  • Using SuricataContext so as to compile suricata crate without C for unit tests

For testing : https://github.com/jasonish/suricata-http-range-test

victorjulien and others added 18 commits September 7, 2021 10:35
Compares two buffers with their two sizes
adds a container, ie a thread safe hash table whose
key is the filename

keep a tree of unordered ranges, up to a memcap limit

adds HTPFileOpenWithRange to handle like HTPFileOpen
if there is a range : open 2 files, one for the whole reassembled,
and one only for the current range
Simplify locking by using the THashData lock instead of a separate
range lock.

Avoid size_t in function arguments.

Clean up file handling functions.

Implement handling of alloc errors.

Rename yaml entry to byterange

Unify public api naming
Better structure design to ensure that one flow maximum
is owning and appending into the file, adding fileOwning field.

Adds also a gap field in a range buffer, so that we can
feed the gap on closing, when we are protected from concurrency
by a lock, (lock which got removed in the append path)

Fixes memcap when encountering a duplicate while inserting
in red and black tree

Adds many comments
To make concurrency reasoning clearer
so that borrow check gets happy
for future compatibility with rust
A block is determined out of order on opening.
But on closing, the gap before it may have been filled.
So, we must post-process it, ie iterate over the red and black
tree so see what blocks we can get.
Move the content-range parsing code to rust
@codecov
Copy link

codecov bot commented Sep 7, 2021

Codecov Report

Merging #6355 (2758109) into master (ca760e3) will decrease coverage by 0.02%.
The diff coverage is 69.26%.

@@            Coverage Diff             @@
##           master    #6355      +/-   ##
==========================================
- Coverage   76.96%   76.94%   -0.03%     
==========================================
  Files         612      613       +1     
  Lines      186410   186796     +386     
==========================================
+ Hits       143477   143723     +246     
- Misses      42933    43073     +140     
Flag Coverage Δ
fuzzcorpus 52.69% <49.06%> (-0.07%) ⬇️
suricata-verify 51.60% <70.68%> (+0.08%) ⬆️
unittests 62.91% <3.90%> (-0.13%) ⬇️

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

@catenacyber
Copy link
Contributor Author

@suricata-qa
Copy link

Information:

field test baseline %
tlpr1_stats_chk
.uptime 1344 1220 110.16%
.flow.mgr.rows_maxlen 450 404 111.39%
.detect.alert 3090528 3947262 78.3%

Pipeline 4089

@victorjulien
Copy link
Member

try: close before free < bad commit msg

@victorjulien victorjulien marked this pull request as draft September 24, 2021 08:01
match unsafe { SC } {
None => panic!("BUG no suricata_config"),
Some(c) => {
//TODO get a file container instead of NULL
Copy link
Member

Choose a reason for hiding this comment

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

TODO: address or remove comment if its not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be much easier when we have file per tx

Right now, I should do something like state.files.get(STREAM_TOCLIENT) but I do not have an easy reference to state in HTTP2Transaction::free

So, what should we do ?

@@ -350,6 +402,7 @@ pub struct HTTP2State {
transactions: Vec<HTTP2Transaction>,
progress: HTTP2ConnectionState,
pub files: Files,
flow: *const Flow,
Copy link
Member

Choose a reason for hiding this comment

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

ideally we're not adding this if we can just pass it around as a function argument

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right

@@ -0,0 +1,241 @@
/* Copyright (C) 2021 Open Information Security Foundation
Copy link
Member

Choose a reason for hiding this comment

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

Is the parsing of the content-range string the same for http1 and http2? If so I'd like to consolidate the parsing in Rust

Copy link
Member

Choose a reason for hiding this comment

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

whoops already done it seems, please ignore


return 0;
uint32_t len = bstr_len(rawvalue);
return rs_http2_parse_content_range(range, bstr_ptr(rawvalue), len);
Copy link
Member

Choose a reason for hiding this comment

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

nit: I don't like that the call has 'http2' in the name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, some leftover from development version when there were 2 parsing functions

@catenacyber
Copy link
Contributor Author

try: close before free < bad commit msg

squashed into the right commit

@catenacyber
Copy link
Contributor Author

Replaced by #6409

0xEniola added a commit to 0xEniola/suricata that referenced this pull request Oct 21, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
0xEniola added a commit to 0xEniola/suricata that referenced this pull request Oct 23, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
0xEniola added a commit to 0xEniola/suricata that referenced this pull request Nov 11, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
0xEniola added a commit to 0xEniola/suricata that referenced this pull request Nov 11, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
0xEniola added a commit to 0xEniola/suricata that referenced this pull request Nov 12, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
0xEniola added a commit to 0xEniola/suricata that referenced this pull request Nov 13, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
0xEniola added a commit to 0xEniola/suricata that referenced this pull request Nov 13, 2023
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
catenacyber pushed a commit to catenacyber/suricata that referenced this pull request Apr 12, 2024
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
catenacyber pushed a commit to catenacyber/suricata that referenced this pull request Apr 12, 2024
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
catenacyber pushed a commit to catenacyber/suricata that referenced this pull request Apr 12, 2024
Add more details to the tcp.mss keyword engine analysis output
Issue: OISF#6355
catenacyber added a commit to catenacyber/suricata that referenced this pull request Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants