Add support for msix packages by ksykulev · Pull Request #8585 · osquery/osquery

std::string line;
std::string buffer;
while (std::getline(xmlFile, line)) {
if (line.find("<Identity") != std::string::npos) {
buffer += line;

// Continue reading lines until the tag is complete (contains "/>")
while (buffer.find("/>") == std::string::npos &&
std::getline(xmlFile, line)) {
buffer += line;
}
auto attributes = parseAttributes(buffer);
result["name"] = attributes["Name"];
result["publisher"] = attributes["Publisher"];
result["version"] = attributes["Version"];

buffer.clear();
}

if (line.find("<Properties") != std::string::npos) {
buffer += line;

// Continue reading lines until the tag is complete (contains
// "</Properties>")
while (buffer.find("</Properties>") == std::string::npos &&
std::getline(xmlFile, line)) {
buffer += line;
}
auto displayName = extractTagContent(buffer, "DisplayName");
auto publisherDisplayName =
extractTagContent(buffer, "PublisherDisplayName");

// "ms-resource:" prefix means that the string is dynamically
// generated from a .pri file .pri file is a binary index of all
// localized and scaled resources compiled from .resw files or
// .resources at build time
if (!displayName.empty() &&
displayName.find("ms-resource") == std::string::npos) {
result["name"] = displayName;
}
if (!publisherDisplayName.empty() &&
publisherDisplayName.find("ms-resource") == std::string::npos) {
result["publisher"] = publisherDisplayName;
}

buffer.clear();

// done parsing the appxmanifest.xml file for the things we need, so
// we don't have to continue reading the file
break;
}