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

Add support to TCP and UDP protocols #224

Open
wants to merge 45 commits into
base: dev
Choose a base branch
from
Open

Conversation

ThibaudCartegnie
Copy link
Contributor

@ThibaudCartegnie ThibaudCartegnie commented Jun 15, 2021

✨ Add support to TCP and UDP protocols #224

‼️ Once all the checklist is done you have to:

  • stash merge this pull request
  • delete the corresponding branch
  • close the associated issue

📃 Type of change

Breaking change: fix or feature that would cause existing functionality to not work as expected.

✒️ Description

This PR adds the support for udp and tcp besides Unix sockets.

There are 2 major changes for the protocol :

  • The Darwin Header no longer contains a Certitude by default and it is now defined as packed, lowering its size from 56 bytes to 48 bytes.
  • The Manager configuration file holds a 'network' field to specify how the filter receives data (Unix Socket, TCP or UDP)

This draft is pushed for early comments.

🎯 Test Environments

Ubuntu (20.04)

  • Redis (5.0.7)
  • Boost (1.71.0)
  • g++ (9.3)
  • CMake (3.16.3)
  • Python (3.8.5)
  • Valgrind (3.15.0)

HardenedBSD (12.2)

  • Redis (6.0.14)
  • Boost (1.72.0)
  • clang (10.0.1)
  • CMake (3.20.4)
  • Python (3.8.10)
  • Valgrind(N/A)

✔️ Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • (If new filter) I have added corresponding page to the documentation
  • (If other changes) I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

  • 🙋 I certify on my honor that all the information provided is true, and I've done all I can to deliver a high quality code

Thibaud Cartegnie and others added 30 commits June 9, 2021 17:51
If more than 1 certitude is sent back to client AND a body is set, the body is copied on the memory location of the certitudes
It is fixed by using the correct offset when copying the body data.
The other function using similar logic has been modified to keep it coherent.
UnixSessions are spawn by UnixServer and TcpSessions by TcpServer
Included a modification when passing arguments from sessions to task (move instead of ref)
 - Used to pass needed data from Session to Task
(some work is still need for the tasks)
State accessible by const getters only
State mutable with only two methods : add Certitude and mutateBody
Added a few methods for DarwinPacket
Added ParseBody in ATask::run with error handling
Fixed issues with threadpool instance and size issues in the ASession
Fixed issues in the serialization
Added support for ipv6 in Tcp sessions
Adapted python manager to handle tcp sockets
The packet was illformed near the certitudes
NextFilterConnector: Working WIP
Abstract/Tcp/Unix, fixed configuration for nextFilter
- DarwinPacket copied only the first 15 bytes of event id
- Destructor of AServer wasn't virtual leading to memory leak when
UnixServer was destroyed
Service.update did not update nettwork field
Added retry attempts, modified tests accordingly
Proprietary filters needed additional methods for accessing private
fields of a packet
Added possibility to run all tests in TCP mode
Assured working with ipv4 and ipv6 addresses
Fixed a few log lines in the redis test file
Fixed a few problems and cleaned some code
Added tests for tcp and udp
Added possibility to run all test in unix or tcp
Removed unused methods
Specification of move semantic for DarwinPacket
EvtIdToString passed from Session to DarwinPacket
added packed attribute to darwin header
Removed certitude list default size
Modified parsing and serializing accordingly
Most case were unused variables or poorly chosen types
Fixed issue with positional flags between test/manager and filters
@ThibaudCartegnie ThibaudCartegnie marked this pull request as ready for review July 30, 2021 12:47
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
samples/base/AGenerator.hpp Outdated Show resolved Hide resolved
samples/base/ATask.cpp Outdated Show resolved Hide resolved
toolkit/Network.cpp Outdated Show resolved Hide resolved
samples/fbuffer/Connectors/AConnector.cpp Outdated Show resolved Hide resolved
samples/ftest/TestTask.cpp Show resolved Hide resolved
samples/ftest/TestTask.cpp Show resolved Hide resolved
samples/fyara/YaraTask.cpp Outdated Show resolved Hide resolved
samples/base/network/ASession.hpp Outdated Show resolved Hide resolved
- errors in comments
- missing parts of tests (and logging missing)
- removed useless variable in NextFilterConnector
@frikilax
Copy link
Member

Yeah, I'll try being lighter next time when suggesting changes: applying/validating them is a pain on github 😅

@frikilax
Copy link
Member

Outside my remaining comments (which aren't really important, except the one on RedisManager.cpp), everything seems great!

@HugoSoszynski thoughts on the PR and remaining comments I made (especially this one)?

frikilax
frikilax previously approved these changes Feb 1, 2022
HugoSoszynski
HugoSoszynski previously approved these changes Mar 28, 2022
Removed TODO : No handling of tcp case needed in that part, nothing to be changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants