mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
moving fs to the global namespace
This commit is contained in:
parent
d29c58f795
commit
de426754d9
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <glog/logging.h>
|
||||
|
||||
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);
|
||||
|
@ -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 {
|
||||
|
@ -42,7 +42,7 @@ std::vector<std::string> getAppInfoPlistPaths() {
|
||||
|
||||
std::vector<std::string> 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<std::string> getAppInfoPlistPaths() {
|
||||
}
|
||||
|
||||
std::vector<std::string> 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<std::string> getAppInfoPlistPaths() {
|
||||
if (boost::filesystem::is_directory(apps_path)) {
|
||||
std::vector<std::string> 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 {
|
||||
|
@ -52,7 +52,7 @@ const std::map<std::string, std::string> 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;
|
||||
|
@ -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) {
|
||||
|
@ -52,7 +52,7 @@ std::vector<std::string> getLaunchdFiles() {
|
||||
|
||||
for (const auto& path : kLaunchdSearchPaths) {
|
||||
std::vector<std::string> 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<std::string> getLaunchdFiles() {
|
||||
}
|
||||
|
||||
std::vector<std::string> 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<std::string> 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 {
|
||||
|
@ -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;
|
||||
|
@ -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<std::string>(proc_info->vm_rss);
|
||||
r["phys_footprint"] = boost::lexical_cast<std::string>(proc_info->vm_size);
|
||||
|
Loading…
Reference in New Issue
Block a user