Make gbs-build stable
authorSangwan Kwon <sangwan.kwon@samsung.com>
Mon, 16 Sep 2019 06:03:58 +0000 (15:03 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Tue, 24 Sep 2019 06:35:48 +0000 (15:35 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
.gbs.conf [new file with mode: 0644]
Makefile
packaging/osquery.spec
src/osquery/CMakeLists.txt
src/osquery/core/plugins/plugin.h
src/osquery/devtools/CMakeLists.txt
src/osquery/registry/registry.cpp [deleted file]
src/osquery/sql/CMakeLists.txt

diff --git a/.gbs.conf b/.gbs.conf
new file mode 100644 (file)
index 0000000..d7c223f
--- /dev/null
+++ b/.gbs.conf
@@ -0,0 +1,82 @@
+[general]
+
+# Tizen 5.5
+profile = profile.standard
+profile = profile.emulator
+
+# Tizen 5.0
+profile = profile.standard-5.0
+profile = profile.emulator-5.0
+
+# Tizen 4.0
+profile = profile.standard-4.0
+profile = profile.emulator-4.0
+
+buildroot = ~/GBS-ROOT
+
+packaging_dir = packaging
+
+## Public Tizen ######################################
+[profile.standard]
+obs   = obs.tizen
+repos = repo.base, repo.standard
+buildroot = ~/GBS-ROOT-standard
+
+[profile.emulator]
+obs   = obs.tizen
+repos = repo.base, repo.emulator
+buildroot = ~/GBS-ROOT-emulator
+
+[repo.base]
+url=http://download.tizen.org/snapshots/tizen/base/latest/repos/standard/packages/
+[repo.standard]
+url=http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/
+[repo.emulator]
+url=http://download.tizen.org/snapshots/tizen/unified/latest/repos/emulator/packages/
+
+## Public Tizen 5.0 ######################################
+[profile.standard-5.0]
+obs   = obs.tizen
+repos = repo.base-5.0, repo.standard-5.0
+buildroot = ~/GBS-ROOT-standard-5.0
+
+[profile.emulator-5.0]
+obs   = obs.tizen
+repos = repo.base-5.0, repo.emulator-5.0
+buildroot = ~/GBS-ROOT-emulator-5.0
+
+[repo.base-5.0]
+url=http://download.tizen.org/snapshots/tizen/5.0-base/latest/repos/standard/packages/
+[repo.standard-5.0]
+url=http://download.tizen.org/snapshots/tizen/5.0-unified/latest/repos/standard/packages/
+[repo.emulator-5.0]
+url=http://download.tizen.org/snapshots/tizen/5.0-unified/latest/repos/emulator/packages/
+
+## Public Tizen 4.0 #################################
+[profile.standard-4.0]
+obs   = obs.tizen
+repos = repo.base-4.0-arm, repo.base-4.0-arm64, repo.base-4.0-ia32, repo.base-4.0-x86_64, repo.standard-4.0
+buildroot = ~/GBS-ROOT-standard-4.0
+
+[profile.emulator-4.0]
+obs   = obs.tizen
+repos = repo.base-4.0-ia32, repo.base-4.0-x86_64, repo.emulator-4.0
+buildroot = ~/GBS-ROOT-emulator-4.0
+
+[repo.base-4.0-arm]
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/arm/packages/
+[repo.base-4.0-arm64]
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/arm64/packages/
+[repo.base-4.0-ia32]
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/ia32/packages/
+[repo.base-4.0-x86_64]
+url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/x86_64/packages/
+[repo.standard-4.0]
+url=http://download.tizen.org/snapshots/tizen/4.0-unified/latest/repos/standard/packages/
+[repo.emulator-4.0]
+url=http://download.tizen.org/snapshots/tizen/4.0-unified/latest/repos/emulator/packages/
+
+[obs.tizen]
+url = https://api.tizen.org
+user =
+passwdx =
index c8c03400f1ff2e708c6401dbd17498118d24e118..5cb33f723081dc6436983ec3321c69d079d40c2d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,9 @@ docker_run:
        docker build --network=host --tag tizen-osquery ./.docker
        docker run --rm -it --net=host --privileged -v $(shell pwd):/usr/src tizen-osquery
 
+gbs_run:
+       gbs lb -A armv7l --include-all -P standard
+
 %::
        mkdir -p build
        cd build && cmake .. && make --no-print-directory $@
index 688d6d770a21c803f301df43e326fb3152afca1f..6a06d6cc71109717e7f94ce72606094eec8994a9 100644 (file)
@@ -1,5 +1,5 @@
 Name: osquery
-Version: 1.5.0
+Version: 0.0.0
 Release: 0
 License: Apache-2.0 and GPLv2 and MIT
 Summary: A SQL powered operating system instrumentation, monitoring framework.
@@ -27,6 +27,7 @@ BuildRequires: pkgconfig(libsystemd)
 BuildRequires: pkgconfig(openssl)
 BuildRequires: iptables-devel
 BuildRequires: python-jinja2
+BuildRequires: libuuid-devel
 Requires: glog
 Requires: gflag
 Requires: rocksdb
@@ -49,7 +50,6 @@ This allows you to write SQL-based queries to explore operating system data.
 %files
 %manifest %{name}.manifest
 %license MIT-LICENSE
-%{_bindir}/osqueryi
 
 %prep
 %setup -q
index 726a11a0adf5b28753e7f4e1efe6224e8a836e85..a9ac14106bd4779baeec234e30aa69dc3d8fcf35 100644 (file)
@@ -50,13 +50,15 @@ IF(DEFINED GBS_BUILD)
        INCLUDE_DIRECTORIES(SYSTEM ${GBS_DEPS_INCLUDE_DIRS})
 
        ADD_OSQUERY_LINK(${GBS_DEPS_LIBRARIES})
+ELSE(DEFINED GBS_BUILD)
+       ## osqueryi
+       ADD_SUBDIRECTORY(devtools)
 ENDIF(DEFINED GBS_BUILD)
 
 ## osquery v4.0.0
 ADD_SUBDIRECTORY(config)
 ADD_SUBDIRECTORY(core)
 ADD_SUBDIRECTORY(database)
-ADD_SUBDIRECTORY(devtools)
 ADD_SUBDIRECTORY(dispatcher)
 ADD_SUBDIRECTORY(events)
 ADD_SUBDIRECTORY(filesystem)
@@ -95,16 +97,18 @@ INSTALL(TARGETS ${TARGET_OSQUERY_TEST}
                                        WORLD_READ
                                        WORLD_EXECUTE)
 
-ADD_EXECUTABLE(${TARGET_OSQUERY_SHELL} devtools/shell.cpp
-                                                                          main/main.cpp
-                                                                          main/posix/main.cpp)
-TARGET_LINK_WHOLE(${TARGET_OSQUERY_SHELL} ${TARGET_OSQUERY_LIB})
-INSTALL(TARGETS ${TARGET_OSQUERY_SHELL}
-               DESTINATION ${CMAKE_INSTALL_BINDIR}
-               PERMISSIONS OWNER_READ
-                                       OWNER_WRITE
-                                       OWNER_EXECUTE
-                                       GROUP_READ
-                                       GROUP_EXECUTE
-                                       WORLD_READ
-                                       WORLD_EXECUTE)
+IF(NOT DEFINED GBS_BUILD)
+       ADD_EXECUTABLE(${TARGET_OSQUERY_SHELL} devtools/shell.cpp
+                                                                                  main/main.cpp
+                                                                                  main/posix/main.cpp)
+       TARGET_LINK_WHOLE(${TARGET_OSQUERY_SHELL} ${TARGET_OSQUERY_LIB})
+       INSTALL(TARGETS ${TARGET_OSQUERY_SHELL}
+                       DESTINATION ${CMAKE_INSTALL_BINDIR}
+                       PERMISSIONS OWNER_READ
+                                               OWNER_WRITE
+                                               OWNER_EXECUTE
+                                               GROUP_READ
+                                               GROUP_EXECUTE
+                                               WORLD_READ
+                                               WORLD_EXECUTE)
+ENDIF(NOT DEFINED GBS_BUILD)
index dffc3068e638492672d319bedd87c94d6e2c93a4..801cad46570a19d55fa24e4fb1fc9ef2e2fb5965 100644 (file)
@@ -82,27 +82,6 @@ class Plugin : private boost::noncopyable {
     return name_;
   }
 
- public:
-
-  /**
-   * @brief Bind this plugin to an external plugin reference.
-   *
-   * Allow a specialized plugin type to act when an external plugin is
-   * registered (e.g., a TablePlugin will attach the table name).
-   *
-   * @param name The broadcasted name of the plugin.
-   * @param info The routing info for the owning extension.
-   */
-  static Status addExternal(const std::string& name,
-                            const PluginResponse& info) {
-    (void)name;
-    (void)info;
-    return Status::success();
-  }
-
-  /// Allow a specialized plugin type to act when an external plugin is removed.
-  static void removeExternal(const std::string& /*name*/) {}
-
  protected:
   /// Customized name for the plugin, usually set by the registry.
   std::string name_;
index 1cb6bd3c8668b80bd557628ef63bbabd3d286cbb..94054dfe42ef717410847533bc54215267c2a532 100644 (file)
@@ -15,7 +15,6 @@
 ADD_OSQUERY_LINK(linenoise)
 
 ADD_OSQUERY_LIBRARY(osquery_devtools printer.cpp)
-#                                                                       shell.cpp)
 
 FILE(GLOB OSQUERY_DEVTOOLS_TESTS "tests/*.cpp")
 ADD_OSQUERY_TEST(${OSQUERY_DEVTOOLS_TESTS})
diff --git a/src/osquery/registry/registry.cpp b/src/osquery/registry/registry.cpp
deleted file mode 100644 (file)
index 80cf10f..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *  Copyright (c) 2014, Facebook, Inc.
- *  All rights reserved.
- *
- *  This source code is licensed under the BSD-style license found in the
- *  LICENSE file in the root directory of this source tree. An additional grant
- *  of patent rights can be found in the PATENTS file in the same directory.
- *
- */
-
-#include <cstdlib>
-#include <sstream>
-
-#include <dlfcn.h>
-
-#include <boost/property_tree/json_parser.hpp>
-
-#include <osquery/logger.h>
-#include <osquery/registry.h>
-
-namespace osquery {
-
-HIDDEN_FLAG(bool, registry_exceptions, false, "Allow plugin exceptions");
-
-void RegistryHelperCore::remove(const std::string& item_name) {
-  if (items_.count(item_name) > 0) {
-    items_[item_name]->tearDown();
-    items_.erase(item_name);
-  }
-
-  // Populate list of aliases to remove (those that mask item_name).
-  std::vector<std::string> removed_aliases;
-  for (const auto& alias : aliases_) {
-    if (alias.second == item_name) {
-      removed_aliases.push_back(alias.first);
-    }
-  }
-
-  for (const auto& alias : removed_aliases) {
-    aliases_.erase(alias);
-  }
-}
-
-bool RegistryHelperCore::isInternal(const std::string& item_name) const {
-  if (std::find(internal_.begin(), internal_.end(), item_name) ==
-      internal_.end()) {
-    return false;
-  }
-  return true;
-}
-
-Status RegistryHelperCore::setActive(const std::string& item_name) {
-  if (items_.count(item_name) == 0) {
-    return Status(1, "Unknown registry item");
-  }
-
-  active_ = item_name;
-  // The active plugin is setup when initialized.
-  if (exists(item_name, true)) {
-    Registry::get(name_, item_name)->setUp();
-  }
-  return Status(0, "OK");
-}
-
-const std::string& RegistryHelperCore::getActive() const { return active_; }
-
-Status RegistryHelperCore::call(const std::string& item_name,
-                                const PluginRequest& request,
-                                PluginResponse& response) {
-  if (items_.count(item_name) > 0) {
-    return items_.at(item_name)->call(request, response);
-  }
-
-  return Status(1, "Cannot call registry item: " + item_name);
-}
-
-Status RegistryHelperCore::addAlias(const std::string& item_name,
-                                    const std::string& alias) {
-  if (aliases_.count(alias) > 0) {
-    return Status(1, "Duplicate alias: " + alias);
-  }
-  aliases_[alias] = item_name;
-  return Status(0, "OK");
-}
-
-const std::string& RegistryHelperCore::getAlias(
-    const std::string& alias) const {
-  if (aliases_.count(alias) == 0) {
-    return alias;
-  }
-  return aliases_.at(alias);
-}
-
-void RegistryHelperCore::setUp() {
-  // If this registry does not auto-setup do NOT setup the registry items.
-  if (!auto_setup_) {
-    return;
-  }
-
-  // If the registry is using a single 'active' plugin, setUp that plugin.
-  // For config and logger, only setUp the selected plugin.
-  if (active_.size() != 0 && exists(active_, true)) {
-    items_.at(active_)->setUp();
-    return;
-  }
-
-  // Try to set up each of the registry items.
-  // If they fail, remove them from the registry.
-  std::vector<std::string> failed;
-  for (auto& item : items_) {
-    if (!item.second->setUp().ok()) {
-      failed.push_back(item.first);
-    }
-  }
-
-  for (const auto& failed_item : failed) {
-    remove(failed_item);
-  }
-}
-
-/// Facility method to check if a registry item exists.
-bool RegistryHelperCore::exists(const std::string& item_name,
-                                bool local) const {
-  return (items_.count(item_name) > 0);
-}
-
-/// Facility method to list the registry item identifiers.
-std::vector<std::string> RegistryHelperCore::names() const {
-  std::vector<std::string> names;
-  for (const auto& item : items_) {
-    names.push_back(item.first);
-  }
-
-  return names;
-}
-
-/// Facility method to count the number of items in this registry.
-size_t RegistryHelperCore::count() const { return items_.size(); }
-
-/// Allow the registry to introspect into the registered name (for logging).
-void RegistryHelperCore::setName(const std::string& name) { name_ = name; }
-
-const std::map<std::string, PluginRegistryHelperRef>& RegistryFactory::all() {
-  return instance().registries_;
-}
-
-PluginRegistryHelperRef RegistryFactory::registry(
-    const std::string& registry_name) {
-  return instance().registries_.at(registry_name);
-}
-
-const std::map<std::string, PluginRef> RegistryFactory::all(
-    const std::string& registry_name) {
-  return instance().registry(registry_name)->all();
-}
-
-PluginRef RegistryFactory::get(const std::string& registry_name,
-                               const std::string& item_name) {
-  return instance().registry(registry_name)->get(item_name);
-}
-
-/// Adds an alias for an internal registry item. This registry will only
-/// broadcast the alias name.
-Status RegistryFactory::addAlias(const std::string& registry_name,
-                                 const std::string& item_name,
-                                 const std::string& alias) {
-  if (instance().registries_.count(registry_name) == 0) {
-    return Status(1, "Unknown registry: " + registry_name);
-  }
-  return instance().registries_.at(registry_name)->addAlias(item_name, alias);
-}
-
-/// Returns the item_name or the item alias if an alias exists.
-const std::string& RegistryFactory::getAlias(const std::string& registry_name,
-                                             const std::string& alias) {
-  if (instance().registries_.count(registry_name) == 0) {
-    return alias;
-  }
-  return instance().registries_.at(registry_name)->getAlias(alias);
-}
-
-Status RegistryFactory::call(const std::string& registry_name,
-                             const std::string& item_name,
-                             const PluginRequest& request,
-                             PluginResponse& response) {
-  // Forward factory call to the registry.
-  try {
-    return registry(registry_name)->call(item_name, request, response);
-  } catch (const std::exception& e) {
-    LOG(ERROR) << registry_name << " registry " << item_name
-               << " plugin caused exception: " << e.what();
-    if (FLAGS_registry_exceptions) {
-      throw e;
-    }
-    return Status(1, e.what());
-  } catch (...) {
-    LOG(ERROR) << registry_name << " registry " << item_name
-               << " plugin caused unknown exception";
-    if (FLAGS_registry_exceptions) {
-      throw std::runtime_error(registry_name + ": " + item_name + " failed");
-    }
-    return Status(2, "Unknown exception");
-  }
-}
-
-Status RegistryFactory::call(const std::string& registry_name,
-                             const std::string& item_name,
-                             const PluginRequest& request) {
-  PluginResponse response;
-  // Wrapper around a call expecting a response.
-  return call(registry_name, item_name, request, response);
-}
-
-Status RegistryFactory::call(const std::string& registry_name,
-                             const PluginRequest& request,
-                             PluginResponse& response) {
-  auto& plugin = registry(registry_name)->getActive();
-  return call(registry_name, plugin, request, response);
-}
-
-Status RegistryFactory::call(const std::string& registry_name,
-                             const PluginRequest& request) {
-  PluginResponse response;
-  return call(registry_name, request, response);
-}
-
-Status RegistryFactory::setActive(const std::string& registry_name,
-                                  const std::string& item_name) {
-  if (!exists(registry_name, item_name)) {
-    return Status(1, "Registry plugin does not exist");
-  }
-  return registry(registry_name)->setActive(item_name);
-}
-
-const std::string& RegistryFactory::getActive(
-    const std::string& registry_name) {
-  return registry(registry_name)->getActive();
-}
-
-void RegistryFactory::setUp() {
-  for (const auto& registry : instance().all()) {
-    registry.second->setUp();
-  }
-}
-
-bool RegistryFactory::exists(const std::string& registry_name,
-                             const std::string& item_name,
-                             bool local) {
-  if (instance().registries_.count(registry_name) == 0) {
-    return false;
-  }
-
-  // Check the registry.
-  return registry(registry_name)->exists(item_name, local);
-}
-
-std::vector<std::string> RegistryFactory::names() {
-  std::vector<std::string> names;
-  for (const auto& registry : all()) {
-    names.push_back(registry.second->getName());
-  }
-  return names;
-}
-
-std::vector<std::string> RegistryFactory::names(
-    const std::string& registry_name) {
-  if (instance().registries_.at(registry_name) == 0) {
-    std::vector<std::string> names;
-    return names;
-  }
-  return instance().registry(registry_name)->names();
-}
-
-size_t RegistryFactory::count() { return instance().registries_.size(); }
-
-size_t RegistryFactory::count(const std::string& registry_name) {
-  if (instance().registries_.count(registry_name) == 0) {
-    return 0;
-  }
-  return instance().registry(registry_name)->count();
-}
-
-Status RegistryHelperCore::add(const std::string& item_name, bool internal) {
-  // The item can be listed as internal, meaning it does not broadcast.
-  if (internal) {
-    internal_.push_back(item_name);
-  }
-
-  return Status(0, "OK");
-}
-
-void Plugin::getResponse(const std::string& key,
-                         const PluginResponse& response,
-                         boost::property_tree::ptree& tree) {
-  for (const auto& item : response) {
-    boost::property_tree::ptree child;
-    for (const auto& item_detail : item) {
-      child.put(item_detail.first, item_detail.second);
-    }
-    tree.add_child(key, child);
-  }
-}
-
-void Plugin::setResponse(const std::string& key,
-                         const boost::property_tree::ptree& tree,
-                         PluginResponse& response) {
-  std::ostringstream output;
-  try {
-    boost::property_tree::write_json(output, tree, false);
-  } catch (const pt::json_parser::json_parser_error& e) {
-    // The plugin response could not be serialized.
-  }
-  response.push_back({{key, output.str()}});
-}
-}
index 600d7e7a07a694c67ae6b85752f293beb0d35919..41d30def81be8ab8aabc0acd821f4789276025de 100644 (file)
@@ -12,8 +12,6 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License
 
-ADD_OSQUERY_LINK(linenoise)
-
 ADD_OSQUERY_LIBRARY(osquery_sql dynamic_table_row.cpp
                                                                sqlite_encoding.cpp
                                                                sqlite_hashing.cpp