This is an automated email from the ASF dual-hosted git repository. szaszm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 186f163599b6526d20e1dd6b73fe2ec27770dce0 Author: Martin Zink <[email protected]> AuthorDate: Mon Jun 14 16:26:07 2021 +0200 MINIFICPP-1567 enable linter checks in extensions (part 1) extensions: wel, bustache, civetweb, coap Closes #1089 Signed-off-by: Marton Szasz <[email protected]> --- extensions/bustache/ApplyTemplate.cpp | 4 +- extensions/bustache/ApplyTemplate.h | 8 +- extensions/bustache/CMakeLists.txt | 1 + extensions/bustache/TemplateLoader.h | 8 +- extensions/civetweb/CMakeLists.txt | 2 +- extensions/civetweb/processors/ListenHTTP.cpp | 5 ++ extensions/civetweb/processors/ListenHTTP.h | 13 +-- extensions/coap/CMakeLists.txt | 2 +- extensions/coap/COAPLoader.h | 8 +- .../coap/controllerservice/CoapConnector.cpp | 6 +- extensions/coap/controllerservice/CoapConnector.h | 17 ++-- extensions/coap/controllerservice/CoapMessaging.h | 14 ++- extensions/coap/controllerservice/CoapResponse.h | 11 +-- extensions/coap/nanofi/coap_functions.h | 2 - extensions/coap/nanofi/coap_message.h | 5 +- extensions/coap/nanofi/coap_server.h | 5 +- extensions/coap/protocols/CoapC2Protocol.cpp | 2 +- extensions/coap/protocols/CoapC2Protocol.h | 11 +-- extensions/coap/server/CoapServer.cpp | 2 + extensions/coap/server/CoapServer.h | 28 +++--- extensions/coap/tests/CoapC2VerifyHeartbeat.cpp | 6 +- extensions/coap/tests/CoapIntegrationBase.h | 11 +-- extensions/windows-event-log/Bookmark.cpp | 17 +++- extensions/windows-event-log/Bookmark.h | 16 ++-- extensions/windows-event-log/CMakeLists.txt | 1 + .../CollectorInitiatedSubscription.cpp | 26 +++--- .../CollectorInitiatedSubscription.h | 21 +++-- .../windows-event-log/ConsumeWindowsEventLog.cpp | 33 +++---- .../windows-event-log/ConsumeWindowsEventLog.h | 35 +++++--- extensions/windows-event-log/SupportedProperty.h | 12 +-- extensions/windows-event-log/TailEventLog.cpp | 24 +++-- extensions/windows-event-log/TailEventLog.h | 23 ++--- .../tests/CWELCustomProviderTests.cpp | 3 +- extensions/windows-event-log/tests/CWELTestUtils.h | 6 ++ .../tests/MetadataWalkerTests.cpp | 100 ++++++++++----------- .../tests/custom-provider/CPPLINT.cfg | 1 + extensions/windows-event-log/wel/JSONUtils.h | 6 +- .../windows-event-log/wel/MetadataWalker.cpp | 34 +++---- extensions/windows-event-log/wel/MetadataWalker.h | 25 ++++-- .../windows-event-log/wel/UnicodeConversion.h | 36 ++++---- .../windows-event-log/wel/WindowsEventLog.cpp | 33 +++---- extensions/windows-event-log/wel/WindowsEventLog.h | 49 +++++----- extensions/windows-event-log/wel/XMLString.h | 31 ++++--- libminifi/include/io/ClientSocket.h | 4 +- 44 files changed, 380 insertions(+), 327 deletions(-) diff --git a/extensions/bustache/ApplyTemplate.cpp b/extensions/bustache/ApplyTemplate.cpp index 5550900..d4cdde5 100644 --- a/extensions/bustache/ApplyTemplate.cpp +++ b/extensions/bustache/ApplyTemplate.cpp @@ -17,16 +17,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "ApplyTemplate.h" + #include <iostream> #include <fstream> #include <memory> #include <set> +#include <string> #include <boost/iostreams/device/mapped_file.hpp> #include <bustache/model.hpp> -#include "ApplyTemplate.h" namespace org { namespace apache { diff --git a/extensions/bustache/ApplyTemplate.h b/extensions/bustache/ApplyTemplate.h index 7b0526e..a2c0e6f 100644 --- a/extensions/bustache/ApplyTemplate.h +++ b/extensions/bustache/ApplyTemplate.h @@ -17,10 +17,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef __APPLY_TEMPLATE_H__ -#define __APPLY_TEMPLATE_H__ +#pragma once #include <memory> +#include <string> #include "core/Processor.h" #include "core/ProcessSession.h" @@ -41,7 +41,7 @@ class ApplyTemplate : public core::Processor { /*! * Create a new processor */ - ApplyTemplate(const std::string& name, const utils::Identifier& uuid = {}) + explicit ApplyTemplate(const std::string& name, const utils::Identifier& uuid = {}) : Processor(name, uuid), logger_(logging::LoggerFactory<ApplyTemplate>::getLogger()) {} ~ApplyTemplate() = default; @@ -81,5 +81,3 @@ REGISTER_RESOURCE(ApplyTemplate, "Applies the mustache template specified by the } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif diff --git a/extensions/bustache/CMakeLists.txt b/extensions/bustache/CMakeLists.txt index 7cdf351..2dfb31d 100644 --- a/extensions/bustache/CMakeLists.txt +++ b/extensions/bustache/CMakeLists.txt @@ -33,3 +33,4 @@ target_link_libraries(minifi-bustache-extensions BUSTACHE::libbustache) SET (BUSTACHE-EXTENSIONS minifi-bustache-extensions PARENT_SCOPE) register_extension(minifi-bustache-extensions) +register_extension_linter(minifi-bustache-extensions-linter) diff --git a/extensions/bustache/TemplateLoader.h b/extensions/bustache/TemplateLoader.h index 2378aa1..edc7808 100644 --- a/extensions/bustache/TemplateLoader.h +++ b/extensions/bustache/TemplateLoader.h @@ -15,8 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSION_TEMPLATELOADER_H -#define EXTENSION_TEMPLATELOADER_H +#pragma once + +#include <memory> +#include <string> +#include <vector> #include "ApplyTemplate.h" #include "core/ClassLoader.h" @@ -60,4 +63,3 @@ class TemplateFactory : public core::ObjectFactory { extern "C" { DLL_EXPORT void *createTemplateFactory(void); } -#endif /* EXTENSION_TEMPLATELOADER_H */ diff --git a/extensions/civetweb/CMakeLists.txt b/extensions/civetweb/CMakeLists.txt index aaa9968..e7e8985 100644 --- a/extensions/civetweb/CMakeLists.txt +++ b/extensions/civetweb/CMakeLists.txt @@ -34,4 +34,4 @@ target_link_libraries(minifi-civet-extensions CIVETWEB::c-library CIVETWEB::cive SET (civet-EXTENSIONS minifi-civet-extensions PARENT_SCOPE) register_extension(minifi-civet-extensions) - +register_extension_linter(minifi-civet-extensions-linter) diff --git a/extensions/civetweb/processors/ListenHTTP.cpp b/extensions/civetweb/processors/ListenHTTP.cpp index eaf0626..e544e82 100644 --- a/extensions/civetweb/processors/ListenHTTP.cpp +++ b/extensions/civetweb/processors/ListenHTTP.cpp @@ -20,6 +20,11 @@ */ #include "ListenHTTP.h" +#include <set> +#include <vector> +#include <utility> +#include <string> + #include "utils/gsl.h" namespace org { diff --git a/extensions/civetweb/processors/ListenHTTP.h b/extensions/civetweb/processors/ListenHTTP.h index 5b4bdd0..57cc1dd 100644 --- a/extensions/civetweb/processors/ListenHTTP.h +++ b/extensions/civetweb/processors/ListenHTTP.h @@ -17,11 +17,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef __LISTEN_HTTP_H__ -#define __LISTEN_HTTP_H__ +#pragma once +#include <map> #include <memory> #include <regex> +#include <string> +#include <utility> #include <CivetServer.h> @@ -48,7 +50,7 @@ class ListenHTTP : public core::Processor { /*! * Create a new processor */ - ListenHTTP(const std::string& name, const utils::Identifier& uuid = {}) + explicit ListenHTTP(const std::string& name, const utils::Identifier& uuid = {}) : Processor(name, uuid), logger_(logging::LoggerFactory<ListenHTTP>::getLogger()), batch_size_(0) { @@ -148,7 +150,7 @@ class ListenHTTP : public core::Processor { // Write callback for transferring data from HTTP request to content repo class WriteCallback : public OutputStreamCallback { public: - WriteCallback(std::unique_ptr<io::BufferStream>); + explicit WriteCallback(std::unique_ptr<io::BufferStream>); int64_t process(const std::shared_ptr<io::BaseStream>& stream) override; private: @@ -190,6 +192,7 @@ class ListenHTTP : public core::Processor { } return 0; } + protected: void notifyStop() override; @@ -223,5 +226,3 @@ REGISTER_RESOURCE(ListenHTTP, "Starts an HTTP Server and listens on a given base } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif diff --git a/extensions/coap/CMakeLists.txt b/extensions/coap/CMakeLists.txt index a28da86..f96f54c 100644 --- a/extensions/coap/CMakeLists.txt +++ b/extensions/coap/CMakeLists.txt @@ -35,4 +35,4 @@ target_link_libraries(minifi-coap nanofi-coap-c Threads::Threads COAP::libcoap m SET (COAP-EXTENSION minifi-coap PARENT_SCOPE) register_extension(minifi-coap) - +register_extension_linter(minifi-coap-extensions-linter) diff --git a/extensions/coap/COAPLoader.h b/extensions/coap/COAPLoader.h index 70f8b76..acbccd4 100644 --- a/extensions/coap/COAPLoader.h +++ b/extensions/coap/COAPLoader.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSIONS_COAPLOADER_H_ -#define EXTENSIONS_COAPLOADER_H_ +#pragma once #ifdef WIN32 #pragma comment(lib, "wldap32.lib" ) @@ -24,6 +23,10 @@ #pragma comment(lib, "Ws2_32.lib") #endif +#include <memory> +#include <string> +#include <vector> + #include "core/ClassLoader.h" #include "utils/StringUtils.h" #include "protocols/CoapC2Protocol.h" @@ -86,4 +89,3 @@ class COAPObjectFactory : public core::ObjectFactory { extern "C" { DLL_EXPORT void *createCOAPFactory(void); } -#endif /* EXTENSIONS_COAPLOADER_H_ */ diff --git a/extensions/coap/controllerservice/CoapConnector.cpp b/extensions/coap/controllerservice/CoapConnector.cpp index 066e5fb..d90be2a 100644 --- a/extensions/coap/controllerservice/CoapConnector.cpp +++ b/extensions/coap/controllerservice/CoapConnector.cpp @@ -18,13 +18,13 @@ #include "CoapConnector.h" -#include "core/logging/LoggerConfiguration.h" -#include "core/controller/ControllerService.h" #include <string> #include <memory> #include <set> + +#include "core/logging/LoggerConfiguration.h" +#include "core/controller/ControllerService.h" #include "core/Property.h" -#include "CoapConnector.h" #include "io/validation.h" #include "properties/Configure.h" diff --git a/extensions/coap/controllerservice/CoapConnector.h b/extensions/coap/controllerservice/CoapConnector.h index c0e2a5e..1524ab0 100644 --- a/extensions/coap/controllerservice/CoapConnector.h +++ b/extensions/coap/controllerservice/CoapConnector.h @@ -15,8 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CONTROLLERS_COAPCONNECTOR_H_ -#define LIBMINIFI_INCLUDE_CONTROLLERS_COAPCONNECTOR_H_ +#pragma once + +#include <memory> +#include <string> +#include <mutex> +#include <atomic> +#include <utility> #include "core/logging/LoggerConfiguration.h" #include "core/controller/ControllerService.h" @@ -26,9 +31,6 @@ #include "coap_functions.h" #include "coap_connection.h" #include "coap_message.h" -#include <memory> -#include <unordered_map> -#include <utility> namespace org { namespace apache { @@ -87,7 +89,6 @@ class CoapConnectorService : public core::controller::ControllerService { CoapResponse sendPayload(uint8_t type, const std::string &endpoint, const CoapMessage * message); protected: - void initializeProperties(); // connector mutex to controll access to the mapping, above. @@ -99,7 +100,6 @@ class CoapConnectorService : public core::controller::ControllerService { std::atomic<bool> initialized_{ false }; private: - // host connecting to. std::string host_; // port connecting to @@ -107,12 +107,9 @@ class CoapConnectorService : public core::controller::ControllerService { std::shared_ptr<logging::Logger> logger_{ logging::LoggerFactory<CoapConnectorService>::getLogger() }; }; - } /* namespace controllers */ } /* namespace coap */ } /* namespace minifi */ } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif /* LIBMINIFI_INCLUDE_CONTROLLERS_COAPCONNECTOR_H_ */ diff --git a/extensions/coap/controllerservice/CoapMessaging.h b/extensions/coap/controllerservice/CoapMessaging.h index a3893b3..e75f41d 100644 --- a/extensions/coap/controllerservice/CoapMessaging.h +++ b/extensions/coap/controllerservice/CoapMessaging.h @@ -15,15 +15,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSIONS_COAP_CONTROLLERSERVICE_COAPMESSAGING_H_ -#define EXTENSIONS_COAP_CONTROLLERSERVICE_COAPMESSAGING_H_ +#pragma once + +#include <unordered_map> +#include <mutex> +#include <utility> #include "CoapResponse.h" #include "coap_functions.h" #include "coap_connection.h" #include "coap_message.h" -#include <memory> -#include <unordered_map> namespace org { namespace apache { @@ -59,8 +60,8 @@ class CoapMessaging { } return response; } - protected: + protected: /** * Intended to receive errors from the context. */ @@ -100,12 +101,9 @@ class CoapMessaging { // at any given time. std::unordered_map<coap_context_t*, CoapResponse> messages_; }; - } /* namespace controllers */ } /* namespace coap */ } /* namespace minifi */ } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif /* EXTENSIONS_COAP_CONTROLLERSERVICE_COAPMESSAGING_H_ */ diff --git a/extensions/coap/controllerservice/CoapResponse.h b/extensions/coap/controllerservice/CoapResponse.h index 47c592e..1923d9d 100644 --- a/extensions/coap/controllerservice/CoapResponse.h +++ b/extensions/coap/controllerservice/CoapResponse.h @@ -15,13 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef LIBMINIFI_INCLUDE_CONTROLLERS_COAPRESPONSE_H_ -#define LIBMINIFI_INCLUDE_CONTROLLERS_COAPRESPONSE_H_ - -#include "coap_message.h" +#pragma once #include <memory> +#include "coap_message.h" + namespace org { namespace apache { namespace nifi { @@ -34,7 +33,6 @@ namespace controllers { */ class CoapResponse { public: - /** * Creates a CoAPResponse to a CoAPMessage. Takes ownership of the argument * and copies the data. @@ -96,6 +94,7 @@ class CoapResponse { CoapResponse &operator=(const CoapResponse &other) = delete; CoapResponse &operator=(CoapResponse &&other) = default; + private: uint32_t code_; size_t size_; @@ -108,5 +107,3 @@ class CoapResponse { } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif /* LIBMINIFI_INCLUDE_CONTROLLERS_COAPRESPONSE_H_ */ diff --git a/extensions/coap/nanofi/coap_functions.h b/extensions/coap/nanofi/coap_functions.h index 75a4785..8e3b2c1 100644 --- a/extensions/coap/nanofi/coap_functions.h +++ b/extensions/coap/nanofi/coap_functions.h @@ -29,8 +29,6 @@ typedef unsigned char method_t; #include "coap2/uri.h" #include "coap2/address.h" -#include <stdio.h> -#include <string.h> #ifdef WIN32 #include <winsock2.h> #else diff --git a/extensions/coap/nanofi/coap_message.h b/extensions/coap/nanofi/coap_message.h index 4eb5eb9..65e0b80 100644 --- a/extensions/coap/nanofi/coap_message.h +++ b/extensions/coap/nanofi/coap_message.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSIONS_COAP_NANOFI_COAP_MESSAGE_H -#define EXTENSIONS_COAP_NANOFI_COAP_MESSAGE_H +#pragma once #ifdef __cplusplus @@ -51,5 +50,3 @@ void free_coap_message(CoapMessage *msg); #ifdef __cplusplus } #endif - -#endif /* EXTENSIONS_COAP_NANOFI_COAP_CONNECTION_H_ */ diff --git a/extensions/coap/nanofi/coap_server.h b/extensions/coap/nanofi/coap_server.h index 8e1e7e4..cd49f8b 100644 --- a/extensions/coap/nanofi/coap_server.h +++ b/extensions/coap/nanofi/coap_server.h @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSIONS_COAP_NANOFI_COAP_SERVER_H -#define EXTENSIONS_COAP_NANOFI_COAP_SERVER_H +#pragma once #ifdef __cplusplus extern "C" { @@ -79,5 +78,3 @@ void free_server(CoapServerContext * const); #ifdef __cplusplus } #endif - -#endif /* EXTENSIONS_COAP_NANOFI_COAP_SERVER_H */ diff --git a/extensions/coap/protocols/CoapC2Protocol.cpp b/extensions/coap/protocols/CoapC2Protocol.cpp index 1a2854d..d3343e0 100644 --- a/extensions/coap/protocols/CoapC2Protocol.cpp +++ b/extensions/coap/protocols/CoapC2Protocol.cpp @@ -237,7 +237,7 @@ minifi::c2::C2Payload CoapProtocol::serialize(const minifi::c2::C2Payload &paylo default: logger_->log_error("Could not identify operation"); return minifi::c2::C2Payload(payload.getOperation(), state::UpdateState::READ_ERROR); - }; + } size_t bsize = stream.size(); diff --git a/extensions/coap/protocols/CoapC2Protocol.h b/extensions/coap/protocols/CoapC2Protocol.h index 6fad389..03ce24b 100644 --- a/extensions/coap/protocols/CoapC2Protocol.h +++ b/extensions/coap/protocols/CoapC2Protocol.h @@ -15,9 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSIONS_COAPPROTOCOL_H_ -#define EXTENSIONS_COAPPROTOCOL_H_ +#pragma once +#include <cstring> #include <algorithm> #include <iostream> #include <memory> @@ -25,6 +25,8 @@ #include <map> #include <string> #include <vector> +#include <stdexcept> +#include <mutex> #include "c2/C2Protocol.h" #include "io/BaseStream.h" @@ -34,8 +36,6 @@ #include "coap2/coap.h" #include "coap2/uri.h" #include "coap2/address.h" -#include <stdio.h> -#include <string.h> #include "protocols/RESTSender.h" #undef RAPIDJSON_ASSERT @@ -89,7 +89,6 @@ class CoapProtocol : public minifi::c2::RESTSender { // Supported Properties protected: - bool isRegistrationMessage(controllers::CoapResponse &response) { if (LIKELY(response.getSize() != 8)) { return false; @@ -131,7 +130,6 @@ class CoapProtocol : public minifi::c2::RESTSender { std::string controller_service_name_; private: - static uint8_t REGISTRATION_MSG[8]; std::shared_ptr<logging::Logger> logger_; @@ -142,4 +140,3 @@ class CoapProtocol : public minifi::c2::RESTSender { } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ -#endif /* EXTENSIONS_COAPPROTOCOL_H_ */ diff --git a/extensions/coap/server/CoapServer.cpp b/extensions/coap/server/CoapServer.cpp index df43b86..8b77190 100644 --- a/extensions/coap/server/CoapServer.cpp +++ b/extensions/coap/server/CoapServer.cpp @@ -17,6 +17,8 @@ */ #include "CoapServer.h" #include <coap2/coap.h> +#include <map> +#include <functional> namespace org { namespace apache { diff --git a/extensions/coap/server/CoapServer.h b/extensions/coap/server/CoapServer.h index 223c7b9..24be636 100644 --- a/extensions/coap/server/CoapServer.h +++ b/extensions/coap/server/CoapServer.h @@ -16,16 +16,21 @@ * limitations under the License. */ -#ifndef EXTENSIONS_COAP_SERVER_COAPSERVER_H_ -#define EXTENSIONS_COAP_SERVER_COAPSERVER_H_ +#pragma once -#include "core/Connectable.h" -#include "coap_server.h" -#include "coap_message.h" #include <coap2/coap.h> #include <functional> #include <thread> #include <future> +#include <map> +#include <memory> +#include <string> +#include <utility> +#include <atomic> + +#include "core/Connectable.h" +#include "coap_server.h" +#include "coap_message.h" namespace org { namespace apache { @@ -84,6 +89,7 @@ class CoapResponse { CoapResponse(const CoapResponse &qry) = delete; CoapResponse(CoapResponse &&qry) = default; CoapResponse &operator=(CoapResponse &&qry) = default; + private: int code_; std::unique_ptr<uint8_t[]> data_; @@ -101,7 +107,7 @@ class CoapServer : public core::Connectable { : core::Connectable(name, uuid), server_(nullptr), port_(0) { - // TODO: this allows this class to be instantiated via the the class loader + // TODO(_): this allows this class to be instantiated via the the class loader // need to define this capability in the future. } CoapServer(const std::string &hostname, uint16_t port) @@ -203,8 +209,12 @@ class CoapServer : public core::Connectable { } protected: - - static void handle_response_with_passthrough(coap_context_t* /*ctx*/, struct coap_resource_t *resource, coap_session_t *session, coap_pdu_t *request, coap_binary_t* /*token*/, coap_string_t* /*query*/, + static void handle_response_with_passthrough(coap_context_t* /*ctx*/, + struct coap_resource_t *resource, + coap_session_t *session, + coap_pdu_t *request, + coap_binary_t* /*token*/, + coap_string_t* /*query*/, coap_pdu_t *response) { auto fx = functions_.find(resource); if (fx != functions_.end()) { @@ -234,5 +244,3 @@ class CoapServer : public core::Connectable { } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif /* EXTENSIONS_COAP_SERVER_COAPSERVER_H_ */ diff --git a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp index 25c86ce..8c39329 100644 --- a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp +++ b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp @@ -153,10 +153,8 @@ class VerifyCoAPServer : public CoapIntegrationBase { responses.try_dequeue(resp); return resp; } - else { - minifi::coap::CoapResponse response(500, 0, 0); - return response; - } + minifi::coap::CoapResponse response(500, 0, 0); + return response; }); server->start(); configuration->set("c2.enable", "true"); diff --git a/extensions/coap/tests/CoapIntegrationBase.h b/extensions/coap/tests/CoapIntegrationBase.h index 87ab800..4c9ee67 100644 --- a/extensions/coap/tests/CoapIntegrationBase.h +++ b/extensions/coap/tests/CoapIntegrationBase.h @@ -15,8 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef EXTENSIONS_COAP_TESTS_COAPINTEGRATIONBASE_H -#define EXTENSIONS_COAP_TESTS_COAPINTEGRATIONBASE_H +#pragma once + +#include <utility> +#include <memory> +#include <string> #include "../tests/TestServer.h" #include "CivetServer.h" @@ -33,7 +36,7 @@ int ssl_enable(void *, void *) { class CoapIntegrationBase : public IntegrationBase { public: - CoapIntegrationBase(uint64_t waitTime = 5000) + explicit CoapIntegrationBase(uint64_t waitTime = 5000) : IntegrationBase(waitTime), server(nullptr) { } @@ -109,5 +112,3 @@ void CoapIntegrationBase::setUrl(std::string url, CivetHandler *handler) { } } } - -#endif // EXTENSIONS_COAP_TESTS_COAPINTEGRATIONBASE_H diff --git a/extensions/windows-event-log/Bookmark.cpp b/extensions/windows-event-log/Bookmark.cpp index 8b72e65..7896c1b 100644 --- a/extensions/windows-event-log/Bookmark.cpp +++ b/extensions/windows-event-log/Bookmark.cpp @@ -19,6 +19,9 @@ #include "Bookmark.h" #include <direct.h> +#include <vector> +#include <unordered_map> +#include <fstream> #include "wel/UnicodeConversion.h" #include "utils/file/FileUtils.h" @@ -30,9 +33,15 @@ namespace minifi { namespace processors { static const std::string BOOKMARK_KEY = "bookmark"; -Bookmark::Bookmark(const std::wstring& channel, const std::wstring& query, const std::string& bookmarkRootDir, const utils::Identifier& uuid, bool processOldEvents, std::shared_ptr<core::CoreComponentStateManager> state_manager, std::shared_ptr<logging::Logger> logger) - : logger_(logger) - , state_manager_(state_manager) { +Bookmark::Bookmark(const std::wstring& channel, + const std::wstring& query, + const std::string& bookmarkRootDir, + const utils::Identifier& uuid, + bool processOldEvents, + std::shared_ptr<core::CoreComponentStateManager> state_manager, + std::shared_ptr<logging::Logger> logger) + : logger_(logger), + state_manager_(state_manager) { std::unordered_map<std::string, std::string> state_map; if (state_manager_->get(state_map) && state_map.count(BOOKMARK_KEY) == 1U) { bookmarkXml_ = wel::to_wstring(state_map[BOOKMARK_KEY].c_str()); @@ -171,7 +180,7 @@ bool Bookmark::getBookmarkXmlFromFile(std::wstring& bookmarkXml) { return false; } - // Generically is not efficient, but bookmarkXML is small ~100 bytes. + // Generally is not efficient, but bookmarkXML is small ~100 bytes. wchar_t c; do { file.read(&c, 1); diff --git a/extensions/windows-event-log/Bookmark.h b/extensions/windows-event-log/Bookmark.h index d2e7742..8def098 100644 --- a/extensions/windows-event-log/Bookmark.h +++ b/extensions/windows-event-log/Bookmark.h @@ -18,10 +18,10 @@ #pragma once -#include <string> -#include <memory> #include <windows.h> #include <winevt.h> +#include <string> +#include <memory> #include <type_traits> #include "core/ProcessContext.h" @@ -37,8 +37,14 @@ namespace processors { #define LOG_LAST_ERROR(func) logger_->log_error("!"#func" error %x", GetLastError()) class Bookmark { -public: - Bookmark(const std::wstring& channel, const std::wstring& query, const std::string& bookmarkRootDir, const utils::Identifier& uuid, bool processOldEvents, std::shared_ptr<core::CoreComponentStateManager> state_manager, std::shared_ptr<logging::Logger> logger); + public: + Bookmark(const std::wstring& channel, + const std::wstring& query, + const std::string& bookmarkRootDir, + const utils::Identifier& uuid, + bool processOldEvents, + std::shared_ptr<core::CoreComponentStateManager> state_manager, + std::shared_ptr<logging::Logger> logger); ~Bookmark(); explicit operator bool() const noexcept; @@ -46,7 +52,7 @@ public: bool getNewBookmarkXml(EVT_HANDLE hEvent, std::wstring& bookmarkXml); bool saveBookmarkXml(const std::wstring& bookmarkXml); -private: + private: bool saveBookmark(EVT_HANDLE hEvent); bool getBookmarkXmlFromFile(std::wstring& bookmarkXml); diff --git a/extensions/windows-event-log/CMakeLists.txt b/extensions/windows-event-log/CMakeLists.txt index c205245..7aaf512 100644 --- a/extensions/windows-event-log/CMakeLists.txt +++ b/extensions/windows-event-log/CMakeLists.txt @@ -30,3 +30,4 @@ target_link_libraries(minifi-wel PUGI::libpugixml ZLIB::ZLIB Wevtapi.lib) SET(WEL-EXTENSION minifi-wel PARENT_SCOPE) register_extension(minifi-wel) +register_extension_linter(minifi-wel-extension-linter) diff --git a/extensions/windows-event-log/CollectorInitiatedSubscription.cpp b/extensions/windows-event-log/CollectorInitiatedSubscription.cpp index a57aa87..b1d7201 100644 --- a/extensions/windows-event-log/CollectorInitiatedSubscription.cpp +++ b/extensions/windows-event-log/CollectorInitiatedSubscription.cpp @@ -24,11 +24,10 @@ #include <map> #include <set> #include <sstream> -#include <stdio.h> #include <string> -#include <iostream> #include <memory> #include <codecvt> +#include <utility> #include "io/BufferStream.h" #include "core/ProcessContext.h" @@ -64,8 +63,7 @@ CollectorInitiatedSubscription::CollectorInitiatedSubscription(const std::string DWORD size = sizeof(buff); if (GetComputerName(buff, &size)) { computerName_ = buff; - } - else { + } else { LOG_SUBSCRIPTION_WINDOWS_ERROR("GetComputerName"); } @@ -226,8 +224,7 @@ void CollectorInitiatedSubscription::onTrigger(const std::shared_ptr<core::Proce if (flowFileCount > 0) { lastActivityTimestamp_ = now; - } - else if (inactiveDurationToReconnect_.value() > 0) { + } else if (inactiveDurationToReconnect_.value() > 0) { if ((now - lastActivityTimestamp_) > inactiveDurationToReconnect_.value()) { logger_->log_info("Exceeds configured 'inactive duration to reconnect' %lld ms. Unsubscribe to reconnect..", inactiveDurationToReconnect_.value()); unsubscribe(); @@ -285,8 +282,7 @@ bool CollectorInitiatedSubscription::checkSubscriptionRuntimeStatus() { LOG_SUBSCRIPTION_WINDOWS_ERROR("EcGetObjectArrayProperty"); return false; } - } - else { + } else { LOG_SUBSCRIPTION_WINDOWS_ERROR("EcGetObjectArrayProperty"); return false; } @@ -302,8 +298,8 @@ bool CollectorInitiatedSubscription::checkSubscriptionRuntimeStatus() { buffer.resize(sizeof(EC_VARIANT)); DWORD dwBufferSize{}; if (!EcGetSubscriptionRunTimeStatus( - subscriptionName_.value().c_str(), - statusInfoID, + subscriptionName_.value().c_str(), + statusInfoID, eventSource.c_str(), flags, static_cast<DWORD>(buffer.size()), @@ -516,7 +512,7 @@ bool CollectorInitiatedSubscription::createSubscription(const std::shared_ptr<co if (!getSubscriptionProperty(hSubscription, EcSubscriptionEventSources, 0, buffer, vProperty)) return false; - // Event Sources is a collection. Ensure that we have obtained handle to the Array Property. + // Event Sources is a collection. Ensure that we have obtained handle to the Array Property. if (vProperty->Type != EcVarTypeNull && vProperty->Type != EcVarObjectArrayPropertyHandle) { logInvalidSubscriptionPropertyType(__LINE__, vProperty->Type); return false; @@ -628,13 +624,13 @@ void CollectorInitiatedSubscription::unsubscribe() { int CollectorInitiatedSubscription::processQueue(const std::shared_ptr<core::ProcessSession> &session) { struct WriteCallback: public OutputStreamCallback { - WriteCallback(const std::string& str) + explicit WriteCallback(const std::string& str) : str_(str) { status_ = 0; } int64_t process(const std::shared_ptr<io::BaseStream>& stream) { - return stream->write((uint8_t*)&str_[0], gsl::narrow<int>(str_.size())); + return stream->write(reinterpret_cast<uint8_t*>(&str_[0]), gsl::narrow<int>(str_.size())); } std::string str_; @@ -699,10 +695,10 @@ void CollectorInitiatedSubscription::logWindowsError(int line, const std::string error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsg, - 0, + 0, NULL); - logger_->log_error("Line %d: '%s': error %d: %s\n", line, info.c_str(), (int)error, (char *)lpMsg); + logger_->log_error("Line %d: '%s': error %d: %s\n", line, info.c_str(), static_cast<int>(error), reinterpret_cast<char *>(lpMsg)); LocalFree(lpMsg); } diff --git a/extensions/windows-event-log/CollectorInitiatedSubscription.h b/extensions/windows-event-log/CollectorInitiatedSubscription.h index 1cdc18f..e9b6671 100644 --- a/extensions/windows-event-log/CollectorInitiatedSubscription.h +++ b/extensions/windows-event-log/CollectorInitiatedSubscription.h @@ -20,6 +20,14 @@ #pragma once +#include <Windows.h> +#include <winevt.h> +#include <EvColl.h> + +#include <vector> +#include <string> +#include <memory> + #include "core/Core.h" #include "FlowFileRecord.h" #include "concurrentqueue.h" @@ -27,8 +35,6 @@ #include "core/ProcessSession.h" #include "SupportedProperty.h" -#include <winevt.h> -#include <EvColl.h> namespace org { namespace apache { @@ -38,12 +44,12 @@ namespace processors { //! CollectorInitiatedSubscription Class class CollectorInitiatedSubscription : public core::Processor { -public: + public: //! Constructor /*! * Create a new processor */ - CollectorInitiatedSubscription(const std::string& name, const utils::Identifier& uuid = {}); + explicit CollectorInitiatedSubscription(const std::string& name, const utils::Identifier& uuid = {}); //! Destructor virtual ~CollectorInitiatedSubscription() = default; @@ -51,7 +57,7 @@ public: //! Processor Name static const std::string ProcessorName; -public: + public: /** * Function that's executed when the processor is scheduled. * @param context process context. @@ -65,7 +71,7 @@ public: void initialize(void) override; void notifyStop() override; -protected: + protected: bool createSubscription(const std::shared_ptr<core::ProcessContext> &context); bool subscribe(const std::shared_ptr<core::ProcessContext> &context); void unsubscribe(); @@ -75,7 +81,8 @@ protected: void logInvalidSubscriptionPropertyType(int line, DWORD type); bool getSubscriptionProperty(EC_HANDLE hSubscription, EC_SUBSCRIPTION_PROPERTY_ID propID, DWORD flags, std::vector<BYTE>& buffer, PEC_VARIANT& vProperty); bool checkSubscriptionRuntimeStatus(); -private: + + private: // Logger std::shared_ptr<logging::Logger> logger_; moodycamel::ConcurrentQueue<std::string> renderedXMLs_; diff --git a/extensions/windows-event-log/ConsumeWindowsEventLog.cpp b/extensions/windows-event-log/ConsumeWindowsEventLog.cpp index eeeeb40..3746826 100644 --- a/extensions/windows-event-log/ConsumeWindowsEventLog.cpp +++ b/extensions/windows-event-log/ConsumeWindowsEventLog.cpp @@ -19,12 +19,14 @@ */ #include "ConsumeWindowsEventLog.h" +#include <stdio.h> #include <vector> +#include <tuple> +#include <utility> #include <queue> #include <map> #include <set> #include <sstream> -#include <stdio.h> #include <string> #include <iostream> #include <memory> @@ -127,8 +129,10 @@ core::Property ConsumeWindowsEventLog::EventHeaderDelimiter( core::Property ConsumeWindowsEventLog::EventHeader( core::PropertyBuilder::createProperty("Event Header")-> isRequired(false)-> - withDefaultValue("LOG_NAME=Log Name, SOURCE = Source, TIME_CREATED = Date,EVENT_RECORDID=Record ID,EVENTID = Event ID,TASK_CATEGORY = Task Category,LEVEL = Level,KEYWORDS = Keywords,USER = User,COMPUTER = Computer, EVENT_TYPE = EventType")-> - withDescription("Comma seperated list of key/value pairs with the following keys LOG_NAME, SOURCE, TIME_CREATED,EVENT_RECORDID,EVENTID,TASK_CATEGORY,LEVEL,KEYWORDS,USER,COMPUTER, and EVENT_TYPE. Eliminating fields will remove them from the header.")-> + withDefaultValue("LOG_NAME=Log Name, SOURCE = Source, TIME_CREATED = Date,EVENT_RECORDID=Record ID,EVENTID = Event ID," + "TASK_CATEGORY = Task Category,LEVEL = Level,KEYWORDS = Keywords,USER = User,COMPUTER = Computer, EVENT_TYPE = EventType")-> + withDescription("Comma seperated list of key/value pairs with the following keys LOG_NAME, SOURCE, TIME_CREATED,EVENT_RECORDID," + "EVENTID,TASK_CATEGORY,LEVEL,KEYWORDS,USER,COMPUTER, and EVENT_TYPE. Eliminating fields will remove them from the header.")-> build()); core::Property ConsumeWindowsEventLog::OutputFormat( @@ -491,15 +495,12 @@ void ConsumeWindowsEventLog::substituteXMLPercentageItems(pugi::xml_document& do const auto it = xmlPercentageItemsResolutions_.find(key); if (it == xmlPercentageItemsResolutions_.end()) { LPTSTR pBuffer{}; - if (FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, - hMsobjsDll_, - number, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&pBuffer, - 1024, - 0 - )) { + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, + hMsobjsDll_, + number, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&pBuffer, + 1024, 0)) { value = pBuffer; LocalFree(pBuffer); @@ -656,7 +657,7 @@ void ConsumeWindowsEventLog::refreshTimeZoneData() { DYNAMIC_TIME_ZONE_INFORMATION tzinfo; auto ret = GetDynamicTimeZoneInformation(&tzinfo); std::wstring tzstr; - long tzbias = 0; + long tzbias = 0; // NOLINT long comes from WINDOWS API bool dst = false; switch (ret) { case TIME_ZONE_ID_INVALID: @@ -689,8 +690,8 @@ void ConsumeWindowsEventLog::refreshTimeZoneData() { void ConsumeWindowsEventLog::putEventRenderFlowFileToSession(const EventRender& eventRender, core::ProcessSession& session) const { struct WriteCallback : public OutputStreamCallback { - WriteCallback(const std::string& str) - : str_(str) { + explicit WriteCallback(const std::string& str) + : str_(str) { } int64_t process(const std::shared_ptr<io::BaseStream>& stream) { @@ -755,7 +756,7 @@ void ConsumeWindowsEventLog::LogWindowsError(std::string error) const { (LPTSTR)&lpMsg, 0, NULL); - logger_->log_error((error + " %x: %s\n").c_str(), (int)error_id, (char *)lpMsg); + logger_->log_error((error + " %x: %s\n").c_str(), static_cast<int>(error_id), reinterpret_cast<char *>(lpMsg)); LocalFree(lpMsg); } diff --git a/extensions/windows-event-log/ConsumeWindowsEventLog.h b/extensions/windows-event-log/ConsumeWindowsEventLog.h index f6f4835..e40a8f4 100644 --- a/extensions/windows-event-log/ConsumeWindowsEventLog.h +++ b/extensions/windows-event-log/ConsumeWindowsEventLog.h @@ -20,21 +20,28 @@ #pragma once -#include "core/Core.h" -#include "wel/WindowsEventLog.h" -#include "FlowFileRecord.h" -#include "concurrentqueue.h" -#include "core/Processor.h" -#include "core/ProcessSession.h" -#include "pugixml.hpp" +#include <Windows.h> #include <winevt.h> +#include <Objbase.h> + #include <sstream> #include <regex> #include <codecvt> -#include "utils/OsUtils.h" -#include <Objbase.h> #include <mutex> #include <unordered_map> +#include <tuple> +#include <map> +#include <memory> +#include <string> + +#include "core/Core.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "utils/OsUtils.h" +#include "wel/WindowsEventLog.h" +#include "FlowFileRecord.h" +#include "concurrentqueue.h" +#include "pugixml.hpp" namespace org { namespace apache { @@ -53,12 +60,12 @@ class Bookmark; //! ConsumeWindowsEventLog Class class ConsumeWindowsEventLog : public core::Processor { -public: + public: //! Constructor /*! * Create a new processor */ - ConsumeWindowsEventLog(const std::string& name, const utils::Identifier& uuid = {}); + explicit ConsumeWindowsEventLog(const std::string& name, const utils::Identifier& uuid = {}); //! Destructor virtual ~ConsumeWindowsEventLog(); @@ -86,7 +93,7 @@ public: //! Supported Relationships static core::Relationship Success; -public: + public: /** * Function that's executed when the processor is scheduled. * @param context process context. @@ -100,7 +107,7 @@ public: void initialize(void) override; void notifyStop() override; -protected: + protected: void refreshTimeZoneData(); void putEventRenderFlowFileToSession(const EventRender& eventRender, core::ProcessSession& session) const; wel::WindowsEventLogHandler getEventLogHandler(const std::string & name); @@ -117,7 +124,7 @@ protected: static constexpr const char* JSONSimple = "Simple"; static constexpr const char* JSONFlattened = "Flattened"; -private: + private: struct TimeDiff { auto operator()() const { return int64_t{ std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - time_).count() }; diff --git a/extensions/windows-event-log/SupportedProperty.h b/extensions/windows-event-log/SupportedProperty.h index 7dd140f..3ab912e 100644 --- a/extensions/windows-event-log/SupportedProperty.h +++ b/extensions/windows-event-log/SupportedProperty.h @@ -21,6 +21,8 @@ */ #include <vector> +#include <memory> +#include <string> #include <set> #include <codecvt> @@ -40,7 +42,7 @@ class SupportedProperties { std::vector<ISupportedProperty*> listISupportedProperty_; std::vector<core::Property*> listProperties_; -public: + public: void init(const std::shared_ptr<core::ProcessContext>& context) { for (auto pProp : listISupportedProperty_) { pProp->Init(context); @@ -62,7 +64,7 @@ public: add(arg, args...); } -private: + private: template <typename Arg> void add(Arg& arg) { listISupportedProperty_.emplace_back(&arg); @@ -80,9 +82,9 @@ template <typename T> class SupportedProperty : public ISupportedProperty, public core::Property { T t_; -public: + public: template <typename ...Args> - SupportedProperty(const Args& ...args): core::Property(args...) { + explicit SupportedProperty(const Args& ...args): core::Property(args...) { } void Init(const std::shared_ptr<core::ProcessContext>& context) override { @@ -99,7 +101,7 @@ void SupportedProperty<std::wstring>::Init(const std::shared_ptr<core::ProcessCo context->getProperty(getName(), val); t_ = std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(val); -}; +} } /* namespace processors */ } /* namespace minifi */ diff --git a/extensions/windows-event-log/TailEventLog.cpp b/extensions/windows-event-log/TailEventLog.cpp index 3e05208..db93cba 100644 --- a/extensions/windows-event-log/TailEventLog.cpp +++ b/extensions/windows-event-log/TailEventLog.cpp @@ -19,14 +19,12 @@ */ #include "TailEventLog.h" + #include <vector> -#include <queue> #include <map> #include <set> -#include <sstream> -#include <stdio.h> #include <string> -#include <iostream> +#include <memory> #include "io/BufferStream.h" #include "core/ProcessContext.h" @@ -77,14 +75,14 @@ void TailEventLog::onTrigger(const std::shared_ptr<core::ProcessContext> &contex BYTE buffer[MAX_RECORD_BUFFER_SIZE]; - EVENTLOGRECORD *event_record = (EVENTLOGRECORD*)&buffer; + EVENTLOGRECORD *event_record = reinterpret_cast<EVENTLOGRECORD*>(&buffer); DWORD bytes_to_read = 0, min_bytes = 0; - + GetOldestEventLogRecord(log_handle_, ¤t_record_); GetNumberOfEventLogRecords(log_handle_, &num_records_); current_record_ = num_records_-max_events_; - + logger_->log_trace("%d and %d", current_record_, num_records_); if (ReadEventLog(log_handle_, EVENTLOG_FORWARDS_READ | EVENTLOG_SEEK_READ, current_record_, event_record, MAX_RECORD_BUFFER_SIZE, &bytes_to_read, &min_bytes)) { @@ -107,23 +105,21 @@ void TailEventLog::onTrigger(const std::shared_ptr<core::ProcessContext> &contex flowFile->addAttribute("source", source); flowFile->addAttribute("record_number", std::to_string(event_record->RecordNumber)); flowFile->addAttribute("computer_name", computer_name); - + flowFile->addAttribute("event_time", getTimeStamp(event_record->TimeGenerated)); flowFile->addAttribute("event_type", typeToString(event_record->EventType)); - + io::BufferStream stream((const uint8_t*)(event_record + event_record->DataOffset), event_record->DataLength); // need an import from the data stream. session->importFrom(stream, flowFile); session->transfer(flowFile, Success); bytes_to_read -= event_record->Length; - event_record = (EVENTLOGRECORD *) - ((LPBYTE)event_record + event_record->Length); + event_record = reinterpret_cast<EVENTLOGRECORD *>((LPBYTE)event_record + event_record->Length); } - event_record = (EVENTLOGRECORD *)&buffer; + event_record = reinterpret_cast<EVENTLOGRECORD*>(&buffer); logger_->log_trace("All done no more"); - } - else { + } else { LogWindowsError(); logger_->log_trace("Yielding due to error"); context->yield(); diff --git a/extensions/windows-event-log/TailEventLog.h b/extensions/windows-event-log/TailEventLog.h index e1421e8..5d8dfa5 100644 --- a/extensions/windows-event-log/TailEventLog.h +++ b/extensions/windows-event-log/TailEventLog.h @@ -17,8 +17,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef TAIL_EVENT_LOG_H_ -#define TAIL_EVENT_LOG_H_ +#pragma once + +#include <memory> +#include <string> #include "core/Core.h" #include "FlowFileRecord.h" @@ -36,8 +38,8 @@ const LPCWSTR pEventTypeNames[] = { L"Error", L"Warning", L"Informational", L"Au const char log_name[255] = "Application"; class TailEventLog : public core::Processor { -public: - TailEventLog(const std::string& name, const utils::Identifier& uuid = {}) + public: + explicit TailEventLog(const std::string& name, const utils::Identifier& uuid = {}) : core::Processor(name, uuid), logger_(logging::LoggerFactory<TailEventLog>::getLogger()), max_events_(1) { } virtual ~TailEventLog() = default; @@ -50,7 +52,7 @@ public: // Supported Relationships static core::Relationship Success; -public: + public: /** * Function that's executed when the processor is scheduled. * @param context process context. @@ -63,8 +65,7 @@ public: // Initialize, over write by NiFi TailEventLog void initialize(void) override; -protected: - + protected: void notifyStop() override { CloseEventLog(log_handle_); } @@ -120,10 +121,12 @@ protected: (LPTSTR)&lpMsg, 0, NULL); - logger_->log_debug("Error %d: %s\n", (int)error_id, (char *)lpMsg); + logger_->log_debug("Error %d: %s\n", static_cast<int>(error_id), reinterpret_cast<char *>(lpMsg)); + + LocalFree(lpMsg); } -private: + private: std::mutex log_mutex_; std::string log_source_; uint32_t max_events_; @@ -141,5 +144,3 @@ REGISTER_RESOURCE(TailEventLog, "Windows event log reader that functions as a st } /* namespace nifi */ } /* namespace apache */ } /* namespace org */ - -#endif diff --git a/extensions/windows-event-log/tests/CWELCustomProviderTests.cpp b/extensions/windows-event-log/tests/CWELCustomProviderTests.cpp index 5fb73a0..6898e0a 100644 --- a/extensions/windows-event-log/tests/CWELCustomProviderTests.cpp +++ b/extensions/windows-event-log/tests/CWELCustomProviderTests.cpp @@ -58,8 +58,7 @@ bool dispatchCustomEvent(const CustomEventData& event) { event.second.c_str(), event.third.c_str(), event.binary_length, - event.binary_data - ); + event.binary_data); return result == ERROR_SUCCESS; } diff --git a/extensions/windows-event-log/tests/CWELTestUtils.h b/extensions/windows-event-log/tests/CWELTestUtils.h index fdccd5c..46988ca 100644 --- a/extensions/windows-event-log/tests/CWELTestUtils.h +++ b/extensions/windows-event-log/tests/CWELTestUtils.h @@ -17,6 +17,12 @@ #pragma once +#include <utility> +#include <memory> +#include <string> +#include <fstream> +#include <iterator> + #include "ConsumeWindowsEventLog.h" #include "processors/PutFile.h" #include "TestBase.h" diff --git a/extensions/windows-event-log/tests/MetadataWalkerTests.cpp b/extensions/windows-event-log/tests/MetadataWalkerTests.cpp index 29e5efa..3008a57 100644 --- a/extensions/windows-event-log/tests/MetadataWalkerTests.cpp +++ b/extensions/windows-event-log/tests/MetadataWalkerTests.cpp @@ -55,13 +55,13 @@ std::string readFile(const std::string &file_name) { } const std::string METADATA_WALKER_TESTS_LOG_NAME = "MetadataWalkerTests"; -const short event_type_index = 178; +const short event_type_index = 178; // NOLINT short comes from WINDOWS API class FakeWindowsEventLogMetadata : public WindowsEventLogMetadata { public: std::string getEventData(EVT_FORMAT_MESSAGE_FLAGS flags) const override { return "event_data_for_flag_" + std::to_string(flags); } std::string getEventTimestamp() const override { return "event_timestamp"; } - short getEventTypeIndex() const override { return event_type_index; } + short getEventTypeIndex() const override { return event_type_index; } // NOLINT short comes from WINDOWS API }; } // namespace @@ -152,12 +152,12 @@ TEST_CASE("MetadataWalker extracts mappings correctly when there is a single Sid const std::map<std::string, std::string> expected_identifiers{{"S-1-0-0", "S-1-0-0"}}; - using namespace org::apache::nifi::minifi::wel; + using org::apache::nifi::minifi::wel::METADATA; const std::map<METADATA, std::string> expected_metadata{ - {SOURCE, "Microsoft-Windows-Security-Auditing"}, - {TIME_CREATED, "event_timestamp"}, - {EVENTID, "4672"}, - {EVENT_RECORDID, "2575952"}}; + {METADATA::SOURCE, "Microsoft-Windows-Security-Auditing"}, + {METADATA::TIME_CREATED, "event_timestamp"}, + {METADATA::EVENTID, "4672"}, + {METADATA::EVENT_RECORDID, "2575952"}}; const std::map<std::string, std::string> expected_field_values{}; @@ -175,18 +175,18 @@ TEST_CASE("MetadataWalker extracts mappings correctly when there is a single Sid const std::map<std::string, std::string> expected_identifiers{{"S-1-0-0", "Nobody"}}; - using namespace org::apache::nifi::minifi::wel; + using org::apache::nifi::minifi::wel::METADATA; const std::map<METADATA, std::string> expected_metadata{ - {LOG_NAME, "MetadataWalkerTests"}, - {SOURCE, "Microsoft-Windows-Security-Auditing"}, - {TIME_CREATED, "event_timestamp"}, - {EVENTID, "4672"}, - {OPCODE, "event_data_for_flag_4"}, - {EVENT_RECORDID, "2575952"}, - {EVENT_TYPE, "178"}, - {TASK_CATEGORY, "event_data_for_flag_3"}, - {LEVEL, "event_data_for_flag_2"}, - {KEYWORDS, "event_data_for_flag_5"}}; + {METADATA::LOG_NAME, "MetadataWalkerTests"}, + {METADATA::SOURCE, "Microsoft-Windows-Security-Auditing"}, + {METADATA::TIME_CREATED, "event_timestamp"}, + {METADATA::EVENTID, "4672"}, + {METADATA::OPCODE, "event_data_for_flag_4"}, + {METADATA::EVENT_RECORDID, "2575952"}, + {METADATA::EVENT_TYPE, "178"}, + {METADATA::TASK_CATEGORY, "event_data_for_flag_3"}, + {METADATA::LEVEL, "event_data_for_flag_2"}, + {METADATA::KEYWORDS, "event_data_for_flag_5"}}; SECTION("update_xml is false => fields are collected into walker.getFieldValues()") { const std::map<std::string, std::string> expected_field_values{ @@ -212,12 +212,12 @@ TEST_CASE("MetadataWalker extracts mappings correctly when there are multiple Si const std::map<std::string, std::string> expected_identifiers{{"S-1-0-0", "S-1-0-0"}}; - using namespace org::apache::nifi::minifi::wel; + using org::apache::nifi::minifi::wel::METADATA; const std::map<METADATA, std::string> expected_metadata{ - {SOURCE, "Microsoft-Windows-Security-Auditing"}, - {TIME_CREATED, "event_timestamp"}, - {EVENTID, "4672"}, - {EVENT_RECORDID, "2575952"}}; + {METADATA::SOURCE, "Microsoft-Windows-Security-Auditing"}, + {METADATA::TIME_CREATED, "event_timestamp"}, + {METADATA::EVENTID, "4672"}, + {METADATA::EVENT_RECORDID, "2575952"}}; const std::map<std::string, std::string> expected_field_values{}; @@ -241,18 +241,18 @@ TEST_CASE("MetadataWalker extracts mappings correctly when there are multiple Si {"S-1-0-0", "Nobody"}, {"S-1-1-0", "Everyone"}}; - using namespace org::apache::nifi::minifi::wel; + using org::apache::nifi::minifi::wel::METADATA; const std::map<METADATA, std::string> expected_metadata{ - {LOG_NAME, "MetadataWalkerTests"}, - {SOURCE, "Microsoft-Windows-Security-Auditing"}, - {TIME_CREATED, "event_timestamp"}, - {EVENTID, "4672"}, - {OPCODE, "event_data_for_flag_4"}, - {EVENT_RECORDID, "2575952"}, - {EVENT_TYPE, "178"}, - {TASK_CATEGORY, "event_data_for_flag_3"}, - {LEVEL, "event_data_for_flag_2"}, - {KEYWORDS, "event_data_for_flag_5"}}; + {METADATA::LOG_NAME, "MetadataWalkerTests"}, + {METADATA::SOURCE, "Microsoft-Windows-Security-Auditing"}, + {METADATA::TIME_CREATED, "event_timestamp"}, + {METADATA::EVENTID, "4672"}, + {METADATA::OPCODE, "event_data_for_flag_4"}, + {METADATA::EVENT_RECORDID, "2575952"}, + {METADATA::EVENT_TYPE, "178"}, + {METADATA::TASK_CATEGORY, "event_data_for_flag_3"}, + {METADATA::LEVEL, "event_data_for_flag_2"}, + {METADATA::KEYWORDS, "event_data_for_flag_5"}}; SECTION("update_xml is false => fields are collected into walker.getFieldValues()") { const std::map<std::string, std::string> expected_field_values{ @@ -278,12 +278,12 @@ TEST_CASE("MetadataWalker extracts mappings correctly when the Sid is unknown an const std::map<std::string, std::string> expected_identifiers{{"S-1-8-6-5-3-0-9", "S-1-8-6-5-3-0-9"}}; - using namespace org::apache::nifi::minifi::wel; + using org::apache::nifi::minifi::wel::METADATA; const std::map<METADATA, std::string> expected_metadata{ - {SOURCE, "Microsoft-Windows-Security-Auditing"}, - {TIME_CREATED, "event_timestamp"}, - {EVENTID, "4672"}, - {EVENT_RECORDID, "2575952"}}; + {METADATA::SOURCE, "Microsoft-Windows-Security-Auditing"}, + {METADATA::TIME_CREATED, "event_timestamp"}, + {METADATA::EVENTID, "4672"}, + {METADATA::EVENT_RECORDID, "2575952"}}; const std::map<std::string, std::string> expected_field_values{}; @@ -301,18 +301,18 @@ TEST_CASE("MetadataWalker extracts mappings correctly when the Sid is unknown an const std::map<std::string, std::string> expected_identifiers{{"S-1-8-6-5-3-0-9", "S-1-8-6-5-3-0-9"}}; - using namespace org::apache::nifi::minifi::wel; + using org::apache::nifi::minifi::wel::METADATA; const std::map<METADATA, std::string> expected_metadata{ - {LOG_NAME, "MetadataWalkerTests"}, - {SOURCE, "Microsoft-Windows-Security-Auditing"}, - {TIME_CREATED, "event_timestamp"}, - {EVENTID, "4672"}, - {OPCODE, "event_data_for_flag_4"}, - {EVENT_RECORDID, "2575952"}, - {EVENT_TYPE, "178"}, - {TASK_CATEGORY, "event_data_for_flag_3"}, - {LEVEL, "event_data_for_flag_2"}, - {KEYWORDS, "event_data_for_flag_5"}}; + {METADATA::LOG_NAME, "MetadataWalkerTests"}, + {METADATA::SOURCE, "Microsoft-Windows-Security-Auditing"}, + {METADATA::TIME_CREATED, "event_timestamp"}, + {METADATA::EVENTID, "4672"}, + {METADATA::OPCODE, "event_data_for_flag_4"}, + {METADATA::EVENT_RECORDID, "2575952"}, + {METADATA::EVENT_TYPE, "178"}, + {METADATA::TASK_CATEGORY, "event_data_for_flag_3"}, + {METADATA::LEVEL, "event_data_for_flag_2"}, + {METADATA::KEYWORDS, "event_data_for_flag_5"}}; SECTION("update_xml is false => fields are collected into walker.getFieldValues()") { const std::map<std::string, std::string> expected_field_values{ diff --git a/extensions/windows-event-log/tests/custom-provider/CPPLINT.cfg b/extensions/windows-event-log/tests/custom-provider/CPPLINT.cfg new file mode 100644 index 0000000..c180f1d --- /dev/null +++ b/extensions/windows-event-log/tests/custom-provider/CPPLINT.cfg @@ -0,0 +1 @@ +exclude_files=unit-test-provider.h diff --git a/extensions/windows-event-log/wel/JSONUtils.h b/extensions/windows-event-log/wel/JSONUtils.h index 5b3b8ab..5afcbc6 100644 --- a/extensions/windows-event-log/wel/JSONUtils.h +++ b/extensions/windows-event-log/wel/JSONUtils.h @@ -20,9 +20,11 @@ #undef RAPIDJSON_ASSERT #define RAPIDJSON_ASSERT(x) if (!(x)) throw std::logic_error("rapidjson exception"); // NOLINT -#include <pugixml.hpp> +#include <stdexcept> // for the RAPIDJSON_ASSERT redefine +#include <string> -#include <stdexcept> // for std::logic_error + +#include "pugixml.hpp" #include "rapidjson/document.h" namespace org { diff --git a/extensions/windows-event-log/wel/MetadataWalker.cpp b/extensions/windows-event-log/wel/MetadataWalker.cpp index 4b85d6e..7d68676 100644 --- a/extensions/windows-event-log/wel/MetadataWalker.cpp +++ b/extensions/windows-event-log/wel/MetadataWalker.cpp @@ -17,9 +17,18 @@ */ #include <windows.h> +#include <strsafe.h> + +#include <map> +#include <functional> +#include <codecvt> +#include <regex> +#include <string> +#include <utility> +#include <vector> + #include "MetadataWalker.h" #include "XMLString.h" -#include <strsafe.h> namespace org { namespace apache { @@ -64,20 +73,15 @@ bool MetadataWalker::for_each(pugi::xml_node &node) { } node.text().set(nodeText.c_str()); } - } - else if (node_name == "TimeCreated") { + } else if (node_name == "TimeCreated") { metadata_["TimeCreated"] = node.attribute("SystemTime").value(); - } - else if (node_name == "EventRecordID") { + } else if (node_name == "EventRecordID") { metadata_["EventRecordID"] = node.text().get(); - } - else if (node_name == "Provider") { + } else if (node_name == "Provider") { metadata_["Provider"] = node.attribute("Name").value(); - } - else if (node_name == "EventID") { + } else if (node_name == "EventID") { metadata_["EventID"] = node.text().get(); - } - else { + } else { static std::map<std::string, EVT_FORMAT_MESSAGE_FLAGS> formatFlagMap = { {"Channel", EvtFormatMessageChannel}, {"Keywords", EvtFormatMessageKeyword}, {"Level", EvtFormatMessageLevel}, {"Opcode", EvtFormatMessageOpcode}, {"Task", EvtFormatMessageTask} @@ -94,8 +98,7 @@ bool MetadataWalker::for_each(pugi::xml_node &node) { return input; }; updateText(node, node.name(), std::move(updateFunc)); - } - else { + } else { // no conversion is required here, so let the node fall through } } @@ -144,7 +147,7 @@ std::string MetadataWalker::getMetadata(METADATA metadata) const { return std::to_string(windows_event_log_metadata_.getEventTypeIndex()); case COMPUTER: return windows_event_log_metadata_.getComputerName(); - }; + } return "N/A"; } @@ -168,8 +171,7 @@ std::string MetadataWalker::updateXmlMetadata(const std::string &xml, EVT_HANDLE wel::XmlString writer; doc.print(writer, "", pugi::format_raw); // no indentation or formatting return writer.xml_; - } - else { + } else { throw std::runtime_error("Could not parse XML document"); } } diff --git a/extensions/windows-event-log/wel/MetadataWalker.h b/extensions/windows-event-log/wel/MetadataWalker.h index faebc08..f779a7d 100644 --- a/extensions/windows-event-log/wel/MetadataWalker.h +++ b/extensions/windows-event-log/wel/MetadataWalker.h @@ -20,18 +20,25 @@ #pragma once -#include "WindowsEventLog.h" -#include "core/Core.h" -#include "FlowFileRecord.h" -#include "concurrentqueue.h" -#include "core/Processor.h" -#include "core/ProcessSession.h" -#include <pugixml.hpp> +#include <Windows.h> #include <winevt.h> +#include <codecvt> + +#include <map> #include <sstream> +#include <string> #include <regex> -#include <codecvt> +#include <vector> + +#include "core/Core.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" #include "utils/OsUtils.h" +#include "FlowFileRecord.h" +#include "WindowsEventLog.h" + +#include "concurrentqueue.h" +#include "pugixml.hpp" namespace org { namespace apache { @@ -63,7 +70,7 @@ class MetadataWalker : public pugi::xml_tree_walker { bool for_each(pugi::xml_node &node) override; static std::string updateXmlMetadata(const std::string &xml, EVT_HANDLE metadata_ptr, EVT_HANDLE event_ptr, bool update_xml, bool resolve, const std::string ®ex = ""); - + std::map<std::string, std::string> getFieldValues() const; std::map<std::string, std::string> getIdentifiers() const; diff --git a/extensions/windows-event-log/wel/UnicodeConversion.h b/extensions/windows-event-log/wel/UnicodeConversion.h index 90f5200..b382774 100644 --- a/extensions/windows-event-log/wel/UnicodeConversion.h +++ b/extensions/windows-event-log/wel/UnicodeConversion.h @@ -20,27 +20,27 @@ #pragma once -#include <string> - #include <atlbase.h> #include <atlconv.h> +#include <string> + namespace org { - namespace apache { - namespace nifi { - namespace minifi { - namespace wel { - inline std::string to_string(const wchar_t* pChar) { - ATL::CW2A aString(pChar, CP_UTF8); - return std::string(aString); - } +namespace apache { +namespace nifi { +namespace minifi { +namespace wel { +inline std::string to_string(const wchar_t* pChar) { + ATL::CW2A aString(pChar, CP_UTF8); + return std::string(aString); +} - inline std::wstring to_wstring(const char* pChar) { - ATL::CA2W wString(pChar, CP_UTF8); - return std::wstring(wString); - } - } /* namespace wel */ - } /* namespace minifi */ - } /* namespace nifi */ - } /* namespace apache */ +inline std::wstring to_wstring(const char* pChar) { + ATL::CA2W wString(pChar, CP_UTF8); + return std::wstring(wString); +} +} /* namespace wel */ +} /* namespace minifi */ +} /* namespace nifi */ +} /* namespace apache */ } /* namespace org */ diff --git a/extensions/windows-event-log/wel/WindowsEventLog.cpp b/extensions/windows-event-log/wel/WindowsEventLog.cpp index 3c9c0b9..5887632 100644 --- a/extensions/windows-event-log/wel/WindowsEventLog.cpp +++ b/extensions/windows-event-log/wel/WindowsEventLog.cpp @@ -16,11 +16,14 @@ * limitations under the License. */ #include <winmeta.h> + +#include <algorithm> +#include <memory> +#include <string> + #include "WindowsEventLog.h" #include "UnicodeConversion.h" #include "utils/Deleters.h" -#include <algorithm> - #include "utils/gsl.h" namespace org { @@ -46,18 +49,17 @@ void WindowsEventLogMetadataImpl::renderMetadata() { EvtClose(context); }); if (!EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize, rendered_values.get(), &dwBufferUsed, &dwPropertyCount)) { - if (ERROR_INSUFFICIENT_BUFFER == (status = GetLastError())) { - dwBufferSize = dwBufferUsed; - rendered_values.reset((PEVT_VARIANT)(malloc(dwBufferSize))); - if (!rendered_values) { - return; - } - EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize, rendered_values.get(), &dwBufferUsed, &dwPropertyCount); + if (ERROR_INSUFFICIENT_BUFFER != (status = GetLastError())) { + return; } - else { + + dwBufferSize = dwBufferUsed; + rendered_values.reset((PEVT_VARIANT)(malloc(dwBufferSize))); + if (!rendered_values) { return; } + EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize, rendered_values.get(), &dwBufferUsed, &dwPropertyCount); if (ERROR_SUCCESS != (status = GetLastError())) { return; } @@ -82,7 +84,8 @@ void WindowsEventLogMetadataImpl::renderMetadata() { hour -= 12; if (hour == 0) hour = 12; - datestr << st.wMonth << "/" << st.wDay << "/" << st.wYear << " " << std::setfill('0') << std::setw(2) << hour << ":" << std::setfill('0') << std::setw(2) << st.wMinute << ":" << std::setfill('0') << std::setw(2) << st.wSecond << " " << period; + datestr << st.wMonth << "/" << st.wDay << "/" << st.wYear << " " << std::setfill('0') << std::setw(2) << hour << ":" << std::setfill('0') + << std::setw(2) << st.wMinute << ":" << std::setfill('0') << std::setw(2) << st.wSecond << " " << period; event_timestamp_str_ = datestr.str(); auto level = static_cast<PEVT_VARIANT>(rendered_values.get())[EvtSystemLevel]; auto keyword = static_cast<PEVT_VARIANT>(rendered_values.get())[EvtSystemKeywords]; @@ -104,9 +107,8 @@ void WindowsEventLogMetadataImpl::renderMetadata() { break; default: event_type_index_ = 0; - }; - } - else { + } + } else { event_type_ = "N/A"; } @@ -205,8 +207,7 @@ void WindowsEventLogHeader::setDelimiter(const std::string &delim) { std::string WindowsEventLogHeader::createDefaultDelimiter(size_t max, size_t length) const { if (max > length) { return ":" + std::string(max - length, ' '); - } - else { + } else { return ": "; } } diff --git a/extensions/windows-event-log/wel/WindowsEventLog.h b/extensions/windows-event-log/wel/WindowsEventLog.h index a2247b1..c550e5f 100644 --- a/extensions/windows-event-log/wel/WindowsEventLog.h +++ b/extensions/windows-event-log/wel/WindowsEventLog.h @@ -18,19 +18,26 @@ #pragma once +#include <Windows.h> +#include <winevt.h> + +#include <algorithm> +#include <codecvt> +#include <map> +#include <sstream> +#include <string> +#include <regex> +#include <utility> +#include <vector> + #include "core/Core.h" -#include "FlowFileRecord.h" #include "concurrentqueue.h" #include "core/Processor.h" #include "core/ProcessSession.h" -#include <pugixml.hpp> -#include <winevt.h> -#include <sstream> -#include <regex> -#include <codecvt> #include "utils/OsUtils.h" +#include "FlowFileRecord.h" - +#include "pugixml.hpp" namespace org { namespace apache { @@ -61,7 +68,7 @@ namespace wel { typedef std::vector<std::pair<METADATA, std::string>> METADATA_NAMES; class WindowsEventLogHandler { -public: + public: WindowsEventLogHandler() : metadata_provider_(nullptr) { } @@ -73,7 +80,7 @@ public: EVT_HANDLE getMetadata() const; -private: + private: EVT_HANDLE metadata_provider_; }; @@ -82,11 +89,11 @@ class WindowsEventLogMetadata { virtual ~WindowsEventLogMetadata() = default; virtual std::string getEventData(EVT_FORMAT_MESSAGE_FLAGS flags) const = 0; virtual std::string getEventTimestamp() const = 0; - virtual short getEventTypeIndex() const = 0; + virtual short getEventTypeIndex() const = 0; // NOLINT short comes from WINDOWS API static std::string getMetadataString(METADATA val) { - static std::map< METADATA, std::string> map = { - {LOG_NAME, "LOG_NAME" }, + static std::map<METADATA, std::string> map = { + {LOG_NAME, "LOG_NAME" }, {SOURCE, "SOURCE"}, {TIME_CREATED, "TIME_CREATED" }, {EVENTID, "EVENTID"}, @@ -104,7 +111,7 @@ class WindowsEventLogMetadata { } static METADATA getMetadataFromString(const std::string &val) { - static std::map< std::string, METADATA> map = { + static std::map<std::string, METADATA> map = { {"LOG_NAME", LOG_NAME}, {"SOURCE", SOURCE}, {"TIME_CREATED", TIME_CREATED }, @@ -122,8 +129,7 @@ class WindowsEventLogMetadata { auto enumVal = map.find(val); if (enumVal != std::end(map)) { return enumVal->second; - } - else { + } else { return METADATA::UNKNOWN; } } @@ -135,8 +141,7 @@ class WindowsEventLogMetadata { DWORD size = sizeof(buff); if (GetComputerNameExA(ComputerNameDnsFullyQualified, buff, &size)) { computer_name = buff; - } - else { + } else { computer_name = "N/A"; } } @@ -145,7 +150,7 @@ class WindowsEventLogMetadata { }; class WindowsEventLogMetadataImpl : public WindowsEventLogMetadata { -public: + public: WindowsEventLogMetadataImpl(EVT_HANDLE metadataProvider, EVT_HANDLE event_ptr) : metadata_ptr_(metadataProvider), event_timestamp_(0), event_ptr_(event_ptr) { renderMetadata(); } @@ -154,21 +159,21 @@ public: std::string getEventTimestamp() const override { return event_timestamp_str_; } - short getEventTypeIndex() const override { return event_type_index_; } + short getEventTypeIndex() const override { return event_type_index_; } // NOLINT short comes from WINDOWS API private: void renderMetadata(); uint64_t event_timestamp_; std::string event_type_; - short event_type_index_; + short event_type_index_; // NOLINT short comes from WINDOWS API std::string event_timestamp_str_; EVT_HANDLE event_ptr_; EVT_HANDLE metadata_ptr_; }; class WindowsEventLogHeader { -public: + public: explicit WindowsEventLogHeader(METADATA_NAMES header_names) : header_names_(header_names) {} void setDelimiter(const std::string &delim); @@ -176,7 +181,7 @@ public: template<typename MetadataCollection> std::string getEventHeader(const MetadataCollection& metadata_collection) const; -private: + private: std::string createDefaultDelimiter(size_t max, size_t length) const; std::string delimiter_; diff --git a/extensions/windows-event-log/wel/XMLString.h b/extensions/windows-event-log/wel/XMLString.h index d4f1c1f..18d35bb 100644 --- a/extensions/windows-event-log/wel/XMLString.h +++ b/extensions/windows-event-log/wel/XMLString.h @@ -20,18 +20,21 @@ #pragma once -#include "core/Core.h" -#include "FlowFileRecord.h" -#include "concurrentqueue.h" -#include "core/Processor.h" -#include "core/ProcessSession.h" -#include <pugixml.hpp> +#include <Windows.h> #include <winevt.h> + #include <sstream> +#include <string> #include <regex> -#include <codecvt> + +#include "core/Core.h" +#include "core/Processor.h" +#include "core/ProcessSession.h" +#include "FlowFileRecord.h" #include "utils/OsUtils.h" +#include "concurrentqueue.h" +#include "pugixml.hpp" namespace org { @@ -40,14 +43,14 @@ namespace nifi { namespace minifi { namespace wel { - class XmlString : public pugi::xml_writer { - public: - std::string xml_; +class XmlString : public pugi::xml_writer { + public: + std::string xml_; - virtual void write(const void* data, size_t size) { - xml_.append(static_cast<const char*>(data), size); - } - }; + virtual void write(const void* data, size_t size) { + xml_.append(static_cast<const char*>(data), size); + } +}; } /* namespace wel */ } /* namespace minifi */ diff --git a/libminifi/include/io/ClientSocket.h b/libminifi/include/io/ClientSocket.h index 37626c8..84f3836 100644 --- a/libminifi/include/io/ClientSocket.h +++ b/libminifi/include/io/ClientSocket.h @@ -125,8 +125,8 @@ class Socket : public BaseStream { */ int initialize() override; - virtual void setInterface(io::NetworkInterface interface) { - local_network_interface_ = std::move(interface); + virtual void setInterface(io::NetworkInterface network_interface) { + local_network_interface_ = std::move(network_interface); } /**
