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.
This commit is contained in:
Sida Chen 2018-10-09 17:33:43 -04:00
parent 3c72fa29a6
commit 3fe894c5ad
2 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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{