Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: build config can specify package CPE #1768

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ type Package struct {
Scriptlets *Scriptlets `json:"scriptlets,omitempty" yaml:"scriptlets,omitempty"`
// Optional: enabling, disabling, and configuration of build checks
Checks Checks `json:"checks,omitempty" yaml:"checks,omitempty"`
// The CPE field values to be used for matching against NVD vulnerability
// records, if known.
CPE CPE `json:"cpe,omitempty" yaml:"cpe,omitempty"`

// Optional: The amount of time to allow this build to take before timing out.
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Expand Down Expand Up @@ -646,6 +649,21 @@ type Configuration struct {
root *yaml.Node
}

// CPE stores values used to produce a CPE to describe the package, suitable for
// matching against NVD records.
//
// For Melange, the "part" attribute should always be interpreted as "a" (for
// "application").
type CPE struct {
Vendor string
Product string
}

// String returns a CPE string for the package.
func (c CPE) String() string {
return fmt.Sprintf("cpe:2.3:a:%s:%s:*:*:*:*:*:*:*:*", c.Vendor, c.Product)
luhring marked this conversation as resolved.
Show resolved Hide resolved
}

// AllPackageNames returns a sequence of all package names in the configuration,
// i.e. the origin package name and the names of all subpackages.
func (cfg Configuration) AllPackageNames() iter.Seq[string] {
Expand Down Expand Up @@ -1168,6 +1186,7 @@ func replacePackage(r *strings.Replacer, commit string, in Package) Package {
Options: in.Options,
Scriptlets: replaceScriptlets(r, in.Scriptlets),
Checks: in.Checks,
CPE: in.CPE,
Timeout: in.Timeout,
Resources: in.Resources,
}
Expand Down
Loading