2015-02-03 05:21:36 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-02-19 01:19:45 +00:00
|
|
|
#include <osquery/sdk.h>
|
2015-02-03 05:21:36 +00:00
|
|
|
|
2015-02-19 01:19:45 +00:00
|
|
|
using namespace osquery;
|
2015-02-03 05:21:36 +00:00
|
|
|
|
2015-03-13 15:11:08 +00:00
|
|
|
class ExampleConfigPlugin : public ConfigPlugin {
|
|
|
|
public:
|
|
|
|
std::pair<Status, std::string> genConfig() {
|
|
|
|
return std::make_pair(Status(0, "OK"),
|
|
|
|
"{\"options\": [], \"scheduledQueries\": []}");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
class ExampleTable : public tables::TablePlugin {
|
|
|
|
private:
|
2015-02-16 02:15:06 +00:00
|
|
|
tables::TableColumns columns() const {
|
2015-02-03 05:21:36 +00:00
|
|
|
return {{"example_text", "TEXT"}, {"example_integer", "INTEGER"}};
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryData generate(tables::QueryContext& request) {
|
|
|
|
QueryData results;
|
|
|
|
|
|
|
|
Row r;
|
|
|
|
r["example_text"] = "example";
|
|
|
|
r["example_integer"] = INTEGER(1);
|
|
|
|
|
|
|
|
results.push_back(r);
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-03-13 15:11:08 +00:00
|
|
|
REGISTER_EXTERNAL(ExampleConfigPlugin, "config", "example");
|
2015-03-04 02:40:24 +00:00
|
|
|
REGISTER_EXTERNAL(ExampleTable, "table", "example");
|
2015-02-03 05:21:36 +00:00
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
2015-03-03 23:03:14 +00:00
|
|
|
osquery::Initializer runner(argc, argv, OSQUERY_EXTENSION);
|
2015-02-19 01:19:45 +00:00
|
|
|
|
|
|
|
auto status = startExtension("example", "0.0.1");
|
|
|
|
if (!status.ok()) {
|
|
|
|
LOG(ERROR) << status.getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally shutdown.
|
2015-03-03 23:03:14 +00:00
|
|
|
runner.shutdown();
|
2015-02-19 01:19:45 +00:00
|
|
|
return 0;
|
2015-02-03 05:21:36 +00:00
|
|
|
}
|