From cbd408e1c9a15087d9732359e2ecb70f8acc25df Mon Sep 17 00:00:00 2001 From: Alessandro Gario Date: Sat, 23 Nov 2019 14:12:37 +0100 Subject: [PATCH 01/20] CMake: Add the system layer diff --git a/CMakeLists.txt b/CMakeLists.txt index 47b5f2e7..13d1dd2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,6 @@ include(cmake/utilities.cmake) include(cmake/toolchain.cmake) project(osquery) - if(OSQUERY_BUILD_TESTS) enable_testing() endif() diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 0166b48d..af3c0e71 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -33,10 +33,10 @@ function(setupBuildFlags) if(DEFINED PLATFORM_POSIX) set(posix_common_compile_options - -Qunused-arguments + #-Qunused-arguments -Wno-shadow-field - -Wall - -Wextra + #-Wall + #-Wextra -Wno-unused-local-typedef -Wno-deprecated-register -Wno-unknown-warning-option @@ -57,13 +57,13 @@ function(setupBuildFlags) -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden - -fno-limit-debug-info + #-fno-limit-debug-info -pipe -pedantic ) if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - list(APPEND posix_common_compile_options INTERFACE -Oz) + list(APPEND posix_common_compile_options INTERFACE -O2) endif() set(osquery_posix_common_defines @@ -122,13 +122,12 @@ function(setupBuildFlags) ) set(linux_cxx_link_options - --no-undefined + #--no-undefined -lresolv -pthread ) set(linux_cxx_link_libraries - c++abi rt dl ) @@ -163,7 +162,6 @@ function(setupBuildFlags) cups bsm xar - c++abi "-framework AppKit" "-framework Foundation" "-framework CoreServices" diff --git a/cmake/options.cmake b/cmake/options.cmake index 4b6df1a4..3116cd51 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -80,7 +80,13 @@ set(OSQUERY_CLANG_TIDY_CHECKS "-checks=cert-*,cppcoreguidelines-*,performance-*, # Unfortunately, due glog always enabling BUILD_TESTING, we have to force it off, so that tests won't be built overwrite_cache_variable("BUILD_TESTING" "BOOL" "OFF") -set(third_party_source_list "source;formula") +# Linux can use source and formula modules to link dependencies; this +# feature is not yet available on Windows and macOS +if(DEFINED PLATFORM_LINUX) + set(third_party_source_list "system;source") +else() + set(third_party_source_list "source_migration;facebook") +endif() set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" CACHE STRING "A list of paths containing CMake module files") set(OSQUERY_THIRD_PARTY_SOURCE "${third_party_source_list}" CACHE STRING "Sources used to acquire third-party dependencies") diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 873aa97a..7918289c 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -34,7 +34,7 @@ function(librariesMain) if(DEFINED PLATFORM_POSIX) set(compile_options - -Oz + -O2 -g0 ) endif() diff --git a/libraries/cmake/system/modules/Findaugeas.cmake b/libraries/cmake/system/modules/Findaugeas.cmake new file mode 100644 index 00000000..259df793 --- /dev/null +++ b/libraries/cmake/system/modules/Findaugeas.cmake @@ -0,0 +1,17 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME augeas + REQUIRED ${augeas_REQUIRED} + MAIN_HEADER "augeas.h" + LIBRARIES "augeas" "fa" +) + +target_link_libraries(augeas INTERFACE libxml2) \ No newline at end of file diff --git a/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake b/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake new file mode 100644 index 00000000..aa85e7fc --- /dev/null +++ b/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findaws-sdk-cpp.cmake") diff --git a/libraries/cmake/system/modules/Findberkeley-db.cmake b/libraries/cmake/system/modules/Findberkeley-db.cmake new file mode 100644 index 00000000..30b24f4f --- /dev/null +++ b/libraries/cmake/system/modules/Findberkeley-db.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME berkeley-db + REQUIRED ${berkeley-db_REQUIRED} + MAIN_HEADER "db.h" + LIBRARIES "db" "db_cxx" "db_stl" +) diff --git a/libraries/cmake/system/modules/Findboost.cmake b/libraries/cmake/system/modules/Findboost.cmake new file mode 100644 index 00000000..50161989 --- /dev/null +++ b/libraries/cmake/system/modules/Findboost.cmake @@ -0,0 +1,21 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME boost + REQUIRED ${boost_REQUIRED} + MAIN_HEADER "boost/any.hpp" + LIBRARIES + "boost_system" + "boost_regex" + "boost_filesystem" + "boost_thread" + "boost_context" + "boost_chrono" +) diff --git a/libraries/cmake/system/modules/Findbzip2.cmake b/libraries/cmake/system/modules/Findbzip2.cmake new file mode 100644 index 00000000..22ee87d0 --- /dev/null +++ b/libraries/cmake/system/modules/Findbzip2.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME bzip2 + REQUIRED ${bzip2_REQUIRED} + MAIN_HEADER "bzlib.h" + LIBRARIES "bz2" +) diff --git a/libraries/cmake/system/modules/Findgflags.cmake b/libraries/cmake/system/modules/Findgflags.cmake new file mode 100644 index 00000000..b8985a84 --- /dev/null +++ b/libraries/cmake/system/modules/Findgflags.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME gflags + REQUIRED ${gflags_REQUIRED} + MAIN_HEADER "gflags/gflags.h" + LIBRARIES "gflags" +) diff --git a/libraries/cmake/system/modules/Findglibc.cmake b/libraries/cmake/system/modules/Findglibc.cmake new file mode 100644 index 00000000..9a9ba530 --- /dev/null +++ b/libraries/cmake/system/modules/Findglibc.cmake @@ -0,0 +1,10 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/facebook/modules/api.cmake") +add_subdirectory("${CMAKE_SOURCE_DIR}/libraries/cmake/facebook/glibc") diff --git a/libraries/cmake/system/modules/Findglog.cmake b/libraries/cmake/system/modules/Findglog.cmake new file mode 100644 index 00000000..6904c845 --- /dev/null +++ b/libraries/cmake/system/modules/Findglog.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME glog + REQUIRED ${glog_REQUIRED} + MAIN_HEADER "glog/logging.h" + LIBRARIES "glog" +) diff --git a/libraries/cmake/system/modules/Findgoogletest.cmake b/libraries/cmake/system/modules/Findgoogletest.cmake new file mode 100644 index 00000000..2ce20e47 --- /dev/null +++ b/libraries/cmake/system/modules/Findgoogletest.cmake @@ -0,0 +1,17 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME googletest + REQUIRED ${gtest_REQUIRED} + MAIN_HEADER "gtest/gtest.h" + LIBRARIES "gtest" +) + +add_library(thirdparty_googletest_headers INTERFACE) diff --git a/libraries/cmake/system/modules/Findjinja2.cmake b/libraries/cmake/system/modules/Findjinja2.cmake new file mode 100644 index 00000000..bc6e196a --- /dev/null +++ b/libraries/cmake/system/modules/Findjinja2.cmake @@ -0,0 +1,10 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/facebook/modules/api.cmake") +add_subdirectory("${CMAKE_SOURCE_DIR}/libraries/cmake/facebook/jinja2") diff --git a/libraries/cmake/system/modules/Findlibarchive.cmake b/libraries/cmake/system/modules/Findlibarchive.cmake new file mode 100644 index 00000000..b3542cd4 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibarchive.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libarchive + REQUIRED ${libarchive_REQUIRED} + MAIN_HEADER "archive.h" + LIBRARIES "archive" +) diff --git a/libraries/cmake/system/modules/Findlibaudit.cmake b/libraries/cmake/system/modules/Findlibaudit.cmake new file mode 100644 index 00000000..261f6403 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibaudit.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libaudit + REQUIRED ${libaudit_REQUIRED} + MAIN_HEADER "libaudit.h" + LIBRARIES "audit" "auparse" +) diff --git a/libraries/cmake/system/modules/Findlibcryptsetup.cmake b/libraries/cmake/system/modules/Findlibcryptsetup.cmake new file mode 100644 index 00000000..094df32e --- /dev/null +++ b/libraries/cmake/system/modules/Findlibcryptsetup.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libcryptsetup + REQUIRED ${libcryptsetup_REQUIRED} + MAIN_HEADER "libcryptsetup.h" + LIBRARIES "cryptsetup" +) diff --git a/libraries/cmake/system/modules/Findlibdevmapper.cmake b/libraries/cmake/system/modules/Findlibdevmapper.cmake new file mode 100644 index 00000000..34eb1199 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibdevmapper.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibdevmapper.cmake") diff --git a/libraries/cmake/system/modules/Findlibdpkg.cmake b/libraries/cmake/system/modules/Findlibdpkg.cmake new file mode 100644 index 00000000..5d601b80 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibdpkg.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibdpkg.cmake") diff --git a/libraries/cmake/system/modules/Findlibelfin.cmake b/libraries/cmake/system/modules/Findlibelfin.cmake new file mode 100644 index 00000000..ce5da17f --- /dev/null +++ b/libraries/cmake/system/modules/Findlibelfin.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibelfin.cmake") diff --git a/libraries/cmake/system/modules/Findlibgcrypt.cmake b/libraries/cmake/system/modules/Findlibgcrypt.cmake new file mode 100644 index 00000000..b11afb83 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibgcrypt.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libgcrypt + REQUIRED ${libgcrypt_REQUIRED} + MAIN_HEADER "gcrypt.h" + LIBRARIES "gcrypt" +) diff --git a/libraries/cmake/system/modules/Findlibgpg-error.cmake b/libraries/cmake/system/modules/Findlibgpg-error.cmake new file mode 100644 index 00000000..7ff49839 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibgpg-error.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libgpg-error + REQUIRED ${libgpg-error_REQUIRED} + MAIN_HEADER "gpg-error.h" + LIBRARIES "gpg-error" +) diff --git a/libraries/cmake/system/modules/Findlibiptables.cmake b/libraries/cmake/system/modules/Findlibiptables.cmake new file mode 100644 index 00000000..17cf4047 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibiptables.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libiptables + REQUIRED ${libiptables_REQUIRED} + MAIN_HEADER "libipq.h" + LIBRARIES "ip4tc" "ip6tc" "ipq" "iptc" +) diff --git a/libraries/cmake/system/modules/Findlibmagic.cmake b/libraries/cmake/system/modules/Findlibmagic.cmake new file mode 100644 index 00000000..70a6af44 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibmagic.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libmagic + REQUIRED ${libmagic_REQUIRED} + MAIN_HEADER "magic.h" + LIBRARIES "magic" +) diff --git a/libraries/cmake/system/modules/Findlibrdkafka.cmake b/libraries/cmake/system/modules/Findlibrdkafka.cmake new file mode 100644 index 00000000..38ca0d9e --- /dev/null +++ b/libraries/cmake/system/modules/Findlibrdkafka.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibrdkafka.cmake") diff --git a/libraries/cmake/system/modules/Findlibrpm.cmake b/libraries/cmake/system/modules/Findlibrpm.cmake new file mode 100644 index 00000000..a466800e --- /dev/null +++ b/libraries/cmake/system/modules/Findlibrpm.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibrpm.cmake") + +target_compile_definitions(thirdparty_librpm PRIVATE + HAVE_RSA_SET0_KEY + HAVE_DSA_SET0_KEY + HAVE_DSA_SET0_PQG + HAVE_DSA_SIG_SET0 + HAVE_BN2BINPAD +) diff --git a/libraries/cmake/system/modules/Findlibudev.cmake b/libraries/cmake/system/modules/Findlibudev.cmake new file mode 100644 index 00000000..29809f41 --- /dev/null +++ b/libraries/cmake/system/modules/Findlibudev.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibudev.cmake") diff --git a/libraries/cmake/system/modules/Findlibxml2.cmake b/libraries/cmake/system/modules/Findlibxml2.cmake new file mode 100644 index 00000000..4e4b82eb --- /dev/null +++ b/libraries/cmake/system/modules/Findlibxml2.cmake @@ -0,0 +1,16 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libxml2 + REQUIRED ${libxml2_REQUIRED} + MAIN_HEADER "libxml/xpath.h" + LIBRARIES "xml2" + HEADER_PATH_SUFFIX_LIST "libxml2" +) diff --git a/libraries/cmake/system/modules/Findlinenoise-ng.cmake b/libraries/cmake/system/modules/Findlinenoise-ng.cmake new file mode 100644 index 00000000..87753421 --- /dev/null +++ b/libraries/cmake/system/modules/Findlinenoise-ng.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlinenoise-ng.cmake") diff --git a/libraries/cmake/system/modules/Findlldpd.cmake b/libraries/cmake/system/modules/Findlldpd.cmake new file mode 100644 index 00000000..edcb1a20 --- /dev/null +++ b/libraries/cmake/system/modules/Findlldpd.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME lldpd + REQUIRED ${lldpd_REQUIRED} + MAIN_HEADER "lldpctl.h" + LIBRARIES "lldpctl" +) diff --git a/libraries/cmake/system/modules/Findlzma.cmake b/libraries/cmake/system/modules/Findlzma.cmake new file mode 100644 index 00000000..69c0cb15 --- /dev/null +++ b/libraries/cmake/system/modules/Findlzma.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME lzma + REQUIRED ${lzma_REQUIRED} + MAIN_HEADER "lzma.h" + LIBRARIES "lzma" +) diff --git a/libraries/cmake/system/modules/Findmarkupsafe.cmake b/libraries/cmake/system/modules/Findmarkupsafe.cmake new file mode 100644 index 00000000..c3f0ed75 --- /dev/null +++ b/libraries/cmake/system/modules/Findmarkupsafe.cmake @@ -0,0 +1,10 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/facebook/modules/api.cmake") +add_subdirectory("${CMAKE_SOURCE_DIR}/libraries/cmake/facebook/markupsafe") diff --git a/libraries/cmake/system/modules/Findopenssl.cmake b/libraries/cmake/system/modules/Findopenssl.cmake new file mode 100644 index 00000000..97518d81 --- /dev/null +++ b/libraries/cmake/system/modules/Findopenssl.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME thirdparty_openssl + REQUIRED ${openssl_REQUIRED} + MAIN_HEADER "openssl/crypto.h" + LIBRARIES "ssl" "crypto" +) diff --git a/libraries/cmake/system/modules/Findpopt.cmake b/libraries/cmake/system/modules/Findpopt.cmake new file mode 100644 index 00000000..8468800c --- /dev/null +++ b/libraries/cmake/system/modules/Findpopt.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME popt + REQUIRED ${popt_REQUIRED} + MAIN_HEADER "popt.h" + LIBRARIES "popt" +) diff --git a/libraries/cmake/system/modules/Findrapidjson.cmake b/libraries/cmake/system/modules/Findrapidjson.cmake new file mode 100644 index 00000000..ad691461 --- /dev/null +++ b/libraries/cmake/system/modules/Findrapidjson.cmake @@ -0,0 +1,14 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME rapidjson + REQUIRED ${rapidjson_REQUIRED} + MAIN_HEADER "rapidjson/document.h" +) diff --git a/libraries/cmake/system/modules/Findrocksdb.cmake b/libraries/cmake/system/modules/Findrocksdb.cmake new file mode 100644 index 00000000..caadb1ad --- /dev/null +++ b/libraries/cmake/system/modules/Findrocksdb.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findrocksdb.cmake") diff --git a/libraries/cmake/system/modules/Findsleuthkit.cmake b/libraries/cmake/system/modules/Findsleuthkit.cmake new file mode 100644 index 00000000..6250f66e --- /dev/null +++ b/libraries/cmake/system/modules/Findsleuthkit.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME sleuthkit + REQUIRED ${sleuthkit_REQUIRED} + MAIN_HEADER "tsk/base/tsk_os.h" + LIBRARIES "tsk" +) diff --git a/libraries/cmake/system/modules/Findsmartmontools.cmake b/libraries/cmake/system/modules/Findsmartmontools.cmake new file mode 100644 index 00000000..156e23bd --- /dev/null +++ b/libraries/cmake/system/modules/Findsmartmontools.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findsmartmontools.cmake") diff --git a/libraries/cmake/system/modules/Findsqlite.cmake b/libraries/cmake/system/modules/Findsqlite.cmake new file mode 100644 index 00000000..3a214efb --- /dev/null +++ b/libraries/cmake/system/modules/Findsqlite.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME sqlite + REQUIRED ${sqlite_REQUIRED} + MAIN_HEADER "sqlite3.h" + LIBRARIES "sqlite3" +) diff --git a/libraries/cmake/system/modules/Findssdeep-cpp.cmake b/libraries/cmake/system/modules/Findssdeep-cpp.cmake new file mode 100644 index 00000000..b68b03f3 --- /dev/null +++ b/libraries/cmake/system/modules/Findssdeep-cpp.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findssdeep-cpp.cmake") diff --git a/libraries/cmake/system/modules/Findssdeep.cmake b/libraries/cmake/system/modules/Findssdeep.cmake new file mode 100644 index 00000000..8f566f2b --- /dev/null +++ b/libraries/cmake/system/modules/Findssdeep.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME ssdeep + REQUIRED ${ssdeep_REQUIRED} + MAIN_HEADER "fuzzy.h" + LIBRARIES "fuzzy" +) diff --git a/libraries/cmake/system/modules/Findthrift.cmake.bak b/libraries/cmake/system/modules/Findthrift.cmake.bak new file mode 100644 index 00000000..f0dd2d45 --- /dev/null +++ b/libraries/cmake/system/modules/Findthrift.cmake.bak @@ -0,0 +1,16 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME thrift + REQUIRED ${thrift_REQUIRED} + MAIN_HEADER "thrift/version.h" + LIBRARIES "thrift" "thrift_c_glib" "thriftc" "thriftnb" "thriftz" +) + diff --git a/libraries/cmake/system/modules/Findutil-linux.cmake b/libraries/cmake/system/modules/Findutil-linux.cmake new file mode 100644 index 00000000..2858fae0 --- /dev/null +++ b/libraries/cmake/system/modules/Findutil-linux.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME util-linux + REQUIRED ${util-linux_REQUIRED} + MAIN_HEADER "blkid/blkid.h" + LIBRARIES "blkid" "fdisk" "mount" "smartcols" +) diff --git a/libraries/cmake/system/modules/Findyara.cmake b/libraries/cmake/system/modules/Findyara.cmake new file mode 100644 index 00000000..8c27dc5d --- /dev/null +++ b/libraries/cmake/system/modules/Findyara.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME yara + REQUIRED ${yara_REQUIRED} + MAIN_HEADER "yara.h" + LIBRARIES "yara" +) diff --git a/libraries/cmake/system/modules/Findzlib.cmake b/libraries/cmake/system/modules/Findzlib.cmake new file mode 100644 index 00000000..14d2807f --- /dev/null +++ b/libraries/cmake/system/modules/Findzlib.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME zlib + REQUIRED ${zlib_REQUIRED} + MAIN_HEADER "zlib.h" + LIBRARIES "z" +) diff --git a/libraries/cmake/system/modules/Findzstd.cmake b/libraries/cmake/system/modules/Findzstd.cmake new file mode 100644 index 00000000..39285d35 --- /dev/null +++ b/libraries/cmake/system/modules/Findzstd.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME zstd + REQUIRED ${zstd_REQUIRED} + MAIN_HEADER "zstd.h" + LIBRARIES "zstd" +) diff --git a/libraries/cmake/system/modules/api.cmake b/libraries/cmake/system/modules/api.cmake new file mode 100644 index 00000000..ca948a43 --- /dev/null +++ b/libraries/cmake/system/modules/api.cmake @@ -0,0 +1,89 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) + +function(locateSystemLibrary) + cmake_parse_arguments( + PARSE_ARGV 0 + "ARGS" + "REQUIRED" + "NAME;MAIN_HEADER" + "LIBRARIES;HEADER_PATH_SUFFIX_LIST" + ) + + set(find_path_hints + "${CMAKE_INSTALL_PREFIX}/include" + "/usr/local/include" + "/usr/include" + "/include" + ) + + set(find_library_hints + "${CMAKE_INSTALL_PREFIX}/lib64" + "/usr/local/lib64" + "/usr/lib64" + "/lib64" + + "${CMAKE_INSTALL_PREFIX}/lib" + "/usr/local/lib" + "/usr/lib" + "/lib" + ) + + if(ARGS_REQUIRED) + set(error_type "FATAL_ERROR") + else() + set(error_type "WARNING") + endif() + + if(NOT "${ARGS_HEADER_PATH_SUFFIX_LIST}" STREQUAL "") + set(optional_path_suffixes_parameter PATH_SUFFIXES ${ARGS_HEADER_PATH_SUFFIX_LIST}) + endif() + + unset(main_header_path CACHE) + find_path(main_header_path + NAME "${ARGS_MAIN_HEADER}" + PATHS ${find_path_hints} + ${optional_path_suffixes_parameter} + ) + + if("${main_header_path}" STREQUAL "main_header_path-NOTFOUND") + message("${error_type}" "Failed to import library ${ARGS_NAME}. The following header file was not found: ${ARGS_MAIN_HEADER}") + return() + endif() + + foreach(current_library_name ${ARGS_LIBRARIES}) + unset(current_library_path CACHE) + find_library(current_library_path + NAME "${current_library_name}" + PATHS ${find_library_hints} + ) + + if("${current_library_path}" STREQUAL "current_library_path-NOTFOUND") + message("${error_type}" "Failed to import library ${ARGS_NAME}. The following library was not found: ${current_library_name}") + return() + endif() + + set(imported_library_name "${ARGS_NAME}_${current_library_name}") + + add_library("${imported_library_name}" UNKNOWN IMPORTED GLOBAL) + set_target_properties("${imported_library_name}" PROPERTIES + IMPORTED_LOCATION "${current_library_path}" + ) + + list(APPEND imported_library_list "${imported_library_name}") + + unset(current_library_path CACHE) + unset(current_library_path) + endforeach() + + add_library("${ARGS_NAME}" INTERFACE) + target_link_libraries("${ARGS_NAME}" INTERFACE ${imported_library_list}) + target_include_directories("${ARGS_NAME}" INTERFACE "${main_header_path}") + + set("${ARGS_NAME}_FOUND" true PARENT_SCOPE) +endfunction() diff --git a/osquery/utils/system/linux/ebpf/program.cpp b/osquery/utils/system/linux/ebpf/program.cpp index 58c5a021..c0e7db67 100644 --- a/osquery/utils/system/linux/ebpf/program.cpp +++ b/osquery/utils/system/linux/ebpf/program.cpp @@ -41,16 +41,13 @@ Expected Program::load( constexpr auto kLogBufSize = std::uint32_t{1 << 16}; auto bpf_log_buf = std::array{}; - union bpf_attr attr = { - .prog_type = program_type, - .insns = reinterpret_cast<__aligned_u64>(prog.data()), - .insn_cnt = static_cast(prog.size()), - .license = reinterpret_cast<__aligned_u64>(kLicense), - .log_buf = 0u, - .log_size = 0u, - .log_level = 0u, - .kern_version = LINUX_VERSION_CODE, - }; + union bpf_attr attr{}; + attr.prog_type = program_type; + attr.insns = reinterpret_cast<__aligned_u64>(prog.data()); + attr.insn_cnt = static_cast(prog.size()); + attr.license = reinterpret_cast<__aligned_u64>(kLicense); + attr.kern_version = LINUX_VERSION_CODE; + if (debug) { bpf_log_buf.fill('\0'); attr.log_buf = reinterpret_cast(bpf_log_buf.data()); diff --git a/osquery/utils/system/linux/ebpf/program.h b/osquery/utils/system/linux/ebpf/program.h index 0dd0b499..32299c2e 100644 --- a/osquery/utils/system/linux/ebpf/program.h +++ b/osquery/utils/system/linux/ebpf/program.h @@ -9,6 +9,8 @@ #pragma once +#include + #include #include -- 2.28.0 From 581eee0087c36f65ea253e1cb1cbdf6142ed20f6 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Sun, 24 Nov 2019 09:38:32 -0800 Subject: [PATCH 02/20] Use system libraries diff --git a/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake b/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake index aa85e7fc..64344a58 100644 --- a/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake +++ b/libraries/cmake/system/modules/Findaws-sdk-cpp.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findaws-sdk-cpp.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME aws-sdk-cpp + REQUIRED ${aws-sdk-cpp_REQUIRED} + MAIN_HEADER "aws/core/Version.h" "aws/ec2/EC2Client.h" "aws/firehose/FirehoseClient.h" "aws/kinesis/KinesisClient.h " + LIBRARIES "aws-cpp-sdk-core" "aws-cpp-sdk-ec2" "aws-cpp-sdk-firehose" "aws-cpp-sdk-kinesis" "aws-cpp-sdk-sts" +) diff --git a/libraries/cmake/system/modules/Findlibdevmapper.cmake b/libraries/cmake/system/modules/Findlibdevmapper.cmake index 34eb1199..47b5f566 100644 --- a/libraries/cmake/system/modules/Findlibdevmapper.cmake +++ b/libraries/cmake/system/modules/Findlibdevmapper.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibdevmapper.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libdevmapper + REQUIRED ${libdevmapper_REQUIRED} + MAIN_HEADER "libdevmapper.h" + LIBRARIES "devmapper" "lvm2app" +) diff --git a/libraries/cmake/system/modules/Findlibdpkg.cmake b/libraries/cmake/system/modules/Findlibdpkg.cmake index 5d601b80..92d94a94 100644 --- a/libraries/cmake/system/modules/Findlibdpkg.cmake +++ b/libraries/cmake/system/modules/Findlibdpkg.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibdpkg.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libdpkg + REQUIRED ${libdpkg_REQUIRED} + MAIN_HEADER "dpkg/dpkg.h" + LIBRARIES "dpkg" +) diff --git a/libraries/cmake/system/modules/Findlibelfin.cmake b/libraries/cmake/system/modules/Findlibelfin.cmake index ce5da17f..b231a74e 100644 --- a/libraries/cmake/system/modules/Findlibelfin.cmake +++ b/libraries/cmake/system/modules/Findlibelfin.cmake @@ -4,4 +4,9 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibelfin.cmake") +locateSystemLibrary( + NAME libelfin + REQUIRED ${libelfin_REQUIRED} + MAIN_HEADER "libelfin/elf/elf++.hh" "libelfin/dwarf/dwarf++.hh" + LIBRARIES "dwarf++" "elf++" +) \ No newline at end of file diff --git a/libraries/cmake/system/modules/Findlibrdkafka.cmake b/libraries/cmake/system/modules/Findlibrdkafka.cmake index 38ca0d9e..657bd568 100644 --- a/libraries/cmake/system/modules/Findlibrdkafka.cmake +++ b/libraries/cmake/system/modules/Findlibrdkafka.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibrdkafka.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME librdkafka + REQUIRED ${librdkafka_REQUIRED} + MAIN_HEADER "librdkafka/rdkafka.h" + LIBRARIES "rdkafka" "rdkafka++" +) \ No newline at end of file diff --git a/libraries/cmake/system/modules/Findlibrpm.cmake b/libraries/cmake/system/modules/Findlibrpm.cmake index a466800e..2f48f3b0 100644 --- a/libraries/cmake/system/modules/Findlibrpm.cmake +++ b/libraries/cmake/system/modules/Findlibrpm.cmake @@ -4,12 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibrpm.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") -target_compile_definitions(thirdparty_librpm PRIVATE - HAVE_RSA_SET0_KEY - HAVE_DSA_SET0_KEY - HAVE_DSA_SET0_PQG - HAVE_DSA_SIG_SET0 - HAVE_BN2BINPAD -) +locateSystemLibrary( + NAME librpm + REQUIRED ${librpm_REQUIRED} + MAIN_HEADER "rpm/header.h" + LIBRARIES "rpm" "rpmio" +) \ No newline at end of file diff --git a/libraries/cmake/system/modules/Findlibudev.cmake b/libraries/cmake/system/modules/Findlibudev.cmake index 29809f41..255db383 100644 --- a/libraries/cmake/system/modules/Findlibudev.cmake +++ b/libraries/cmake/system/modules/Findlibudev.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlibudev.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME libudev + REQUIRED ${libudev_REQUIRED} + MAIN_HEADER "libudev.h" + LIBRARIES "udev" +) \ No newline at end of file diff --git a/libraries/cmake/system/modules/Findlinenoise-ng.cmake b/libraries/cmake/system/modules/Findlinenoise-ng.cmake index 87753421..ddb6e681 100644 --- a/libraries/cmake/system/modules/Findlinenoise-ng.cmake +++ b/libraries/cmake/system/modules/Findlinenoise-ng.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findlinenoise-ng.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME linenoise-ng + REQUIRED ${linenoise-ng_REQUIRED} + MAIN_HEADER "linenoise.h" + LIBRARIES "linenoise" +) diff --git a/libraries/cmake/system/modules/Findrocksdb.cmake b/libraries/cmake/system/modules/Findrocksdb.cmake index caadb1ad..bce6e918 100644 --- a/libraries/cmake/system/modules/Findrocksdb.cmake +++ b/libraries/cmake/system/modules/Findrocksdb.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findrocksdb.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME rocksdb + REQUIRED ${rocksdb_REQUIRED} + MAIN_HEADER "rocksdb/db.h" + LIBRARIES "rocksdb" +) diff --git a/libraries/cmake/system/modules/Findssdeep-cpp.cmake b/libraries/cmake/system/modules/Findssdeep-cpp.cmake index b68b03f3..b6e4da83 100644 --- a/libraries/cmake/system/modules/Findssdeep-cpp.cmake +++ b/libraries/cmake/system/modules/Findssdeep-cpp.cmake @@ -4,4 +4,12 @@ # This source code is licensed in accordance with the terms specified in # the LICENSE file found in the root directory of this source tree. -include("${CMAKE_SOURCE_DIR}/libraries/cmake/source/modules/Findssdeep-cpp.cmake") +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME ssdeep-cpp + REQUIRED ${ssdeep_REQUIRED} + MAIN_HEADER "fuzzy.h" + LIBRARIES "fuzzy" +) diff --git a/libraries/cmake/system/modules/Findssdeep.cmake b/libraries/cmake/system/modules/Findssdeep.cmake deleted file mode 100644 index 8f566f2b..00000000 --- a/libraries/cmake/system/modules/Findssdeep.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2014-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed in accordance with the terms specified in -# the LICENSE file found in the root directory of this source tree. - -cmake_minimum_required(VERSION 3.15) -include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") - -locateSystemLibrary( - NAME ssdeep - REQUIRED ${ssdeep_REQUIRED} - MAIN_HEADER "fuzzy.h" - LIBRARIES "fuzzy" -) diff --git a/libraries/cmake/system/modules/Findthrift.cmake.bak b/libraries/cmake/system/modules/Findthrift.cmake similarity index 78% rename from libraries/cmake/system/modules/Findthrift.cmake.bak rename to libraries/cmake/system/modules/Findthrift.cmake index f0dd2d45..1e5d5d93 100644 --- a/libraries/cmake/system/modules/Findthrift.cmake.bak +++ b/libraries/cmake/system/modules/Findthrift.cmake @@ -10,7 +10,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") locateSystemLibrary( NAME thrift REQUIRED ${thrift_REQUIRED} - MAIN_HEADER "thrift/version.h" - LIBRARIES "thrift" "thrift_c_glib" "thriftc" "thriftnb" "thriftz" + MAIN_HEADER "thrift/config.h" + LIBRARIES "thrift" "thrift_c_glib" "thriftnb" "thriftz" "event" ) -- 2.28.0 From 4b2775a37aa28993fd1c450b75e4843b12c1cad7 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Mon, 25 Nov 2019 00:43:39 -0800 Subject: [PATCH 03/20] Regenerate Thrift with version 0.13.0 diff --git a/osquery/extensions/thrift/gen/Extension.cpp b/osquery/extensions/thrift/gen/Extension.cpp index 9f01870a..cdd53dc3 100644 --- a/osquery/extensions/thrift/gen/Extension.cpp +++ b/osquery/extensions/thrift/gen/Extension.cpp @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -9,7 +9,7 @@ namespace osquery { namespace extensions { -Extension_ping_args::~Extension_ping_args() throw() { +Extension_ping_args::~Extension_ping_args() noexcept { } @@ -52,7 +52,7 @@ uint32_t Extension_ping_args::write(::apache::thrift::protocol::TProtocol* oprot } -Extension_ping_pargs::~Extension_ping_pargs() throw() { +Extension_ping_pargs::~Extension_ping_pargs() noexcept { } @@ -67,7 +67,7 @@ uint32_t Extension_ping_pargs::write(::apache::thrift::protocol::TProtocol* opro } -Extension_ping_result::~Extension_ping_result() throw() { +Extension_ping_result::~Extension_ping_result() noexcept { } @@ -129,7 +129,7 @@ uint32_t Extension_ping_result::write(::apache::thrift::protocol::TProtocol* opr } -Extension_ping_presult::~Extension_ping_presult() throw() { +Extension_ping_presult::~Extension_ping_presult() noexcept { } @@ -175,7 +175,7 @@ uint32_t Extension_ping_presult::read(::apache::thrift::protocol::TProtocol* ipr } -Extension_call_args::~Extension_call_args() throw() { +Extension_call_args::~Extension_call_args() noexcept { } @@ -283,7 +283,7 @@ uint32_t Extension_call_args::write(::apache::thrift::protocol::TProtocol* oprot } -Extension_call_pargs::~Extension_call_pargs() throw() { +Extension_call_pargs::~Extension_call_pargs() noexcept { } @@ -319,7 +319,7 @@ uint32_t Extension_call_pargs::write(::apache::thrift::protocol::TProtocol* opro } -Extension_call_result::~Extension_call_result() throw() { +Extension_call_result::~Extension_call_result() noexcept { } @@ -381,7 +381,7 @@ uint32_t Extension_call_result::write(::apache::thrift::protocol::TProtocol* opr } -Extension_call_presult::~Extension_call_presult() throw() { +Extension_call_presult::~Extension_call_presult() noexcept { } @@ -427,7 +427,7 @@ uint32_t Extension_call_presult::read(::apache::thrift::protocol::TProtocol* ipr } -Extension_shutdown_args::~Extension_shutdown_args() throw() { +Extension_shutdown_args::~Extension_shutdown_args() noexcept { } @@ -470,7 +470,7 @@ uint32_t Extension_shutdown_args::write(::apache::thrift::protocol::TProtocol* o } -Extension_shutdown_pargs::~Extension_shutdown_pargs() throw() { +Extension_shutdown_pargs::~Extension_shutdown_pargs() noexcept { } @@ -485,7 +485,7 @@ uint32_t Extension_shutdown_pargs::write(::apache::thrift::protocol::TProtocol* } -Extension_shutdown_result::~Extension_shutdown_result() throw() { +Extension_shutdown_result::~Extension_shutdown_result() noexcept { } @@ -529,7 +529,7 @@ uint32_t Extension_shutdown_result::write(::apache::thrift::protocol::TProtocol* } -Extension_shutdown_presult::~Extension_shutdown_presult() throw() { +Extension_shutdown_presult::~Extension_shutdown_presult() noexcept { } @@ -910,10 +910,10 @@ void ExtensionProcessor::process_shutdown(int32_t seqid, ::apache::thrift::proto } } -::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > ExtensionProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { +::std::shared_ptr< ::apache::thrift::TProcessor > ExtensionProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { ::apache::thrift::ReleaseHandler< ExtensionIfFactory > cleanup(handlerFactory_); - ::apache::thrift::stdcxx::shared_ptr< ExtensionIf > handler(handlerFactory_->getHandler(connInfo), cleanup); - ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > processor(new ExtensionProcessor(handler)); + ::std::shared_ptr< ExtensionIf > handler(handlerFactory_->getHandler(connInfo), cleanup); + ::std::shared_ptr< ::apache::thrift::TProcessor > processor(new ExtensionProcessor(handler)); return processor; } @@ -925,8 +925,8 @@ void ExtensionConcurrentClient::ping(ExtensionStatus& _return) int32_t ExtensionConcurrentClient::send_ping() { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("ping", ::apache::thrift::protocol::T_CALL, cseqid); Extension_ping_pargs args; @@ -949,10 +949,10 @@ void ExtensionConcurrentClient::recv_ping(ExtensionStatus& _return, const int32_ // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -993,10 +993,10 @@ void ExtensionConcurrentClient::recv_ping(ExtensionStatus& _return, const int32_ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "ping failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -1008,8 +1008,8 @@ void ExtensionConcurrentClient::call(ExtensionResponse& _return, const std::stri int32_t ExtensionConcurrentClient::send_call(const std::string& registry, const std::string& item, const ExtensionPluginRequest& request) { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("call", ::apache::thrift::protocol::T_CALL, cseqid); Extension_call_pargs args; @@ -1035,10 +1035,10 @@ void ExtensionConcurrentClient::recv_call(ExtensionResponse& _return, const int3 // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -1079,10 +1079,10 @@ void ExtensionConcurrentClient::recv_call(ExtensionResponse& _return, const int3 throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "call failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -1094,8 +1094,8 @@ void ExtensionConcurrentClient::shutdown() int32_t ExtensionConcurrentClient::send_shutdown() { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("shutdown", ::apache::thrift::protocol::T_CALL, cseqid); Extension_shutdown_pargs args; @@ -1118,10 +1118,10 @@ void ExtensionConcurrentClient::recv_shutdown(const int32_t seqid) // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -1156,10 +1156,10 @@ void ExtensionConcurrentClient::recv_shutdown(const int32_t seqid) return; } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } diff --git a/osquery/extensions/thrift/gen/Extension.h b/osquery/extensions/thrift/gen/Extension.h index df1df112..d0e33bb8 100644 --- a/osquery/extensions/thrift/gen/Extension.h +++ b/osquery/extensions/thrift/gen/Extension.h @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -9,6 +9,7 @@ #include #include +#include #include "osquery_types.h" namespace osquery { namespace extensions { @@ -38,7 +39,7 @@ class ExtensionIfFactory { class ExtensionIfSingletonFactory : virtual public ExtensionIfFactory { public: - ExtensionIfSingletonFactory(const ::apache::thrift::stdcxx::shared_ptr& iface) : iface_(iface) {} + ExtensionIfSingletonFactory(const ::std::shared_ptr& iface) : iface_(iface) {} virtual ~ExtensionIfSingletonFactory() {} virtual ExtensionIf* getHandler(const ::apache::thrift::TConnectionInfo&) { @@ -47,7 +48,7 @@ class ExtensionIfSingletonFactory : virtual public ExtensionIfFactory { virtual void releaseHandler(ExtensionIf* /* handler */) {} protected: - ::apache::thrift::stdcxx::shared_ptr iface_; + ::std::shared_ptr iface_; }; class ExtensionNull : virtual public ExtensionIf { @@ -73,7 +74,7 @@ class Extension_ping_args { Extension_ping_args() { } - virtual ~Extension_ping_args() throw(); + virtual ~Extension_ping_args() noexcept; bool operator == (const Extension_ping_args & /* rhs */) const { @@ -95,7 +96,7 @@ class Extension_ping_pargs { public: - virtual ~Extension_ping_pargs() throw(); + virtual ~Extension_ping_pargs() noexcept; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -114,7 +115,7 @@ class Extension_ping_result { Extension_ping_result() { } - virtual ~Extension_ping_result() throw(); + virtual ~Extension_ping_result() noexcept; ExtensionStatus success; _Extension_ping_result__isset __isset; @@ -147,7 +148,7 @@ class Extension_ping_presult { public: - virtual ~Extension_ping_presult() throw(); + virtual ~Extension_ping_presult() noexcept; ExtensionStatus* success; _Extension_ping_presult__isset __isset; @@ -171,7 +172,7 @@ class Extension_call_args { Extension_call_args() : registry(), item() { } - virtual ~Extension_call_args() throw(); + virtual ~Extension_call_args() noexcept; std::string registry; std::string item; ExtensionPluginRequest request; @@ -210,7 +211,7 @@ class Extension_call_pargs { public: - virtual ~Extension_call_pargs() throw(); + virtual ~Extension_call_pargs() noexcept; const std::string* registry; const std::string* item; const ExtensionPluginRequest* request; @@ -232,7 +233,7 @@ class Extension_call_result { Extension_call_result() { } - virtual ~Extension_call_result() throw(); + virtual ~Extension_call_result() noexcept; ExtensionResponse success; _Extension_call_result__isset __isset; @@ -265,7 +266,7 @@ class Extension_call_presult { public: - virtual ~Extension_call_presult() throw(); + virtual ~Extension_call_presult() noexcept; ExtensionResponse* success; _Extension_call_presult__isset __isset; @@ -283,7 +284,7 @@ class Extension_shutdown_args { Extension_shutdown_args() { } - virtual ~Extension_shutdown_args() throw(); + virtual ~Extension_shutdown_args() noexcept; bool operator == (const Extension_shutdown_args & /* rhs */) const { @@ -305,7 +306,7 @@ class Extension_shutdown_pargs { public: - virtual ~Extension_shutdown_pargs() throw(); + virtual ~Extension_shutdown_pargs() noexcept; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -320,7 +321,7 @@ class Extension_shutdown_result { Extension_shutdown_result() { } - virtual ~Extension_shutdown_result() throw(); + virtual ~Extension_shutdown_result() noexcept; bool operator == (const Extension_shutdown_result & /* rhs */) const { @@ -342,7 +343,7 @@ class Extension_shutdown_presult { public: - virtual ~Extension_shutdown_presult() throw(); + virtual ~Extension_shutdown_presult() noexcept; uint32_t read(::apache::thrift::protocol::TProtocol* iprot); @@ -350,27 +351,27 @@ class Extension_shutdown_presult { class ExtensionClient : virtual public ExtensionIf { public: - ExtensionClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + ExtensionClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { setProtocol(prot); } - ExtensionClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + ExtensionClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { setProtocol(iprot,oprot); } private: - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { setProtocol(prot,prot); } - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { piprot_=iprot; poprot_=oprot; iprot_ = iprot.get(); oprot_ = oprot.get(); } public: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { return piprot_; } - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { return poprot_; } void ping(ExtensionStatus& _return); @@ -383,15 +384,15 @@ class ExtensionClient : virtual public ExtensionIf { void send_shutdown(); void recv_shutdown(); protected: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; ::apache::thrift::protocol::TProtocol* iprot_; ::apache::thrift::protocol::TProtocol* oprot_; }; class ExtensionProcessor : public ::apache::thrift::TDispatchProcessor { protected: - ::apache::thrift::stdcxx::shared_ptr iface_; + ::std::shared_ptr iface_; virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); private: typedef void (ExtensionProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); @@ -401,7 +402,7 @@ class ExtensionProcessor : public ::apache::thrift::TDispatchProcessor { void process_call(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_shutdown(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); public: - ExtensionProcessor(::apache::thrift::stdcxx::shared_ptr iface) : + ExtensionProcessor(::std::shared_ptr iface) : iface_(iface) { processMap_["ping"] = &ExtensionProcessor::process_ping; processMap_["call"] = &ExtensionProcessor::process_call; @@ -413,24 +414,24 @@ class ExtensionProcessor : public ::apache::thrift::TDispatchProcessor { class ExtensionProcessorFactory : public ::apache::thrift::TProcessorFactory { public: - ExtensionProcessorFactory(const ::apache::thrift::stdcxx::shared_ptr< ExtensionIfFactory >& handlerFactory) : + ExtensionProcessorFactory(const ::std::shared_ptr< ExtensionIfFactory >& handlerFactory) : handlerFactory_(handlerFactory) {} - ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); + ::std::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); protected: - ::apache::thrift::stdcxx::shared_ptr< ExtensionIfFactory > handlerFactory_; + ::std::shared_ptr< ExtensionIfFactory > handlerFactory_; }; class ExtensionMultiface : virtual public ExtensionIf { public: - ExtensionMultiface(std::vector >& ifaces) : ifaces_(ifaces) { + ExtensionMultiface(std::vector >& ifaces) : ifaces_(ifaces) { } virtual ~ExtensionMultiface() {} protected: - std::vector > ifaces_; + std::vector > ifaces_; ExtensionMultiface() {} - void add(::apache::thrift::stdcxx::shared_ptr iface) { + void add(::std::shared_ptr iface) { ifaces_.push_back(iface); } public: @@ -470,27 +471,29 @@ class ExtensionMultiface : virtual public ExtensionIf { // only be used when you need to share a connection among multiple threads class ExtensionConcurrentClient : virtual public ExtensionIf { public: - ExtensionConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + ExtensionConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ setProtocol(prot); } - ExtensionConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + ExtensionConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ setProtocol(iprot,oprot); } private: - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { setProtocol(prot,prot); } - void setProtocol(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { piprot_=iprot; poprot_=oprot; iprot_ = iprot.get(); oprot_ = oprot.get(); } public: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { return piprot_; } - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { return poprot_; } void ping(ExtensionStatus& _return); @@ -503,11 +506,11 @@ class ExtensionConcurrentClient : virtual public ExtensionIf { int32_t send_shutdown(); void recv_shutdown(const int32_t seqid); protected: - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; ::apache::thrift::protocol::TProtocol* iprot_; ::apache::thrift::protocol::TProtocol* oprot_; - ::apache::thrift::async::TConcurrentClientSyncInfo sync_; + std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync_; }; #ifdef _MSC_VER diff --git a/osquery/extensions/thrift/gen/ExtensionManager.cpp b/osquery/extensions/thrift/gen/ExtensionManager.cpp index 9ca1ff5b..4f3b163f 100644 --- a/osquery/extensions/thrift/gen/ExtensionManager.cpp +++ b/osquery/extensions/thrift/gen/ExtensionManager.cpp @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -9,7 +9,7 @@ namespace osquery { namespace extensions { -ExtensionManager_extensions_args::~ExtensionManager_extensions_args() throw() { +ExtensionManager_extensions_args::~ExtensionManager_extensions_args() noexcept { } @@ -52,7 +52,7 @@ uint32_t ExtensionManager_extensions_args::write(::apache::thrift::protocol::TPr } -ExtensionManager_extensions_pargs::~ExtensionManager_extensions_pargs() throw() { +ExtensionManager_extensions_pargs::~ExtensionManager_extensions_pargs() noexcept { } @@ -67,7 +67,7 @@ uint32_t ExtensionManager_extensions_pargs::write(::apache::thrift::protocol::TP } -ExtensionManager_extensions_result::~ExtensionManager_extensions_result() throw() { +ExtensionManager_extensions_result::~ExtensionManager_extensions_result() noexcept { } @@ -153,7 +153,7 @@ uint32_t ExtensionManager_extensions_result::write(::apache::thrift::protocol::T } -ExtensionManager_extensions_presult::~ExtensionManager_extensions_presult() throw() { +ExtensionManager_extensions_presult::~ExtensionManager_extensions_presult() noexcept { } @@ -214,7 +214,7 @@ uint32_t ExtensionManager_extensions_presult::read(::apache::thrift::protocol::T } -ExtensionManager_options_args::~ExtensionManager_options_args() throw() { +ExtensionManager_options_args::~ExtensionManager_options_args() noexcept { } @@ -257,7 +257,7 @@ uint32_t ExtensionManager_options_args::write(::apache::thrift::protocol::TProto } -ExtensionManager_options_pargs::~ExtensionManager_options_pargs() throw() { +ExtensionManager_options_pargs::~ExtensionManager_options_pargs() noexcept { } @@ -272,7 +272,7 @@ uint32_t ExtensionManager_options_pargs::write(::apache::thrift::protocol::TProt } -ExtensionManager_options_result::~ExtensionManager_options_result() throw() { +ExtensionManager_options_result::~ExtensionManager_options_result() noexcept { } @@ -358,7 +358,7 @@ uint32_t ExtensionManager_options_result::write(::apache::thrift::protocol::TPro } -ExtensionManager_options_presult::~ExtensionManager_options_presult() throw() { +ExtensionManager_options_presult::~ExtensionManager_options_presult() noexcept { } @@ -419,7 +419,7 @@ uint32_t ExtensionManager_options_presult::read(::apache::thrift::protocol::TPro } -ExtensionManager_registerExtension_args::~ExtensionManager_registerExtension_args() throw() { +ExtensionManager_registerExtension_args::~ExtensionManager_registerExtension_args() noexcept { } @@ -583,7 +583,7 @@ uint32_t ExtensionManager_registerExtension_args::write(::apache::thrift::protoc } -ExtensionManager_registerExtension_pargs::~ExtensionManager_registerExtension_pargs() throw() { +ExtensionManager_registerExtension_pargs::~ExtensionManager_registerExtension_pargs() noexcept { } @@ -641,7 +641,7 @@ uint32_t ExtensionManager_registerExtension_pargs::write(::apache::thrift::proto } -ExtensionManager_registerExtension_result::~ExtensionManager_registerExtension_result() throw() { +ExtensionManager_registerExtension_result::~ExtensionManager_registerExtension_result() noexcept { } @@ -703,7 +703,7 @@ uint32_t ExtensionManager_registerExtension_result::write(::apache::thrift::prot } -ExtensionManager_registerExtension_presult::~ExtensionManager_registerExtension_presult() throw() { +ExtensionManager_registerExtension_presult::~ExtensionManager_registerExtension_presult() noexcept { } @@ -749,7 +749,7 @@ uint32_t ExtensionManager_registerExtension_presult::read(::apache::thrift::prot } -ExtensionManager_deregisterExtension_args::~ExtensionManager_deregisterExtension_args() throw() { +ExtensionManager_deregisterExtension_args::~ExtensionManager_deregisterExtension_args() noexcept { } @@ -809,7 +809,7 @@ uint32_t ExtensionManager_deregisterExtension_args::write(::apache::thrift::prot } -ExtensionManager_deregisterExtension_pargs::~ExtensionManager_deregisterExtension_pargs() throw() { +ExtensionManager_deregisterExtension_pargs::~ExtensionManager_deregisterExtension_pargs() noexcept { } @@ -828,7 +828,7 @@ uint32_t ExtensionManager_deregisterExtension_pargs::write(::apache::thrift::pro } -ExtensionManager_deregisterExtension_result::~ExtensionManager_deregisterExtension_result() throw() { +ExtensionManager_deregisterExtension_result::~ExtensionManager_deregisterExtension_result() noexcept { } @@ -890,7 +890,7 @@ uint32_t ExtensionManager_deregisterExtension_result::write(::apache::thrift::pr } -ExtensionManager_deregisterExtension_presult::~ExtensionManager_deregisterExtension_presult() throw() { +ExtensionManager_deregisterExtension_presult::~ExtensionManager_deregisterExtension_presult() noexcept { } @@ -936,7 +936,7 @@ uint32_t ExtensionManager_deregisterExtension_presult::read(::apache::thrift::pr } -ExtensionManager_query_args::~ExtensionManager_query_args() throw() { +ExtensionManager_query_args::~ExtensionManager_query_args() noexcept { } @@ -996,7 +996,7 @@ uint32_t ExtensionManager_query_args::write(::apache::thrift::protocol::TProtoco } -ExtensionManager_query_pargs::~ExtensionManager_query_pargs() throw() { +ExtensionManager_query_pargs::~ExtensionManager_query_pargs() noexcept { } @@ -1015,7 +1015,7 @@ uint32_t ExtensionManager_query_pargs::write(::apache::thrift::protocol::TProtoc } -ExtensionManager_query_result::~ExtensionManager_query_result() throw() { +ExtensionManager_query_result::~ExtensionManager_query_result() noexcept { } @@ -1077,7 +1077,7 @@ uint32_t ExtensionManager_query_result::write(::apache::thrift::protocol::TProto } -ExtensionManager_query_presult::~ExtensionManager_query_presult() throw() { +ExtensionManager_query_presult::~ExtensionManager_query_presult() noexcept { } @@ -1123,7 +1123,7 @@ uint32_t ExtensionManager_query_presult::read(::apache::thrift::protocol::TProto } -ExtensionManager_getQueryColumns_args::~ExtensionManager_getQueryColumns_args() throw() { +ExtensionManager_getQueryColumns_args::~ExtensionManager_getQueryColumns_args() noexcept { } @@ -1183,7 +1183,7 @@ uint32_t ExtensionManager_getQueryColumns_args::write(::apache::thrift::protocol } -ExtensionManager_getQueryColumns_pargs::~ExtensionManager_getQueryColumns_pargs() throw() { +ExtensionManager_getQueryColumns_pargs::~ExtensionManager_getQueryColumns_pargs() noexcept { } @@ -1202,7 +1202,7 @@ uint32_t ExtensionManager_getQueryColumns_pargs::write(::apache::thrift::protoco } -ExtensionManager_getQueryColumns_result::~ExtensionManager_getQueryColumns_result() throw() { +ExtensionManager_getQueryColumns_result::~ExtensionManager_getQueryColumns_result() noexcept { } @@ -1264,7 +1264,7 @@ uint32_t ExtensionManager_getQueryColumns_result::write(::apache::thrift::protoc } -ExtensionManager_getQueryColumns_presult::~ExtensionManager_getQueryColumns_presult() throw() { +ExtensionManager_getQueryColumns_presult::~ExtensionManager_getQueryColumns_presult() noexcept { } @@ -1990,10 +1990,10 @@ void ExtensionManagerProcessor::process_getQueryColumns(int32_t seqid, ::apache: } } -::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > ExtensionManagerProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { +::std::shared_ptr< ::apache::thrift::TProcessor > ExtensionManagerProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { ::apache::thrift::ReleaseHandler< ExtensionManagerIfFactory > cleanup(handlerFactory_); - ::apache::thrift::stdcxx::shared_ptr< ExtensionManagerIf > handler(handlerFactory_->getHandler(connInfo), cleanup); - ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > processor(new ExtensionManagerProcessor(handler)); + ::std::shared_ptr< ExtensionManagerIf > handler(handlerFactory_->getHandler(connInfo), cleanup); + ::std::shared_ptr< ::apache::thrift::TProcessor > processor(new ExtensionManagerProcessor(handler)); return processor; } @@ -2005,8 +2005,8 @@ void ExtensionManagerConcurrentClient::extensions(InternalExtensionList& _return int32_t ExtensionManagerConcurrentClient::send_extensions() { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("extensions", ::apache::thrift::protocol::T_CALL, cseqid); ExtensionManager_extensions_pargs args; @@ -2029,10 +2029,10 @@ void ExtensionManagerConcurrentClient::recv_extensions(InternalExtensionList& _r // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -2073,10 +2073,10 @@ void ExtensionManagerConcurrentClient::recv_extensions(InternalExtensionList& _r throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "extensions failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -2088,8 +2088,8 @@ void ExtensionManagerConcurrentClient::options(InternalOptionList& _return) int32_t ExtensionManagerConcurrentClient::send_options() { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("options", ::apache::thrift::protocol::T_CALL, cseqid); ExtensionManager_options_pargs args; @@ -2112,10 +2112,10 @@ void ExtensionManagerConcurrentClient::recv_options(InternalOptionList& _return, // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -2156,10 +2156,10 @@ void ExtensionManagerConcurrentClient::recv_options(InternalOptionList& _return, throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "options failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -2171,8 +2171,8 @@ void ExtensionManagerConcurrentClient::registerExtension(ExtensionStatus& _retur int32_t ExtensionManagerConcurrentClient::send_registerExtension(const InternalExtensionInfo& info, const ExtensionRegistry& registry) { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("registerExtension", ::apache::thrift::protocol::T_CALL, cseqid); ExtensionManager_registerExtension_pargs args; @@ -2197,10 +2197,10 @@ void ExtensionManagerConcurrentClient::recv_registerExtension(ExtensionStatus& _ // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -2241,10 +2241,10 @@ void ExtensionManagerConcurrentClient::recv_registerExtension(ExtensionStatus& _ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "registerExtension failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -2256,8 +2256,8 @@ void ExtensionManagerConcurrentClient::deregisterExtension(ExtensionStatus& _ret int32_t ExtensionManagerConcurrentClient::send_deregisterExtension(const ExtensionRouteUUID uuid) { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("deregisterExtension", ::apache::thrift::protocol::T_CALL, cseqid); ExtensionManager_deregisterExtension_pargs args; @@ -2281,10 +2281,10 @@ void ExtensionManagerConcurrentClient::recv_deregisterExtension(ExtensionStatus& // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -2325,10 +2325,10 @@ void ExtensionManagerConcurrentClient::recv_deregisterExtension(ExtensionStatus& throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "deregisterExtension failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -2340,8 +2340,8 @@ void ExtensionManagerConcurrentClient::query(ExtensionResponse& _return, const s int32_t ExtensionManagerConcurrentClient::send_query(const std::string& sql) { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("query", ::apache::thrift::protocol::T_CALL, cseqid); ExtensionManager_query_pargs args; @@ -2365,10 +2365,10 @@ void ExtensionManagerConcurrentClient::recv_query(ExtensionResponse& _return, co // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -2409,10 +2409,10 @@ void ExtensionManagerConcurrentClient::recv_query(ExtensionResponse& _return, co throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "query failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } @@ -2424,8 +2424,8 @@ void ExtensionManagerConcurrentClient::getQueryColumns(ExtensionResponse& _retur int32_t ExtensionManagerConcurrentClient::send_getQueryColumns(const std::string& sql) { - int32_t cseqid = this->sync_.generateSeqId(); - ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); oprot_->writeMessageBegin("getQueryColumns", ::apache::thrift::protocol::T_CALL, cseqid); ExtensionManager_getQueryColumns_pargs args; @@ -2449,10 +2449,10 @@ void ExtensionManagerConcurrentClient::recv_getQueryColumns(ExtensionResponse& _ // the read mutex gets dropped and reacquired as part of waitForWork() // The destructor of this sentry wakes up other clients - ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); while(true) { - if(!this->sync_.getPending(fname, mtype, rseqid)) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { iprot_->readMessageBegin(fname, mtype, rseqid); } if(seqid == rseqid) { @@ -2493,10 +2493,10 @@ void ExtensionManagerConcurrentClient::recv_getQueryColumns(ExtensionResponse& _ throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "getQueryColumns failed: unknown result"); } // seqid != rseqid - this->sync_.updatePending(fname, mtype, rseqid); + this->sync_->updatePending(fname, mtype, rseqid); // this will temporarily unlock the readMutex, and let other clients get work done - this->sync_.waitForWork(seqid); + this->sync_->waitForWork(seqid); } // end while(true) } diff --git a/osquery/extensions/thrift/gen/ExtensionManager.h b/osquery/extensions/thrift/gen/ExtensionManager.h index 0e4b15b2..5d64a593 100644 --- a/osquery/extensions/thrift/gen/ExtensionManager.h +++ b/osquery/extensions/thrift/gen/ExtensionManager.h @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -9,6 +9,7 @@ #include #include +#include #include "osquery_types.h" #include "Extension.h" @@ -42,7 +43,7 @@ class ExtensionManagerIfFactory : virtual public ExtensionIfFactory { class ExtensionManagerIfSingletonFactory : virtual public ExtensionManagerIfFactory { public: - ExtensionManagerIfSingletonFactory(const ::apache::thrift::stdcxx::shared_ptr& iface) : iface_(iface) {} + ExtensionManagerIfSingletonFactory(const ::std::shared_ptr& iface) : iface_(iface) {} virtual ~ExtensionManagerIfSingletonFactory() {} virtual ExtensionManagerIf* getHandler(const ::apache::thrift::TConnectionInfo&) { @@ -51,7 +52,7 @@ class ExtensionManagerIfSingletonFactory : virtual public ExtensionManagerIfFact virtual void releaseHandler(ExtensionIf* /* handler */) {} protected: - ::apache::thrift::stdcxx::shared_ptr iface_; + ::std::shared_ptr iface_; }; class ExtensionManagerNull : virtual public ExtensionManagerIf , virtual public ExtensionNull { @@ -86,7 +87,7 @@ class ExtensionManager_extensions_args { ExtensionManager_extensions_args() { } - virtual ~ExtensionManager_extensions_args() throw(); + virtual ~ExtensionManager_extensions_args() noexcept; bool operator == (const ExtensionManager_extensions_args & /* rhs */) const { @@ -108,7 +109,7 @@ class ExtensionManager_extensions_pargs { public: - virtual ~ExtensionManager_extensions_pargs() throw(); + virtual ~ExtensionManager_extensions_pargs() noexcept; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -127,7 +128,7 @@ class ExtensionManager_extensions_result { ExtensionManager_extensions_result() { } - virtual ~ExtensionManager_extensions_result() throw(); + virtual ~ExtensionManager_extensions_result() noexcept; InternalExtensionList success; _ExtensionManager_extensions_result__isset __isset; @@ -160,7 +161,7 @@ class ExtensionManager_extensions_presult { public: - virtual ~ExtensionManager_extensions_presult() throw(); + virtual ~ExtensionManager_extensions_presult() noexcept; InternalExtensionList* success; _ExtensionManager_extensions_presult__isset __isset; @@ -178,7 +179,7 @@ class ExtensionManager_options_args { ExtensionManager_options_args() { } - virtual ~ExtensionManager_options_args() throw(); + virtual ~ExtensionManager_options_args() noexcept; bool operator == (const ExtensionManager_options_args & /* rhs */) const { @@ -200,7 +201,7 @@ class ExtensionManager_options_pargs { public: - virtual ~ExtensionManager_options_pargs() throw(); + virtual ~ExtensionManager_options_pargs() noexcept; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -219,7 +220,7 @@ class ExtensionManager_options_result { ExtensionManager_options_result() { } - virtual ~ExtensionManager_options_result() throw(); + virtual ~ExtensionManager_options_result() noexcept; InternalOptionList success; _ExtensionManager_options_result__isset __isset; @@ -252,7 +253,7 @@ class ExtensionManager_options_presult { public: - virtual ~ExtensionManager_options_presult() throw(); + virtual ~ExtensionManager_options_presult() noexcept; InternalOptionList* success; _ExtensionManager_options_presult__isset __isset; @@ -275,7 +276,7 @@ class ExtensionManager_registerExtension_args { ExtensionManager_registerExtension_args() { } - virtual ~ExtensionManager_registerExtension_args() throw(); + virtual ~ExtensionManager_registerExtension_args() noexcept; InternalExtensionInfo info; ExtensionRegistry registry; @@ -309,7 +310,7 @@ class ExtensionManager_registerExtension_pargs { public: - virtual ~ExtensionManager_registerExtension_pargs() throw(); + virtual ~ExtensionManager_registerExtension_pargs() noexcept; const InternalExtensionInfo* info; const ExtensionRegistry* registry; @@ -330,7 +331,7 @@ class ExtensionManager_registerExtension_result { ExtensionManager_registerExtension_result() { } - virtual ~ExtensionManager_registerExtension_result() throw(); + virtual ~ExtensionManager_registerExtension_result() noexcept; ExtensionStatus success; _ExtensionManager_registerExtension_result__isset __isset; @@ -363,7 +364,7 @@ class ExtensionManager_registerExtension_presult { public: - virtual ~ExtensionManager_registerExtension_presult() throw(); + virtual ~ExtensionManager_registerExtension_presult() noexcept; ExtensionStatus* success; _ExtensionManager_registerExtension_presult__isset __isset; @@ -385,7 +386,7 @@ class ExtensionManager_deregisterExtension_args { ExtensionManager_deregisterExtension_args() : uuid(0) { } - virtual ~ExtensionManager_deregisterExtension_args() throw(); + virtual ~ExtensionManager_deregisterExtension_args() noexcept; ExtensionRouteUUID uuid; _ExtensionManager_deregisterExtension_args__isset __isset; @@ -414,7 +415,7 @@ class ExtensionManager_deregisterExtension_pargs { public: - virtual ~ExtensionManager_deregisterExtension_pargs() throw(); + virtual ~ExtensionManager_deregisterExtension_pargs() noexcept; const ExtensionRouteUUID* uuid; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -434,7 +435,7 @@ class ExtensionManager_deregisterExtension_result { ExtensionManager_deregisterExtension_result() { } - virtual ~ExtensionManager_deregisterExtension_result() throw(); + virtual ~ExtensionManager_deregisterExtension_result() noexcept; ExtensionStatus success; _ExtensionManager_deregisterExtension_result__isset __isset; @@ -467,7 +468,7 @@ class ExtensionManager_deregisterExtension_presult { public: - virtual ~ExtensionManager_deregisterExtension_presult() throw(); + virtual ~ExtensionManager_deregisterExtension_presult() noexcept; ExtensionStatus* success; _ExtensionManager_deregisterExtension_presult__isset __isset; @@ -489,7 +490,7 @@ class ExtensionManager_query_args { ExtensionManager_query_args() : sql() { } - virtual ~ExtensionManager_query_args() throw(); + virtual ~ExtensionManager_query_args() noexcept; std::string sql; _ExtensionManager_query_args__isset __isset; @@ -518,7 +519,7 @@ class ExtensionManager_query_pargs { public: - virtual ~ExtensionManager_query_pargs() throw(); + virtual ~ExtensionManager_query_pargs() noexcept; const std::string* sql; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -538,7 +539,7 @@ class ExtensionManager_query_result { ExtensionManager_query_result() { } - virtual ~ExtensionManager_query_result() throw(); + virtual ~ExtensionManager_query_result() noexcept; ExtensionResponse success; _ExtensionManager_query_result__isset __isset; @@ -571,7 +572,7 @@ class ExtensionManager_query_presult { public: - virtual ~ExtensionManager_query_presult() throw(); + virtual ~ExtensionManager_query_presult() noexcept; ExtensionResponse* success; _ExtensionManager_query_presult__isset __isset; @@ -593,7 +594,7 @@ class ExtensionManager_getQueryColumns_args { ExtensionManager_getQueryColumns_args() : sql() { } - virtual ~ExtensionManager_getQueryColumns_args() throw(); + virtual ~ExtensionManager_getQueryColumns_args() noexcept; std::string sql; _ExtensionManager_getQueryColumns_args__isset __isset; @@ -622,7 +623,7 @@ class ExtensionManager_getQueryColumns_pargs { public: - virtual ~ExtensionManager_getQueryColumns_pargs() throw(); + virtual ~ExtensionManager_getQueryColumns_pargs() noexcept; const std::string* sql; uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; @@ -642,7 +643,7 @@ class ExtensionManager_getQueryColumns_result { ExtensionManager_getQueryColumns_result() { } - virtual ~ExtensionManager_getQueryColumns_result() throw(); + virtual ~ExtensionManager_getQueryColumns_result() noexcept; ExtensionResponse success; _ExtensionManager_getQueryColumns_result__isset __isset; @@ -675,7 +676,7 @@ class ExtensionManager_getQueryColumns_presult { public: - virtual ~ExtensionManager_getQueryColumns_presult() throw(); + virtual ~ExtensionManager_getQueryColumns_presult() noexcept; ExtensionResponse* success; _ExtensionManager_getQueryColumns_presult__isset __isset; @@ -686,13 +687,13 @@ class ExtensionManager_getQueryColumns_presult { class ExtensionManagerClient : virtual public ExtensionManagerIf, public ExtensionClient { public: - ExtensionManagerClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) : + ExtensionManagerClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) : ExtensionClient(prot, prot) {} - ExtensionManagerClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) : ExtensionClient(iprot, oprot) {} - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + ExtensionManagerClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) : ExtensionClient(iprot, oprot) {} + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { return piprot_; } - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { return poprot_; } void extensions(InternalExtensionList& _return); @@ -717,7 +718,7 @@ class ExtensionManagerClient : virtual public ExtensionManagerIf, public Extensi class ExtensionManagerProcessor : public ExtensionProcessor { protected: - ::apache::thrift::stdcxx::shared_ptr iface_; + ::std::shared_ptr iface_; virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); private: typedef void (ExtensionManagerProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); @@ -730,7 +731,7 @@ class ExtensionManagerProcessor : public ExtensionProcessor { void process_query(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); void process_getQueryColumns(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); public: - ExtensionManagerProcessor(::apache::thrift::stdcxx::shared_ptr iface) : + ExtensionManagerProcessor(::std::shared_ptr iface) : ExtensionProcessor(iface), iface_(iface) { processMap_["extensions"] = &ExtensionManagerProcessor::process_extensions; @@ -746,28 +747,28 @@ class ExtensionManagerProcessor : public ExtensionProcessor { class ExtensionManagerProcessorFactory : public ::apache::thrift::TProcessorFactory { public: - ExtensionManagerProcessorFactory(const ::apache::thrift::stdcxx::shared_ptr< ExtensionManagerIfFactory >& handlerFactory) : + ExtensionManagerProcessorFactory(const ::std::shared_ptr< ExtensionManagerIfFactory >& handlerFactory) : handlerFactory_(handlerFactory) {} - ::apache::thrift::stdcxx::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); + ::std::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); protected: - ::apache::thrift::stdcxx::shared_ptr< ExtensionManagerIfFactory > handlerFactory_; + ::std::shared_ptr< ExtensionManagerIfFactory > handlerFactory_; }; class ExtensionManagerMultiface : virtual public ExtensionManagerIf, public ExtensionMultiface { public: - ExtensionManagerMultiface(std::vector >& ifaces) : ifaces_(ifaces) { - std::vector >::iterator iter; + ExtensionManagerMultiface(std::vector >& ifaces) : ifaces_(ifaces) { + std::vector >::iterator iter; for (iter = ifaces.begin(); iter != ifaces.end(); ++iter) { ExtensionMultiface::add(*iter); } } virtual ~ExtensionManagerMultiface() {} protected: - std::vector > ifaces_; + std::vector > ifaces_; ExtensionManagerMultiface() {} - void add(::apache::thrift::stdcxx::shared_ptr iface) { + void add(::std::shared_ptr iface) { ExtensionMultiface::add(iface); ifaces_.push_back(iface); } @@ -839,13 +840,13 @@ class ExtensionManagerMultiface : virtual public ExtensionManagerIf, public Exte // only be used when you need to share a connection among multiple threads class ExtensionManagerConcurrentClient : virtual public ExtensionManagerIf, public ExtensionConcurrentClient { public: - ExtensionManagerConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) : - ExtensionConcurrentClient(prot, prot) {} - ExtensionManagerConcurrentClient(apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) : ExtensionConcurrentClient(iprot, oprot) {} - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + ExtensionManagerConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : + ExtensionConcurrentClient(prot, prot, sync) {} + ExtensionManagerConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : ExtensionConcurrentClient(iprot, oprot, sync) {} + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { return piprot_; } - apache::thrift::stdcxx::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { return poprot_; } void extensions(InternalExtensionList& _return); diff --git a/osquery/extensions/thrift/gen/ExtensionManager_server.skeleton.cpp b/osquery/extensions/thrift/gen/ExtensionManager_server.skeleton.cpp index 4257e40e..dbcb1171 100644 --- a/osquery/extensions/thrift/gen/ExtensionManager_server.skeleton.cpp +++ b/osquery/extensions/thrift/gen/ExtensionManager_server.skeleton.cpp @@ -54,11 +54,11 @@ class ExtensionManagerHandler : virtual public ExtensionManagerIf { int main(int argc, char **argv) { int port = 9090; - ::apache::thrift::stdcxx::shared_ptr handler(new ExtensionManagerHandler()); - ::apache::thrift::stdcxx::shared_ptr processor(new ExtensionManagerProcessor(handler)); - ::apache::thrift::stdcxx::shared_ptr serverTransport(new TServerSocket(port)); - ::apache::thrift::stdcxx::shared_ptr transportFactory(new TBufferedTransportFactory()); - ::apache::thrift::stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + ::std::shared_ptr handler(new ExtensionManagerHandler()); + ::std::shared_ptr processor(new ExtensionManagerProcessor(handler)); + ::std::shared_ptr serverTransport(new TServerSocket(port)); + ::std::shared_ptr transportFactory(new TBufferedTransportFactory()); + ::std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); server.serve(); diff --git a/osquery/extensions/thrift/gen/Extension_server.skeleton.cpp b/osquery/extensions/thrift/gen/Extension_server.skeleton.cpp index 31eab1ef..6b1bfe2b 100644 --- a/osquery/extensions/thrift/gen/Extension_server.skeleton.cpp +++ b/osquery/extensions/thrift/gen/Extension_server.skeleton.cpp @@ -39,11 +39,11 @@ class ExtensionHandler : virtual public ExtensionIf { int main(int argc, char **argv) { int port = 9090; - ::apache::thrift::stdcxx::shared_ptr handler(new ExtensionHandler()); - ::apache::thrift::stdcxx::shared_ptr processor(new ExtensionProcessor(handler)); - ::apache::thrift::stdcxx::shared_ptr serverTransport(new TServerSocket(port)); - ::apache::thrift::stdcxx::shared_ptr transportFactory(new TBufferedTransportFactory()); - ::apache::thrift::stdcxx::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + ::std::shared_ptr handler(new ExtensionHandler()); + ::std::shared_ptr processor(new ExtensionProcessor(handler)); + ::std::shared_ptr serverTransport(new TServerSocket(port)); + ::std::shared_ptr transportFactory(new TBufferedTransportFactory()); + ::std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); server.serve(); diff --git a/osquery/extensions/thrift/gen/osquery_constants.cpp b/osquery/extensions/thrift/gen/osquery_constants.cpp index 0c8e9e90..7f040585 100644 --- a/osquery/extensions/thrift/gen/osquery_constants.cpp +++ b/osquery/extensions/thrift/gen/osquery_constants.cpp @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated diff --git a/osquery/extensions/thrift/gen/osquery_constants.h b/osquery/extensions/thrift/gen/osquery_constants.h index a2dc20ed..2b85ca59 100644 --- a/osquery/extensions/thrift/gen/osquery_constants.h +++ b/osquery/extensions/thrift/gen/osquery_constants.h @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated diff --git a/osquery/extensions/thrift/gen/osquery_types.cpp b/osquery/extensions/thrift/gen/osquery_types.cpp index e1bec899..a0a71fc1 100644 --- a/osquery/extensions/thrift/gen/osquery_types.cpp +++ b/osquery/extensions/thrift/gen/osquery_types.cpp @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -35,8 +35,17 @@ std::ostream& operator<<(std::ostream& out, const ExtensionCode::type& val) { return out; } +std::string to_string(const ExtensionCode::type& val) { + std::map::const_iterator it = _ExtensionCode_VALUES_TO_NAMES.find(val); + if (it != _ExtensionCode_VALUES_TO_NAMES.end()) { + return std::string(it->second); + } else { + return std::to_string(static_cast(val)); + } +} + -InternalOptionInfo::~InternalOptionInfo() throw() { +InternalOptionInfo::~InternalOptionInfo() noexcept { } @@ -168,7 +177,7 @@ void InternalOptionInfo::printTo(std::ostream& out) const { } -InternalExtensionInfo::~InternalExtensionInfo() throw() { +InternalExtensionInfo::~InternalExtensionInfo() noexcept { } @@ -320,7 +329,7 @@ void InternalExtensionInfo::printTo(std::ostream& out) const { } -ExtensionStatus::~ExtensionStatus() throw() { +ExtensionStatus::~ExtensionStatus() noexcept { } @@ -452,7 +461,7 @@ void ExtensionStatus::printTo(std::ostream& out) const { } -ExtensionResponse::~ExtensionResponse() throw() { +ExtensionResponse::~ExtensionResponse() noexcept { } @@ -608,7 +617,7 @@ void ExtensionResponse::printTo(std::ostream& out) const { } -ExtensionException::~ExtensionException() throw() { +ExtensionException::~ExtensionException() noexcept { } @@ -739,7 +748,7 @@ void ExtensionException::printTo(std::ostream& out) const { out << ")"; } -const char* ExtensionException::what() const throw() { +const char* ExtensionException::what() const noexcept { try { std::stringstream ss; ss << "TException - service has thrown: " << *this; diff --git a/osquery/extensions/thrift/gen/osquery_types.h b/osquery/extensions/thrift/gen/osquery_types.h index 818ca3db..83efb27c 100644 --- a/osquery/extensions/thrift/gen/osquery_types.h +++ b/osquery/extensions/thrift/gen/osquery_types.h @@ -1,5 +1,5 @@ /** - * Autogenerated by Thrift Compiler (0.11.0) + * Autogenerated by Thrift Compiler (0.13.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @@ -15,7 +15,8 @@ #include #include -#include +#include +#include namespace osquery { namespace extensions { @@ -32,6 +33,8 @@ extern const std::map _ExtensionCode_VALUES_TO_NAMES; std::ostream& operator<<(std::ostream& out, const ExtensionCode::type& val); +std::string to_string(const ExtensionCode::type& val); + typedef std::map ExtensionPluginRequest; typedef std::vector > ExtensionPluginResponse; @@ -71,7 +74,7 @@ class InternalOptionInfo : public virtual ::apache::thrift::TBase { InternalOptionInfo() : value(), default_value(), type() { } - virtual ~InternalOptionInfo() throw(); + virtual ~InternalOptionInfo() noexcept; std::string value; std::string default_value; std::string type; @@ -126,7 +129,7 @@ class InternalExtensionInfo : public virtual ::apache::thrift::TBase { InternalExtensionInfo() : name(), version(), sdk_version(), min_sdk_version() { } - virtual ~InternalExtensionInfo() throw(); + virtual ~InternalExtensionInfo() noexcept; std::string name; std::string version; std::string sdk_version; @@ -185,7 +188,7 @@ class ExtensionStatus : public virtual ::apache::thrift::TBase { ExtensionStatus() : code(0), message(), uuid(0) { } - virtual ~ExtensionStatus() throw(); + virtual ~ExtensionStatus() noexcept; int32_t code; std::string message; ExtensionRouteUUID uuid; @@ -238,7 +241,7 @@ class ExtensionResponse : public virtual ::apache::thrift::TBase { ExtensionResponse() { } - virtual ~ExtensionResponse() throw(); + virtual ~ExtensionResponse() noexcept; ExtensionStatus status; ExtensionPluginResponse response; @@ -287,7 +290,7 @@ class ExtensionException : public ::apache::thrift::TException { ExtensionException() : code(0), message(), uuid(0) { } - virtual ~ExtensionException() throw(); + virtual ~ExtensionException() noexcept; int32_t code; std::string message; ExtensionRouteUUID uuid; @@ -321,7 +324,7 @@ class ExtensionException : public ::apache::thrift::TException { virtual void printTo(std::ostream& out) const; mutable std::string thriftTExceptionMessageHolder_; - const char* what() const throw(); + const char* what() const noexcept; }; void swap(ExtensionException &a, ExtensionException &b); -- 2.28.0 From 1fa91fae8e198651ac54bb22a2f75c24ad0376d3 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Mon, 25 Nov 2019 11:00:56 -0800 Subject: [PATCH 04/20] Adopt code for the upstream dpkg API changes dpkg changed naming from pkg_db to pkg_hash in the upstream commit 31eb544919a46c6170ac39f5eebd17ba6d48d508 diff --git a/osquery/tables/system/linux/deb_packages.cpp b/osquery/tables/system/linux/deb_packages.cpp index 70c2383b..5f4b5839 100644 --- a/osquery/tables/system/linux/deb_packages.cpp +++ b/osquery/tables/system/linux/deb_packages.cpp @@ -81,7 +81,7 @@ void dpkg_setup(struct pkg_array* packages) { modstatdb_init(); modstatdb_open(msdbrw_readonly); - pkg_array_init_from_db(packages); + pkg_array_init_from_hash(packages); pkg_array_sort(packages, pkg_sorter); } @@ -91,7 +91,7 @@ void dpkg_setup(struct pkg_array* packages) { void dpkg_teardown(struct pkg_array* packages) { pkg_array_destroy(packages); - pkg_db_reset(); + pkg_hash_reset(); modstatdb_done(); pop_error_context(ehflag_normaltidy); -- 2.28.0 From f5e4c595d4c27e3fc8e64e18da65e976dea4aa9c Mon Sep 17 00:00:00 2001 From: Alessandro Gario Date: Wed, 27 Nov 2019 01:54:35 +0100 Subject: [PATCH 05/20] CMake: Fix AWS library name inconsistency diff --git a/libraries/cmake/system/modules/api.cmake b/libraries/cmake/system/modules/api.cmake index ca948a43..49849050 100644 --- a/libraries/cmake/system/modules/api.cmake +++ b/libraries/cmake/system/modules/api.cmake @@ -56,6 +56,16 @@ function(locateSystemLibrary) return() endif() + # Some targets may prefer to link against each specific library. If we have + # multiple dependencies, let's also create a interface target for each + # one of them + list(LENGTH ARGS_LIBRARIES child_library_count) + if(${child_library_count} GREATER 1) + set(generate_library_aliases true) + else() + set(generate_library_aliases false) + endif() + foreach(current_library_name ${ARGS_LIBRARIES}) unset(current_library_path CACHE) find_library(current_library_path @@ -75,6 +85,10 @@ function(locateSystemLibrary) IMPORTED_LOCATION "${current_library_path}" ) + if(generate_library_aliases) + add_library("thirdparty_${current_library_name}" ALIAS "${imported_library_name}") + endif() + list(APPEND imported_library_list "${imported_library_name}") unset(current_library_path CACHE) diff --git a/osquery/tables/cloud/CMakeLists.txt b/osquery/tables/cloud/CMakeLists.txt index 3c2cbdaf..1068fda1 100644 --- a/osquery/tables/cloud/CMakeLists.txt +++ b/osquery/tables/cloud/CMakeLists.txt @@ -24,8 +24,8 @@ function(generateOsqueryTablesCloudAws) osquery_logger osquery_utils_aws thirdparty_boost - thirdparty_aws_core - thirdparty_aws_ec2 + thirdparty_aws-cpp-sdk-core + thirdparty_aws-cpp-sdk-ec2 ) endfunction() diff --git a/osquery/utils/aws/CMakeLists.txt b/osquery/utils/aws/CMakeLists.txt index 7859f251..94ab0f96 100644 --- a/osquery/utils/aws/CMakeLists.txt +++ b/osquery/utils/aws/CMakeLists.txt @@ -25,8 +25,8 @@ function(generateOsqueryUtilsAws) osquery_remote_transports_transportstls osquery_utils_json osquery_utils_status - thirdparty_aws_core - thirdparty_aws_sts + thirdparty_aws-cpp-sdk-core + thirdparty_aws-cpp-sdk-sts ) set(public_header_files diff --git a/plugins/logger/CMakeLists.txt b/plugins/logger/CMakeLists.txt index 3d69272a..89f064fa 100644 --- a/plugins/logger/CMakeLists.txt +++ b/plugins/logger/CMakeLists.txt @@ -45,8 +45,8 @@ function(generatePluginsLoggerAwsfirehose) osquery_cxx_settings osquery_dispatcher plugins_logger_awslogforwarder - thirdparty_aws_core - thirdparty_aws_firehose + thirdparty_aws-cpp-sdk-core + thirdparty_aws-cpp-sdk-firehose ) set(public_header_files @@ -69,8 +69,8 @@ function(generatePluginsLoggerAwskinesis) osquery_process osquery_registry plugins_logger_awslogforwarder - thirdparty_aws_core - thirdparty_aws_kinesis + thirdparty_aws-cpp-sdk-core + thirdparty_aws-cpp-sdk-kinesis ) set(public_header_files -- 2.28.0 From 6bdbd28b0c31d34820a4f4b38b201bf0e5517a20 Mon Sep 17 00:00:00 2001 From: Alessandro Gario Date: Wed, 27 Nov 2019 02:15:51 +0100 Subject: [PATCH 06/20] CMake: Remove -Weffc++ diff --git a/cmake/flags.cmake b/cmake/flags.cmake index af3c0e71..729961a9 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -75,7 +75,6 @@ function(setupBuildFlags) -Wno-c++11-extensions -Woverloaded-virtual -Wnon-virtual-dtor - -Weffc++ -stdlib=libc++ ) -- 2.28.0 From 0710233b3c5311e97bd7b64a6f317bf3d0689472 Mon Sep 17 00:00:00 2001 From: Alessandro Gario Date: Wed, 27 Nov 2019 02:16:01 +0100 Subject: [PATCH 07/20] CMake: librpm should depend on liblmdb diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d1dd2e..b8be2c82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,6 +124,7 @@ function(importLibraries) "Linux,Darwin,Windows:openssl" "Linux,Darwin,Windows:aws-sdk-cpp" "Linux,Darwin,Windows:icu" + "Linux:lmdb" ) foreach(library_descriptor ${library_descriptor_list}) diff --git a/libraries/cmake/system/modules/Findlibrpm.cmake b/libraries/cmake/system/modules/Findlibrpm.cmake index 2f48f3b0..425cb2e8 100644 --- a/libraries/cmake/system/modules/Findlibrpm.cmake +++ b/libraries/cmake/system/modules/Findlibrpm.cmake @@ -12,4 +12,9 @@ locateSystemLibrary( REQUIRED ${librpm_REQUIRED} MAIN_HEADER "rpm/header.h" LIBRARIES "rpm" "rpmio" -) \ No newline at end of file +) + +target_link_libraries(librpm INTERFACE + lmdb +) + diff --git a/libraries/cmake/system/modules/Findlmdb.cmake b/libraries/cmake/system/modules/Findlmdb.cmake new file mode 100644 index 00000000..11e428a7 --- /dev/null +++ b/libraries/cmake/system/modules/Findlmdb.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2014-present, Facebook, Inc. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME lmdb + REQUIRED ${bzip2_REQUIRED} + MAIN_HEADER "lmdb.h" + LIBRARIES "lmdb" +) -- 2.28.0 From f29d325ca84a1b65fe044e9e3180bb7ae5cc7c61 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Tue, 26 Nov 2019 18:59:52 -0800 Subject: [PATCH 08/20] Add 'resolv' library as a dependency of posix/dns_resolvers.cpp -lresolv parameter is a part of linker command line. However we still have a linking problem: /usr/bin/ld: osquery/tables/networking/libosquery_tables_networking.a(dns_resolvers.cpp.o): undefined reference to symbol '__res_close@@GLIBC_2.2.5' /usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib/libresolv.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status The linker expects *.so that provides the required symbol appended *after* the static library that needs it. To fix the issue we explicitly add 'resolv' as a dependency of networking library. It forces CMake to add all this dependency after the *.a. diff --git a/osquery/tables/networking/CMakeLists.txt b/osquery/tables/networking/CMakeLists.txt index 3517ea9d..26255e34 100644 --- a/osquery/tables/networking/CMakeLists.txt +++ b/osquery/tables/networking/CMakeLists.txt @@ -84,6 +84,12 @@ function(generateOsqueryTablesNetworking) thirdparty_boost ) + if(DEFINED PLATFORM_POSIX) + list(APPEND platform_deps + resolv + ) + endif() + if(DEFINED PLATFORM_LINUX) list(APPEND platform_deps thirdparty_libiptables -- 2.28.0 From 6cae7be4c55ef510becaf1966d2360f2cb87898d Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Tue, 26 Nov 2019 19:06:42 -0800 Subject: [PATCH 09/20] Do not install augeas lenses if we use system libraries If we do not build in-tree version of augeas then nothing to install here. diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake index cd01a698..dbb83484 100644 --- a/cmake/packaging.cmake +++ b/cmake/packaging.cmake @@ -170,12 +170,14 @@ function(generateInstallTargets) file(COPY "${CMAKE_SOURCE_DIR}/tools/deployment/osquery.example.conf" DESTINATION "${CMAKE_BINARY_DIR}/package/linux") install(FILES "${CMAKE_BINARY_DIR}/package/linux/osquery.example.conf" DESTINATION share/osquery COMPONENT osquery) - install(DIRECTORY "${augeas_lenses_path}/" - DESTINATION share/osquery/lenses - COMPONENT osquery - FILES_MATCHING PATTERN "*.aug" - PATTERN "tests" EXCLUDE) - install(FILES "${augeas_lenses_path}/../COPYING" DESTINATION share/osquery/lenses COMPONENT osquery) + if(NOT "${augeas_lenses_path}" STREQUAL "") + install(DIRECTORY "${augeas_lenses_path}/" + DESTINATION share/osquery/lenses + COMPONENT osquery + FILES_MATCHING PATTERN "*.aug" + PATTERN "tests" EXCLUDE) + install(FILES "${augeas_lenses_path}/../COPYING" DESTINATION share/osquery/lenses COMPONENT osquery) + endif() if("${PACKAGING_SYSTEM}" STREQUAL "DEB") file(COPY "${CMAKE_SOURCE_DIR}/tools/deployment/copyright.debian" DESTINATION "${CMAKE_BINARY_DIR}/package/deb") diff --git a/osquery/tables/system/tests/CMakeLists.txt b/osquery/tables/system/tests/CMakeLists.txt index e1b0f3e0..065874b6 100644 --- a/osquery/tables/system/tests/CMakeLists.txt +++ b/osquery/tables/system/tests/CMakeLists.txt @@ -173,12 +173,14 @@ function(generateOsqueryTablesSystemTestsAugeasTestsTest) get_property(augeas_lenses_path GLOBAL PROPERTY AUGEAS_LENSES_FOLDER_PATH) - add_custom_target(osquery_tables_system_tests_augeaslenses - COMMAND "${CMAKE_COMMAND}" -E make_directory "${TEST_CONFIGS_DIR}/augeas/lenses" - COMMAND "${CMAKE_COMMAND}" -E copy "${augeas_lenses_path}/*.aug" "${TEST_CONFIGS_DIR}/augeas/lenses") + if(NOT "${augeas_lenses_path}" STREQUAL "") + add_custom_target(osquery_tables_system_tests_augeaslenses + COMMAND "${CMAKE_COMMAND}" -E make_directory "${TEST_CONFIGS_DIR}/augeas/lenses" + COMMAND "${CMAKE_COMMAND}" -E copy "${augeas_lenses_path}/*.aug" "${TEST_CONFIGS_DIR}/augeas/lenses") - add_dependencies(osquery_tables_system_tests_augeastests-test osquery_tables_system_tests_augeaslenses) - add_dependencies(osquery_tables_system_tests_augeaslenses thirdparty_augeas) + add_dependencies(osquery_tables_system_tests_augeastests-test osquery_tables_system_tests_augeaslenses) + add_dependencies(osquery_tables_system_tests_augeaslenses thirdparty_augeas) + endif() endfunction() -- 2.28.0 From cb297525d04136d4ee86ed953059c9ab8764f307 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Wed, 27 Nov 2019 17:37:21 -0800 Subject: [PATCH 10/20] Add gtest library that contains 'main' function definition It is needed to create binaries with tests and void following linking error: $ /usr/bin/c++ -O2 -g -DNDEBUG -Wno-sign-compare -Wl,-z,relro,-z,now -Wl,--build-id=sha1 -lresolv -pthread osquery/utils/caches/tests/CMakeFiles/osquery_utils_caches_tests_lrutests-test.dir/lru.cpp.o -o osquery/utils/caches/tests/osquery_utils_caches_tests_lrutests-test /usr/lib/libgtest.so -lrt -ldl /usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib/Scrt1.o: in function `_start': (.text+0x24): undefined reference to `main' diff --git a/libraries/cmake/system/modules/Findgoogletest.cmake b/libraries/cmake/system/modules/Findgoogletest.cmake index 2ce20e47..b0bd4296 100644 --- a/libraries/cmake/system/modules/Findgoogletest.cmake +++ b/libraries/cmake/system/modules/Findgoogletest.cmake @@ -11,7 +11,7 @@ locateSystemLibrary( NAME googletest REQUIRED ${gtest_REQUIRED} MAIN_HEADER "gtest/gtest.h" - LIBRARIES "gtest" + LIBRARIES "gtest" "gtest_main" ) add_library(thirdparty_googletest_headers INTERFACE) -- 2.28.0 From 4660f3166174af47cd4f5a1cac578a5a8091a218 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Fri, 28 Feb 2020 12:18:16 -0800 Subject: [PATCH 11/20] Recent versions of iptables dropped iptc library. It is expected users depend on ip4tc or ip6tc explicitly if needed. diff --git a/libraries/cmake/system/modules/Findlibiptables.cmake b/libraries/cmake/system/modules/Findlibiptables.cmake index 17cf4047..462db890 100644 --- a/libraries/cmake/system/modules/Findlibiptables.cmake +++ b/libraries/cmake/system/modules/Findlibiptables.cmake @@ -11,5 +11,5 @@ locateSystemLibrary( NAME libiptables REQUIRED ${libiptables_REQUIRED} MAIN_HEADER "libipq.h" - LIBRARIES "ip4tc" "ip6tc" "ipq" "iptc" + LIBRARIES "ip4tc" "ip6tc" "ipq" ) -- 2.28.0 From 2fb484520896186bcee5f626e9e7f2b070d6e8c0 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Fri, 28 Feb 2020 12:21:41 -0800 Subject: [PATCH 12/20] Drop references to libc++ added in 4.2.0 diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 729961a9..ec7c7330 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -75,11 +75,9 @@ function(setupBuildFlags) -Wno-c++11-extensions -Woverloaded-virtual -Wnon-virtual-dtor - -stdlib=libc++ ) set(posix_cxx_link_options - -stdlib=libc++ -ldl ) -- 2.28.0 From c490cf2ccf94273c797fc567c5ecbcabec260503 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Fri, 24 Apr 2020 10:52:11 -0700 Subject: [PATCH 13/20] Add CMake module for system icu library Signed-off-by: Anatol Pomozov diff --git a/libraries/cmake/system/modules/Findicu.cmake b/libraries/cmake/system/modules/Findicu.cmake new file mode 100644 index 00000000..5e9eb2b4 --- /dev/null +++ b/libraries/cmake/system/modules/Findicu.cmake @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME icu + REQUIRED ${icu_REQUIRED} + MAIN_HEADER "unicode/utypes.h" + LIBRARIES "icui18n" +) -- 2.28.0 From 1aad11269285d2a00eea605100cd2eb424e4d67e Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Fri, 15 May 2020 19:04:57 -0700 Subject: [PATCH 14/20] Adopt code for the YARA 4 API changes https://github.com/VirusTotal/yara/wiki/Backward-incompatible-changes-in-YARA-4.0-API Signed-off-by: Anatol Pomozov diff --git a/osquery/tables/yara/yara_utils.cpp b/osquery/tables/yara/yara_utils.cpp index fe60a9ef..7d0a38e6 100644 --- a/osquery/tables/yara/yara_utils.cpp +++ b/osquery/tables/yara/yara_utils.cpp @@ -17,6 +17,8 @@ #include +#include + namespace osquery { DECLARE_bool(enable_yara_string); diff --git a/osquery/tables/yara/yara_utils.h b/osquery/tables/yara/yara_utils.h index 5f367269..491fc904 100644 --- a/osquery/tables/yara/yara_utils.h +++ b/osquery/tables/yara/yara_utils.h @@ -31,6 +31,7 @@ const std::string kYARAHome{OSQUERY_HOME "yara/"}; void YARACompilerCallback(int error_level, const char* file_name, int line_number, + const YR_RULE* rule, const char* message, void* user_data); -- 2.28.0 From 87e7e393e9b64d0d4d11b7071da654086380cce3 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Tue, 2 Jun 2020 11:26:51 -0700 Subject: [PATCH 15/20] Add Arch Linux package manager integration Signed-off-by: Anatol Pomozov diff --git a/CMakeLists.txt b/CMakeLists.txt index b8be2c82..412fe8f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ function(importLibraries) "Linux:libcryptsetup" "Linux:libdevmapper" "Linux:libdpkg" + "Linux:alpm" "Linux:libelfin" "Linux:libgcrypt" "Linux:libgpg-error" diff --git a/libraries/cmake/system/modules/Findalpm.cmake b/libraries/cmake/system/modules/Findalpm.cmake new file mode 100644 index 00000000..dd5947e7 --- /dev/null +++ b/libraries/cmake/system/modules/Findalpm.cmake @@ -0,0 +1,19 @@ +# Copyright (c) 2020-present, Anatol Pomazau. +# All rights reserved. +# +# This source code is licensed in accordance with the terms specified in +# the LICENSE file found in the root directory of this source tree. + +cmake_minimum_required(VERSION 3.15) +include("${CMAKE_CURRENT_LIST_DIR}/api.cmake") + +locateSystemLibrary( + NAME alpm + REQUIRED ${alpm_REQUIRED} + MAIN_HEADER "alpm.h" + LIBRARIES "alpm" +) + +target_link_libraries(alpm INTERFACE +) + diff --git a/osquery/tables/system/CMakeLists.txt b/osquery/tables/system/CMakeLists.txt index 81ac8f84..3eb2fab6 100644 --- a/osquery/tables/system/CMakeLists.txt +++ b/osquery/tables/system/CMakeLists.txt @@ -68,6 +68,7 @@ function(generateOsqueryTablesSystemSystemtable) linux/mounts.cpp linux/npm_packages.cpp linux/os_version.cpp + linux/pacman_packages.cpp linux/pci_devices.cpp linux/portage.cpp linux/process_open_files.cpp @@ -263,6 +264,7 @@ function(generateOsqueryTablesSystemSystemtable) thirdparty_libelfin thirdparty_libcryptsetup thirdparty_librpm + thirdparty_alpm thirdparty_popt ) diff --git a/osquery/tables/system/linux/pacman_packages.cpp b/osquery/tables/system/linux/pacman_packages.cpp new file mode 100644 index 00000000..db5326e3 --- /dev/null +++ b/osquery/tables/system/linux/pacman_packages.cpp @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2020-present, Anatol Pomazau. + * All rights reserved. + * + * This source code is licensed in accordance with the terms specified in + * the LICENSE file found in the root directory of this source tree. + */ + +#include + +#include +#include +#include +#include + +namespace osquery { +namespace tables { + +static const std::string kPacmanRoot{"/"}; +static const std::string kPacmanDbPath{"/var/lib/pacman"}; + +const char* pacmanPackageOrigin(alpm_pkgfrom_t origin) { + switch(origin) { + case ALPM_PKG_FROM_FILE: + return "file"; + case ALPM_PKG_FROM_LOCALDB: + return "localdb"; + case ALPM_PKG_FROM_SYNCDB: + return "syncdb"; + default: + return ""; + } +} + +std::string extractText(const char *val) { + std::string ret; + if (val != nullptr) { + ret = TEXT(val); + } + + return ret; +} + +void extractPacmanPackageInfo(alpm_pkg_t* pkg, QueryData& results) { + Row r; + + r["name"] = TEXT(alpm_pkg_get_name(pkg)); + r["version"] = TEXT(alpm_pkg_get_version(pkg)); + r["origin"] = TEXT(pacmanPackageOrigin(alpm_pkg_get_origin(pkg))); + r["url"] = TEXT(alpm_pkg_get_url(pkg)); + r["md5sum"] = extractText(alpm_pkg_get_md5sum(pkg)); + r["sha256sum"] = extractText(alpm_pkg_get_sha256sum(pkg)); + r["arch"] = TEXT(alpm_pkg_get_arch(pkg)); + r["packager"] = TEXT(alpm_pkg_get_packager(pkg)); + r["build_date"] = INTEGER(alpm_pkg_get_builddate(pkg)); + r["install_date"] = INTEGER(alpm_pkg_get_installdate(pkg)); + r["package_size"] = BIGINT(alpm_pkg_get_size(pkg)); + r["install_size"] = BIGINT(alpm_pkg_get_isize(pkg)); + + results.push_back(r); +} + +QueryData genPacmanPackages(QueryContext& context) { + QueryData results; + + if (!osquery::isDirectory(kPacmanDbPath)) { + TLOG << "Cannot find Pacman database: " << kPacmanDbPath; + return results; + } + + auto dropper = DropPrivileges::get(); + dropper->dropTo("nobody"); + + alpm_errno_t err; + alpm_handle_t *handle = alpm_initialize(kPacmanRoot.c_str(), kPacmanDbPath.c_str(), &err); + if (!handle) { + TLOG << "Cannot initialize Pacman ALPM library: " << alpm_strerror(err); + return results; + } + alpm_db_t *db_local = alpm_get_localdb(handle); + if (!db_local) { + TLOG << "Cannot read Pacman local database: " << alpm_strerror(alpm_errno(handle)); + return results; + } + + for (alpm_list_t *j = alpm_db_get_pkgcache(db_local); j; j = alpm_list_next(j)) { + alpm_pkg_t *pkg = (alpm_pkg_t *)j->data; + extractPacmanPackageInfo(pkg, results); + } + + return results; +} +} // namespace tables +} // namespace osquery diff --git a/specs/CMakeLists.txt b/specs/CMakeLists.txt index a350ff36..4214a9cc 100644 --- a/specs/CMakeLists.txt +++ b/specs/CMakeLists.txt @@ -157,6 +157,7 @@ function(generateNativeTables) "linux/md_devices.table:linux" "linux/process_namespaces.table:linux" "linux/syslog_events.table:linux" + "linux/pacman_packages.table:linux" "linux/rpm_packages.table:linux" "linux/portage_packages.table:linux" "linux/process_file_events.table:linux" diff --git a/specs/linux/pacman_packages.table b/specs/linux/pacman_packages.table new file mode 100644 index 00000000..26677a65 --- /dev/null +++ b/specs/linux/pacman_packages.table @@ -0,0 +1,18 @@ +table_name("pacman_packages") +description("Pacman packages that are currently installed on the host system.") +schema([ + Column("name", TEXT, "Pacman package name", index=True), + Column("version", TEXT, "Package version" ,index=True), + Column("origin", TEXT, "Origin of the package"), + Column("url", TEXT, "URL of the package upstream"), + Column("md5sum", TEXT, "MD5 hash of the package contents"), + Column("sha256sum", TEXT, "SHA256 hash of the package contents"), + Column("arch", TEXT, "Architecture the package built for", index=True), + Column("packager", TEXT, "Packager of the package"), + Column("build_date", INTEGER, "When the package was built"), + Column("install_date", INTEGER, "When the package was installed"), + Column("package_size", BIGINT, "Package size in bytes"), + Column("install_size", BIGINT, "Installed package size in bytes"), +]) +attributes(cacheable=True) +implementation("@genPacmanPackages") diff --git a/tests/integration/tables/CMakeLists.txt b/tests/integration/tables/CMakeLists.txt index 4ff65192..506fbcf1 100644 --- a/tests/integration/tables/CMakeLists.txt +++ b/tests/integration/tables/CMakeLists.txt @@ -163,6 +163,7 @@ function(generateTestsIntegrationTablesTestsTest) memory_map.cpp msr.cpp npm_packages.cpp + pacman_packages.cpp portage_keywords.cpp portage_packages.cpp portage_use.cpp diff --git a/tests/integration/tables/pacman_packages.cpp b/tests/integration/tables/pacman_packages.cpp new file mode 100644 index 00000000..93eee486 --- /dev/null +++ b/tests/integration/tables/pacman_packages.cpp @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2020-present, Anatol Pomazau. + * All rights reserved. + * + * This source code is licensed in accordance with the terms specified in + * the LICENSE file found in the root directory of this source tree. + */ + +// Sanity check integration test for pacman_packages +// Spec file: specs/linux/pacman_packages.table + +#include + +#include + +namespace osquery { +namespace table_tests { + +class PacmanPackages : public testing::Test { + protected: + void SetUp() override { + setUpEnvironment(); + } +}; + +TEST_F(PacmanPackages, test_sanity) { + QueryData rows = execute_query("select * from pacman_packages"); + if (rows.size() > 0) { + ValidationMap row_map = {{"name", NonEmptyString}, + {"version", NonEmptyString}, + {"origin", NormalType}, + {"url", NormalType}, + {"md5sum", MD5}, + {"sha256sum", SHA256}, + {"arch", NonEmptyString}, + {"packager", NonEmptyString}, + {"build_date", IntType}, + {"install_date", IntType}, + {"package_size", IntType}, + {"install_size", IntType}, + }; + validate_rows(rows, row_map); + + auto all_packages = std::unordered_set{}; + for (const auto& row : rows) { + auto pckg_name = row.at("name"); + all_packages.insert(pckg_name); + } + + ASSERT_EQ(all_packages.count("linux"), 1u); + + } else { + LOG(WARNING) << "Empty results of query from 'pacman_packages', assume there " + "is no linux in the system"; + } +} + +} // namespace table_tests +} // namespace osquery -- 2.28.0 From cd5be4ac04210f1cfc8174c1f44117b18f030ae1 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Mon, 3 Aug 2020 14:06:00 -0700 Subject: [PATCH 16/20] Fix include path for smarttools config dir Signed-off-by: Anatol Pomozov diff --git a/osquery/tables/smart/CMakeLists.txt b/osquery/tables/smart/CMakeLists.txt index 844cf56c..e361fe4e 100644 --- a/osquery/tables/smart/CMakeLists.txt +++ b/osquery/tables/smart/CMakeLists.txt @@ -43,6 +43,8 @@ function(generateOsqueryTablesSmart) generateIncludeNamespace(osquery_tables_smart "osquery/tables/smart" "FILE_ONLY" ${public_header_files}) endif() + include_directories("${PROJECT_SOURCE_DIR}/libraries/cmake/source/smartmontools/config/${TARGET_PROCESSOR}/linux") + if(DEFINED PLATFORM_POSIX) add_test(NAME osquery_tables_smart_tests_smartdrivestests-test COMMAND osquery_tables_smart_tests_smartdrivestests-test) endif() -- 2.28.0 From 70e7149c5873960508b63cf069519110c818b90d Mon Sep 17 00:00:00 2001 From: loqs Date: Fri, 16 Oct 2020 21:02:32 +0100 Subject: [PATCH 17/20] Update AWS for aws-sdk-cpp 1.8.46 diff --git a/osquery/utils/aws/aws_util.cpp b/osquery/utils/aws/aws_util.cpp index 6552b9c0..e0eda5ba 100644 --- a/osquery/utils/aws/aws_util.cpp +++ b/osquery/utils/aws/aws_util.cpp @@ -127,7 +127,7 @@ OsqueryHttpClientFactory::CreateHttpRequest( } std::shared_ptr OsqueryHttpClient::MakeRequest( - Aws::Http::HttpRequest& request, + const std::shared_ptr& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter, Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter) const { // AWS allows rate limiters to be passed around, but we are doing rate @@ -136,21 +136,21 @@ std::shared_ptr OsqueryHttpClient::MakeRequest( LOG(WARNING) << "Read/write limiters are unsupported"; } - Aws::Http::URI uri = request.GetUri(); + Aws::Http::URI uri = request->GetUri(); uri.SetPath(Aws::Http::URI::URLEncodePath(uri.GetPath())); Aws::String url = uri.GetURIString(); http::Client client(TLSTransport().getInternalOptions()); http::Request req(url); - for (const auto& requestHeader : request.GetHeaders()) { + for (const auto& requestHeader : request->GetHeaders()) { req << http::Request::Header(requestHeader.first, requestHeader.second); } std::string body; - if (request.GetContentBody()) { + if (request->GetContentBody()) { std::stringstream ss; - ss << request.GetContentBody()->rdbuf(); + ss << request->GetContentBody()->rdbuf(); body = ss.str(); } @@ -158,15 +158,15 @@ std::shared_ptr OsqueryHttpClient::MakeRequest( try { http::Response resp; - switch (request.GetMethod()) { + switch (request->GetMethod()) { case Aws::Http::HttpMethod::HTTP_GET: resp = client.get(req); break; case Aws::Http::HttpMethod::HTTP_POST: - resp = client.post(req, body, request.GetContentType()); + resp = client.post(req, body, request->GetContentType()); break; case Aws::Http::HttpMethod::HTTP_PUT: - resp = client.put(req, body, request.GetContentType()); + resp = client.put(req, body, request->GetContentType()); break; case Aws::Http::HttpMethod::HTTP_HEAD: resp = client.head(req); @@ -180,7 +180,7 @@ std::shared_ptr OsqueryHttpClient::MakeRequest( break; default: LOG(ERROR) << "Unrecognized HTTP Method used: " - << static_cast(request.GetMethod()); + << static_cast(request->GetMethod()); return nullptr; break; } @@ -207,13 +207,6 @@ std::shared_ptr OsqueryHttpClient::MakeRequest( return response; } -std::shared_ptr OsqueryHttpClient::MakeRequest( - const std::shared_ptr& request, - Aws::Utils::RateLimits::RateLimiterInterface* readLimiter, - Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter) const { - return MakeRequest(*request, readLimiter, writeLimiter); -} - Aws::Auth::AWSCredentials OsqueryFlagsAWSCredentialsProvider::GetAWSCredentials() { // Note that returning empty credentials means the provider chain will just diff --git a/osquery/utils/aws/aws_util.h b/osquery/utils/aws/aws_util.h index 260bd7de..7314085a 100644 --- a/osquery/utils/aws/aws_util.h +++ b/osquery/utils/aws/aws_util.h @@ -74,11 +74,6 @@ class OsqueryHttpClient : public Aws::Http::HttpClient { public: OsqueryHttpClient() : HttpClient() {} - std::shared_ptr MakeRequest( - Aws::Http::HttpRequest& request, - Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr, - Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = - nullptr) const override; std::shared_ptr MakeRequest( const std::shared_ptr& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter, -- 2.28.0 From 6bbf85eedbd75def0ac43b90d4ff6b230f777266 Mon Sep 17 00:00:00 2001 From: loqs Date: Fri, 16 Oct 2020 21:06:49 +0100 Subject: [PATCH 18/20] Drop use of sysctl dropped in glibc 2.32 diff --git a/osquery/tables/system/linux/sysctl_utils.cpp b/osquery/tables/system/linux/sysctl_utils.cpp index 1ff3e0b0..a0102e75 100644 --- a/osquery/tables/system/linux/sysctl_utils.cpp +++ b/osquery/tables/system/linux/sysctl_utils.cpp @@ -7,8 +7,6 @@ * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) */ -#include - #include #include @@ -70,20 +68,8 @@ void genControlInfo(int* oid, size_t oid_size, QueryData& results, const std::map& config) { - // Get control size - size_t response_size = CTL_MAX_VALUE; - char response[CTL_MAX_VALUE + 1] = {0}; - if (sysctl(oid, oid_size, response, &response_size, 0, 0) != 0) { - // Cannot request MIB data. - return; - } - // Data is output, but no way to determine type (long, int, string, struct). - Row r; - r["oid"] = stringFromMIB(oid, oid_size); - r["current_value"] = std::string(response); - r["type"] = "string"; - results.push_back(r); + return; } void genAllControls(QueryData& results, diff --git a/osquery/tables/system/posix/sysctl_utils.h b/osquery/tables/system/posix/sysctl_utils.h index e119f8a9..f2f77630 100644 --- a/osquery/tables/system/posix/sysctl_utils.h +++ b/osquery/tables/system/posix/sysctl_utils.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #include -- 2.28.0 From e1dc5a6e04445b56442dd74a518550ec19c4adcd Mon Sep 17 00:00:00 2001 From: loqs Date: Fri, 16 Oct 2020 21:08:20 +0100 Subject: [PATCH 19/20] C++ compat for g++ 10 diff --git a/osquery/core/shutdown.cpp b/osquery/core/shutdown.cpp index f790ac63..58cc60ab 100644 --- a/osquery/core/shutdown.cpp +++ b/osquery/core/shutdown.cpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace osquery { diff --git a/osquery/numeric_monitoring/numeric_monitoring.h b/osquery/numeric_monitoring/numeric_monitoring.h index e7adf1f1..57d90af7 100644 --- a/osquery/numeric_monitoring/numeric_monitoring.h +++ b/osquery/numeric_monitoring/numeric_monitoring.h @@ -11,6 +11,7 @@ #include #include +#include #include "osquery/utils/conversions/tryto.h" #include -- 2.28.0 From 97ec082a0d7bea4217b357287bda6ac358207914 Mon Sep 17 00:00:00 2001 From: loqs Date: Fri, 16 Oct 2020 21:09:39 +0100 Subject: [PATCH 20/20] Boost 1.74 compat diff --git a/osquery/config/tests/test_utils.cpp b/osquery/config/tests/test_utils.cpp index ed180dd6..43fbc588 100644 --- a/osquery/config/tests/test_utils.cpp +++ b/osquery/config/tests/test_utils.cpp @@ -15,7 +15,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include diff --git a/osquery/database/database.cpp b/osquery/database/database.cpp index 40662b86..94571909 100644 --- a/osquery/database/database.cpp +++ b/osquery/database/database.cpp @@ -8,7 +8,12 @@ */ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/dispatcher/scheduler.cpp b/osquery/dispatcher/scheduler.cpp index f0f72294..0ebb5669 100644 --- a/osquery/dispatcher/scheduler.cpp +++ b/osquery/dispatcher/scheduler.cpp @@ -11,7 +11,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/experimental/events_stream/events_stream.cpp b/osquery/experimental/events_stream/events_stream.cpp index c9c1924e..c9c936c3 100644 --- a/osquery/experimental/events_stream/events_stream.cpp +++ b/osquery/experimental/events_stream/events_stream.cpp @@ -14,7 +14,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif namespace osquery { diff --git a/osquery/experimental/events_stream/events_stream_registry.cpp b/osquery/experimental/events_stream/events_stream_registry.cpp index 8658953d..7f4deb63 100644 --- a/osquery/experimental/events_stream/events_stream_registry.cpp +++ b/osquery/experimental/events_stream/events_stream_registry.cpp @@ -9,7 +9,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include diff --git a/osquery/experimental/tracing/linux/ebpf_tracepoint.cpp b/osquery/experimental/tracing/linux/ebpf_tracepoint.cpp index 802a72e5..1824c27b 100644 --- a/osquery/experimental/tracing/linux/ebpf_tracepoint.cpp +++ b/osquery/experimental/tracing/linux/ebpf_tracepoint.cpp @@ -14,7 +14,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include diff --git a/osquery/numeric_monitoring/numeric_monitoring.cpp b/osquery/numeric_monitoring/numeric_monitoring.cpp index 735dfd46..206e1b88 100644 --- a/osquery/numeric_monitoring/numeric_monitoring.cpp +++ b/osquery/numeric_monitoring/numeric_monitoring.cpp @@ -9,7 +9,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/numeric_monitoring/pre_aggregation_cache.cpp b/osquery/numeric_monitoring/pre_aggregation_cache.cpp index 475b5eae..06213621 100644 --- a/osquery/numeric_monitoring/pre_aggregation_cache.cpp +++ b/osquery/numeric_monitoring/pre_aggregation_cache.cpp @@ -7,7 +7,12 @@ * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only) */ +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include "osquery/numeric_monitoring/pre_aggregation_cache.h" #include diff --git a/osquery/profiler/posix/code_profiler.cpp b/osquery/profiler/posix/code_profiler.cpp index ea9fe74c..fb1b306c 100644 --- a/osquery/profiler/posix/code_profiler.cpp +++ b/osquery/profiler/posix/code_profiler.cpp @@ -22,7 +22,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/sdk/tests/registry_tests.cpp b/osquery/sdk/tests/registry_tests.cpp index bb82a3ff..2b641b73 100644 --- a/osquery/sdk/tests/registry_tests.cpp +++ b/osquery/sdk/tests/registry_tests.cpp @@ -11,7 +11,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/utils/conversions/tryto.cpp b/osquery/utils/conversions/tryto.cpp index 9b47a374..6a174b8e 100644 --- a/osquery/utils/conversions/tryto.cpp +++ b/osquery/utils/conversions/tryto.cpp @@ -11,7 +11,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif namespace osquery { diff --git a/osquery/utils/error/tests/error.cpp b/osquery/utils/error/tests/error.cpp index a94e5d5a..90aad221 100644 --- a/osquery/utils/error/tests/error.cpp +++ b/osquery/utils/error/tests/error.cpp @@ -10,7 +10,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include diff --git a/osquery/utils/system/linux/cpu.cpp b/osquery/utils/system/linux/cpu.cpp index 8c0dc2ca..f4327041 100644 --- a/osquery/utils/system/linux/cpu.cpp +++ b/osquery/utils/system/linux/cpu.cpp @@ -8,7 +8,12 @@ */ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/utils/system/linux/ebpf/ebpf.cpp b/osquery/utils/system/linux/ebpf/ebpf.cpp index ef1598d1..72fbab05 100644 --- a/osquery/utils/system/linux/ebpf/ebpf.cpp +++ b/osquery/utils/system/linux/ebpf/ebpf.cpp @@ -10,7 +10,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/utils/system/linux/ebpf/map.cpp b/osquery/utils/system/linux/ebpf/map.cpp index 5d67f8f4..4397ba81 100644 --- a/osquery/utils/system/linux/ebpf/map.cpp +++ b/osquery/utils/system/linux/ebpf/map.cpp @@ -10,7 +10,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/utils/system/linux/ebpf/perf_output_impl.h b/osquery/utils/system/linux/ebpf/perf_output_impl.h index 4dad8de3..35008194 100644 --- a/osquery/utils/system/linux/ebpf/perf_output_impl.h +++ b/osquery/utils/system/linux/ebpf/perf_output_impl.h @@ -14,7 +14,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/utils/system/linux/ebpf/program.cpp b/osquery/utils/system/linux/ebpf/program.cpp index c0e7db67..b093098d 100644 --- a/osquery/utils/system/linux/ebpf/program.cpp +++ b/osquery/utils/system/linux/ebpf/program.cpp @@ -10,7 +10,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include diff --git a/osquery/utils/system/linux/perf_event/perf_event.cpp b/osquery/utils/system/linux/perf_event/perf_event.cpp index 26709bad..6c72f3ef 100644 --- a/osquery/utils/system/linux/perf_event/perf_event.cpp +++ b/osquery/utils/system/linux/perf_event/perf_event.cpp @@ -9,7 +9,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include diff --git a/osquery/utils/system/linux/tracing/native_event.cpp b/osquery/utils/system/linux/tracing/native_event.cpp index 84bff729..31dc498a 100644 --- a/osquery/utils/system/linux/tracing/native_event.cpp +++ b/osquery/utils/system/linux/tracing/native_event.cpp @@ -14,7 +14,12 @@ #include #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include diff --git a/osquery/utils/versioning/semantic.cpp b/osquery/utils/versioning/semantic.cpp index f8daa252..f3b73161 100644 --- a/osquery/utils/versioning/semantic.cpp +++ b/osquery/utils/versioning/semantic.cpp @@ -9,7 +9,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif namespace osquery { diff --git a/tests/integration/tables/helper.cpp b/tests/integration/tables/helper.cpp index 22cdb51c..e8c1b2cb 100644 --- a/tests/integration/tables/helper.cpp +++ b/tests/integration/tables/helper.cpp @@ -17,7 +17,12 @@ #include -#include +#include +#if BOOST_VERSION >= 107400 +#include +#else +#include +#endif // TODO(5591) Remove this when addressed by Boost's ASIO config. // https://www.boost.org/doc/libs/1_67_0/boost/asio/detail/config.hpp diff --git a/tests/integration/tables/process_envs.cpp b/tests/integration/tables/process_envs.cpp index 4c4eebb7..b2ea825a 100644 --- a/tests/integration/tables/process_envs.cpp +++ b/tests/integration/tables/process_envs.cpp @@ -14,7 +14,12 @@ #include +#include +#if BOOST_VERSION >= 107400 +#include +#else #include +#endif #include #include -- 2.28.0