diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 6d9e23f1a..05b25121a 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -1364,6 +1364,28 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("deno-binary"), }, }, + { + logicalFixture: "haskell-ghc/7.10.3/linux-amd64", + expected: pkg.Package{ + Name: "haskell/ghc", + Version: "7.10.3", + Type: "binary", + PURL: "pkg:generic/haskell/ghc@7.10.3", + Locations: locations("ghc"), + Metadata: metadata("haskell-ghc-binary"), + }, + }, + { + logicalFixture: "haskell-ghc/8.10.4/linux-amd64", + expected: pkg.Package{ + Name: "haskell/ghc", + Version: "8.10.4", + Type: "binary", + PURL: "pkg:generic/haskell/ghc@8.10.4", + Locations: locations("ghc"), + Metadata: metadata("haskell-ghc-binary"), + }, + }, { logicalFixture: "haskell-ghc/9.6.5/linux-amd64", expected: pkg.Package{ @@ -1375,6 +1397,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("haskell-ghc-binary"), }, }, + { + logicalFixture: "haskell-cabal/1.22.6.0/linux-amd64", + expected: pkg.Package{ + Name: "haskell/cabal", + Version: "1.22.6.0", + Type: "binary", + PURL: "pkg:generic/haskell/cabal@1.22.6.0", + Locations: locations("cabal"), + Metadata: metadata("haskell-cabal-binary"), + }, + }, { logicalFixture: "haskell-cabal/3.10.3.0/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index e5a3e2f4e..65f24e666 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -438,8 +438,15 @@ func DefaultClassifiers() []binutils.Classifier { { Class: "haskell-ghc-binary", FileGlob: "**/ghc*", - EvidenceMatcher: m.FileContentsVersionMatcher( - `(?m)\x00GHC (?P[0-9]+\.[0-9]+\.[0-9]+)\x00`, + EvidenceMatcher: binutils.MatchAny( + m.FileContentsVersionMatcher( + `(?m)\x00GHC (?P[0-9]+\.[0-9]+\.[0-9]+)\x00`, + ), + m.FileContentsVersionMatcher( + // [NUL]libHSghc-7.10.3-0AG9TOjDEtx4Ji3wSwHOBe-ghc7.10.3.so[NUL] + // [NUL]libHSghc-8.10.4-ghc8.10.4.so[NUL] + `\x00libHSghc\-(?P[0-9]+\.[0-9]+\.[0-9]+)\-([a-zA-Z0-9]+\-)?ghc[0-9]+\.[0-9]+\.[0-9]+\.so\x00`, + ), ), Package: "haskell/ghc", PURL: mustPURL("pkg:generic/haskell/ghc@version"), @@ -448,8 +455,14 @@ func DefaultClassifiers() []binutils.Classifier { { Class: "haskell-cabal-binary", FileGlob: "**/cabal", - EvidenceMatcher: m.FileContentsVersionMatcher( - `(?m)\x00Cabal-(?P[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)-`, + EvidenceMatcher: binutils.MatchAny( + m.FileContentsVersionMatcher( + `(?m)\x00Cabal-(?P[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)-`, + ), + m.FileContentsVersionMatcher( + // [NUL][NUL][NUL]/opt/cabal/1.22/lib/x86_64-linux-ghc-7.10.2/cabal-install-1.22.6.0-AfxbHivcmw40BMGrAXG3jJ[NUL][NUL][NUL] + `\x00.{0,50}cabal\-install\-(?P[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)\-[a-zA-Z0-9]+\x00+`, + ), ), Package: "haskell/cabal", PURL: mustPURL("pkg:generic/haskell/cabal@version"), diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-cabal/1.22.6.0/linux-amd64/cabal b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-cabal/1.22.6.0/linux-amd64/cabal new file mode 100644 index 000000000..8a1534ed2 Binary files /dev/null and b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-cabal/1.22.6.0/linux-amd64/cabal differ diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-ghc/7.10.3/linux-amd64/ghc b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-ghc/7.10.3/linux-amd64/ghc new file mode 100644 index 000000000..4db6b7ffb Binary files /dev/null and b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-ghc/7.10.3/linux-amd64/ghc differ diff --git a/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-ghc/8.10.4/linux-amd64/ghc b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-ghc/8.10.4/linux-amd64/ghc new file mode 100644 index 000000000..b3e385f00 Binary files /dev/null and b/syft/pkg/cataloger/binary/testdata/classifiers/snippets/haskell-ghc/8.10.4/linux-amd64/ghc differ diff --git a/syft/pkg/cataloger/binary/testdata/config.yaml b/syft/pkg/cataloger/binary/testdata/config.yaml index a161ed732..0100b8315 100644 --- a/syft/pkg/cataloger/binary/testdata/config.yaml +++ b/syft/pkg/cataloger/binary/testdata/config.yaml @@ -147,6 +147,23 @@ from-images: paths: - /usr/bin/deno + # haskell:7.10.3 detail information is missing. + - name: haskell-ghc + version: 7.10.3 + images: + - ref: haskell:7.10.3 + platform: linux/amd64 + paths: + - /opt/ghc/7.10.3/lib/ghc-7.10.3/bin/ghc + + - name: haskell-ghc + version: 8.10.4 + images: + - ref: haskell:8.10.4@sha256:30ecdaee0fd59cdcddf004a68c2d8995ba4212a64106abc3e411742c606e59ac + platform: linux/amd64 + paths: + - /opt/ghc/8.10.4/lib/ghc-8.10.4/bin/ghc + - name: haskell-ghc version: 9.6.5 images: @@ -155,6 +172,15 @@ from-images: paths: - /opt/ghc/9.6.5/lib/ghc-9.6.5/bin/ghc-9.6.5 + # haskell:7.10.3 detail information is missing. + - name: haskell-cabal + version: 1.22.6.0 + images: + - ref: haskell:7.10.3 + platform: linux/amd64 + paths: + - /opt/cabal/1.22/bin/cabal + - name: haskell-cabal version: 3.10.3.0 images: