clang-format on feature-predicate updates

This commit is contained in:
Teddy Reed 2014-11-29 21:55:14 -08:00
parent 76780aa6f0
commit e33443d354
8 changed files with 40 additions and 34 deletions

View File

@ -117,10 +117,10 @@ struct ConstraintList {
return (!exists() || matches(expr));
}
template<typename T>
template <typename T>
bool existsAndMatches(const T& expr);
template<typename T>
template <typename T>
bool notExistsOrMatches(const T& expr);
/**
@ -167,6 +167,5 @@ struct QueryContext {
typedef struct QueryContext QueryContext;
typedef struct Constraint Constraint;
}
}

View File

@ -125,11 +125,11 @@ static unsigned char PADDING[64] = {0x80,
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.
#define FF(a, b, c, d, x, s, ac) \
{ \
#define FF(a, b, c, d, x, s, ac) \
{ \
(a) += FFF((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
(a) = ROTATE_LEFT((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) \
{ \

View File

@ -10,7 +10,7 @@ namespace tables {
bool ConstraintList::matches(const std::string& expr) {
// Support each affinity type casting.
if (affinity == "TEXT") {
return literal_matches<TEXT_LITERAL>(expr);
return literal_matches<TEXT_LITERAL>(expr);
} else if (affinity == "INTEGER") {
INTEGER_LITERAL lexpr = AS_LITERAL(INTEGER_LITERAL, expr);
return literal_matches<INTEGER_LITERAL>(lexpr);
@ -64,12 +64,12 @@ std::vector<std::string> ConstraintList::getAll(ConstraintOperator op) {
return set;
}
template<typename T>
template <typename T>
bool ConstraintList::existsAndMatches(const T& expr) {
return (exists() && literal_matches<T>(expr));
}
template<typename T>
template <typename T>
bool ConstraintList::notExistsOrMatches(const T& expr) {
return (!exists() || literal_matches<T>(expr));
}

View File

@ -64,24 +64,33 @@ std::vector<std::string> getUserApplications(const std::string& home_dir) {
if (status.ok()) {
for (const auto& user_app : user_apps) {
std::string plist_path = user_app + "/Contents/Info.plist";
if (boost::filesystem::exists(plist_path)) {
results.push_back(plist_path);
}
if (boost::filesystem::exists(plist_path)) {
results.push_back(plist_path);
}
}
} else {
VLOG(1) << "Error listing " << apps_path << ": "
<< status.toString();
VLOG(1) << "Error listing " << apps_path << ": " << status.toString();
}
}
}
return results;
}
std::string getNameFromInfoPlistPath(const std::string& path) {
boost::filesystem::path full = path;
return full.parent_path().parent_path().filename().string();
}
std::string getPathFromInfoPlistPath(const std::string& path) {
boost::filesystem::path full = path;
return full.parent_path().parent_path().string();
}
Row parseInfoPlist(const std::string& path, const pt::ptree& tree) {
Row r;
boost::filesystem::path full = path;
r["name"] = full.parent_path().parent_path().filename().string();
r["path"] = full.parent_path().parent_path().string();
r["name"] = getNameFromInfoPlistPath(path);
r["path"] = getPathFromInfoPlistPath(path);
for (const auto& it : kAppsInfoPlistTopLevelStringKeys) {
try {
r[it.second] = tree.get<std::string>(it.first);
@ -118,7 +127,6 @@ QueryData genApps(QueryContext& context) {
} else {
VLOG(1) << "Error parsing user applications: " << path;
}
}
}

View File

@ -4,16 +4,15 @@
#include <glog/logging.h>
#include "osquery/core/darwin/test_util.h"
#include "osquery/database.h"
#include "osquery/filesystem.h"
#include "osquery/tables.h"
using namespace osquery::core;
namespace pt = boost::property_tree;
namespace osquery {
namespace tables {
std::vector<std::string> getAppInfoPlistPaths();
std::vector<std::string> getSystemApplications();
std::string getNameFromInfoPlistPath(const std::string& path);
std::string getPathFromInfoPlistPath(const std::string& path);
Row parseInfoPlist(const std::string& path, const pt::ptree& tree);
@ -51,7 +50,7 @@ TEST_F(AppsTests, get_path_from_info_plist_path) {
}
TEST_F(AppsTests, test_parse_info_plist) {
auto tree = getInfoPlistTree();
auto tree = osquery::core::getInfoPlistTree();
Row expected = {
{"name", "Foobar.app"},
{"path", "/Applications/Foobar.app"},

View File

@ -60,7 +60,7 @@ static void fillRow(struct udev_device *dev, Row &r) {
}
}
QueryData genBlockDevs(QueryContext& context) {
QueryData genBlockDevs(QueryContext &context) {
QueryData results;
struct udev *udev;
struct udev_enumerate *enumerate;

View File

@ -19,7 +19,7 @@ struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device *dev;
QueryData genPCIDevices(QueryContext& context) {
QueryData genPCIDevices(QueryContext &context) {
QueryData results;
// Create the udev object

View File

@ -16,15 +16,15 @@ QueryData genHash(QueryContext& context) {
auto paths = context.constraints["path"].getAll(EQUALS);
for (const auto& path_string : paths) {
boost::filesystem::path path = path_string;
if (!boost::filesystem::is_regular_file(path)) {
continue;
}
Row r;
r["path"] = path.string();
r["md5"] = std::string(digest.digestFile(path.c_str()));
r["directory"] = path.parent_path().string();
results.push_back(r);
boost::filesystem::path path = path_string;
if (!boost::filesystem::is_regular_file(path)) {
continue;
}
Row r;
r["path"] = path.string();
r["md5"] = std::string(digest.digestFile(path.c_str()));
r["directory"] = path.parent_path().string();
results.push_back(r);
}
auto directories = context.constraints["directory"].getAll(EQUALS);