Merge pull request #1054 from theopolis/chrome_profiles

[Fix #1017] Use a fs glob in chrome-extensions searching
This commit is contained in:
Teddy Reed 2015-04-27 11:45:30 -07:00
commit df5ee4aca8
2 changed files with 20 additions and 16 deletions

View File

@ -18,9 +18,9 @@ namespace tables {
/// Each home directory will include custom extensions. /// Each home directory will include custom extensions.
#ifdef __APPLE__ #ifdef __APPLE__
#define kChromePath "/Library/Application Support/Google/Chrome/Default/" #define kChromePath "/Library/Application Support/Google/Chrome/%/"
#else #else
#define kChromePath "/.config/google-chrome/Default/" #define kChromePath "/.config/google-chrome/%/"
#endif #endif
#define kChromeExtensionsPath "Extensions/" #define kChromeExtensionsPath "Extensions/"

View File

@ -76,24 +76,28 @@ QueryData genChromeBasedExtensions(QueryContext& context, const fs::path sub_dir
auto homes = osquery::getHomeDirectories(); auto homes = osquery::getHomeDirectories();
for (const auto& home : homes) { for (const auto& home : homes) {
// For each user, enumerate all of their opera profiles. // For each user, enumerate all of their chrome profiles.
std::vector<std::string> extensions; std::vector<std::string> profiles;
fs::path extension_path = home.string() + sub_dir.string(); fs::path extension_path = home / sub_dir;
if (!listDirectoriesInDirectory(extension_path, extensions).ok()) { if (!resolveFilePattern(extension_path, profiles, REC_LIST_FOLDERS).ok()) {
continue; continue;
} }
// Generate an addons list from their extensions JSON. // For each profile list each extension in the Extensions directory.
for (const auto& extension : extensions) { std::vector<std::string> extensions;
std::vector<std::string> versions; for (const auto& profile : profiles) {
if (!listDirectoriesInDirectory(extension, versions).ok()) { listDirectoriesInDirectory(profile, extensions);
continue; }
}
// Extensions use /<ID>/<VERSION>/manifest.json. // Generate an addons list from their extensions JSON.
for (const auto& version : versions) { std::vector<std::string> versions;
genExtension(version, results); for (const auto& extension : extensions) {
} listDirectoriesInDirectory(extension, versions);
}
// Extensions use /<EXTENSION>/<VERSION>/manifest.json.
for (const auto& version : versions) {
genExtension(version, results);
} }
} }