From e4203224943d03dd69438680bc1544f2745784d4 Mon Sep 17 00:00:00 2001 From: witchcraze <67056980+witchcraze@users.noreply.github.com> Date: Sun, 12 Apr 2026 23:54:08 +0900 Subject: [PATCH] fix: more istio classifier matching (#4645) Signed-off-by: witchcraze --- .../binary/classifier_cataloger_test.go | 88 ++++++++++++++++++ syft/pkg/cataloger/binary/classifiers.go | 16 ++-- .../1.10-dev/linux-amd64/pilot-agent | Bin 0 -> 356 bytes .../1.29.0-alpha.0/linux-amd64/pilot-agent | Bin 0 -> 356 bytes .../1.29.0-beta.0/linux-amd64/pilot-agent | Bin 0 -> 356 bytes .../1.29.0-rc.3/linux-amd64/pilot-agent | Bin 0 -> 356 bytes .../1.10-dev/linux-amd64/pilot-discovery | Bin 0 -> 360 bytes .../linux-amd64/pilot-discovery | Bin 0 -> 360 bytes .../1.29.0-beta.0/linux-amd64/pilot-discovery | Bin 0 -> 360 bytes .../1.29.0-rc.3/linux-amd64/pilot-discovery | Bin 0 -> 360 bytes .../pkg/cataloger/binary/testdata/config.yaml | 64 +++++++++++++ 11 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.10-dev/linux-amd64/pilot-agent create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-alpha.0/linux-amd64/pilot-agent create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-beta.0/linux-amd64/pilot-agent create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-rc.3/linux-amd64/pilot-agent create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.10-dev/linux-amd64/pilot-discovery create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.29.0-alpha.0/linux-amd64/pilot-discovery create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.29.0-beta.0/linux-amd64/pilot-discovery create mode 100644 syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.29.0-rc.3/linux-amd64/pilot-discovery diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index dcb84d898..2c847837a 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -1589,6 +1589,39 @@ func Test_Cataloger_PositiveCases(t *testing.T) { }, }, }, + { + logicalFixture: "istio_pilot-discovery/1.29.0-alpha.0/linux-amd64", + expected: pkg.Package{ + Name: "pilot-discovery", + Version: "1.29.0-alpha.0", + Type: "binary", + PURL: "pkg:generic/istio@1.29.0-alpha.0", + Locations: locations("pilot-discovery"), + Metadata: metadata("istio-binary"), + }, + }, + { + logicalFixture: "istio_pilot-discovery/1.29.0-beta.0/linux-amd64", + expected: pkg.Package{ + Name: "pilot-discovery", + Version: "1.29.0-beta.0", + Type: "binary", + PURL: "pkg:generic/istio@1.29.0-beta.0", + Locations: locations("pilot-discovery"), + Metadata: metadata("istio-binary"), + }, + }, + { + logicalFixture: "istio_pilot-discovery/1.29.0-rc.3/linux-amd64", + expected: pkg.Package{ + Name: "pilot-discovery", + Version: "1.29.0-rc.3", + Type: "binary", + PURL: "pkg:generic/istio@1.29.0-rc.3", + Locations: locations("pilot-discovery"), + Metadata: metadata("istio-binary"), + }, + }, { logicalFixture: "istio_pilot-discovery/1.26.8/linux-amd64", expected: pkg.Package{ @@ -1600,6 +1633,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("istio-binary"), }, }, + { + logicalFixture: "istio_pilot-discovery/1.10-dev/linux-amd64", + expected: pkg.Package{ + Name: "pilot-discovery", + Version: "1.10-dev", + Type: "binary", + PURL: "pkg:generic/istio@1.10-dev", + Locations: locations("pilot-discovery"), + Metadata: metadata("istio-binary"), + }, + }, { logicalFixture: "istio_pilot-discovery/1.8.0/linux-amd64", expected: pkg.Package{ @@ -1633,6 +1677,39 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("istio-binary"), }, }, + { + logicalFixture: "istio_pilot-agent/1.29.0-alpha.0/linux-amd64", + expected: pkg.Package{ + Name: "pilot-agent", + Version: "1.29.0-alpha.0", + Type: "binary", + PURL: "pkg:generic/istio@1.29.0-alpha.0", + Locations: locations("pilot-agent"), + Metadata: metadata("istio-binary"), + }, + }, + { + logicalFixture: "istio_pilot-agent/1.29.0-beta.0/linux-amd64", + expected: pkg.Package{ + Name: "pilot-agent", + Version: "1.29.0-beta.0", + Type: "binary", + PURL: "pkg:generic/istio@1.29.0-beta.0", + Locations: locations("pilot-agent"), + Metadata: metadata("istio-binary"), + }, + }, + { + logicalFixture: "istio_pilot-agent/1.29.0-rc.3/linux-amd64", + expected: pkg.Package{ + Name: "pilot-agent", + Version: "1.29.0-rc.3", + Type: "binary", + PURL: "pkg:generic/istio@1.29.0-rc.3", + Locations: locations("pilot-agent"), + Metadata: metadata("istio-binary"), + }, + }, { logicalFixture: "istio_pilot-agent/1.26.8/linux-amd64", expected: pkg.Package{ @@ -1644,6 +1721,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("istio-binary"), }, }, + { + logicalFixture: "istio_pilot-agent/1.10-dev/linux-amd64", + expected: pkg.Package{ + Name: "pilot-agent", + Version: "1.10-dev", + Type: "binary", + PURL: "pkg:generic/istio@1.10-dev", + Locations: locations("pilot-agent"), + Metadata: metadata("istio-binary"), + }, + }, { logicalFixture: "istio_pilot-agent/1.8.0/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index bd115b5e8..e9692b3cb 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -718,11 +718,13 @@ func DefaultClassifiers() []binutils.Classifier { EvidenceMatcher: binutils.MatchAny( // [NUL]1.26.8[NUL][NUL]1.26.8[NUL] // [NUL]1.3.7[NUL][NUL][NUL]1.3.8[NUL] - m.FileContentsVersionMatcher(`[0-9]+\.[0-9]+\.[0-9]+\x00+(?P[0-9]+\.[0-9]+\.[0-9]+)\x00+`), + m.FileContentsVersionMatcher(`[0-9]+\.[0-9]+\.[0-9]+\x00+(?P[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+|-dev)?)\x00+`), // Clean[NUL][NUL][NUL]1.8.0[NUL] - m.FileContentsVersionMatcher(`Clean\x00+(?P[0-9]+\.[0-9]+\.[0-9]+)\x00+`), + m.FileContentsVersionMatcher(`Clean\x00+(?P[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+|-dev)?)\x00+`), + // Modified[NUL][NUL][NUL][NUL][NUL][NUL][NUL][NUL]1.10-dev[NUL][NUL][NUL] + m.FileContentsVersionMatcher(`Modified\x00+(?P[0-9]+\.[0-9]+-dev)\x00+`), // 1.1.17[NUL]...S=v[0-9]+\.[0-9]+\.[0-9]+)\x00+.{1,100}S?=v[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+|-dev)?)\x00+.{1,100}S?=v[0-9]+\.[0-9]+\.[0-9]+)\x00+`), + m.FileContentsVersionMatcher(`[0-9]+\.[0-9]+\.[0-9]+\x00+(?P[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+|-dev)?)\x00+`), // Clean[NUL][NUL][NUL]1.8.0[NUL] - m.FileContentsVersionMatcher(`Clean\x00+(?P[0-9]+\.[0-9]+\.[0-9]+)\x00+`), + m.FileContentsVersionMatcher(`Clean\x00+(?P[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+|-dev)?)\x00+`), + // Modified[NUL][NUL][NUL][NUL][NUL][NUL][NUL][NUL]1.10-dev[NUL][NUL][NUL] + m.FileContentsVersionMatcher(`Modified\x00+(?P[0-9]+\.[0-9]+-dev)\x00+`), // 1.1.17[NUL]...S=v[0-9]+\.[0-9]+\.[0-9]+)\x00+.{1,100}S?=v[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+|-dev)?)\x00+.{1,100}S?=v+fq|Kk7-pvrUi7hU zt)J<_dsj{5#(mK^C!138YUBOVuZspW>b9@P!TtS8==`EXHrb0Y39BJWC^i>@>axI0 zt{MwiqfZn|2;?yMg(b#GeQwzV%kPHGx>Yju^C>s{XguVBuVKY!gcJq__P K`1}a|!~X!_he}fb literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-alpha.0/linux-amd64/pilot-agent b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-alpha.0/linux-amd64/pilot-agent new file mode 100644 index 0000000000000000000000000000000000000000..f9909838641b7201cc81b88a3a7cf306afed2039 GIT binary patch literal 356 zcmZWjJ5Izf5Z&dE`BfBjmbOG2jh)Qc*$#;tzy+Lmyt`6Jg4PIe5$HGo2ce>%prhp; z;Ao-Z74zoJdo!BW-SABI%chG{H|I8rE`$}wnN)AkeVltV?>LIfHeN)CxhOTM4dzmaT zN|<*l)0pAV4@j!aVCtHF;WGHI*Qs^=PB=L}Iy?~jd%HW^Tbmo>(Z~7a^*Gs&r(drF UzdxPb4g5TMc^kGac5Xj^0BFxz&j0`b literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-beta.0/linux-amd64/pilot-agent b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-beta.0/linux-amd64/pilot-agent new file mode 100644 index 0000000000000000000000000000000000000000..c8e18e905f1b7d5bc071519cef4db93056132b12 GIT binary patch literal 356 zcmZurJ5Izf5Z&dofcaGvbe6V68##77cG4kn1GvCA9`8m9$)YtvTm(7}z(J@ewxFZs z9^jy*;}tXW=Dm5E4sWUA%ckw)4CmBE)`zg7Sn(XRDU6b=rEVS3 z_uvUj1fxp|0ID{Kb>W=$!O0{6S>sWpR0t?@p}h!-JY&=8l)J}BeDfxcJr8}`_76Ns zY?LtX^GxbY5A%S;%1q20Ma;xM{MWQ8-wCHD$47_kV1IA2yR*GD9(`O~-Hem|boTW& U^!4-k{m@@VukXXz<>c=32P~LdZvX%Q literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-rc.3/linux-amd64/pilot-agent b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-agent/1.29.0-rc.3/linux-amd64/pilot-agent new file mode 100644 index 0000000000000000000000000000000000000000..17c5a9235d48ce7d44ad3f01ece08b1cbf47a5cd GIT binary patch literal 356 zcmZurJ5B>J5Z&;{{3;4MODR!S{*4`{<_2&9+dGp)T6QC1gt!QF9DsvRQBZIM?g3r| z4dNB^=Dm3{nl4=9jIWk$pC@6CU1mMe8uN@x3r+%9)?zo$i()9j*4=Wo!hE?13ha!N z(ioG_DMXtzCYQ*CD6OR=4R~lYIxUH)Nr+yOG2S*Vk_uiJFC(L6i@(Pj;idF}gwX;W zqy#F26oOFJ8*tM|!T71O&^WJRG!ei7X=ADE#i$t@kHsWyGq2 zc`s`PwHx{YMfqAxZc?rP)!*iy@>y_ld~|rg_V;#owzoDnM%DZI#nq_f9!@`A27Y@y LyB+wcdVc)^7RFeF literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.10-dev/linux-amd64/pilot-discovery b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.10-dev/linux-amd64/pilot-discovery new file mode 100644 index 0000000000000000000000000000000000000000..a1345a273e7fd29b6c44aa269c2ffdb09f97842b GIT binary patch literal 360 zcmb_WTWZ5F5Olv9bP9pL6IQZzE%^@p>Iw8%H3HW%wMfbBtI+fY9axx|U1oOkpS;Mu zthJp}Ibyx>*Im?{4{nPzmT)F*#md`9yDm~`5XV;bo!k4>YotZa0Rm+JrxSSZbT%P+ zl`v#Ac}!rGPL`avai06F!GH)MlGa)oc1h&2@?RK1F9gS&fI}dT+GK0c!(`%QkzCJ+ z$_AfVV@4tuXYv%4aSD=;LX6`m!@aS5zA0Okxvp#dmVG6Lj<=dhE}S0x0d-MuPJH`S P!|>9{sn6@v_z(R9tqDs! literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.29.0-alpha.0/linux-amd64/pilot-discovery b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/istio_pilot-discovery/1.29.0-alpha.0/linux-amd64/pilot-discovery new file mode 100644 index 0000000000000000000000000000000000000000..47cfa4aed6a8b7817a7f8e74a1826a6af6f23a43 GIT binary patch literal 360 zcmZXOOHRZv42EZT6J9I!k-9`vrH8}v%#!{eQ zU4>+vH`D|qtuZ)-00A+>uu>ljKWUMF(?zeN~zi;w6aZ1CGUU?p|MbIRHh>RQf(4^AqNXYY_Q5u-_iPa&u#To`oo5%>YS&a`Fo@Xo{C5mAwb6U)zyL># zo+rl;w`^S*F~mxfLpBv@EXn&29IJ|f&?rJeAr^~;Y_^%@@0&6w8B^bmPcG~Ny&MG{frt=iWv!{!{xkR%qZhPHp_Ok!v1#QxzaUb zz+uqYac!N^$fOi#rR6R~9w95AWHR2^l!T8Vdc(YDK|7lTD(^^cJNzwUm?0;gtWzE{ zlg#)4Dub IZ!cF5UzrtGZvX%Q literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/testdata/config.yaml b/syft/pkg/cataloger/binary/testdata/config.yaml index eb69ede10..54dfaca3d 100644 --- a/syft/pkg/cataloger/binary/testdata/config.yaml +++ b/syft/pkg/cataloger/binary/testdata/config.yaml @@ -907,6 +907,30 @@ from-images: paths: - /usr/local/lib/python3.11/site-packages/opencv_contrib_python.libs/libavcodec-9aae324f.so.59.37.100 + - name: istio_pilot-discovery + version: 1.29.0-alpha.0 + images: + - ref: istio/pilot:1.29.0-alpha.0@sha256:9ef461d06e22cdfd874043b42292406a3988b50d4ee83ebcd028da85f02f4cf4 + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-discovery + + - name: istio_pilot-discovery + version: 1.29.0-beta.0 + images: + - ref: istio/pilot:1.29.0-beta.0@sha256:d8d347ef47eebff948542243c23c1682c55c20ff0c122a30db5bcfbd8f7b36dd + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-discovery + + - name: istio_pilot-discovery + version: 1.29.0-rc.3 + images: + - ref: istio/pilot:1.29.0-rc.3@sha256:b5f60ecfe3fb34239169b46e01d2b1126f79b3f6da65734bdd3c63cf62042ad2 + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-discovery + - name: istio_pilot-discovery version: 1.26.8 images: @@ -915,6 +939,14 @@ from-images: paths: - /usr/local/bin/pilot-discovery + - name: istio_pilot-discovery + version: 1.10-dev + images: + - ref: istio/pilot:377977f494e3a37d4c77818a77fe677a4e3eb1a5@sha256:c4466fe97d981d31e84a367f1a1df1f7f976b45b96a73483ba04725414aa96e9 + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-discovery + - name: istio_pilot-discovery version: 1.8.0 images: @@ -939,6 +971,30 @@ from-images: paths: - /usr/local/bin/pilot-discovery + - name: istio_pilot-agent + version: 1.29.0-alpha.0 + images: + - ref: istio/proxyv2:1.29.0-alpha.0@sha256:ed845d471e9e85d60ae26f14f166bb09eaef01ed0fede850e688ca18fa304873 + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-agent + + - name: istio_pilot-agent + version: 1.29.0-beta.0 + images: + - ref: istio/proxyv2:1.29.0-beta.0@sha256:a5b9427e7de50149911ce0181c058ee2476999482bd02de5cab52d8456bc6b4d + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-agent + + - name: istio_pilot-agent + version: 1.29.0-rc.3 + images: + - ref: istio/proxyv2:1.29.0-rc.3@sha256:c91bfb91cd4da0c6877b7e675c7b190eca9747bd4e3e1b4f9b3ba3a4246df744 + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-agent + - name: istio_pilot-agent version: 1.26.8 images: @@ -947,6 +1003,14 @@ from-images: paths: - /usr/local/bin/pilot-agent + - name: istio_pilot-agent + version: 1.10-dev + images: + - ref: istio/proxyv2:377977f494e3a37d4c77818a77fe677a4e3eb1a5@sha256:336fd56493fb69a260483adc6a77d773e8c2cba42ac116bfd52d56c16d91f92b + platform: linux/amd64 + paths: + - /usr/local/bin/pilot-agent + - name: istio_pilot-agent version: 1.8.0 images: