Add 'maintainer', 'section', 'priority' columns to deb_packages (#6442)

This commit is contained in:
Stefano Bonicatti 2020-05-21 02:55:40 +02:00 committed by GitHub
parent 9373b30375
commit baa8ebe885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

@ -74,7 +74,7 @@ void dpkg_setup(struct pkg_array* packages) {
dpkg_set_progname("osquery");
push_error_context();
dpkg_db_set_dir("/var/lib/dpkg/");
dpkg_db_set_dir(kDPKGPath.c_str());
modstatdb_init();
modstatdb_open(msdbrw_readonly);
@ -101,7 +101,10 @@ const std::map<std::string, std::string> kFieldMappings = {
{"Architecture", "arch"},
{"Source", "source"},
{"Revision", "revision"},
{"Status", "status"}};
{"Status", "status"},
{"Maintainer", "maintainer"},
{"Section", "section"},
{"Priority", "priority"}};
/**
* @brief Field names and function references to extract information.
@ -121,6 +124,9 @@ const struct fieldinfo fieldinfos[] = {
{FIELD("Version"), f_version, w_version, PKGIFPOFF(version)},
{FIELD("Revision"), f_revision, w_revision, 0},
{FIELD("Status"), f_status, w_status, 0},
{FIELD("Maintainer"), f_charfield, w_charfield, PKGIFPOFF(maintainer)},
{FIELD("Priority"), f_priority, w_priority, 0},
{FIELD("Section"), f_section, w_section, 0},
{}};
void extractDebPackageInfo(const struct pkginfo* pkg, QueryData& results) {

View File

@ -7,7 +7,10 @@ schema([
Column("size", BIGINT, "Package size in bytes"),
Column("arch", TEXT, "Package architecture"),
Column("revision", TEXT, "Package revision"),
Column("status", TEXT, "Package status")
Column("status", TEXT, "Package status"),
Column("maintainer", TEXT, "Package maintainer"),
Column("section", TEXT, "Package section"),
Column("priority", TEXT, "Package priority")
])
attributes(cacheable=True)
implementation("system/deb_packages@genDebPackages")

View File

@ -32,7 +32,10 @@ TEST_F(DebPackages, test_sanity) {
{"size", IntType},
{"arch", NonEmptyString},
{"revision", NormalType},
{"status", NonEmptyString}};
{"status", NonEmptyString},
{"maintainer", NonEmptyString},
{"section", NonEmptyString},
{"priority", NonEmptyString}};
validate_rows(rows, row_map);
auto all_packages = std::unordered_set<std::string>{};