Repository navigation
fix(echo): retain upstream advisories for Echo packages - #11652
LaizaAngrest wants to merge 5 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@DmitriyLewen I opened this PR with the upstream-baseline + Echo-overlay approach we discussed. Echo advisories override matching primary vulnerability IDs and use the Echo comparer, while unrelated upstream advisories use the ecosystem comparer against the upstream base version. I added coverage for all five Echo language ecosystems and verified it against a fresh DB: fixed Echo CVEs disappeared while unrelated upstream findings remained. Could you please review it when you have time? |
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@DmitriyLewen Follow-up from a full fresh-DB audit: Maven inclusive upstream ranges such as |
|
@DmitriyLewen I added an explicit regression test and documentation for the no-range behavior. The fixture now has a vulnerable upstream advisory and a matching active Echo advisory with no vulnerable or patched versions; The corresponding feed implementation is in https://github.com/buildecho/platform/pull/2215. It publishes only our supported language-package This intentionally relies on the active empty-range Echo advisory replacing the matching upstream advisory. Could you please double-check that this is the behavior you want us to rely on? |
|
Hi @DmitriyLewen, just a gentle reminder when you have time to review this PR. All CI checks are green. The main point we would appreciate your confirmation on is relying on an active Echo advisory without affected ranges to suppress the matching upstream advisory. Thanks! |
|
Hi Laiza, We have a release coming up soon, and right now we're busy with priority tasks for it. As for your question about empty ranges: from the OSV point of view, a package without However, for language packages we use more than just OSV, so we need some time to look at the other sources and decide what to do: make this behavior the default, mark vulnerabilities with statuses, or something else. To give us more information for the discussion, could you please answer two questions:
We'll discuss it with the team and get back to you once we have a decision. Regards, Dmitriy |
|
Hi Dmitriy, Thanks — the empty-range interpretation is clear. Here is a sample based on a current {
"id": "ECHO-042f-77a6-c297",
"upstream": ["CVE-2023-6378"],
"affected": [
{
"package": {
"ecosystem": "Echo:Maven",
"name": "ch.qos.logback:logback-core",
"purl": "pkg:maven/ch.qos.logback/logback-core"
},
"database_specific": {
"status": "not_affected",
"justification": "code_not_in_use"
}
}
]
}The For the second question: no, We understand that the marker is package-wide and could hide a future finding if the package contents change. We will not merge the feed change until this limitation is agreed on. Is this narrow temporary use acceptable, or would you prefer that we publish no no-range entries until we have a lifecycle guarantee or use VEX? Regards, |
This reverts commit c7e0ca6.
|
Hi Dmitriy, After reviewing the lifecycle risk, we decided not to publish package-wide no-range entries for I closed the corresponding Platform PR and removed the no-range regression test and documentation from this Trivy PR. For now, these cases will continue to fall back to upstream, so we accept the known false positives and can consider version-scoped VEX separately. The core of this PR is unchanged: fixed Echo advisories override matching upstream advisories, while unresolved and unrelated vulnerabilities continue to use upstream. This means the empty-range policy no longer needs to block this PR. Please review the remaining core change when your release work allows. Regards, |
|
Hi Laiza, I understand your decision about Now we need to settle the version comparison for Maven. One option: a single comparer for all Echo ecosystems that decides how to compare by itself. // echoComparer evaluates Echo and upstream advisories for an Echo package.
type echoComparer struct {
eco ecosystem.Type
def compare.Comparer // ecosystem comparer for upstream advisories
special compare.Comparer // Echo comparer where "+echo.N" is significant
}
func (c echoComparer) IsVulnerable(ver string, adv dbTypes.Advisory) bool {
if adv.DataSource != nil && adv.DataSource.ID == vulnerability.EchoOSV {
return c.special.IsVulnerable(ver, adv)
}
if c.eco == ecosystem.Maven {
// Maven orders X+echo.N above X, so upstream advisories use the base version.
ver, _, _ = strings.Cut(ver, "+echo.")
}
// pip/npm/NuGet/Go ignore local versions / build metadata by themselves.
return c.def.IsVulnerable(ver, adv)
}Then @knqyf263 what do you think about this approach? Regards, Dmitriy |
|
Thanks, Dmitriy. Your approach makes sense to me. I’ll wait for @knqyf263’s feedback before updating the PR. |
|
I like the idea of keeping the version comparison in What do you think about replacing That also lets Echo return diff --git a/pkg/detector/library/supplier.go b/pkg/detector/library/supplier.go
--- a/pkg/detector/library/supplier.go
+++ b/pkg/detector/library/supplier.go
@@ -25,8 +27,2 @@ const (
Candidate
-
- // MatchedWithUpstream indicates the package definitely belongs to the
- // supplier, but advisories from the default ecosystem bucket are also
- // required. Supplier advisories override default advisories for the same
- // primary vulnerability ID.
- MatchedWithUpstream
)
@@ -51,5 +42,6 @@ type Supplier interface {
- // BucketPrefix returns the advisory bucket prefix for the given ecosystem.
- // For example, "seal pip::" for Seal Security pip packages.
- BucketPrefix(eco ecosystem.Type) string
+ // Advisories returns the advisories to evaluate for the matched package.
+ // pkgName is the normalized package name used for database lookups.
+ // A Candidate must return an empty list if supplier ownership cannot be confirmed.
+ Advisories(dbc db.Config, eco ecosystem.Type, pkgName string) ([]dbTypes.Advisory, error)
diff --git a/pkg/detector/library/echo/echo.go b/pkg/detector/library/echo/echo.go
--- a/pkg/detector/library/echo/echo.go
+++ b/pkg/detector/library/echo/echo.go
@@ -62 +66 @@ func (echoSupplier) Match(eco ecosystem.Type, _, pkgVer string) library.MatchRes
- return library.MatchedWithUpstream
+ return library.Matched
@@ -70 +74 @@ func (echoSupplier) Match(eco ecosystem.Type, _, pkgVer string) library.MatchRes
- return library.MatchedWithUpstream
+ return library.Matched
@@ -86,7 +89,26 @@ func (e echoSupplier) BucketPrefix(eco ecosystem.Type) string {
-// UpstreamVersion removes Echo's local/build metadata so upstream advisories
-// are evaluated against the upstream version from which the Echo build derives.
-func (echoSupplier) UpstreamVersion(pkgVer string) string {
- upstreamVersion, _, _ := strings.Cut(pkgVer, "+echo.")
- return upstreamVersion
+// Advisories combines upstream and Echo advisories, preferring Echo when the
+// primary vulnerability IDs match.
+func (e echoSupplier) Advisories(dbc db.Config, eco ecosystem.Type, pkgName string) ([]dbTypes.Advisory, error) {
+ echoAdvisories, err := dbc.GetAdvisories(e.bucketPrefix(eco), pkgName)
+ if err != nil {
+ return nil, err
+ }
+ upstreamAdvisories, err := dbc.GetAdvisories(string(eco)+"::", pkgName)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get upstream advisories: %w", err)
+ }
+
+ echoIDs := set.New[string]()
+ for _, adv := range echoAdvisories {
+ echoIDs.Append(adv.VulnerabilityID)
+ }
+
+ merged := make([]dbTypes.Advisory, 0, len(upstreamAdvisories)+len(echoAdvisories))
+ for _, adv := range upstreamAdvisories {
+ if !echoIDs.Contains(adv.VulnerabilityID) {
+ merged = append(merged, adv)
+ }
+ }
+ return append(merged, echoAdvisories...), nil
}
diff --git a/pkg/detector/library/seal/seal.go b/pkg/detector/library/seal/seal.go
--- a/pkg/detector/library/seal/seal.go
+++ b/pkg/detector/library/seal/seal.go
@@ -133,2 +134,7 @@ func (s sealSecurity) BucketPrefix(eco ecosystem.Type) string {
+// Advisories returns the advisories from the Seal Security bucket.
+func (s sealSecurity) Advisories(dbc db.Config, eco ecosystem.Type, pkgName string) ([]dbTypes.Advisory, error) {
+ return dbc.GetAdvisories(s.bucketPrefix(eco), pkgName)
+}
+
// Comparer returns a version comparer for the given ecosystem. |
|
Thanks, @knqyf263. I like the idea of replacing When I was thinking about the new So I'd like to propose going one step further: if we move the advisory lookup into
My proposal (sketch below):
A sketch (simplified, error wrapping omitted; // supplier.go
type Supplier interface {
Name() string
// Match reports whether a package may be provided by the supplier.
Match(eco ecosystem.Type, pkgName, pkgVer string) bool
// Advisories returns the advisories to evaluate for the matched package.
Advisories(dbc db.Config, eco ecosystem.Type, pkgName, pkgVer string) ([]dbTypes.Advisory, error)
// Comparer must handle every advisory returned by Advisories.
Comparer(eco ecosystem.Type, defaultComparer compare.Comparer) compare.Comparer
}
// driver.go
func (d *Driver) advisories(pkgName, pkgVer string) ([]dbTypes.Advisory, compare.Comparer, error) {
if v := lookupSupplier(d.ecosystem, pkgName, pkgVer); v != nil {
advisories, err := v.Advisories(d.dbc, d.ecosystem, pkgName, pkgVer)
return advisories, v.Comparer(d.ecosystem, d.comparer), err
}
advisories, err := d.dbc.GetAdvisories(DefaultBucketPrefix(d.ecosystem), pkgName)
return advisories, d.comparer, err
}
// seal.go
func (sealSecurity) Match(eco ecosystem.Type, pkgName, pkgVer string) bool {
return match(eco, pkgName, pkgVer) != noMatch // noMatch/matched/candidate are unexported now
}
func (s sealSecurity) Advisories(dbc db.Config, eco ecosystem.Type, pkgName, pkgVer string) ([]dbTypes.Advisory, error) {
advisories, err := dbc.GetAdvisories(s.bucketPrefix(eco), pkgName)
if err != nil || len(advisories) > 0 || match(eco, pkgName, pkgVer) != candidate {
return advisories, err
}
// A candidate without Seal advisories is not a Seal package.
return dbc.GetAdvisories(library.DefaultBucketPrefix(eco), pkgName)
}However, this approach has one problem: Seal would have to decide what to do with candidates that are not actually its packages, and the Seal comparer is applied to them, which is safe today only because Seal returns the default comparer for npm, Go and RubyGems. // supplier.go
// ok == false: the supplier could not confirm that it owns the package.
Advisories(dbc db.Config, eco ecosystem.Type, pkgName, pkgVer string) (advisories []dbTypes.Advisory, ok bool, err error)
// driver.go
func (d *Driver) advisories(pkgName, pkgVer string) ([]dbTypes.Advisory, compare.Comparer, error) {
if v := lookupSupplier(d.ecosystem, pkgName, pkgVer); v != nil {
advisories, ok, err := v.Advisories(d.dbc, d.ecosystem, pkgName, pkgVer)
if err != nil || ok {
return advisories, v.Comparer(d.ecosystem, d.comparer), err
}
}
advisories, err := d.dbc.GetAdvisories(DefaultBucketPrefix(d.ecosystem), pkgName)
return advisories, d.comparer, err
}
// seal.go (Echo always returns ok == true)
func (s sealSecurity) Advisories(dbc db.Config, eco ecosystem.Type, pkgName, pkgVer string) ([]dbTypes.Advisory, bool, error) {
advisories, err := dbc.GetAdvisories(s.bucketPrefix(eco), pkgName)
if err != nil {
return nil, false, err
}
// A candidate without Seal advisories is not a Seal package.
if len(advisories) == 0 && match(eco, pkgName, pkgVer) == candidate {
return nil, false, nil
}
return advisories, true, nil
}If
What do you think? |
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@knqyf263 @DmitriyLewen I implemented the
The focused library tests, race tests, vet, and Trivy build pass. Could you please take another look? |
Description
Echo language packages were previously routed only to the
echo-osvbucket. This meant unrelated upstream vulnerabilities disappeared as soon as a package version had an Echo suffix.This PR keeps the upstream advisory set as the baseline for Echo packages and overlays Echo advisories on top:
+echo.Nwith the ecosystem's normal comparerIf no active Echo advisory exists for a vulnerability, the upstream advisory remains visible. This is the behavior discussed in #11621.
Version-scoped
not_applicablerecordsThe current Echo feed publishes version-scoped
not_applicabledecisions only as withdrawn records. trivy-db does not store withdrawn records, so there is no active Echo advisory to override the upstream one and a matching upstream finding remains visible. As discussed, those known non-applicable findings can be handled with VEX separately.Testing
go test ./pkg/detector/library/...go test -race ./pkg/detector/library/...go vet ./pkg/detector/library/...go test ./pkg/detector/...golangci-lint run ./...go mod tidywith nogo.modorgo.sumchangesThe test matrix covers PyPI, Maven, npm, NuGet, and Go, including:
<=1.2.3I also tested a fresh vulnerability DB end to end:
org.springframework:spring-webflux5.3.39+echo.1now reports upstreamCVE-2026-22735from the<=5.3.39rangegolang.org/x/net,CVE-2023-45288was removed forv0.22.0+echo.1, while unrelated upstream findings remainedCVE-2026-46600correctly used the Echo advisory and Echo fixed version instead of the matching upstream advisory