Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions syft/pkg/cataloger/binary/cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,18 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
Metadata: metadata("ruby-binary"),
},
},
{
name: "positive-consul-1.15.2",
fixtureDir: "test-fixtures/classifiers/dynamic/consul-1.15.2",
expected: pkg.Package{
Name: "consul",
Version: "1.15.2",
Type: "binary",
PURL: "pkg:golang/github.com/hashicorp/consul@1.15.2",
Locations: locations("consul"),
Metadata: metadata("consul-binary"),
},
},
}

for _, test := range tests {
Expand Down
11 changes: 11 additions & 0 deletions syft/pkg/cataloger/binary/default_classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ var defaultClassifiers = []classifier{
PURL: mustPURL("pkg:generic/ruby@version"),
CPEs: singleCPE("cpe:2.3:a:ruby-lang:ruby:*:*:*:*:*:*:*:*"),
},
{
Class: "consul-binary",
FileGlob: "**/consul",
EvidenceMatcher: fileContentsVersionMatcher(
// NOTE: This is brittle and may not work for past or future versions
`CONSUL_VERSION: (?P<version>\d+\.\d+\.\d+)`,
),
Package: "consul",
PURL: mustPURL("pkg:golang/github.com/hashicorp/consul@version"),
CPEs: singleCPE("cpe:2.3:a:hashicorp:consul:*:*:*:*:*:*:*:*"),
},
}

// in both binaries and shared libraries, the version pattern is [NUL]3.11.2[NUL]
Expand Down
10 changes: 9 additions & 1 deletion syft/pkg/cataloger/binary/test-fixtures/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ all: \
classifiers/dynamic/kubectl-1.25.7 \
classifiers/dynamic/kubectl-1.26.2 \
classifiers/dynamic/kustomize-4.5.7 \
classifiers/dynamic/kustomize-5.0.0
classifiers/dynamic/kustomize-5.0.0 \
classifiers/dynamic/consul-1.15.2



classifiers/dynamic/python-binary-shared-lib-3.11:
Expand Down Expand Up @@ -141,6 +143,12 @@ classifiers/dynamic/kustomize-5.0.0:
/usr/local/bin/kustomize \
$@/kustomize

classifiers/dynamic/consul-1.15.2:
$(eval $@_image := "hashicorp/consul:1.15.2@sha256:c2169f3bb18dd947ae8eb5f6766896695c71fb439f050a3343e0007d895615b8")
./get-image-file.sh $($@_image) \
/bin/consul \
$@/consul

.PHONY: clean
clean:
rm -rf classifiers/dynamic
Expand Down