Skip to content

Comments

Websockets 2695 v12#10130

Closed
catenacyber wants to merge 12 commits intoOISF:masterfrom
catenacyber:websockets-2695-v12
Closed

Websockets 2695 v12#10130
catenacyber wants to merge 12 commits intoOISF:masterfrom
catenacyber:websockets-2695-v12

Conversation

@catenacyber
Copy link
Contributor

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

Describe changes:

SV_BRANCH=pr/1571

OISF/suricata-verify#1571

#10121 with last commit to optionally log websocket payload in alerts. cc @jasonish for the jsonbuilder hack

I think this is good enough for a first version even if there may be improvements (that should happen in later tickets) :

  • using latest HTTP/1 transaction in a single rule, instead of splitting rule and using flowbits. Should the Websocket state own the last HTTP1 transaction ? And if so, need to see with DOH2 as well the mechanism to get the right transaction for each keyword...
  • support websockets over HTTP/2 : need pcap
    This is a big one as websockets over HTTP/2 only use a single HTTP/2 stream and not the whole TCP connection which keeps having newer regular HTTP/2 streams (or other websocket ones). That means a HTTP2 transactions will own a Websocket State + some streaming buffer as TCP...

#9870 should likely precede this

catenacyber and others added 12 commits January 5, 2024 09:23
So that we can write enip.revision: 0x203

Ticket: 6645
Ticket: 6647

Allows keywords using integers to use strings in signature
parsing based on a rust enumeration with a derive.
Ticket: 6648

Like &0x40=0x40 to test for a specific bit set
Ticket: 6628

Document the generic detection capabilities for integer keywords.
and make every integer keyword pointing to this section.
if no config option is found,
as is done for udp

Ticket: 6304
Including the one for websocket over HTTP/2
port is used in AppLayerProtoDetectProbingParserPort
and not in AppLayerProtoDetectProbingParserElement
As for WebSocket which is detected only by protocol change.
When there is a protocol change, and a specific protocol is
expected, like WebSeocket, always run it, no matter the port.
@codecov
Copy link

codecov bot commented Jan 7, 2024

Codecov Report

Attention: 100 lines in your changes are missing coverage. Please review.

Comparison is base (a37fa62) 82.15% compared to head (e685ad0) 82.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10130      +/-   ##
==========================================
- Coverage   82.15%   82.06%   -0.09%     
==========================================
  Files         974      980       +6     
  Lines      271925   272559     +634     
==========================================
+ Hits       223394   223682     +288     
- Misses      48531    48877     +346     
Flag Coverage Δ
fuzzcorpus 62.73% <51.52%> (-0.16%) ⬇️
suricata-verify 61.46% <75.76%> (+0.01%) ⬆️
unittests 62.76% <29.81%> (-0.09%) ⬇️

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

@suricata-qa
Copy link

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.tcp.pseudo 2810 3014 107.26%

Pipeline 17386

Comment on lines +189 to +197
// Unclose an object which must not be empty.
pub fn unclose(&mut self) -> Result<&mut Self, JsonError> {
match self.buf.pop() {
Some('}') => {}
_ => {return Err(JsonError::InvalidState);}
}
self.push_state(State::ObjectNth)?;
Ok(self)
}
Copy link
Member

Choose a reason for hiding this comment

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

Its quite confusing to me why this is even required? Wouldn't refactoring the calling code a little get rid of this need?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

answering in the next comment as they are both about the same thing...

Comment on lines +317 to +326
if (proto == ALPROTO_WEBSOCKET) {
if (option_flags &
(LOG_JSON_WEBSOCKET_PAYLOAD | LOG_JSON_WEBSOCKET_PAYLOAD_BASE64)) {
bool pp = (option_flags & LOG_JSON_WEBSOCKET_PAYLOAD) != 0;
bool pb64 = (option_flags & LOG_JSON_WEBSOCKET_PAYLOAD_BASE64) != 0;
if (!SCWebSocketLogDetails(tx, jb, pp, pb64)) {
jb_restore_mark(jb, &mark);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I guess here we've already opened, logged and closed the app-layer TX. It does feel like a hack. I think I would rather see:

  • the opening and closing of the object here, then LogTx just fills in the open object but doesn't make the choice about closing it, somewhat undoes some previous work you did though.
  • or passing in extra flags to LogTx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First, I had the flags to the logging function, but it did not feel right.

I will switch back to that in the next version so that we can talk about it

@catenacyber
Copy link
Contributor Author

Replaced by #10163

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