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

ndpi: ndpi as a plugin - v10 #12560

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jasonish
Copy link
Member

Previous PR: #12476

Changes:

  • Addresses comments in previous PR
  • Adds chapter on nDPI plugin that contains installation instructs and both keywords.

This is probably my final iteration on this as it handles the "mechanics" of
bundled plugins I think. When reviewing, if you can, please try to consider the
"bundling" of plugins, vs the plugin itself.

Ticket: https://redmine.openinfosecfoundation.org/issues/7231

cardigliano and others added 6 commits February 11, 2025 13:12
- Download and build nDPI
- Enable nDPI during Suricata ./configure
- Test that the plugin was built and installed
The format is left free-form, as its controled by a plugin.
Split DetectHelperKeywordRegister into 2 functions, one for acquiring
a new keyword ID, and another to perform the registration.

This makes it easier to do the traditional C keyword initialization
with a dynamic ID.
- remove duplicate calls to ndpi_init_detection_module
- cleanup ndpi_init_detection_module when no longer needed
Moves the nDPI documentation to an nDPI page in the plugins
section. Remove the duplication of installation and setup
documentation.
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.

Project coverage is 80.70%. Comparing base (ef044b2) to head (1ac8450).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12560      +/-   ##
==========================================
- Coverage   80.71%   80.70%   -0.01%     
==========================================
  Files         928      928              
  Lines      259007   259008       +1     
==========================================
- Hits       209063   209044      -19     
- Misses      49944    49964      +20     
Flag Coverage Δ
fuzzcorpus 56.96% <88.88%> (+<0.01%) ⬆️
livemode 19.40% <88.88%> (+<0.01%) ⬆️
pcap 44.21% <88.88%> (-0.04%) ⬇️
suricata-verify 63.39% <88.88%> (+<0.01%) ⬆️
unittests 58.38% <88.88%> (+<0.01%) ⬆️

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

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24687

- Known Proto on Non Std Port
- Binary App Transfer
- Self-signed Certificate
- Susp DGA Domain name
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Suggest using full word instead of abbreviation.

Match on the flow risks detected by nDPI. Risks are potential issues detected
by nDPI during the packet dissection and include:

- Known Proto on Non Std Port
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/Non Std/non standard/

@@ -0,0 +1,537 @@
/* Copyright (C) 2024 Open Information Security Foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 2025

}
}

if (flowctx->detection_completed) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is DEBUG only, suggest guarding block with if (SCLogDebugEnabled())

{
struct NdpiThreadContext *threadctx = ThreadGetStorageById(tv, thread_storage_id);
struct NdpiFlowContext *flowctx = FlowGetStorageById(f, flow_storage_id);
uint16_t ip_len = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit -- neither ip_len nor ip_ptr require initialization as they're set by all logic paths before later user

/* Use ndpi_dpi2json to get a JSON with nDPI metadata */
ndpi_dpi2json(threadctx->ndpi, flowctx->ndpi_flow, flowctx->detected_l7_protocol, &serializer);

buffer = ndpi_serializer_get_buffer(&serializer, &buffer_len);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can ndpi_serializer_get_buffer return NULL?


- name: Build and install nDPI
run: |
curl -OL https://github.com/ntop/nDPI/archive/refs/tags/4.12.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the version number be refactored with a variable so it's easier to maintain across version updates?

@@ -6873,6 +6873,10 @@
}
},
"additionalProperties": false
},
"ndpi": {
"description": "nDPI plugin, contents provided by 3rd party library",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/3rd party/NTOP/?

ndpi-risk:[!]<risk>;

Where risk is one (or multiple comma-separated) of the risk codes supported by
nDPI (e.g. NDPI_BINARY_APPLICATION_TRANSFER). Please check ndpiReader -H for the
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: suggest using backticks with ndpiReader -H.

Additionally, rules using the ``ndpi-risk`` keyword should check if
the keyword exists using the ``requires`` keyword, for example::

``requires: keyword ndpi-risk``
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the backticks

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.

4 participants