diff --git a/include/osquery/filesystem.h b/include/osquery/filesystem.h index d57025a6..131adaf7 100644 --- a/include/osquery/filesystem.h +++ b/include/osquery/filesystem.h @@ -11,7 +11,6 @@ #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 @@ -42,4 +41,3 @@ osquery::Status parsePlistContent(const std::string& fileContent, boost::property_tree::ptree& tree); #endif } -} diff --git a/osquery/core/darwin/test_util.cpp b/osquery/core/darwin/test_util.cpp index 57df9551..09201be8 100644 --- a/osquery/core/darwin/test_util.cpp +++ b/osquery/core/darwin/test_util.cpp @@ -215,7 +215,7 @@ std::string getALFContent() { pt::ptree getALFTree() { auto content = getALFContent(); pt::ptree tree; - fs::parsePlistContent(content, tree); + parsePlistContent(content, tree); return tree; } @@ -358,14 +358,14 @@ std::string getLaunchdContent() { pt::ptree getInfoPlistTree() { auto content = getInfoPlistContent(); pt::ptree tree; - fs::parsePlistContent(content, tree); + parsePlistContent(content, tree); return tree; } pt::ptree getLaunchdTree() { auto content = getLaunchdContent(); pt::ptree tree; - fs::parsePlistContent(content, tree); + parsePlistContent(content, tree); return tree; } } diff --git a/osquery/filesystem/darwin/plist.mm b/osquery/filesystem/darwin/plist.mm index 191fa050..85b212f7 100644 --- a/osquery/filesystem/darwin/plist.mm +++ b/osquery/filesystem/darwin/plist.mm @@ -14,7 +14,6 @@ using osquery::Status; namespace pt = boost::property_tree; namespace osquery { -namespace fs { NSMutableArray* filterArray(id dataStructure); @@ -168,4 +167,3 @@ Status parsePlist(const std::string& path, pt::ptree& tree) { return parsePlistContent(fileContent, tree); } } -} diff --git a/osquery/filesystem/darwin/plist_benchmark.cpp b/osquery/filesystem/darwin/plist_benchmark.cpp index 5fbb91c2..a2fd2d87 100644 --- a/osquery/filesystem/darwin/plist_benchmark.cpp +++ b/osquery/filesystem/darwin/plist_benchmark.cpp @@ -13,7 +13,6 @@ using namespace osquery::core; namespace pt = boost::property_tree; namespace osquery { -namespace fs { // run this benchmark with --iterations=9001 to parse over 9000 property lists DEFINE_int32(iterations, 100, "Iterations to execute"); @@ -53,7 +52,6 @@ TEST_F(PlistBenchmark, bench_parse_plist_content) { << " seconds"; } } -} int main(int argc, char* argv[]) { google::ParseCommandLineFlags(&argc, &argv, true); diff --git a/osquery/filesystem/darwin/plist_tests.cpp b/osquery/filesystem/darwin/plist_tests.cpp index c03bdf91..aaa535a3 100644 --- a/osquery/filesystem/darwin/plist_tests.cpp +++ b/osquery/filesystem/darwin/plist_tests.cpp @@ -11,7 +11,6 @@ using namespace osquery::core; namespace pt = boost::property_tree; namespace osquery { -namespace fs { class PlistTests : public testing::Test {}; @@ -46,7 +45,6 @@ TEST_F(PlistTests, test_parse_plist_content) { EXPECT_EQ(program_arguments_parsed, program_arguments); } } -} int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); diff --git a/osquery/filesystem/filesystem.cpp b/osquery/filesystem/filesystem.cpp index 2b631250..98cbf083 100644 --- a/osquery/filesystem/filesystem.cpp +++ b/osquery/filesystem/filesystem.cpp @@ -14,7 +14,6 @@ using osquery::Status; namespace osquery { -namespace fs { Status readFile(const std::string& path, std::string& content) { if (!boost::filesystem::exists(path)) { @@ -89,4 +88,3 @@ Status listFilesInDirectory(const std::string& path, } } } -} diff --git a/osquery/filesystem/filesystem_tests.cpp b/osquery/filesystem/filesystem_tests.cpp index cde5d14a..71429520 100644 --- a/osquery/filesystem/filesystem_tests.cpp +++ b/osquery/filesystem/filesystem_tests.cpp @@ -10,7 +10,6 @@ #include namespace osquery { -namespace fs { class FilesystemTests : public testing::Test {}; @@ -51,7 +50,6 @@ TEST_F(FilesystemTests, test_list_files_in_directorty) { results.end()); } } -} int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); diff --git a/osquery/tables/networking/etc_hosts.cpp b/osquery/tables/networking/etc_hosts.cpp index 98f480c2..87fc2940 100644 --- a/osquery/tables/networking/etc_hosts.cpp +++ b/osquery/tables/networking/etc_hosts.cpp @@ -13,7 +13,6 @@ #include "osquery/filesystem.h" using namespace osquery::db; -using namespace osquery::fs; namespace osquery { namespace tables { @@ -43,7 +42,7 @@ QueryData parseEtcHostsContent(const std::string& content) { QueryData genEtcHosts() { std::string content; - auto s = readFile("/etc/hosts", content); + auto s = osquery::readFile("/etc/hosts", content); if (s.ok()) { return parseEtcHostsContent(content); } else { diff --git a/osquery/tables/system/darwin/apps.cpp b/osquery/tables/system/darwin/apps.cpp index 1ec97fae..61c7ea87 100644 --- a/osquery/tables/system/darwin/apps.cpp +++ b/osquery/tables/system/darwin/apps.cpp @@ -42,7 +42,7 @@ std::vector getAppInfoPlistPaths() { std::vector slash_applications; auto slash_apps_s = - osquery::fs::listFilesInDirectory("/Applications", slash_applications); + osquery::listFilesInDirectory("/Applications", slash_applications); if (slash_apps_s.ok()) { for (const auto& app_path : slash_applications) { std::string path = app_path + "/Contents/Info.plist"; @@ -55,7 +55,7 @@ std::vector getAppInfoPlistPaths() { } std::vector home_dirs; - auto home_dirs_s = osquery::fs::listFilesInDirectory("/Users", home_dirs); + auto home_dirs_s = osquery::listFilesInDirectory("/Users", home_dirs); if (home_dirs_s.ok()) { for (const auto& home_dir : home_dirs) { for (const auto& dir_to_check : kHomeDirSearchPaths) { @@ -63,7 +63,7 @@ std::vector getAppInfoPlistPaths() { if (boost::filesystem::is_directory(apps_path)) { std::vector user_apps; auto user_apps_s = - osquery::fs::listFilesInDirectory(apps_path, user_apps); + osquery::listFilesInDirectory(apps_path, user_apps); if (!user_apps_s.ok()) { VLOG(1) << "Error listing " << apps_path << ": " << user_apps_s.toString(); @@ -127,7 +127,7 @@ QueryData genApps() { for (const auto& path : getAppInfoPlistPaths()) { pt::ptree tree; - auto s = osquery::fs::parsePlist(path, tree); + auto s = osquery::parsePlist(path, tree); if (s.ok()) { results.push_back(parseInfoPlist(path, tree)); } else { diff --git a/osquery/tables/system/darwin/firewall.cpp b/osquery/tables/system/darwin/firewall.cpp index 11adf848..7108a290 100644 --- a/osquery/tables/system/darwin/firewall.cpp +++ b/osquery/tables/system/darwin/firewall.cpp @@ -52,7 +52,7 @@ const std::map kTopLevelStringKeys = { Status genALFTreeFromFilesystem(pt::ptree& tree) { try { - Status s = osquery::fs::parsePlist(kALFPlistPath, tree); + Status s = osquery::parsePlist(kALFPlistPath, tree); if (!s.ok()) { LOG(ERROR) << "Error parsing " << kALFPlistPath << ": " << s.toString(); return s; diff --git a/osquery/tables/system/darwin/firewall_tests.cpp b/osquery/tables/system/darwin/firewall_tests.cpp index 23022458..884810ad 100644 --- a/osquery/tables/system/darwin/firewall_tests.cpp +++ b/osquery/tables/system/darwin/firewall_tests.cpp @@ -102,7 +102,7 @@ TEST_F(FirewallTests, test_errors) { TEST_F(FirewallTests, test_on_disk_format) { pt::ptree tree; - auto s = osquery::fs::parsePlist(kALFPlistPath, tree); + auto s = osquery::parsePlist(kALFPlistPath, tree); EXPECT_TRUE(s.ok()); EXPECT_EQ(s.toString(), "OK"); for (const auto& it : kTopLevelIntKeys) { diff --git a/osquery/tables/system/darwin/launchd.cpp b/osquery/tables/system/darwin/launchd.cpp index b15fec93..3256156b 100644 --- a/osquery/tables/system/darwin/launchd.cpp +++ b/osquery/tables/system/darwin/launchd.cpp @@ -52,7 +52,7 @@ std::vector getLaunchdFiles() { for (const auto& path : kLaunchdSearchPaths) { std::vector files; - auto s = osquery::fs::listFilesInDirectory(path, files); + auto s = osquery::listFilesInDirectory(path, files); if (s.ok()) { std::copy(files.begin(), files.end(), std::back_inserter(results)); } else { @@ -61,12 +61,12 @@ std::vector getLaunchdFiles() { } std::vector home_dirs; - auto s = osquery::fs::listFilesInDirectory("/Users", home_dirs); + auto s = osquery::listFilesInDirectory("/Users", home_dirs); if (s.ok()) { for (const auto& home_dir : home_dirs) { std::string path = home_dir + "/Library/LaunchAgents"; std::vector files; - auto user_list_s = osquery::fs::listFilesInDirectory(path, files); + auto user_list_s = osquery::listFilesInDirectory(path, files); if (user_list_s.ok()) { std::copy(files.begin(), files.end(), std::back_inserter(results)); } else { @@ -126,7 +126,7 @@ QueryData genLaunchd() { auto launchd_files = getLaunchdFiles(); for (const auto& path : launchd_files) { pt::ptree tree; - auto s = osquery::fs::parsePlist(path, tree); + auto s = osquery::parsePlist(path, tree); if (s.ok()) { results.push_back(parseLaunchdItem(path, tree)); } else { diff --git a/osquery/tables/system/darwin/processes.cpp b/osquery/tables/system/darwin/processes.cpp index 4085e38d..62881982 100644 --- a/osquery/tables/system/darwin/processes.cpp +++ b/osquery/tables/system/darwin/processes.cpp @@ -97,7 +97,7 @@ QueryData genProcesses() { char path[PROC_PIDPATHINFO_MAXSIZE]; proc_pidpath(pids[i], path, sizeof(path)); r["path"] = std::string(path); - r["on_disk"] = osquery::fs::pathExists(r["path"]).toString(); + r["on_disk"] = osquery::pathExists(r["path"]).toString(); // systems usage and time information struct rusage_info_v2 rusage_info_data; diff --git a/osquery/tables/system/linux/processes.cpp b/osquery/tables/system/linux/processes.cpp index f530b710..e3c56842 100644 --- a/osquery/tables/system/linux/processes.cpp +++ b/osquery/tables/system/linux/processes.cpp @@ -90,7 +90,7 @@ QueryData genProcesses() { r["name"] = proc_name(proc_info); r["cmdline"] = proc_cmdline(proc_info); r["path"] = proc_link(proc_info); - r["on_disk"] = osquery::fs::pathExists(r["path"]).toString(); + r["on_disk"] = osquery::pathExists(r["path"]).toString(); r["resident_size"] = boost::lexical_cast(proc_info->vm_rss); r["phys_footprint"] = boost::lexical_cast(proc_info->vm_size);