Skip to content

Commit

Permalink
feat: add binary classifier for avahi
Browse files Browse the repository at this point in the history
avahi usual installs multiple binaries, for classifier
detection the avahi-browse binary is used.

Signed-off-by: Krystian Gorny <[email protected]>
  • Loading branch information
Krystian Gorny committed Sep 24, 2024
1 parent 2d5fd47 commit e5ac697
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions syft/pkg/cataloger/binary/classifier_cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
Metadata: metadata("syslog-ng-binary"),
},
},
{
logicalFixture: "avahi/0.8/linux-amd64",
expected: pkg.Package{
Name: "avahi",
Version: "0.8",
Type: "binary",
PURL: "pkg:generic/[email protected]",
Locations: locations("avahi-browse"),
Metadata: metadata("avahi-binary"),
},
},
}

for _, test := range tests {
Expand Down
10 changes: 10 additions & 0 deletions syft/pkg/cataloger/binary/classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,16 @@ func DefaultClassifiers() []Classifier {
PURL: mustPURL("pkg:generic/syslog-ng@version"),
CPEs: singleCPE("cpe:2.3:a:oneidentity:syslog-ng:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource),
},
{
Class: "avahi-binary",
FileGlob: "**/avahi-browse",
EvidenceMatcher: FileContentsVersionMatcher(
`\x00\x25s (?P<version>[0-9]+\.[0-9]+)\x0a\x00`,
),
Package: "avahi",
PURL: mustPURL("pkg:generic/avahi@version"),
CPEs: singleCPE("cpe:2.3:a:avahi:avahi:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource),
},
}
}

Expand Down
8 changes: 8 additions & 0 deletions syft/pkg/cataloger/binary/test-fixtures/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -695,3 +695,11 @@ from-images:
platform: linux/amd64
paths:
- /usr/sbin/syslog-ng

- name: avahi
version: 0.8
images:
- ref: ydkn/avahi:latest@sha256:0df3de700d2b12f9bc3a4be6b49e04865bd0f92b992c287021c582c9ca90e535
platform: linux/amd64
paths:
- /usr/bin/avahi-browse

0 comments on commit e5ac697

Please sign in to comment.