Skip to content

Commit

Permalink
feat: add memcached classifier (#1486)
Browse files Browse the repository at this point in the history
Signed-off-by: witchcraze <witchcraze@gmail.com>
  • Loading branch information
witchcraze authored Jan 19, 2023
1 parent 09a5baf commit 7427445
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
17 changes: 16 additions & 1 deletion syft/pkg/cataloger/binary/cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ func TestClassifierCataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
fixtureDir string
expected pkg.Package
}{
{
name: "positive-memcached-1.6.18",
fixtureDir: "test-fixtures/classifiers/positive/memcached-1.6.18",
expected: pkg.Package{
Name: "memcached",
Version: "1.6.18",
Type: "binary",
PURL: "pkg:generic/memcached@1.6.18",
Locations: singleLocation("memcached"),
Metadata: pkg.BinaryMetadata{
Classifier: "memcached-binary",
},
},
},
{
name: "positive-httpd-2.4.54",
fixtureDir: "test-fixtures/classifiers/positive/httpd-2.4.54",
Expand All @@ -30,7 +44,8 @@ func TestClassifierCataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
Classifier: "httpd-binary",
},
},
}, {
},
{
name: "positive-php-cli-8.2.1",
fixtureDir: "test-fixtures/classifiers/positive/php-cli-8.2.1",
expected: pkg.Package{
Expand Down
8 changes: 8 additions & 0 deletions syft/pkg/cataloger/binary/default_classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,12 @@ var defaultClassifiers = []classifier{
PURL: mustPURL("pkg:generic/httpd@version"),
CPEs: singleCPE("cpe:2.3:a:apache:http_server:*:*:*:*:*:*:*:*"),
},
{
Class: "memcached-binary",
FileGlob: "**/memcached",
EvidenceMatcher: fileContentsVersionMatcher(
`(?m)memcached\s(?P<version>[0-9]+\.[0-9]+\.[0-9]+)`),
Package: "memcached",
PURL: mustPURL("pkg:generic/memcached@version"),
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
secs_since_last_cmd
listen
memcached 1.6.18
udp-port
memcached 1.6.18
Failed to allocate memory
%s,%s
--
bget
flush_all
VERSION 1.6.18
quit
BADCLASS invalid class id

0 comments on commit 7427445

Please sign in to comment.