diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 7ec368b851f..e0f71998d58 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -616,6 +616,16 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("busybox-binary", "[", "busybox"), }, }, + { + logicalFixture: `util-linux/2.37.4/linux-amd64`, + expected: pkg.Package{ + Name: "util-linux", + Version: "2.37.4", + PURL: "pkg:generic/util-linux@2.37.4", + Locations: locations("getopt"), + Metadata: metadata("util-linux-binary"), + }, + }, { logicalFixture: "java-jre-openjdk/1.8.0_352-b08/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index c7ebafa9794..229c513397a 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -173,6 +173,15 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/busybox@version"), CPEs: singleCPE("cpe:2.3:a:busybox:busybox:*:*:*:*:*:*:*:*"), }, + { + Class: "util-linux-binary", + FileGlob: "**/getopt", + EvidenceMatcher: FileContentsVersionMatcher( + `\x00util-linux\s(?P[0-9]+\.[0-9]+\.[0-9]+)\x00`), + Package: "util-linux", + PURL: mustPURL("pkg:generic/util-linux@version"), + CPEs: singleCPE("cpe:2.3:a:kernel:util-linux:*:*:*:*:*:*:*:*"), + }, { Class: "haproxy-binary", FileGlob: "**/haproxy", diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/util-linux/2.37.4/linux-amd64/getopt b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/util-linux/2.37.4/linux-amd64/getopt new file mode 100644 index 00000000000..e27f0695fa6 Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/util-linux/2.37.4/linux-amd64/getopt differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index 9e4ad6325ef..3930bfe39af 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -17,6 +17,14 @@ from-images: paths: - /bin/[ + - name: util-linux + version: 2.37.4 + images: + - ref: cirros:0.6.2@sha256:7ba1f5bc57923f65c99677e53758d386320ed699b621d9630b1f2bd7ceb3a878 + platform: linux/amd64 + paths: + - /usr/bin/getopt + - version: 5.1.16 images: - ref: bash:5.1.16@sha256:c7a903a541d8f5fe693cbe7f5ece18a1b6a03734c76092d2b153d7e98a964927