Skip to content

Commit

Permalink
database: Update feature model
Browse files Browse the repository at this point in the history
Remove source name/version fields
Add Type field to indicate if it's binary package or source package
  • Loading branch information
KeyboardNerd committed Feb 19, 2019
1 parent 0e0d8b3 commit f616753
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions database/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,33 @@ type Namespace struct {
VersionFormat string
}

func NewNamespace(name string, versionFormat string) *Namespace {
return &Namespace{name, versionFormat}
}

// Feature represents a package detected in a layer but the namespace is not
// determined.
//
// e.g. Name: Libssl1.0, Version: 1.0, Name: Openssl, Version: 1.0, VersionFormat: dpkg.
// e.g. Name: Libssl1.0, Version: 1.0, VersionFormat: dpkg, Type: binary
// dpkg is the version format of the installer package manager, which in this
// case could be dpkg or apk.
type Feature struct {
Name string
Version string
SourceName string
SourceVersion string
VersionFormat string
Type FeatureType
}

func NewFeature(name string, version string, versionFormat string, featureType FeatureType) *Feature {
return &Feature{name, version, versionFormat, featureType}
}

func NewBinaryPackage(name string, version string, versionFormat string) *Feature {
return &Feature{name, version, versionFormat, BinaryPackage}
}

func NewSourcePackage(name string, version string, versionFormat string) *Feature {
return &Feature{name, version, versionFormat, SourcePackage}
}

// NamespacedFeature is a feature with determined namespace and can be affected
Expand All @@ -179,6 +194,11 @@ type NamespacedFeature struct {
Namespace Namespace
}

func NewNamespacedFeature(namespace *Namespace, feature *Feature) *NamespacedFeature {
// TODO: namespaced feature should use pointer values
return &NamespacedFeature{*feature, *namespace}
}

// AffectedNamespacedFeature is a namespaced feature affected by the
// vulnerabilities with fixed-in versions for this feature.
type AffectedNamespacedFeature struct {
Expand Down

0 comments on commit f616753

Please sign in to comment.