Skip to content

Commit 1f4f933

Browse files
authored
feat: support envoy bin classifier
Signed-off-by: Rez Moss <hi@rezmoss.com>
1 parent 52a4c3b commit 1f4f933

14 files changed

Lines changed: 213 additions & 0 deletions

File tree

syft/pkg/cataloger/binary/classifier_cataloger_test.go

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,6 +2778,127 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
27782778
},
27792779
},
27802780
},
2781+
{
2782+
logicalFixture: "envoy/1.22.10/linux-amd64",
2783+
expected: pkg.Package{
2784+
Name: "envoy",
2785+
Version: "1.22.10",
2786+
Type: "binary",
2787+
PURL: "pkg:generic/envoy@1.22.10",
2788+
Locations: locations("envoy"),
2789+
Metadata: metadata("envoy-binary"),
2790+
},
2791+
},
2792+
{
2793+
logicalFixture: "envoy/1.24.5/linux-amd64",
2794+
expected: pkg.Package{
2795+
Name: "envoy",
2796+
Version: "1.24.5",
2797+
Type: "binary",
2798+
PURL: "pkg:generic/envoy@1.24.5",
2799+
Locations: locations("envoy"),
2800+
Metadata: metadata("envoy-binary"),
2801+
},
2802+
},
2803+
{
2804+
logicalFixture: "envoy/1.30.2/linux-amd64",
2805+
expected: pkg.Package{
2806+
Name: "envoy",
2807+
Version: "1.30.2",
2808+
Type: "binary",
2809+
PURL: "pkg:generic/envoy@1.30.2",
2810+
Locations: locations("envoy"),
2811+
Metadata: metadata("envoy-binary"),
2812+
},
2813+
},
2814+
{
2815+
logicalFixture: "envoy/1.31.2/linux-amd64",
2816+
expected: pkg.Package{
2817+
Name: "envoy",
2818+
Version: "1.31.2",
2819+
Type: "binary",
2820+
PURL: "pkg:generic/envoy@1.31.2",
2821+
Locations: locations("envoy"),
2822+
Metadata: metadata("envoy-binary"),
2823+
},
2824+
},
2825+
{
2826+
logicalFixture: "envoy/1.34.12/linux-amd64",
2827+
expected: pkg.Package{
2828+
Name: "envoy",
2829+
Version: "1.34.12",
2830+
Type: "binary",
2831+
PURL: "pkg:generic/envoy@1.34.12",
2832+
Locations: locations("envoy"),
2833+
Metadata: metadata("envoy-binary"),
2834+
},
2835+
},
2836+
{
2837+
logicalFixture: "envoy/1.35.4/linux-amd64",
2838+
expected: pkg.Package{
2839+
Name: "envoy",
2840+
Version: "1.35.4",
2841+
Type: "binary",
2842+
PURL: "pkg:generic/envoy@1.35.4",
2843+
Locations: locations("envoy"),
2844+
Metadata: metadata("envoy-binary"),
2845+
},
2846+
},
2847+
{
2848+
logicalFixture: "envoy/1.23.7/linux-amd64",
2849+
expected: pkg.Package{
2850+
Name: "envoy",
2851+
Version: "1.23.7",
2852+
Type: "binary",
2853+
PURL: "pkg:generic/envoy@1.23.7",
2854+
Locations: locations("envoy"),
2855+
Metadata: metadata("envoy-binary"),
2856+
},
2857+
},
2858+
{
2859+
logicalFixture: "envoy/1.24.9/linux-amd64",
2860+
expected: pkg.Package{
2861+
Name: "envoy",
2862+
Version: "1.24.9",
2863+
Type: "binary",
2864+
PURL: "pkg:generic/envoy@1.24.9",
2865+
Locations: locations("envoy"),
2866+
Metadata: metadata("envoy-binary"),
2867+
},
2868+
},
2869+
{
2870+
logicalFixture: "envoy/1.30.1/linux-amd64",
2871+
expected: pkg.Package{
2872+
Name: "envoy",
2873+
Version: "1.30.1",
2874+
Type: "binary",
2875+
PURL: "pkg:generic/envoy@1.30.1",
2876+
Locations: locations("envoy"),
2877+
Metadata: metadata("envoy-binary"),
2878+
},
2879+
},
2880+
{
2881+
logicalFixture: "envoy/1.30.6/linux-amd64",
2882+
expected: pkg.Package{
2883+
Name: "envoy",
2884+
Version: "1.30.6",
2885+
Type: "binary",
2886+
PURL: "pkg:generic/envoy@1.30.6",
2887+
Locations: locations("envoy"),
2888+
Metadata: metadata("envoy-binary"),
2889+
},
2890+
},
2891+
{
2892+
logicalFixture: "envoy/1.36.1/linux-amd64",
2893+
expected: pkg.Package{
2894+
Name: "envoy",
2895+
Version: "1.36.1",
2896+
Type: "binary",
2897+
PURL: "pkg:generic/envoy@1.36.1",
2898+
Locations: locations("envoy"),
2899+
Metadata: metadata("envoy-binary"),
2900+
},
2901+
},
27812902
}
27822903

27832904
for _, test := range tests {

syft/pkg/cataloger/binary/classifiers.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,20 @@ func DefaultClassifiers() []binutils.Classifier {
10761076
m.FileContentsVersionMatcher(`(?s)\[source/.{0,200}\x00(?P<version>1\.1[0-9]\.[0-9]+(-dev)?)\x00`),
10771077
// 1.x [NUL]1.6.0[NUL]RELEASE
10781078
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.[0-9]\.[0-9]+(-dev)?)\x00.{0,20}RELEASE`),
1079+
// contrib 1.3x [NUL]1.34.12[NUL]envoy_quiche... or [NUL]1.30.2[NUL]envoy/extensions... or [NUL]1.30.8[NUL]envoy://
1080+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.3[0-9]\.[0-9]+(-dev)?)\x00envoy[/._:]`),
1081+
// contrib 1.3x [NUL]1.30.7[NUL]...envoy.service or [NUL]1.30.6[NUL]...envoy.data
1082+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.3[0-9]\.[0-9]+(-dev)?)\x00.{0,200}envoy[./]`),
1083+
// contrib1.3x [NUL]1.31.2[NUL]...envoy_quic or [NUL]1.36.x[NUL]...envoy_quic
1084+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.3[0-9]\.[0-9]+(-dev)?)\x00.{0,1000}envoy_quic`),
1085+
// contrib 1.3x [NUL]1.30.1[NUL]TLS client
1086+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.3[0-9]\.[0-9]+(-dev)?)\x00TLS `),
1087+
// contrib 1.2x [NUL]1.24.9[NUL]envoy/extensions...
1088+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.2[0-9]\.[0-9]+(-dev)?)\x00envoy[/._]`),
1089+
// contrib 1.2x [NUL]1.22.10[NUL]...envoy. or [NUL]1.24.5[NUL]...envoy.
1090+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.2[0-9]\.[0-9]+(-dev)?)\x00.{0,500}envoy\.`),
1091+
// contrib 1.2x [NUL]1.23.7[NUL]...envoy_internal
1092+
m.FileContentsVersionMatcher(`(?s)\x00(?P<version>1\.2[0-9]\.[0-9]+(-dev)?)\x00.{0,300}envoy_`),
10791093
),
10801094
Package: "envoy",
10811095
PURL: mustPURL("pkg:generic/envoy@version"),
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)