lib/inspect-apps.c: Match name, display name and publisher across all regexs

For McAfee VirusScan, the name is bogus and the display name is the
actual name:

  <application>
    <name>{CE15D1B6-19B6-4D4D-8F43-CF5D2C3356FF}</name>
    <display_name>McAfee VirusScan Enterprise</display_name>
    <version>8.8.04001</version>
    <install_path>C:Program Files (x86)McAfeeVirusScan Enterprise\</install_path>
    <publisher>McAfee, Inc.</publisher>
    <url>http://www.mcafeesecurity.com/</url>
  </application>

Simplify the existing ad hoc code so we just match name, display name
and publisher (if present) against all the virus scanning strings.
This commit is contained in:
Richard W.M. Jones
2025-11-04 13:22:39 +00:00
committed by rwmjones
parent 3c1554e7f2
commit 344d96e158

View File

@@ -582,7 +582,7 @@ list_applications_apk (guestfs_h *g, const char *root)
} }
static void list_applications_windows_from_path (guestfs_h *g, struct guestfs_application2_list *apps, const char **path, size_t path_len); static void list_applications_windows_from_path (guestfs_h *g, struct guestfs_application2_list *apps, const char **path, size_t path_len);
static const char *get_class_from_windows_app (guestfs_h *g, const char *name, const char *publisher); static const char *get_class_from_windows_app (guestfs_h *g, const char *name, const char *display_name, const char *publisher);
static struct guestfs_application2_list * static struct guestfs_application2_list *
list_applications_windows (guestfs_h *g, const char *root) list_applications_windows (guestfs_h *g, const char *root)
@@ -681,7 +681,7 @@ list_applications_windows_from_path (guestfs_h *g,
if (value) if (value)
comments = guestfs_hivex_value_string (g, value); comments = guestfs_hivex_value_string (g, value);
class_ = get_class_from_windows_app (g, name, publisher); class_ = get_class_from_windows_app (g, name, display_name, publisher);
add_application (g, apps, name, display_name, 0, add_application (g, apps, name, display_name, 0,
version ? : "", version ? : "",
@@ -711,19 +711,29 @@ COMPILE_REGEXP (av_avg_tech, "avg technologies", PCRE2_CASELESS);
static const char * static const char *
get_class_from_windows_app (guestfs_h *g, get_class_from_windows_app (guestfs_h *g,
const char *name, const char *publisher) const char *name,
const char *display_name,
const char *publisher)
{ {
if (name && (match (g, name, av_virus) || const char *fields[] = { name, display_name, publisher };
match (g, name, av_kaspersky) || size_t i;
match (g, name, av_mcafee) ||
match (g, name, av_norton) || for (i = 0; i < sizeof (fields) / sizeof (fields[0]); ++i) {
match (g, name, av_sophos) || const char *field = fields[i];
match (g, name, av_trend)))
return "antivirus"; if (field) {
else if (publisher && match (g, publisher, av_avg_tech)) if (match (g, field, av_virus) ||
return "antivirus"; match (g, field, av_kaspersky) ||
else match (g, field, av_mcafee) ||
return ""; match (g, field, av_norton) ||
match (g, field, av_sophos) ||
match (g, field, av_trend) ||
match (g, field, av_avg_tech))
return "antivirus";
}
}
return "";
} }
static void static void