diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 721ee9ee045..2f0104f7ab8 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -951,6 +951,28 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("swipl-binary"), }, }, + { + logicalFixture: "haskell-ghc/9.6.5/linux-amd64", + expected: pkg.Package{ + Name: "haskell/ghc", + Version: "9.6.5", + Type: "binary", + PURL: "pkg:generic/haskell/ghc@9.6.5", + Locations: locations("ghc-9.6.5"), + Metadata: metadata("haskell-ghc-binary"), + }, + }, + { + logicalFixture: "haskell-cabal/3.10.3.0/linux-amd64", + expected: pkg.Package{ + Name: "haskell/cabal", + Version: "3.10.3.0", + Type: "binary", + PURL: "pkg:generic/haskell/cabal@3.10.3.0", + Locations: locations("cabal"), + Metadata: metadata("haskell-cabal-binary"), + }, + }, { logicalFixture: "nginx/1.25.1/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index 24c514c7e45..1982fd83168 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -447,6 +447,36 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/swipl@version"), CPEs: singleCPE("cpe:2.3:a:erlang:erlang\\/otp:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource), }, + { + Class: "haskell-ghc-binary", + FileGlob: "**/ghc*", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m)\x00GHC (?P[0-9]+\.[0-9]+\.[0-9]+)\x00`, + ), + Package: "haskell/ghc", + PURL: mustPURL("pkg:generic/haskell/ghc@version"), + CPEs: singleCPE("cpe:2.3:a:haskell:ghc:*:*:*:*:*:*:*:*"), + }, + { + Class: "haskell-cabal-binary", + FileGlob: "**/cabal", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m)\x00Cabal-(?P[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)-`, + ), + Package: "haskell/cabal", + PURL: mustPURL("pkg:generic/haskell/cabal@version"), + CPEs: singleCPE("cpe:2.3:a:haskell:cabal:*:*:*:*:*:*:*:*"), + }, + { + Class: "haskell-stack-binary", + FileGlob: "**/stack", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m)Version\s*(?P[0-9]+\.[0-9]+\.[0-9]+),\s*Git`, + ), + Package: "haskell/stack", + PURL: mustPURL("pkg:generic/haskell/stack@version"), + CPEs: singleCPE("cpe:2.3:a:haskell:stack:*:*:*:*:*:*:*:*"), + }, { Class: "consul-binary", FileGlob: "**/consul", diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haskell-cabal/3.10.3.0/linux-amd64/cabal b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haskell-cabal/3.10.3.0/linux-amd64/cabal new file mode 100644 index 00000000000..efc08c38af0 Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haskell-cabal/3.10.3.0/linux-amd64/cabal differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haskell-ghc/9.6.5/linux-amd64/ghc-9.6.5 b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haskell-ghc/9.6.5/linux-amd64/ghc-9.6.5 new file mode 100644 index 00000000000..551b9978c44 Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/haskell-ghc/9.6.5/linux-amd64/ghc-9.6.5 differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index 15273d33d2f..7eb3c553526 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -78,6 +78,22 @@ from-images: paths: - /usr/lib/swipl/bin/x86_64-linux/swipl + - name: haskell-ghc + version: 9.6.5 + images: + - ref: haskell:9.6.5-slim-buster@sha256:04a7293eb792b82335dffa7f08532657517ed9b4f01d52c1b499ad22deb3c6b1 + platform: linux/amd64 + paths: + - /opt/ghc/9.6.5/lib/ghc-9.6.5/bin/ghc-9.6.5 + + - name: haskell-cabal + version: 3.10.3.0 + images: + - ref: haskell:9.6.5-slim-buster@sha256:04a7293eb792b82335dffa7f08532657517ed9b4f01d52c1b499ad22deb3c6b1 + platform: linux/amd64 + paths: + - /usr/local/bin/cabal + - version: 1.21.3 images: - ref: golang:1.21.3@sha256:3ce8313c3513515040870c55e0c041a2b94f3576a58cfd3948633604214aa811