feat(echo): add vulnerability detection for Echo-patched Python packages (#10555)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
This commit is contained in:
authored and GitHub committed 2026-10-01 10:15:55 +00:00
1 parent 3683d7d497
commit 98787b870c
18 files changed
+341 -8

No files matched your search

+15 -1
View File
@@ -27,5 +27,19 @@ See [here](../../scanner/vulnerability.md#data-sources).
## License
Same as [Debian](debian.md#license).
## Language Packages
Echo provides patched versions of language packages.
Trivy identifies them by the version suffix and uses Echo's own security advisories from the [Echo OSV feed][osv-feed] for them instead of the upstream ones.
| Ecosystem | Version Suffix | Example |
|---------------------------------|----------------|----------------------------|
| [Python](../language/python.md) | `+echo.N` | `requests` `2.14.2+echo.1` |
Other packages, including those from other ecosystems, are scanned against the upstream advisories as usual.
!!! note
These packages are detected regardless of the OS, including filesystem and repository scans.
[dependency-graph]: ../../configuration/reporting.md#show-origins-of-vulnerable-dependencies
[advisory]: https://advisory.echohq.com/data.json
[advisory]: https://advisory.echohq.com/data.json
[osv-feed]: https://advisory.echohq.com/osv/all.zip
@@ -174,6 +174,7 @@ trivy filesystem [flags] PATH
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
@@ -195,6 +195,7 @@ trivy image [flags] IMAGE_NAME
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
@@ -183,6 +183,7 @@ trivy kubernetes [flags] [CONTEXT]
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
@@ -173,6 +173,7 @@ trivy repository [flags] (REPO_PATH | REPO_URL)
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
@@ -175,6 +175,7 @@ trivy rootfs [flags] ROOTDIR
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
@@ -140,6 +140,7 @@ trivy sbom [flags] SBOM_PATH
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
@@ -159,6 +159,7 @@ trivy vm [flags] VM_IMAGE
- julia
- bottlerocket
- echo
- echo-osv
- minimos
- rootio
- rapidfort
+1 -1
View File
@@ -24,7 +24,7 @@ require (
github.com/aquasecurity/testdocker v0.0.0-20260423080828-99e7cbfdbe56
github.com/aquasecurity/tml v0.6.1
github.com/aquasecurity/trivy-checks v1.12.2-0.20260908095928-2d1b9bec7d6f
github.com/aquasecurity/trivy-db v0.0.0-20260813095258-0e0340a01b57
github.com/aquasecurity/trivy-db v0.0.0-20261001090913-650c4091f951
github.com/aquasecurity/trivy-java-db v0.0.0-20240109071736-184bd7481d48
github.com/aquasecurity/trivy-kubernetes v0.9.1
github.com/aws/aws-sdk-go-v2 v1.47.0
+2 -2
View File
@@ -168,8 +168,8 @@ github.com/aquasecurity/tml v0.6.1 h1:y2ZlGSfrhnn7t4ZJ/0rotuH+v5Jgv6BDDO5jB6A9gw
github.com/aquasecurity/tml v0.6.1/go.mod h1:OnYMWY5lvI9ejU7yH9LCberWaaTBW7hBFsITiIMY2yY=
github.com/aquasecurity/trivy-checks v1.12.2-0.20260908095928-2d1b9bec7d6f h1:6ahWZW0sOHMX7I3iMyJpTbOWxKF2RJV7UXxiBzzWSXo=
github.com/aquasecurity/trivy-checks v1.12.2-0.20260908095928-2d1b9bec7d6f/go.mod h1:X5OcduRKbgtNvrNrDbNJTmVZcmvOy1T4s4LbzSgpUIM=
github.com/aquasecurity/trivy-db v0.0.0-20260813095258-0e0340a01b57 h1:A3Lz/9ip/qigafSxqBWcu7S8i+tJbQS7DB2V0XibOKs=
github.com/aquasecurity/trivy-db v0.0.0-20260813095258-0e0340a01b57/go.mod h1:iIEV2oGuZScvfyX2SMIn78iVMNnepgo0QuJJh/srgVI=
github.com/aquasecurity/trivy-db v0.0.0-20261001090913-650c4091f951 h1:PXX1UgSc28sNeSSojeu5M9t4qVIW2nd/mFFZ7w/iEvA=
github.com/aquasecurity/trivy-db v0.0.0-20261001090913-650c4091f951/go.mod h1:iIEV2oGuZScvfyX2SMIn78iVMNnepgo0QuJJh/srgVI=
github.com/aquasecurity/trivy-java-db v0.0.0-20240109071736-184bd7481d48 h1:JVgBIuIYbwG+ekC5lUHUpGJboPYiCcxiz06RCtz8neI=
github.com/aquasecurity/trivy-java-db v0.0.0-20240109071736-184bd7481d48/go.mod h1:Ldya37FLi0e/5Cjq2T5Bty7cFkzUDwTcPeQua+2M8i8=
github.com/aquasecurity/trivy-kubernetes v0.9.1 h1:bSErQcavKXDh7XMwbGX7Vy//jR5+xhe/bOgfn9G+9lQ=
+2 -1
View File
@@ -1,10 +1,11 @@
// Package all registers all built-in library vulnerability suppliers.
// Import it for side effects to enable supplier-specific advisory detection
// (e.g., Seal Security):
// (e.g., Seal Security, Echo):
//
// import _ "github.com/aquasecurity/trivy/pkg/detector/library/all"
package all
import (
_ "github.com/aquasecurity/trivy/pkg/detector/library/echo"
_ "github.com/aquasecurity/trivy/pkg/detector/library/seal"
)
+110
View File
@@ -14,6 +14,7 @@ import (
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/types"
_ "github.com/aquasecurity/trivy/pkg/detector/library/echo" // register Echo supplier
_ "github.com/aquasecurity/trivy/pkg/detector/library/seal" // register Seal Security supplier
)
@@ -452,6 +453,115 @@ func TestDriver_Detect(t *testing.T) {
},
},
},
{
name: "echo pip package",
fixtures: []string{
"testdata/fixtures/echo.yaml",
"testdata/fixtures/data-source.yaml",
},
libType: ftypes.PythonPkg,
args: args{
pkgName: "wheel",
pkgVer: "0.45.1+echo.1",
},
want: []types.DetectedVulnerability{
{
VulnerabilityID: "CVE-2026-24049",
VendorIDs: []string{
"ECHO-3d34-cec5-cf72",
},
PkgName: "wheel",
InstalledVersion: "0.45.1+echo.1",
FixedVersion: "0.45.1+echo.2",
DataSource: &dbTypes.DataSource{
ID: "echo-osv",
Name: "Echo OSV",
URL: "https://advisory.echohq.com/osv/all.zip",
},
},
},
},
{
name: "echo pip package with the fixed version",
fixtures: []string{
"testdata/fixtures/echo.yaml",
"testdata/fixtures/data-source.yaml",
},
libType: ftypes.PythonPkg,
args: args{
pkgName: "wheel",
pkgVer: "0.45.1+echo.2",
},
want: nil,
},
{
name: "echo pip package with a newer echo revision than the fixed one",
fixtures: []string{
"testdata/fixtures/echo.yaml",
"testdata/fixtures/data-source.yaml",
},
libType: ftypes.PythonPkg,
args: args{
pkgName: "wheel",
pkgVer: "0.45.1+echo.10",
},
want: nil,
},
{
name: "echo pip package with an upstream fixed version",
fixtures: []string{
"testdata/fixtures/echo.yaml",
"testdata/fixtures/data-source.yaml",
},
libType: ftypes.PythonPkg,
args: args{
pkgName: "torch",
pkgVer: "2.12.0+echo.1",
},
want: []types.DetectedVulnerability{
{
VulnerabilityID: "CVE-2025-3000",
VendorIDs: []string{
"ECHO-9320-f34e-79db",
},
PkgName: "torch",
InstalledVersion: "2.12.0+echo.1",
FixedVersion: "2.13.0",
DataSource: &dbTypes.DataSource{
ID: "echo-osv",
Name: "Echo OSV",
URL: "https://advisory.echohq.com/osv/all.zip",
},
},
},
},
{
name: "echo pip package with the upstream fixed version",
fixtures: []string{
"testdata/fixtures/echo.yaml",
"testdata/fixtures/data-source.yaml",
},
libType: ftypes.PythonPkg,
args: args{
pkgName: "torch",
pkgVer: "2.13.0+echo.1",
},
want: nil,
},
{
name: "echo pip package ignores upstream advisories",
fixtures: []string{
"testdata/fixtures/pip.yaml",
"testdata/fixtures/echo.yaml",
"testdata/fixtures/data-source.yaml",
},
libType: ftypes.PythonPkg,
args: args{
pkgName: "Django",
pkgVer: "4.2.1+echo.1",
},
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
+64
View File
@@ -0,0 +1,64 @@
package echo
import (
"fmt"
"regexp"
"github.com/aquasecurity/trivy-db/pkg/ecosystem"
"github.com/aquasecurity/trivy/pkg/detector/library"
"github.com/aquasecurity/trivy/pkg/detector/library/compare"
"github.com/aquasecurity/trivy/pkg/detector/library/compare/pep440"
)
// echoLocalSegmentRe matches the Echo-specific PEP 440 local version segment,
// e.g. "+echo.1" in "2.14.2+echo.1".
var echoLocalSegmentRe = regexp.MustCompile(`\+echo\.\d+$`)
func init() {
library.RegisterSupplier(echoSupplier{
pipComparer: pep440.NewComparer(pep440.AllowLocalSpecifier()),
})
}
// echoSupplier matches pip packages patched by Echo.
// Echo provides patched versions of Python packages with their own vulnerability
// advisories. Their packages are identified by a PEP 440 local version suffix
// of the form "+echo.N" (e.g. "2.14.2+echo.1").
type echoSupplier struct {
pipComparer compare.Comparer
}
func (echoSupplier) Name() string {
return "echo"
}
// Match determines whether a package is provided by Echo.
// Echo packages are identified by a trailing "+echo.N" segment in the version string,
// where N is a numeric revision (e.g. "2.14.2+echo.1").
// The "+echo.N" local segment cannot collide with real PyPI versions, so a
// suffix match is authoritative (Matched) rather than a Candidate.
func (echoSupplier) Match(eco ecosystem.Type, _, pkgVer string) library.MatchResult {
if eco != ecosystem.Pip {
return library.NoMatch
}
if echoLocalSegmentRe.MatchString(pkgVer) {
return library.Matched
}
return library.NoMatch
}
// BucketPrefix returns the supplier-specific advisory bucket prefix.
func (e echoSupplier) BucketPrefix(eco ecosystem.Type) string {
return fmt.Sprintf("%s %s::", e.Name(), eco)
}
// Comparer returns a version comparer for the given ecosystem.
// For pip (Python), it enables local version specifiers to correctly handle
// Echo version suffixes (e.g. "2.14.2+echo.1").
// For other ecosystems, it returns the default comparer unchanged.
func (e echoSupplier) Comparer(eco ecosystem.Type, defaultComparer compare.Comparer) compare.Comparer {
if eco == ecosystem.Pip {
return e.pipComparer
}
return defaultComparer
}
+99
View File
@@ -0,0 +1,99 @@
package echo
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/aquasecurity/trivy-db/pkg/ecosystem"
"github.com/aquasecurity/trivy/pkg/detector/library"
)
func TestEchoSupplier_Match(t *testing.T) {
tests := []struct {
name string
eco ecosystem.Type
pkgName string
pkgVer string
want library.MatchResult
}{
{
name: "pip package with +echo.N suffix",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+echo.1",
want: library.Matched,
},
{
name: "pip package without echo suffix",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2",
want: library.NoMatch,
},
{
name: "pip package with different local suffix",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+local.1",
want: library.NoMatch,
},
{
name: "non-pip ecosystem is not supported",
eco: ecosystem.Npm,
pkgName: "ejs",
pkgVer: "3.1.8+echo.1",
want: library.NoMatch,
},
{
name: "empty version",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "",
want: library.NoMatch,
},
{
name: "version containing echo but not as local segment",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2-echo.1",
want: library.NoMatch,
},
{
name: "pip package with +echo. but no digits",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+echo.",
want: library.NoMatch,
},
{
name: "pip package with +echo. followed by non-digit",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+echo.beta",
want: library.NoMatch,
},
{
name: "pip package with characters after the echo number",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+echo.1foo",
want: library.NoMatch,
},
{
name: "pip package with another segment after the echo number",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+echo.1.2",
want: library.NoMatch,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
e := echoSupplier{}
got := e.Match(tt.eco, tt.pkgName, tt.pkgVer)
require.Equal(t, tt.want, got)
})
}
}
+13 -3
View File
@@ -11,6 +11,7 @@ import (
"github.com/aquasecurity/trivy/pkg/detector/library/compare"
"github.com/aquasecurity/trivy/pkg/detector/library/compare/pep440"
_ "github.com/aquasecurity/trivy/pkg/detector/library/echo" // register Echo supplier
_ "github.com/aquasecurity/trivy/pkg/detector/library/seal" // register Seal Security supplier
)
@@ -76,13 +77,22 @@ func Test_lookupSupplier(t *testing.T) {
wantDefaultComparer: true,
},
{
name: "non-seal pip package returns no match",
name: "echo pip package returns supplier prefix and pep440 comparer",
eco: ecosystem.Pip,
pkgName: "requests",
pkgVer: "2.14.2+echo.1",
wantMatch: library.Matched,
wantPrefix: "echo pip::",
wantDefaultComparer: false,
},
{
name: "non-supplier pip package returns no match",
eco: ecosystem.Pip,
pkgName: "requests",
wantMatch: library.NoMatch,
},
{
name: "non-seal npm package returns no match",
name: "non-supplier npm package returns no match",
eco: ecosystem.Npm,
pkgName: "ejs",
wantMatch: library.NoMatch,
@@ -102,7 +112,7 @@ func Test_lookupSupplier(t *testing.T) {
// When no custom comparer is needed, the default should be returned unchanged.
assert.Equal(t, defaultComparer, comparer)
} else {
// For seal pip, a custom pep440 comparer with AllowLocalSpecifier should be returned.
// For pip suppliers, a custom pep440 comparer with AllowLocalSpecifier should be returned.
assert.IsType(t, pep440.Comparer{}, comparer)
}
})
@@ -60,3 +60,8 @@
ID: "seal"
Name: "Seal Security Database"
URL: "http://vulnfeed.sealsecurity.io/v1/osv/renamed/vulnerabilities.zip"
- key: "echo pip::Echo OSV"
value:
ID: "echo-osv"
Name: "Echo OSV"
URL: "https://advisory.echohq.com/osv/all.zip"
+22
View File
@@ -0,0 +1,22 @@
- bucket: "echo pip::Echo OSV"
pairs:
- bucket: wheel
pairs:
- key: CVE-2026-24049
value:
VendorIDs:
- ECHO-3d34-cec5-cf72
PatchedVersions:
- "0.45.1+echo.2"
VulnerableVersions:
- "<0.45.1+echo.2"
- bucket: torch
pairs:
- key: CVE-2025-3000
value:
VendorIDs:
- ECHO-9320-f34e-79db
PatchedVersions:
- "2.13.0"
VulnerableVersions:
- "<2.13.0"
+1
View File
@@ -948,6 +948,7 @@
"julia",
"bottlerocket",
"echo",
"echo-osv",
"minimos",
"rootio",
"rapidfort",