Skip to content

Commit

Permalink
Add detection for newer version of ErLang/OTP
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre committed May 1, 2024
1 parent ed40833 commit 994e2a1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
15 changes: 13 additions & 2 deletions syft/pkg/cataloger/binary/classifier_cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
},
},
{
logicalFixture: "erlexec/25.3.2.6/linux-amd64",
logicalFixture: "erlang/25.3.2.6/linux-amd64",
expected: pkg.Package{
Name: "erlang",
Version: "25.3.2.6",
Expand All @@ -854,7 +854,7 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
},
},
{
logicalFixture: "erlexec/26.2.0.0/linux-amd64",
logicalFixture: "erlang/26.2.0.0/linux-amd64",
expected: pkg.Package{
Name: "erlang",
Version: "26.2",
Expand All @@ -864,6 +864,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
Metadata: metadata("erlang-binary"),
},
},
{
logicalFixture: "erlang/26.2.4/linux-amd64",
expected: pkg.Package{
Name: "erlang",
Version: "26.2.4",
Type: "binary",
PURL: "pkg:generic/erlang@26.2.4",
Locations: locations("liberts_internal.a"),
Metadata: metadata("erlang-library"),
},
},
{
logicalFixture: "nginx/1.25.1/linux-amd64",
expected: pkg.Package{
Expand Down
21 changes: 19 additions & 2 deletions syft/pkg/cataloger/binary/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,28 @@ func DefaultClassifiers() []Classifier {
EvidenceMatcher: evidenceMatchers(
FileContentsVersionMatcher(
// <artificial>[NUL]/usr/src/otp_src_25.3.2.6/erts/
`(?m)/src/otp_src_(?P<version>[0-9]+\.[0-9]+(\.[0-9]+\.[0-9]+)?)/erts/`,
`(?m)/src/otp_src_(?P<version>[0-9]+\.[0-9]+(\.[0-9]+){0,2}(-rc[0-9])?)/erts/`,
),
FileContentsVersionMatcher(
// <artificial>[NUL]/usr/local/src/otp-25.3.2.7/erts/
`(?m)/usr/local/src/otp-(?P<version>[0-9]+\.[0-9]+(\.[0-9]+\.[0-9]+)?)/erts/`,
`(?m)/usr/local/src/otp-(?P<version>[0-9]+\.[0-9]+(\.[0-9]+){0,2}(-rc[0-9])?)/erts/`,
),
),
Package: "erlang",
PURL: mustPURL("pkg:generic/erlang@version"),
CPEs: singleCPE("cpe:2.3:a:erlang:erlang\\/otp:*:*:*:*:*:*:*:*"),
},
{
Class: "erlang-library",
FileGlob: "**/liberts_internal.a",
EvidenceMatcher: evidenceMatchers(
FileContentsVersionMatcher(
// <artificial>[NUL]/usr/src/otp_src_25.3.2.6/erts/
`(?m)/src/otp_src_(?P<version>[0-9]+\.[0-9]+(\.[0-9]+){0,2}(-rc[0-9])?)/erts/`,
),
FileContentsVersionMatcher(
// <artificial>[NUL]/usr/local/src/otp-25.3.2.7/erts/
`(?m)/usr/local/src/otp-(?P<version>[0-9]+\.[0-9]+(\.[0-9]+){0,2}(-rc[0-9])?)/erts/`,
),
),
Package: "erlang",
Expand Down
Binary file not shown.
14 changes: 12 additions & 2 deletions syft/pkg/cataloger/binary/test-fixtures/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,30 @@ from-images:
paths:
- /usr/local/bin/gcc

- version: 25.3.2.6
- name: erlang
version: 25.3.2.6
images:
- ref: erlang:25.3.2.6@sha256:0d1e530ec0e8047094f0a1d841754515bad9b0554260a3147fb34df31b3064fe
platform: linux/amd64
paths:
- /usr/local/lib/erlang/erts-13.2.2.3/bin/erlexec

- version: 26.2.0.0
- name: erlang
version: 26.2.0.0
images:
- ref: erlang:26.2.0.0@sha256:31c3aa505fbe7526ca83c57b64e56ba505e62733e7e6518f4c06219de6e7396e
platform: linux/amd64
paths:
- /usr/local/lib/erlang/erts-14.2/bin/erlexec

- name: erlang
version: 26.2.4
images:
- ref: erlang:26.2.4.0@sha256:bdb5bac0612856ec85982171dcd4a11de2e08e7f7469c86f3eb936bdfd1ec204
platform: linux/amd64
paths:
- /usr/local/lib/erlang/erts-14.2.4/lib/internal/liberts_internal.a

- version: 1.21.3
images:
- ref: golang:1.21.3@sha256:3ce8313c3513515040870c55e0c041a2b94f3576a58cfd3948633604214aa811
Expand Down

0 comments on commit 994e2a1

Please sign in to comment.