Skip to content

Commit

Permalink
Add haskell binaries cataloger (#3078)
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Goderre <[email protected]>
  • Loading branch information
LaurentGoderre authored Sep 10, 2024
1 parent fce14fd commit dbc4238
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
22 changes: 22 additions & 0 deletions syft/pkg/cataloger/binary/classifier_cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,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/[email protected]",
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/[email protected]",
Locations: locations("cabal"),
Metadata: metadata("haskell-cabal-binary"),
},
},
{
logicalFixture: "nginx/1.25.1/linux-amd64",
expected: pkg.Package{
Expand Down
30 changes: 30 additions & 0 deletions syft/pkg/cataloger/binary/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>[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<version>[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<version>[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",
Expand Down
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions syft/pkg/cataloger/binary/test-fixtures/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbc4238

Please sign in to comment.