Skip to content

Commit

Permalink
remove old version of schedule from the codebase and tests (osquery#4707
Browse files Browse the repository at this point in the history
)
  • Loading branch information
guliashvili authored Jul 14, 2018
1 parent 7dd0691 commit 61b6655
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 57 deletions.
29 changes: 1 addition & 28 deletions osquery/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void Config::scheduledQueries(
for (auto& it : pack->getSchedule()) {
std::string name = it.first;
// The query name may be synthetic.
if (pack->getName() != "main" && pack->getName() != "legacy_main") {
if (pack->getName() != "main") {
name = "pack" + FLAGS_pack_delimiter + pack->getName() +
FLAGS_pack_delimiter + it.first;
}
Expand Down Expand Up @@ -572,33 +572,6 @@ Status Config::updateSource(const std::string& source,
}
}

if (doc.doc().HasMember("scheduledQueries") && !rf.external()) {
auto& schedule = doc.doc()["scheduledQueries"];
if (schedule.IsArray()) {
auto queries_doc = JSON::newObject();
auto queries_obj = queries_doc.getObject();

for (auto& query : schedule.GetArray()) {
if (!query.IsObject()) {
// This is a legacy structure, and it is malformed.
continue;
}

std::string query_name;
if (query.HasMember("name") && query["name"].IsString()) {
query_name = query["name"].GetString();
}
if (query_name.empty()) {
return Status(1, "Error getting name from legacy scheduled query");
}
queries_doc.add(query_name, query, queries_obj);
}

queries_doc.add("queries", queries_obj);
addPack("legacy_main", source, queries_doc.doc());
}
}

// extract the "packs" key into additional pack objects
if (doc.doc().HasMember("packs") && !rf.external()) {
auto& packs = doc.doc()["packs"];
Expand Down
3 changes: 2 additions & 1 deletion osquery/tables/system/darwin/block_devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
* You may select, at your option, one of the above-listed licenses.
*/

#include <DiskArbitration/DASession.h>
#include <DiskArbitration/DADisk.h>
#include <DiskArbitration/DASession.h>
#include <boost/lexical_cast.hpp>

#include <osquery/core.h>
#include <osquery/filesystem.h>
Expand Down
1 change: 1 addition & 0 deletions osquery/tables/system/darwin/smbios_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <IOKit/IOKitLib.h>

#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>

#include <osquery/tables.h>

Expand Down
9 changes: 0 additions & 9 deletions tools/tests/test.badconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
// Deprecated query schedule
"scheduledQueries": [
{
"name": "time",
"query": "select * from time;",
"interval": 1
}
],

// New, recommended query schedule
"schedule": {
"time2": {"query": "select * from time;", "interval": 1}
Expand Down
9 changes: 0 additions & 9 deletions tools/tests/test.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
// Deprecated query schedule
"scheduledQueries": [
{
"name": "time",
"query": "select * from time;",
"interval": 1
}
],

// New, recommended query schedule
"schedule": {
"time2": {"query": "select * from time;", "interval": 1}
Expand Down
10 changes: 3 additions & 7 deletions tools/tests/test.config.d/osquery.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"scheduledQueries": [
{
"name": "time_again",
"query": "select * from time;",
"interval": 1
}
],
"schedule": {
"time_again": {"query": "select * from time;", "interval": 1}
},
"options":{
"custom_optionA" : "optiona-val",
"custom_optionB" : "optionb-val"
Expand Down
3 changes: 0 additions & 3 deletions tools/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ def queries_from_config(config_path):
print("Cannot open/parse config: %s" % str(e))
exit(1)
queries = {}
if "scheduledQueries" in config:
for query in config["scheduledQueries"]:
queries[query["name"]] = query["query"]
if "schedule" in config:
for name, details in config["schedule"].iteritems():
queries[name] = details["query"]
Expand Down

0 comments on commit 61b6655

Please sign in to comment.