mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 18:08:53 +00:00
Allow TableOptions::Additional to influence cost (#2694)
This also allows LIKE for OS X's preferences table.
This commit is contained in:
parent
ed13157fe5
commit
8fc8134d17
@ -343,7 +343,7 @@ static int xBestIndex(sqlite3_vtab* tab, sqlite3_index_info* pIdxInfo) {
|
|||||||
if (options & ColumnOptions::REQUIRED) {
|
if (options & ColumnOptions::REQUIRED) {
|
||||||
index_used = true;
|
index_used = true;
|
||||||
required_satisfied = true;
|
required_satisfied = true;
|
||||||
} else if (options & ColumnOptions::INDEX) {
|
} else if (options & (ColumnOptions::INDEX | ColumnOptions::ADDITIONAL)) {
|
||||||
index_used = true;
|
index_used = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,9 +165,8 @@ void genOSXDefaultPreferences(QueryContext& context, QueryData& results) {
|
|||||||
app_map = (CFArrayRef)CFArrayCreateMutable(
|
app_map = (CFArrayRef)CFArrayCreateMutable(
|
||||||
kCFAllocatorDefault, domains.size(), &kCFTypeArrayCallBacks);
|
kCFAllocatorDefault, domains.size(), &kCFTypeArrayCallBacks);
|
||||||
for (const auto& domain : domains) {
|
for (const auto& domain : domains) {
|
||||||
auto cf_domain = CFStringCreateWithCString(kCFAllocatorDefault,
|
auto cf_domain = CFStringCreateWithCString(
|
||||||
domain.c_str(),
|
kCFAllocatorDefault, domain.c_str(), kCFStringEncodingASCII);
|
||||||
kCFStringEncodingASCII);
|
|
||||||
CFArrayAppendValue((CFMutableArrayRef)app_map, cf_domain);
|
CFArrayAppendValue((CFMutableArrayRef)app_map, cf_domain);
|
||||||
CFRelease(cf_domain);
|
CFRelease(cf_domain);
|
||||||
}
|
}
|
||||||
@ -244,9 +243,24 @@ void genOSXPlistPreferences(const std::string& path, QueryData& results) {
|
|||||||
QueryData genOSXPreferences(QueryContext& context) {
|
QueryData genOSXPreferences(QueryContext& context) {
|
||||||
QueryData results;
|
QueryData results;
|
||||||
|
|
||||||
if (context.constraints["path"].exists(EQUALS)) {
|
if (context.constraints["path"].exists(EQUALS | LIKE)) {
|
||||||
// Read preferences from a plist at path.
|
// Resolve file paths for EQUALS and LIKE operations.
|
||||||
auto paths = context.constraints["path"].getAll(EQUALS);
|
auto paths = context.constraints["path"].getAll(EQUALS);
|
||||||
|
context.expandConstraints(
|
||||||
|
"path",
|
||||||
|
LIKE,
|
||||||
|
paths,
|
||||||
|
([&](const std::string& pattern, std::set<std::string>& out) {
|
||||||
|
std::vector<std::string> patterns;
|
||||||
|
auto status =
|
||||||
|
resolveFilePattern(pattern, patterns, GLOB_ALL | GLOB_NO_CANON);
|
||||||
|
if (status.ok()) {
|
||||||
|
for (const auto& resolved : patterns) {
|
||||||
|
out.insert(resolved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}));
|
||||||
for (const auto& path : paths) {
|
for (const auto& path : paths) {
|
||||||
genOSXPlistPreferences(path, results);
|
genOSXPlistPreferences(path, results);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user