Skip to content

Commit c362af6

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process TLS plugin
1 parent 6646a11 commit c362af6

File tree

8 files changed

+74
-39
lines changed

8 files changed

+74
-39
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ add_subdirectory(netbios)
2323
add_subdirectory(passiveDns)
2424
add_subdirectory(smtp)
2525
add_subdirectory(quic)
26+
add_subdirectory(tls)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
project(ipfixprobe-process-tls VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-tls plugin")
2+
3+
add_library(ipfixprobe-process-tls MODULE
4+
src/tls.cpp
5+
src/tls.hpp
6+
src/md5.cpp
7+
src/md5.hpp
8+
src/sha256.hpp
9+
)
10+
11+
set_target_properties(ipfixprobe-process-tls PROPERTIES
12+
CXX_VISIBILITY_PRESET hidden
13+
VISIBILITY_INLINES_HIDDEN YES
14+
)
15+
16+
target_include_directories(ipfixprobe-process-tls PRIVATE
17+
${CMAKE_SOURCE_DIR}/include/
18+
${CMAKE_SOURCE_DIR}/src/plugins/process/common
19+
)
20+
21+
target_link_libraries(ipfixprobe-process-tls PRIVATE
22+
ipfixprobe-process-tls-parser
23+
)
24+
25+
install(TARGETS ipfixprobe-process-tls
26+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
27+
)

src/plugins/process/tls/README.md

Whitespace-only changes.
Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
1-
/* SPDX-License-Identifier: BSD-3-Clause
2-
* Copyright (C) 2018-2022, CESNET z.s.p.o.
3-
*/
4-
51
/**
6-
* \file tls.cpp
7-
* \brief Plugin for enriching flows for tls data.
8-
* \author Jiri Havranek <[email protected]>
9-
* \author Ondrej Sedlacek <[email protected]>
10-
* \author Karel Hynek <[email protected]>
11-
* \author Andrej Lukacovic [email protected]
12-
* \author Jonas Mücke <[email protected]>
13-
* \date 2018-2022
2+
* @file
3+
* @brief Plugin for enriching flows for tls data.
4+
* @author Jiri Havranek <[email protected]>
5+
* @author Karel Hynek <[email protected]>
6+
* @author Andrej Lukacovic [email protected]
7+
* @author Jonas Mücke <[email protected]>
8+
* @author Pavel Siska <[email protected]>
9+
*
10+
* Copyright (c) 2025 CESNET
11+
*
12+
* SPDX-License-Identifier: BSD-3-Clause
1413
*/
15-
16-
#include "tls.hpp"
17-
1814
#include "md5.hpp"
1915
#include "sha256.hpp"
16+
#include "tls.hpp"
2017

2118
#include <algorithm>
2219
#include <cctype>
2320
#include <functional>
2421
#include <iostream>
2522
#include <numeric>
2623

24+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
25+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
2726
#include <stdio.h>
2827

2928
namespace ipxp {
30-
int RecordExtTLS::REGISTERED_ID = -1;
31-
32-
__attribute__((constructor)) static void register_this_plugin()
33-
{
34-
static PluginRecord rec = PluginRecord("tls", []() { return new TLSPlugin(); });
29+
int RecordExtTLS::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
3530

36-
register_plugin(&rec);
37-
RecordExtTLS::REGISTERED_ID = register_extension();
38-
}
31+
static const PluginManifest tlsPluginManifest = {
32+
.name = "tls",
33+
.description = "Tls process plugin for parsing tls traffic.",
34+
.pluginVersion = "1.0.0",
35+
.apiVersion = "1.0.0",
36+
.usage = nullptr,
37+
};
3938

4039
// Print debug message if debugging is allowed.
4140
#ifdef DEBUG_TLS
@@ -51,6 +50,11 @@ __attribute__((constructor)) static void register_this_plugin()
5150
#define DEBUG_CODE(code)
5251
#endif
5352

53+
TLSPlugin::TLSPlugin(const std::string& params)
54+
{
55+
init(params.c_str());
56+
}
57+
5458
OptionsParser* TLSPlugin::get_parser() const
5559
{
5660
return new OptionsParser("tls", "Parse SNI from TLS traffic");
@@ -412,4 +416,7 @@ void TLSPlugin::finish(bool print_stats)
412416
std::cout << " Parsed SNI: " << parsed_sni << std::endl;
413417
}
414418
}
419+
420+
static const PluginRegistrar<TLSPlugin, ProcessPluginFactory> tlsRegistrar(tlsPluginManifest);
421+
415422
} // namespace ipxp
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/* SPDX-License-Identifier: BSD-3-Clause
2-
* Copyright (C) 2018-2022, CESNET z.s.p.o.
3-
*/
4-
51
/**
6-
* \file tls.hpp
7-
* \brief Plugin for enriching flows for tls data.
8-
* \author Jiri Havranek <[email protected]>
9-
* \author Karel Hynek <[email protected]>
10-
* \author Andrej Lukacovic [email protected]
11-
* \author Jonas Mücke <[email protected]>
12-
* \date 2022
2+
* @file
3+
* @brief Plugin for enriching flows for tls data.
4+
* @author Jiri Havranek <[email protected]>
5+
* @author Karel Hynek <[email protected]>
6+
* @author Andrej Lukacovic [email protected]
7+
* @author Jonas Mücke <[email protected]>
8+
* @author Pavel Siska <[email protected]>
9+
*
10+
* Copyright (c) 2025 CESNET
11+
*
12+
* SPDX-License-Identifier: BSD-3-Clause
1313
*/
1414

15-
#ifndef IPXP_PROCESS_TLS_HPP
16-
#define IPXP_PROCESS_TLS_HPP
15+
#pragma once
1716

1817
#include <array>
1918
#include <cstring>
@@ -27,9 +26,9 @@
2726
#include <ipfixprobe/ipfix-basiclist.hpp>
2827
#include <ipfixprobe/ipfix-elements.hpp>
2928
#include <ipfixprobe/packet.hpp>
30-
#include <ipfixprobe/process.hpp>
29+
#include <ipfixprobe/processPlugin.hpp>
3130
#include <ipfixprobe/utils.hpp>
32-
#include <process/tls_parser.hpp>
31+
#include <tlsParser/tls_parser.hpp>
3332

3433
#ifdef WITH_NEMEA
3534
#include "fields.h"
@@ -191,6 +190,7 @@ struct RecordExtTLS : public RecordExt {
191190
*/
192191
class TLSPlugin : public ProcessPlugin {
193192
public:
193+
TLSPlugin(const std::string& params);
194194
~TLSPlugin() override;
195195
void init(const char* params) override;
196196
void close() override;
@@ -214,5 +214,5 @@ class TLSPlugin : public ProcessPlugin {
214214
TLSParser tls_parser {};
215215
uint32_t parsed_sni {0};
216216
};
217+
217218
} // namespace ipxp
218-
#endif /* IPXP_PROCESS_TLS_HPP */

0 commit comments

Comments
 (0)