core/status to status and header cleanup

This commit is contained in:
mike@arpaia.co 2014-08-05 16:13:55 -07:00
parent dbf09752e9
commit ec30260f37
42 changed files with 188 additions and 144 deletions

View File

@ -10,7 +10,7 @@
#include <utility>
#include <vector>
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace config {
@ -73,7 +73,7 @@ private:
// genConfig() is a symbol that is satisfied by the config plugin that gets
// compiled with osquery
static osquery::core::Status genConfig(OsqueryConfig& conf);
static osquery::Status genConfig(OsqueryConfig& conf);
private:
// cfg_ is the private member that stores the raw osquery config data in a
// native format

View File

@ -16,9 +16,9 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "osquery/core/status.h"
#include "osquery/status.h"
using osquery::core::Status;
using osquery::Status;
namespace pt = boost::property_tree;

View File

@ -6,11 +6,11 @@
#include <gtest/gtest.h>
#include "osquery/core.h"
#include "osquery/core/status.h"
#include "osquery/status.h"
#include "osquery/registry.h"
namespace core = osquery::core;
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace config {

View File

@ -7,14 +7,14 @@
#include <utility>
#include "osquery/registry.h"
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace config {
class ConfigPlugin {
public:
virtual std::pair<osquery::core::Status, std::string> genConfig() {
return std::make_pair(osquery::core::Status(1, "Not implemented"), "");
virtual std::pair<osquery::Status, std::string> genConfig() {
return std::make_pair(osquery::Status(1, "Not implemented"), "");
}
virtual ~ConfigPlugin() {}
protected:
@ -33,4 +33,4 @@ DECLARE_REGISTRY(
#define REGISTER_CONFIG_PLUGIN(name, decorator) \
REGISTER(ConfigPlugins, name, decorator)
#endif
#endif /* OSQUERY_CONFIG_PLUGIN_H */

View File

@ -12,7 +12,7 @@
#include "configerator/distribution/api/api.h"
#include "configerator/structs/osquery/gen-cpp/osquery_types.h"
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace config {
@ -20,7 +20,7 @@ class ConfigeratorConfigPlugin : public ConfigPlugin {
public:
ConfigeratorConfigPlugin() {};
std::pair<osquery::core::Status, std::string> genConfig() {
std::pair<osquery::Status, std::string> genConfig() {
facebook::configerator::ConfigeratorApi api;
std::string content;
api.getConfig("osquery/osquery", &content);

View File

@ -14,7 +14,7 @@
#include <glog/logging.h>
namespace fs = boost::filesystem;
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace config {
@ -28,7 +28,7 @@ class FilesystemConfigPlugin : public ConfigPlugin {
public:
FilesystemConfigPlugin() {};
std::pair<osquery::core::Status, std::string> genConfig() {
std::pair<osquery::Status, std::string> genConfig() {
std::string config;
if (!fs::exists(FLAGS_config_path)) {
return std::make_pair(

View File

@ -11,10 +11,6 @@
namespace osquery { namespace core {
// the callback for populating a std::vector<row> set of results. "argument"
// should be a non-const reference to a std::vector<row>
int callback(void *argument, int argc, char *argv[], char *column[]);
// aggregateQuery accepts a const reference to an std::string and returns a
// resultset of type QueryData.
osquery::db::QueryData
@ -22,8 +18,9 @@ aggregateQuery(const std::string& q, int& error_return);
osquery::db::QueryData
aggregateQuery(const std::string& q, int& error_return, sqlite3* db);
// Return a fully configured sqlite3 database object
sqlite3* createDB();
// initOsquery sets up various aspects of osquery execution state. it should
// be called in an executable's main() function
void initOsquery(int argc, char *argv[]);
}}

View File

@ -1,7 +1,9 @@
ADD_LIBRARY(osquery_core
init_osquery.cpp
sqlite_util.cpp
test_util.cpp
)
TARGET_LINK_LIBRARIES(osquery_core gflags)
TARGET_LINK_LIBRARIES(osquery_core glog)
TARGET_LINK_LIBRARIES(osquery_core gtest)
TARGET_LINK_LIBRARIES(osquery_core osquery_database)

View File

@ -0,0 +1,28 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "osquery/core.h"
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "osquery/registry.h"
namespace osquery { namespace core {
void initOsquery(int argc, char *argv[]) {
// you can access this message later via google::ProgramUsage()
google::SetUsageMessage(
"\n"
" OSQuery - operating system instrumentation framework\n"
"\n"
" Arguments\n"
"\n"
" -help Show complete help text\n"
"\n"
);
google::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
osquery::InitRegistry::get().run();
}
}}

View File

@ -1,5 +1,5 @@
#ifndef MD5_H
#define MD5_H
#ifndef OSQUERY_CORE_MD5_H
#define OSQUERY_CORE_MD5_H
// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
// rights reserved.
@ -365,4 +365,4 @@ public:
}}
#endif
#endif /* OSQUERY_CORE_MD5_H */

View File

@ -1,6 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "osquery/core.h"
#include "osquery/core/sqlite_util.h"
#include "osquery/database.h"
#include "osquery/sqlite3.h"
#include "osquery/tables/base.h"
@ -32,7 +33,7 @@ QueryData
aggregateQuery(const std::string& q, int& error_return, sqlite3* db) {
QueryData d;
char *err = nullptr;
sqlite3_exec(db, q.c_str(), callback, &d, &err);
sqlite3_exec(db, q.c_str(), query_data_callback, &d, &err);
if (err != nullptr) {
LOG(ERROR) << "Error launching query: " << err;
error_return = 1;
@ -44,9 +45,10 @@ aggregateQuery(const std::string& q, int& error_return, sqlite3* db) {
return d;
}
int callback(void* argument, int argc, char *argv[], char *column[]) {
int query_data_callback(
void* argument, int argc, char *argv[], char *column[]) {
if (argument == nullptr) {
LOG(ERROR) << "callback received nullptr as data argument";
LOG(ERROR) << "query_data_callback received nullptr as data argument";
return SQLITE_MISUSE;
}
QueryData *qData = (QueryData*)argument;

View File

@ -0,0 +1,23 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#ifndef OSQUERY_CORE_SQLITE_UTIL_H
#define OSQUERY_CORE_SQLITE_UTIL_H
#include <string>
#include <vector>
#include "osquery/database.h"
#include "osquery/sqlite3.h"
namespace osquery { namespace core {
// the callback for populating a std::vector<row> set of results. "argument"
// should be a non-const reference to a std::vector<row>
int query_data_callback(void *argument, int argc, char *argv[], char *column[]);
// Return a fully configured sqlite3 database object
sqlite3* createDB();
}}
#endif /* OSQUERY_CORE_SQLITE_UTIL_H */

View File

@ -7,6 +7,7 @@
#include <gtest/gtest.h>
#include <glog/logging.h>
#include "osquery/core/sqlite_util.h"
#include "osquery/core/test_util.h"
using namespace osquery::core;
@ -23,7 +24,7 @@ TEST_F(SQLiteUtilTests, test_simple_query_execution) {
TEST_F(SQLiteUtilTests, test_passing_callback_no_data_param) {
char *err = nullptr;
sqlite3_exec(createTestDB(), kTestQuery.c_str(), callback, nullptr, &err);
sqlite3_exec(createTestDB(), kTestQuery.c_str(), query_data_callback, nullptr, &err);
EXPECT_TRUE(err != nullptr);
if (err != nullptr) {
sqlite3_free(err);

View File

@ -1,10 +1,10 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "osquery/core/status.h"
#include "osquery/status.h"
#include <gtest/gtest.h>
namespace osquery { namespace core {
namespace osquery {
class StatusTests : public testing::Test {};
@ -26,7 +26,7 @@ TEST_F(StatusTests, test_to_string) {
EXPECT_EQ(s.toString(), "foobar");
}
}}
}
int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);

View File

@ -9,6 +9,8 @@
#include <glog/logging.h>
#include "osquery/core/sqlite_util.h"
using namespace osquery::db;
namespace pt = boost::property_tree;

View File

@ -3,7 +3,6 @@
#ifndef OSQUERY_DATABASE_H
#define OSQUERY_DATABASE_H
#include "osquery/core/status.h"
#include "osquery/database/db_handle.h"
#include "osquery/database/query.h"
#include "osquery/database/results.h"

View File

@ -10,9 +10,9 @@
#include <rocksdb/env.h>
#include <rocksdb/options.h>
#include "osquery/core/status.h"
#include "osquery/status.h"
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace db {
@ -119,7 +119,7 @@ std::shared_ptr<DBHandle> DBHandle::getInstance(
// getters and setters
/////////////////////////////////////////////////////////////////////////////
osquery::core::Status DBHandle::getStatus() {
osquery::Status DBHandle::getStatus() {
return Status(status_.code(), status_.ToString());
}
@ -154,7 +154,7 @@ void DBHandle::endTransaction() {
// Data manipulation methods
/////////////////////////////////////////////////////////////////////////////
osquery::core::Status DBHandle::Get(
osquery::Status DBHandle::Get(
const std::string& domain,
const std::string& key,
std::string& value){
@ -167,7 +167,7 @@ osquery::core::Status DBHandle::Get(
return Status(s.code(), s.ToString());
}
osquery::core::Status DBHandle::Put(
osquery::Status DBHandle::Put(
const std::string& domain,
const std::string& key,
const std::string& value) {
@ -180,7 +180,7 @@ osquery::core::Status DBHandle::Put(
return Status(s.code(), s.ToString());
}
osquery::core::Status DBHandle::Delete(
osquery::Status DBHandle::Delete(
const std::string& domain,
const std::string& key) {
auto s = getDB()->Delete(
@ -191,7 +191,7 @@ osquery::core::Status DBHandle::Delete(
return Status(s.code(), s.ToString());
}
osquery::core::Status DBHandle::Scan(
osquery::Status DBHandle::Scan(
const std::string& domain,
std::vector<std::string>& results) {
auto it = getDB()->NewIterator(

View File

@ -7,10 +7,10 @@
#include <string>
#include <vector>
#include "gtest/gtest_prod.h"
#include <gtest/gtest_prod.h>
#include <rocksdb/db.h>
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace db {
@ -49,7 +49,7 @@ public:
/////////////////////////////////////////////////////////////////////////////
// getStatus() returns the status_ property
osquery::core::Status getStatus();
osquery::Status getStatus();
// getDB() is a helper that's used to get access to db_
rocksdb::DB* getDB();
@ -68,27 +68,27 @@ public:
/////////////////////////////////////////////////////////////////////////////
// Get a "key" from "domain" and store it's content in "value"
osquery::core::Status Get(
osquery::Status Get(
const std::string& domain,
const std::string& key,
std::string& value
);
// Set "key" to "value" in "domain"
osquery::core::Status Put(
osquery::Status Put(
const std::string& domain,
const std::string& key,
const std::string& value
);
// Delete "key" and it's corresponding value from "domain"
osquery::core::Status Delete(
osquery::Status Delete(
const std::string& domain,
const std::string& key
);
// List all keys in "domain" and store the results in "results"
osquery::core::Status Scan(
osquery::Status Scan(
const std::string& domain,
std::vector<std::string>& results
);
@ -171,4 +171,4 @@ private:
}}
#endif
#endif /* OSQUERY_DATABASE_DB_HANDLE_H */

View File

@ -8,9 +8,9 @@
#include <glog/logging.h>
#include <rocksdb/version.h>
#include "osquery/core/status.h"
#include "osquery/status.h"
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace db {

View File

@ -4,7 +4,7 @@
#include <algorithm>
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace db {
@ -112,14 +112,14 @@ Query::addNewResults(
return addNewResults(qd, dr, false, unix_time, db);
}
osquery::core::Status Query::addNewResults(
osquery::Status Query::addNewResults(
const osquery::db::QueryData& qd,
osquery::db::DiffResults& dr,
int unix_time) {
return addNewResults(qd, dr, true, unix_time, DBHandle::getInstance());
}
osquery::core::Status Query::addNewResults(
osquery::Status Query::addNewResults(
const osquery::db::QueryData& qd,
osquery::db::DiffResults& dr,
bool calculate_diff,
@ -153,7 +153,7 @@ osquery::core::Status Query::addNewResults(
return Status(0, "OK");
}
osquery::core::Status Query::getCurrentResults(osquery::db::QueryData& qd) {
osquery::Status Query::getCurrentResults(osquery::db::QueryData& qd) {
return getCurrentResults(qd, DBHandle::getInstance());
}

View File

@ -7,12 +7,12 @@
#include <memory>
#include <string>
#include "gtest/gtest_prod.h"
#include <gtest/gtest_prod.h>
#include "osquery/config.h"
#include "osquery/database/db_handle.h"
#include "osquery/database/results.h"
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace db {
@ -50,9 +50,9 @@ public:
// getHistoricalQueryResults() returns the entire historical query result
// set for a given scheduled query
public:
osquery::core::Status getHistoricalQueryResults(HistoricalQueryResults& hQR);
osquery::Status getHistoricalQueryResults(HistoricalQueryResults& hQR);
private:
osquery::core::Status
osquery::Status
getHistoricalQueryResults(
HistoricalQueryResults& hQR, std::shared_ptr<DBHandle> db);
@ -76,41 +76,41 @@ private:
// executions. These timestamp values are used as the RocksDB sub-keys which
// represent the data stored as a result of those executions.
public:
osquery::core::Status getExecutions(std::deque<int>& results);
osquery::Status getExecutions(std::deque<int>& results);
private:
osquery::core::Status
osquery::Status
getExecutions(std::deque<int>& results, std::shared_ptr<DBHandle> db);
// addNewResults adds a new result set to the local data store. If you
// want the diff of the results you've just added, pass a reference to a
// diffResults struct
public:
osquery::core::Status addNewResults(
osquery::Status addNewResults(
const osquery::db::QueryData& qd, int unix_time
);
private:
osquery::core::Status
osquery::Status
addNewResults(
const osquery::db::QueryData& qd, int unix_time,
std::shared_ptr<DBHandle> db
);
public:
osquery::core::Status addNewResults(
osquery::Status addNewResults(
const osquery::db::QueryData& qd, osquery::db::DiffResults& dr,
int unix_time
);
private:
osquery::core::Status addNewResults(
osquery::Status addNewResults(
const osquery::db::QueryData& qd, osquery::db::DiffResults& dr,
bool calculate_diff, int unix_time, std::shared_ptr<DBHandle> db
);
// getCurrentResults returns the most recent result set from the database
public:
osquery::core::Status getCurrentResults(osquery::db::QueryData& qd);
osquery::Status getCurrentResults(osquery::db::QueryData& qd);
private:
osquery::core::Status
osquery::Status
getCurrentResults(osquery::db::QueryData& qd, std::shared_ptr<DBHandle> db);
private:
@ -138,4 +138,4 @@ private:
}}
#endif
#endif /* OSQUERY_DATABASE_QUERY_H */

View File

@ -17,7 +17,7 @@
#include <glog/logging.h>
namespace pt = boost::property_tree;
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace db {

View File

@ -10,7 +10,7 @@
#include <boost/property_tree/ptree.hpp>
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace db {
@ -25,9 +25,9 @@ typedef std::map<std::string, std::string> Row;
// serializeRow accepts a const reference to a row and a non-const reference to
// a ptree. The contents of const Row r will be serialized into ptree tree and
// an osquery::core::Status will be returned indicating the success or failure
// an osquery::Status will be returned indicating the success or failure
// of the operation.
osquery::core::Status
osquery::Status
serializeRow(const Row& r, boost::property_tree::ptree& tree);
/////////////////////////////////////////////////////////////////////////////
@ -40,9 +40,9 @@ typedef std::vector<Row> QueryData;
// serializeQueryData accepts a const reference to a QueryData and a non-const
// reference to a ptree. The contents of const QueryData q will be serialized
// into ptree tree and an osquery::core::Status will be returned indicating the
// into ptree tree and an osquery::Status will be returned indicating the
// success or failure of the operation.
osquery::core::Status
osquery::Status
serializeQueryData(const QueryData& q, boost::property_tree::ptree& tree);
/////////////////////////////////////////////////////////////////////////////
@ -75,17 +75,17 @@ typedef struct DiffResults DiffResults;
// serializeDiffResults accepts a const reference to a DiffResults and a
// non-const reference to a ptree. The contents of const DiffResults d will be
// serialized into ptree tree and an osquery::core::Status will be returned
// serialized into ptree tree and an osquery::Status will be returned
// indicating the success or failure of the operation.
osquery::core::Status
osquery::Status
serializeDiffResults(const DiffResults& d, boost::property_tree::ptree& tree);
// serializeDiffResultsJSON accepts a const reference to a DiffResults struct
// and a non-const reference to a std::string. The contents of const
// DiffResults d will be serialized into std::string json and an
// osquery::core::Status will be returned indicating the success or failure of
// osquery::Status will be returned indicating the success or failure of
// the operation.
osquery::core::Status
osquery::Status
serializeDiffResultsJSON(
const DiffResults& d,
std::string& json);
@ -137,9 +137,9 @@ typedef struct HistoricalQueryResults HistoricalQueryResults;
// serializeHistoricalQueryResults accepts a const reference to a
// HistoricalQueryResults struct and a non-const reference to a ptree. The
// contents of const HistoricalQueryResults r will be serialized into ptree
// tree and an osquery::core::Status will be returned indicating the success or
// tree and an osquery::Status will be returned indicating the success or
// failure of the operation.
osquery::core::Status
osquery::Status
serializeHistoricalQueryResults(
const HistoricalQueryResults& r,
boost::property_tree::ptree& tree);
@ -147,9 +147,9 @@ serializeHistoricalQueryResults(
// serializeHistoricalQueryResultsJSON accepts a const reference to a
// HistoricalQueryResults struct and a non-const reference to a std::string.
// The contents of const HistoricalQueryResults r will be serialized into
// std::string json and an osquery::core::Status will be returned indicating the
// std::string json and an osquery::Status will be returned indicating the
// success or failure of the operation.
osquery::core::Status
osquery::Status
serializeHistoricalQueryResultsJSON(
const HistoricalQueryResults& r,
std::string& json);
@ -157,9 +157,9 @@ serializeHistoricalQueryResultsJSON(
// deserializeHistoricalQueryResults accepts a const reference to a ptree of a
// serialized HistoricalQueryResults struct and a non-const reference to a
// historicalQueryResults struct. The contents of const ptree tree will be
// serialized into HistoricalQueryResults r and an osquery::core::Status will be
// serialized into HistoricalQueryResults r and an osquery::Status will be
// returned indicating the success or failure of the operation.
osquery::core::Status
osquery::Status
deserializeHistoricalQueryResults(
const boost::property_tree::ptree& tree,
HistoricalQueryResults& r);
@ -168,9 +168,9 @@ deserializeHistoricalQueryResults(
// std::string of a serialized HistoricalQueryResults struct and a non-const
// reference to a HistoricalQueryResults struct. The contents of const
// std::string json will be serialized into HistoricalQueryResults r and an
// osquery::core::Status will be returned indicating the success or failure of
// osquery::Status will be returned indicating the success or failure of
// the operation.
osquery::core::Status
osquery::Status
deserializeHistoricalQueryResultsJSON(
const std::string& json,
HistoricalQueryResults& r);
@ -205,12 +205,12 @@ struct ScheduledQueryLogItem {
// serializeScheduledQueryLogItem accepts a const reference to a
// ScheduledQueryLogItem and a non-const reference to a ptree. The contents of
// const ScheduledQueryLogItem i will be serialized into ptree tree and an
// osquery::core::Status will be returned indicating the success or failure of
// osquery::Status will be returned indicating the success or failure of
// the operation.
osquery::core::Status serializeScheduledQueryLogItem(
osquery::Status serializeScheduledQueryLogItem(
const ScheduledQueryLogItem& i, boost::property_tree::ptree& tree);
osquery::core::Status serializeScheduledQueryLogItemJSON(
osquery::Status serializeScheduledQueryLogItemJSON(
const ScheduledQueryLogItem& i, std::string& json);
}}

View File

@ -6,16 +6,16 @@
#include <string>
#include <vector>
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace fs {
// readFile accepts a const reference to an std::string indicating the path of
// the file that you'd like to read and a non-const reference to an std::string
// which will be populated with the contents of the file (if all operations are
// successful). An osquery::core::Status is returned indicating the success or
// successful). An osquery::Status is returned indicating the success or
// failure of the operation.
osquery::core::Status readFile(const std::string& path, std::string& content);
osquery::Status readFile(const std::string& path, std::string& content);
}}

View File

@ -12,7 +12,7 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace fs {

View File

@ -7,7 +7,7 @@
#include <string>
#include <vector>
#include "osquery/core/status.h"
#include "osquery/status.h"
#include "osquery/database.h"
namespace osquery { namespace logger {
@ -20,15 +20,15 @@ extern const std::string kDefaultLogReceiverName;
// upstream receiver. If no receiver is specified, it will fail back to what
// was defined via the command-line flags. If none was defined, it will fail
// back to using the default log receiver.
osquery::core::Status logString(const std::string& s);
osquery::core::Status logString(
osquery::Status logString(const std::string& s);
osquery::Status logString(
const std::string& s, const std::string& receiver);
// logScheduledQueryLogItem accepts a const reference to a
// ScheduledQueryLogItem struct and logs it to a specified upstream receiver.
osquery::core::Status logScheduledQueryLogItem(
osquery::Status logScheduledQueryLogItem(
const osquery::db::ScheduledQueryLogItem& item);
osquery::core::Status logScheduledQueryLogItem(
osquery::Status logScheduledQueryLogItem(
const osquery::db::ScheduledQueryLogItem& item, const std::string& receiver);
}}

View File

@ -9,7 +9,7 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace logger {

View File

@ -8,7 +8,7 @@
using namespace osquery::db;
using namespace osquery::logger;
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace logger {

View File

@ -6,14 +6,14 @@
#include <memory>
#include "osquery/registry.h"
#include "osquery/core/status.h"
#include "osquery/status.h"
namespace osquery { namespace logger {
class LoggerPlugin {
public:
virtual osquery::core::Status logString(const std::string& s) {
return osquery::core::Status(1, "Not implemented");
virtual osquery::Status logString(const std::string& s) {
return osquery::Status(1, "Not implemented");
}
virtual ~LoggerPlugin() {}
protected:
@ -32,4 +32,4 @@ DECLARE_REGISTRY(
#define REGISTER_LOGGER_PLUGIN(name, decorator) \
REGISTER(LoggerPlugins, name, decorator)
#endif
#endif /* OSQUERY_LOGGER_PLUGIN_H */

View File

@ -10,7 +10,7 @@
#include "scribe/client/ScribeClient.h"
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace logger {

View File

@ -11,7 +11,7 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
using osquery::core::Status;
using osquery::Status;
namespace osquery { namespace logger {

View File

@ -2,26 +2,11 @@
#include <boost/thread.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "osquery/registry.h"
#include "osquery/core.h"
#include "osquery/scheduler.h"
int main(int argc, char *argv[]) {
// you can access this message later via google::ProgramUsage()
google::SetUsageMessage(
"\n"
" OSQuery - operating system instrumentation framework\n"
"\n"
" Arguments\n"
"\n"
" -help Show complete help text\n"
"\n"
);
google::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
osquery::InitRegistry::get().run();
osquery::core::initOsquery(argc, argv);
boost::thread scheduler_thread(osquery::scheduler::initialize);

View File

@ -1,9 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "osquery/core.h"
#include "osquery/devtools.h"
#include "osquery/registry.h"
int main(int argc, char *argv[]) {
osquery::InitRegistry::get().run();
osquery::core::initOsquery(argc, argv);
return osquery::devtools::launchIntoShell(argc, argv);
}

View File

@ -1,7 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#ifndef OSQUERY_REGISTRY_REGISTRY_H
#define OSQUERY_REGISTRY_REGISTRY_H
#ifndef OSQUERY_REGISTRY_H
#define OSQUERY_REGISTRY_H
#include <functional>
#include <string>
@ -78,4 +78,4 @@ class Registry : public std::unordered_map<Key, Value> {
}); \
}
#endif
#endif /* OSQUERY_REGISTRY_H */

View File

@ -44,4 +44,4 @@ struct RegisterInitFunc : private boost::noncopyable {
} // namespace osquery
#endif
#endif /* OSQUERY_REGISTRY_INIT_REGISTRY_H */

View File

@ -7,6 +7,7 @@
#include <map>
#include <mutex>
#include <vector>
#include <boost/noncopyable.hpp>
namespace osquery {
@ -68,4 +69,4 @@ class RegistryTemplate : private boost::noncopyable {
} // namespace osquery
#endif
#endif /* OSQUERY_REGISTRY_REGISTRY_TEMPLATE_H */

View File

@ -25,4 +25,4 @@ class Singleton : private T {
} // namespace osquery
#endif
#endif /* OSQUERY_REGISTRY_SINGLETON_H */

View File

@ -1,11 +1,11 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#ifndef OSQUERY_CORE_STATUS_H
#define OSQUERY_CORE_STATUS_H
#ifndef OSQUERY_STATUS_H
#define OSQUERY_STATUS_H
#include <string>
namespace osquery { namespace core {
namespace osquery {
class Status {
public:
@ -20,6 +20,6 @@ private:
std::string message_;
};
}}
}
#endif /* OSQUERY_CORE_STATUS_H */
#endif /* OSQUERY_STATUS_H */

View File

@ -1,7 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#ifndef TABLES_IMPLEMENTATIONS_EXAMPLE_H
#define TABLES_IMPLEMENTATIONS_EXAMPLE_H
#ifndef OSQUERY_TABLES_IMPLEMENTATIONS_EXAMPLE_H
#define OSQUERY_TABLES_IMPLEMENTATIONS_EXAMPLE_H
#include "osquery/database.h"
@ -11,4 +11,4 @@ osquery::db::QueryData genExample();
}}
#endif
#endif /* OSQUERY_TABLES_IMPLEMENTATIONS_EXAMPLE_H */

View File

@ -1,7 +1,8 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#ifndef _TABLES_FILESYSTEM_H_
#define _TABLES_FILESYSTEM_H_
#ifndef OSQUERY_TABLES_FILESYSTEM_H
#define OSQUERY_TABLES_FILESYSTEM_H
#include "osquery/sqlite3.h"
// Make sure we can call this stuff from C++.
@ -32,4 +33,5 @@ int sqlite3_filesystem_create(
#ifdef __cplusplus
} // End of the 'extern "C"' block
#endif
#endif /* _TABLES_FILESYSTEM_H_ */
#endif /* OSQUERY_TABLES_FILESYSTEM_H */

View File

@ -1,7 +1,8 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#ifndef TABLES_HASH_H
#define TABLES_HASH_H
#ifndef OSQUERY_TABLES_HASH_H
#define OSQUERY_TABLES_HASH_H
#include "osquery/sqlite3.h"
// Make sure we can call this stuff from C++.
@ -32,4 +33,5 @@ int sqlite3_hash_create(
#ifdef __cplusplus
} // End of the 'extern "C"' block
#endif
#endif /* TABLES_HASH_H */
#endif /* OSQUERY_TABLES_HASH_H */

View File

@ -5,7 +5,7 @@
#include <memory>
#include "osquery/core/status.h"
#include "osquery/status.h"
#include "osquery/registry.h"
#include "osquery/sqlite3.h"
@ -33,4 +33,4 @@ DECLARE_REGISTRY(
#define REGISTER_TABLE(name, decorator) \
REGISTER(TablePlugins, name, decorator)
#endif
#endif /* OSQUERY_TABLES_REGISTRY_H */