Skip to content

Commit 38c1e74

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process OSQUERY plugin
1 parent 3cb500c commit 38c1e74

File tree

5 files changed

+54
-61
lines changed

5 files changed

+54
-61
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ add_subdirectory(ntp)
66
add_subdirectory(nettisa)
77
add_subdirectory(vlan)
88
add_subdirectory(flowHash)
9+
add_subdirectory(osquery)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project(ipfixprobe-process-osquery VERSION 1.0.0 DESCRIPTION "ipfixprobe-process-osquery plugin")
2+
3+
add_library(ipfixprobe-process-osquery MODULE
4+
src/osquery.cpp
5+
src/osquery.hpp
6+
)
7+
8+
set_target_properties(ipfixprobe-process-osquery PROPERTIES
9+
CXX_VISIBILITY_PRESET hidden
10+
VISIBILITY_INLINES_HIDDEN YES
11+
)
12+
13+
target_include_directories(ipfixprobe-process-osquery PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
)
16+
17+
install(TARGETS ipfixprobe-process-osquery
18+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/process/"
19+
)

src/plugins/process/osquery/README.md

Whitespace-only changes.

src/plugins/process/osquery.cpp renamed to src/plugins/process/osquery/src/osquery.cpp

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
/**
2-
* \file osqueryplugin.cpp
3-
* \brief Plugin for parsing osquery traffic.
4-
* \author Anton Aheyeu [email protected]
5-
* \date 2021
6-
*/
7-
8-
/*
9-
* Copyright (C) 2021 CESNET
10-
*
11-
* LICENSE TERMS
12-
*
13-
* Redistribution and use in source and binary forms, with or without
14-
* modification, are permitted provided that the following conditions
15-
* are met:
16-
* 1. Redistributions of source code must retain the above copyright
17-
* notice, this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright
19-
* notice, this list of conditions and the following disclaimer in
20-
* the documentation and/or other materials provided with the
21-
* distribution.
22-
* 3. Neither the name of the Company nor the names of its contributors
23-
* may be used to endorse or promote products derived from this
24-
* software without specific prior written permission.
25-
*
2+
* @file
3+
* @brief Plugin for parsing osquery traffic.
4+
* @author Anton Aheyeu [email protected]
5+
* @author Pavel Siska <[email protected]>
6+
* @date 2025
267
*
8+
* Copyright (c) 2025 CESNET
279
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2811
*/
2912

3013
#include "osquery.hpp"
@@ -35,23 +18,28 @@
3518
#include <iostream>
3619
#include <sstream>
3720

21+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
22+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
23+
3824
#define HEX(x) std::setw(2) << std::setfill('0') << std::hex << (int) (x)
3925

4026
namespace ipxp {
4127

42-
int RecordExtOSQUERY::REGISTERED_ID = -1;
28+
int RecordExtOSQUERY::REGISTERED_ID = ProcessPluginIDGenerator::instance().generatePluginID();
4329

44-
__attribute__((constructor)) static void register_this_plugin()
45-
{
46-
static PluginRecord rec = PluginRecord("osquery", []() { return new OSQUERYPlugin(); });
47-
register_plugin(&rec);
48-
RecordExtOSQUERY::REGISTERED_ID = register_extension();
49-
}
30+
static const PluginManifest osqueryPluginManifest = {
31+
.name = "osquery",
32+
.description = "Osquery process plugin for parsing osquery traffic.",
33+
.pluginVersion = "1.0.0",
34+
.apiVersion = "1.0.0",
35+
.usage = nullptr,
36+
};
5037

51-
OSQUERYPlugin::OSQUERYPlugin()
38+
OSQUERYPlugin::OSQUERYPlugin(const std::string& params)
5239
: manager(nullptr)
5340
, numberOfSuccessfullyRequests(0)
5441
{
42+
init(params.c_str());
5543
}
5644

5745
OSQUERYPlugin::OSQUERYPlugin(const OSQUERYPlugin& p)
@@ -647,4 +635,7 @@ int OsqueryRequestManager::getPositionForParseJson()
647635
return -1;
648636
}
649637

638+
static const PluginRegistrar<OSQUERYPlugin, ProcessPluginFactory>
639+
osqueryRegistrar(osqueryPluginManifest);
640+
650641
} // namespace ipxp

src/plugins/process/osquery.hpp renamed to src/plugins/process/osquery/src/osquery.hpp

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
11
/**
2-
* \file osqueryplugin.hpp
3-
* \brief Plugin for parsing osquery traffic.
4-
* \author Anton Aheyeu [email protected]
5-
* \date 2021
6-
*/
7-
8-
/*
9-
* Copyright (C) 2021 CESNET
10-
*
11-
* LICENSE TERMS
12-
*
13-
* Redistribution and use in source and binary forms, with or without
14-
* modification, are permitted provided that the following conditions
15-
* are met:
16-
* 1. Redistributions of source code must retain the above copyright
17-
* notice, this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright
19-
* notice, this list of conditions and the following disclaimer in
20-
* the documentation and/or other materials provided with the
21-
* distribution.
22-
* 3. Neither the name of the Company nor the names of its contributors
23-
* may be used to endorse or promote products derived from this
24-
* software without specific prior written permission.
25-
*
2+
* @file
3+
* @brief Plugin for parsing osquery traffic.
4+
* @author Anton Aheyeu [email protected]
5+
* @author Pavel Siska <[email protected]>
6+
* @date 2025
267
*
8+
* Copyright (c) 2025 CESNET
279
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2811
*/
2912

30-
#ifndef IPXP_PROCESS_OSQUERY_HPP
31-
#define IPXP_PROCESS_OSQUERY_HPP
13+
#pragma once
3214

15+
#include <cstring>
3316
#include <sstream>
3417
#include <string>
3518

@@ -44,7 +27,7 @@
4427
#include <ipfixprobe/flowifc.hpp>
4528
#include <ipfixprobe/ipfix-elements.hpp>
4629
#include <ipfixprobe/packet.hpp>
47-
#include <ipfixprobe/process.hpp>
30+
#include <ipfixprobe/processPlugin.hpp>
4831

4932
#define DEFAULT_FILL_TEXT "UNDEFINED"
5033

@@ -529,7 +512,7 @@ struct OsqueryRequestManager {
529512
*/
530513
class OSQUERYPlugin : public ProcessPlugin {
531514
public:
532-
OSQUERYPlugin();
515+
OSQUERYPlugin(const std::string& params);
533516
~OSQUERYPlugin();
534517
OSQUERYPlugin(const OSQUERYPlugin& p);
535518
void init(const char* params);
@@ -553,4 +536,3 @@ class OSQUERYPlugin : public ProcessPlugin {
553536
};
554537

555538
} // namespace ipxp
556-
#endif /* IPXP_PROCESS_OSQUERY_HPP */

0 commit comments

Comments
 (0)