void genBrowserPlugin(const std::string& uid, const std::string& path, QueryData& results, bool is_disabled = false) { Row r; pt::ptree tree; r["uid"] = uid; auto info_path = path + "/Contents/Info.plist"; // Ensure that what we're processing is actually a plug-in. if (!pathExists(info_path)) { return; } if (osquery::parsePlist(info_path, tree).ok()) { // Plugin did not include an Info.plist, or it was invalid for (const auto& it : kBrowserPluginKeys) { r[it.second] = tree.get(it.first, ""); // Convert bool-types to an integer. jsonBoolAsInt(r[it.second]); } } if (r.count("native") == 0 || r.at("native").size() == 0) { // The default case for native execution is false. r["native"] = "0"; } r["path"] = path; r["disabled"] = (is_disabled) ? "1" : "0"; results.push_back(std::move(r)); }
void genFirefoxAddonsFromExtensions(const std::string& uid, const std::string& path, QueryData& results) { pt::ptree tree; if (!osquery::parseJSON(path + kFirefoxExtensionsFile, tree).ok()) { TLOG << "Could not parse JSON from: " << path + kFirefoxExtensionsFile; return; } for (const auto& addon : tree.get_child("addons")) { Row r; r["uid"] = uid; // Most of the keys are in the top-level JSON dictionary. for (const auto& it : kFirefoxAddonKeys) { r[it.second] = addon.second.get(it.first, ""); // Convert bool-types to an integer. jsonBoolAsInt(r[it.second]); } // There are several ways to disabled the addon, check each. if (addon.second.get("softDisable", "false") == "true" || addon.second.get("appDisabled", "false") == "true" || addon.second.get("userDisabled", "false") == "true") { r["disabled"] = INTEGER(1); } else { r["disabled"] = INTEGER(0); } results.push_back(r); } }
void genBrowserPlugin(const std::string& uid, const std::string& path, QueryData& results) { Row r; pt::ptree tree; r["uid"] = uid; if (osquery::parsePlist(path + "/Contents/Info.plist", tree).ok()) { // Plugin did not include an Info.plist, or it was invalid for (const auto& it : kBrowserPluginKeys) { r[it.second] = tree.get(it.first, ""); // Convert bool-types to an integer. jsonBoolAsInt(r[it.second]); } } if (r.count("native") == 0 || r.at("native").size() == 0) { // The default case for native execution is false. r["native"] = "0"; } r["path"] = path; results.push_back(std::move(r)); }