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

API: Fix pattern matching of purls and document categories in advisory model #497

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions csaf/advisory.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var cpePattern = patternUnmarshal("^(cpe:2\\.3:[aho\\*\\-](:(((\\?*|\\*?)([a-zA-
// PURL represents a package URL in an advisory.
type PURL string

var pURLPattern = patternUnmarshal(`^pkg:[A-Za-z\\.\\-\\+][A-Za-z0-9\\.\\-\\+]*/.+`)
var pURLPattern = patternUnmarshal("^pkg:[A-Za-z\\.\\-\\+][A-Za-z0-9\\.\\-\\+]*/.+")

// XGenericURI represents an identifier for a product.
type XGenericURI struct {
Expand Down Expand Up @@ -223,7 +223,7 @@ type AggregateSeverity struct {
// DocumentCategory represents a category of a document.
type DocumentCategory string

var documentCategoryPattern = patternUnmarshal(`^[^\\s\\-_\\.](.*[^\\s\\-_\\.])?$`)
var documentCategoryPattern = patternUnmarshal("^[^\\s\\-_\\.](.*[^\\s\\-_\\.])?$")

// Version is the version of a document.
type Version string
Expand Down
11 changes: 11 additions & 0 deletions examples/purls_searcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,15 @@ func (uf *urlFinder) findURLs(adv *csaf.Advisory) {
for _, b := range tree.Branches {
recBranch(b)
}

// Third iterate over relationships.
if tree.RelationShips != nil {
for _, rel := range *tree.RelationShips {
if rel != nil {
if fpn := rel.FullProductName; fpn != nil && fpn.ProductID != nil {
add(slices.Index(uf.ids, *fpn.ProductID), fpn.ProductIdentificationHelper)
}
}
}
}
}
Loading