2015-03-04 02:40:24 +00:00
|
|
|
/*
|
2016-02-11 19:48:58 +00:00
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
2015-03-04 02:40:24 +00:00
|
|
|
* 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 <osquery/sdk.h>
|
|
|
|
|
|
|
|
using namespace osquery;
|
|
|
|
|
2015-05-20 20:27:53 +00:00
|
|
|
class ExampleTable : public TablePlugin {
|
2015-03-04 02:40:24 +00:00
|
|
|
private:
|
2016-05-18 19:23:52 +00:00
|
|
|
TableColumns columns() const override {
|
|
|
|
return {
|
2016-08-31 22:32:20 +00:00
|
|
|
std::make_tuple("example_text", TEXT_TYPE, ColumnOptions::DEFAULT),
|
|
|
|
std::make_tuple(
|
|
|
|
"example_integer", INTEGER_TYPE, ColumnOptions::DEFAULT),
|
2016-05-18 19:23:52 +00:00
|
|
|
};
|
2015-03-04 02:40:24 +00:00
|
|
|
}
|
|
|
|
|
2016-05-18 19:23:52 +00:00
|
|
|
QueryData generate(QueryContext& request) override {
|
2015-03-04 02:40:24 +00:00
|
|
|
QueryData results;
|
|
|
|
|
|
|
|
Row r;
|
|
|
|
r["example_text"] = "example";
|
|
|
|
r["example_integer"] = INTEGER(1);
|
|
|
|
|
|
|
|
results.push_back(r);
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-03-05 19:28:27 +00:00
|
|
|
// Create the module if the environment variable TESTFAIL1 is not defined.
|
|
|
|
// This allows the integration tests to, at run time, test the module
|
|
|
|
// loading workflow.
|
|
|
|
CREATE_MODULE_IF(getenv("TESTFAIL1") == nullptr, "example", "0.0.1", "0.0.0");
|
|
|
|
|
|
|
|
void initModule(void) {
|
|
|
|
// Register a plugin from a module if the environment variable TESTFAIL2
|
|
|
|
// is not defined.
|
|
|
|
if (getenv("TESTFAIL2") == nullptr) {
|
|
|
|
REGISTER_MODULE(ExampleTable, "table", "example");
|
|
|
|
}
|
|
|
|
}
|