From 3fe894c5ad7b33223be4a6d52bc0d88fc0fd3a18 Mon Sep 17 00:00:00 2001 From: Sida Chen Date: Tue, 9 Oct 2018 17:33:43 -0400 Subject: [PATCH] database: Add parent feature pointer to Feature struct Feature now has a pointer to parent feature. If a vulnerability affects a parent feature, this child feature will be affected. --- database/models.go | 6 ++++++ database/pgsql/testutil.go | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/database/models.go b/database/models.go index 4c1d0905..58015011 100644 --- a/database/models.go +++ b/database/models.go @@ -165,6 +165,12 @@ type Feature struct { Name string Version string VersionFormat string + + // Parent feature indicates that the vulnerability affects parent feature + // will also affect this feature. + // + // e.g. A source package is the parent feature of a binary package. + Parent *Feature } // NamespacedFeature is a feature with determined namespace and can be affected diff --git a/database/pgsql/testutil.go b/database/pgsql/testutil.go index 1561e59d..7f71bf15 100644 --- a/database/pgsql/testutil.go +++ b/database/pgsql/testutil.go @@ -26,10 +26,10 @@ import ( // int keys must be the consistent with the database ID. var ( realFeatures = map[int]database.Feature{ - 1: {"ourchat", "0.5", "dpkg"}, - 2: {"openssl", "1.0", "dpkg"}, - 3: {"openssl", "2.0", "dpkg"}, - 4: {"fake", "2.0", "rpm"}, + 1: {"ourchat", "0.5", "dpkg", nil}, + 2: {"openssl", "1.0", "dpkg", nil}, + 3: {"openssl", "2.0", "dpkg", nil}, + 4: {"fake", "2.0", "rpm", nil}, } realNamespaces = map[int]database.Namespace{