mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 00:43:20 +01:00
add remaining binary cataloger patterns and snippets
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
e516eb4967
commit
d849719605
2
.github/workflows/validations.yaml
vendored
2
.github/workflows/validations.yaml
vendored
@ -57,7 +57,7 @@ jobs:
|
|||||||
- name: Restore binary cataloger test-fixture cache
|
- name: Restore binary cataloger test-fixture cache
|
||||||
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
|
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
|
||||||
with:
|
with:
|
||||||
path: syft/pkg/cataloger/binary/test-fixtures/classifiers/dynamic
|
path: syft/pkg/cataloger/binary/test-fixtures/classifiers/bin
|
||||||
key: ${{ runner.os }}-unit-binary-cataloger-cache-${{ hashFiles( 'syft/pkg/cataloger/binary/test-fixtures/cache.fingerprint' ) }}
|
key: ${{ runner.os }}-unit-binary-cataloger-cache-${{ hashFiles( 'syft/pkg/cataloger/binary/test-fixtures/cache.fingerprint' ) }}
|
||||||
|
|
||||||
- name: Restore Kernel test-fixture cache
|
- name: Restore Kernel test-fixture cache
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/testutil"
|
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -17,12 +16,13 @@ import (
|
|||||||
"github.com/anchore/stereoscope/pkg/imagetest"
|
"github.com/anchore/stereoscope/pkg/imagetest"
|
||||||
"github.com/anchore/syft/syft/file"
|
"github.com/anchore/syft/syft/file"
|
||||||
"github.com/anchore/syft/syft/pkg"
|
"github.com/anchore/syft/syft/pkg"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/testutil"
|
||||||
"github.com/anchore/syft/syft/source"
|
"github.com/anchore/syft/syft/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
var mustUseOriginalBinaries = flag.Bool("must-use-original-binaries", false, "force the use of binaries for testing (instead of snippets)")
|
var mustUseOriginalBinaries = flag.Bool("must-use-original-binaries", false, "force the use of binaries for testing (instead of snippets)")
|
||||||
|
|
||||||
func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
func Test_Cataloger_PositiveCases(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
logicalFixture string
|
logicalFixture string
|
||||||
@ -61,18 +61,19 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("postgresql-binary"),
|
Metadata: metadata("postgresql-binary"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO: missing original binary
|
{
|
||||||
//{
|
// TODO: find original binary...
|
||||||
// logicalFixture: "postgres/9.5alpha1/linux-amd64",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// expected: pkg.Package{
|
logicalFixture: "postgres/9.5alpha1/linux-amd64",
|
||||||
// Name: "postgresql",
|
expected: pkg.Package{
|
||||||
// Version: "9.5alpha1",
|
Name: "postgresql",
|
||||||
// Type: "binary",
|
Version: "9.5alpha1",
|
||||||
// PURL: "pkg:generic/postgresql@9.5alpha1",
|
Type: "binary",
|
||||||
// Locations: locations("postgres"),
|
PURL: "pkg:generic/postgresql@9.5alpha1",
|
||||||
// Metadata: metadata("postgresql-binary"),
|
Locations: locations("postgres"),
|
||||||
// },
|
Metadata: metadata("postgresql-binary"),
|
||||||
//},
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
logicalFixture: "mysql/8.0.34/linux-amd64",
|
logicalFixture: "mysql/8.0.34/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
@ -106,29 +107,28 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("mariadb-binary"),
|
Metadata: metadata("mariadb-binary"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO: need to add original binary
|
{
|
||||||
//{
|
logicalFixture: "traefik/1.7.34/linux-amd64",
|
||||||
// logicalFixture: "traefik/2.9.6/linux-amd64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "traefik",
|
||||||
// Name: "traefik",
|
Version: "1.7.34",
|
||||||
// Version: "2.9.6",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/traefik@1.7.34",
|
||||||
// PURL: "pkg:generic/traefik@2.9.6",
|
Locations: locations("traefik"),
|
||||||
// Locations: locations("traefik"),
|
Metadata: metadata("traefik-binary"),
|
||||||
// Metadata: metadata("traefik-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
logicalFixture: "traefik/2.9.6/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/traefik-1.7.34/linux-amd64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "traefik",
|
||||||
// Name: "traefik",
|
Version: "2.9.6",
|
||||||
// Version: "1.7.34",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/traefik@2.9.6",
|
||||||
// PURL: "pkg:generic/traefik@1.7.34",
|
Locations: locations("traefik"),
|
||||||
// Locations: locations("traefik"),
|
Metadata: metadata("traefik-binary"),
|
||||||
// Metadata: metadata("traefik-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
|
||||||
{
|
{
|
||||||
logicalFixture: "memcached/1.6.18/linux-amd64",
|
logicalFixture: "memcached/1.6.18/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
@ -151,78 +151,84 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("httpd-binary"),
|
Metadata: metadata("httpd-binary"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
// TODO: missing original binaries
|
// TODO: find original binary...
|
||||||
//{
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/php-cli-8.2.1/linux-amd64",
|
logicalFixture: "php-cli/8.2.1/linux-amd64",
|
||||||
// expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
// Name: "php-cli",
|
Name: "php-cli",
|
||||||
// Version: "8.2.1",
|
Version: "8.2.1",
|
||||||
// Type: "binary",
|
Type: "binary",
|
||||||
// PURL: "pkg:generic/php-cli@8.2.1",
|
PURL: "pkg:generic/php-cli@8.2.1",
|
||||||
// Locations: locations("php"),
|
Locations: locations("php"),
|
||||||
// Metadata: metadata("php-cli-binary"),
|
Metadata: metadata("php-cli-binary"),
|
||||||
// },
|
},
|
||||||
//},
|
},
|
||||||
//{
|
{
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/php-fpm-8.2.1/linux-amd64",
|
// TODO: find original binary...
|
||||||
// expected: pkg.Package{
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// Name: "php-fpm",
|
logicalFixture: "php-fpm/8.2.1/linux-amd64",
|
||||||
// Version: "8.2.1",
|
expected: pkg.Package{
|
||||||
// Type: "binary",
|
Name: "php-fpm",
|
||||||
// PURL: "pkg:generic/php-fpm@8.2.1",
|
Version: "8.2.1",
|
||||||
// Locations: locations("php-fpm"),
|
Type: "binary",
|
||||||
// Metadata: metadata("php-fpm-binary"),
|
PURL: "pkg:generic/php-fpm@8.2.1",
|
||||||
// },
|
Locations: locations("php-fpm"),
|
||||||
//},
|
Metadata: metadata("php-fpm-binary"),
|
||||||
//{
|
},
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/php-apache-8.2.1/linux-amd64",
|
},
|
||||||
// expected: pkg.Package{
|
{
|
||||||
// Name: "libphp",
|
// TODO: find original binary...
|
||||||
// Version: "8.2.1",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// Type: "binary",
|
logicalFixture: "php-apache/8.2.1/linux-amd64",
|
||||||
// PURL: "pkg:generic/php@8.2.1",
|
expected: pkg.Package{
|
||||||
// Locations: locations("libphp.so"),
|
Name: "libphp",
|
||||||
// Metadata: metadata("php-apache-binary"),
|
Version: "8.2.1",
|
||||||
// },
|
Type: "binary",
|
||||||
//},
|
PURL: "pkg:generic/php@8.2.1",
|
||||||
|
Locations: locations("libphp.so"),
|
||||||
// TODO: original binary is different than test fixture
|
Metadata: metadata("php-apache-binary"),
|
||||||
//{
|
},
|
||||||
// logicalFixture: "perl/5.12.5/linux-amd64",
|
},
|
||||||
// expected: pkg.Package{
|
{
|
||||||
// Name: "perl",
|
// TODO: original binary is different than whats in config.yaml
|
||||||
// Version: "5.12.5",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// Type: "binary",
|
logicalFixture: "perl/5.12.5/linux-amd64",
|
||||||
// PURL: "pkg:generic/perl@5.12.5",
|
expected: pkg.Package{
|
||||||
// Locations: locations("perl"),
|
Name: "perl",
|
||||||
// Metadata: metadata("perl-binary"),
|
Version: "5.12.5",
|
||||||
// },
|
Type: "binary",
|
||||||
//},
|
PURL: "pkg:generic/perl@5.12.5",
|
||||||
//{
|
Locations: locations("perl"),
|
||||||
// name: "positive-perl-5.20.0",
|
Metadata: metadata("perl-binary"),
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/perl-5.20.0/linux-amd64",
|
},
|
||||||
// expected: pkg.Package{
|
},
|
||||||
// Name: "perl",
|
{
|
||||||
// Version: "5.20.0",
|
// TODO: original binary is different than whats in config.yaml
|
||||||
// Type: "binary",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// PURL: "pkg:generic/perl@5.20.0",
|
logicalFixture: "perl/5.20.0/linux-amd64",
|
||||||
// Locations: locations("perl"),
|
expected: pkg.Package{
|
||||||
// Metadata: metadata("perl-binary"),
|
Name: "perl",
|
||||||
// },
|
Version: "5.20.0",
|
||||||
//},
|
Type: "binary",
|
||||||
//{
|
PURL: "pkg:generic/perl@5.20.0",
|
||||||
// name: "positive-perl-5.37.8",
|
Locations: locations("perl"),
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/perl-5.37.8/linux-amd64",
|
Metadata: metadata("perl-binary"),
|
||||||
// expected: pkg.Package{
|
},
|
||||||
// Name: "perl",
|
},
|
||||||
// Version: "5.37.8",
|
{
|
||||||
// Type: "binary",
|
// TODO: original binary is different than whats in config.yaml
|
||||||
// PURL: "pkg:generic/perl@5.37.8",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// Locations: locations("perl"),
|
logicalFixture: "perl/5.37.8/linux-amd64",
|
||||||
// Metadata: metadata("perl-binary"),
|
expected: pkg.Package{
|
||||||
// },
|
Name: "perl",
|
||||||
//},
|
Version: "5.37.8",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/perl@5.37.8",
|
||||||
|
Locations: locations("perl"),
|
||||||
|
Metadata: metadata("perl-binary"),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
logicalFixture: "haproxy/1.5.14/linux-amd64",
|
logicalFixture: "haproxy/1.5.14/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
@ -280,116 +286,112 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: missing original binaries
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-2.8.23/linux-amd64",
|
logicalFixture: "redis-server/2.8.23/linux-amd64",
|
||||||
// expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
// Name: "redis",
|
Name: "redis",
|
||||||
// Version: "2.8.23",
|
Version: "2.8.23",
|
||||||
// Type: "binary",
|
Type: "binary",
|
||||||
// PURL: "pkg:generic/redis@2.8.23",
|
PURL: "pkg:generic/redis@2.8.23",
|
||||||
// Locations: locations("redis-server"),
|
Locations: locations("redis-server"),
|
||||||
// Metadata: metadata("redis-binary"),
|
Metadata: metadata("redis-binary"),
|
||||||
// },
|
},
|
||||||
//},
|
},
|
||||||
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-4.0.11",
|
logicalFixture: "redis-server/4.0.11/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-4.0.11/linux-amd64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "4.0.11",
|
||||||
// Version: "4.0.11",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@4.0.11",
|
||||||
// PURL: "pkg:generic/redis@4.0.11",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-5.0.0",
|
logicalFixture: "redis-server/5.0.0/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-5.0.0/linux-amd64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "5.0.0",
|
||||||
// Version: "5.0.0",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@5.0.0",
|
||||||
// PURL: "pkg:generic/redis@5.0.0",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-6.0.16",
|
logicalFixture: "redis-server/6.0.16/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-6.0.16",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "6.0.16",
|
||||||
// Version: "6.0.16",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@6.0.16",
|
||||||
// PURL: "pkg:generic/redis@6.0.16",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-7.0.0",
|
logicalFixture: "redis-server/7.0.0/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-7.0.0",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "7.0.0",
|
||||||
// Version: "7.0.0",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@7.0.0",
|
||||||
// PURL: "pkg:generic/redis@7.0.0",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-7.0.14",
|
logicalFixture: "redis-server/7.0.14/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-7.0.14",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "7.0.14",
|
||||||
// Version: "7.0.14",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@7.0.14",
|
||||||
// PURL: "pkg:generic/redis@7.0.14",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-7.2.3-amd64",
|
logicalFixture: "redis-server/7.2.3/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-7.2.3-amd64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "7.2.3",
|
||||||
// Version: "7.2.3",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@7.2.3",
|
||||||
// PURL: "pkg:generic/redis@7.2.3",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// note: dynamic (non-snippet) test case
|
||||||
// name: "positive-redis-7.2.3-arm64",
|
logicalFixture: "redis-server/7.2.3/linux-arm64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/redis-server-7.2.3-arm64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "redis",
|
||||||
// Name: "redis",
|
Version: "7.2.3",
|
||||||
// Version: "7.2.3",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/redis@7.2.3",
|
||||||
// PURL: "pkg:generic/redis@7.2.3",
|
Locations: locations("redis-server"),
|
||||||
// Locations: locations("redis-server"),
|
Metadata: metadata("redis-binary"),
|
||||||
// Metadata: metadata("redis-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
|
logicalFixture: "python-shared-lib/3.7.4/linux-amd64",
|
||||||
// TODO: missing original binaries
|
expected: pkg.Package{
|
||||||
//{
|
Name: "python",
|
||||||
// name: "positive-libpython3.7.so",
|
Version: "3.7.4",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/python-binary-lib-3.7",
|
PURL: "pkg:generic/python@3.7.4",
|
||||||
// expected: pkg.Package{
|
Locations: locations("libpython3.7m.so.1.0"),
|
||||||
// Name: "python",
|
Metadata: metadata("python-binary-lib"),
|
||||||
// Version: "3.7.4",
|
},
|
||||||
// PURL: "pkg:generic/python@3.7.4",
|
},
|
||||||
// Locations: locations("libpython3.7.so"),
|
|
||||||
// Metadata: metadata("python-binary-lib"),
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// note: dynamic (non-snippet) test case
|
// note: dynamic (non-snippet) test case
|
||||||
@ -457,51 +459,49 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO: missing original binary
|
{
|
||||||
//{
|
// TODO: find original binary...
|
||||||
// name: "positive-python-3.5-with-incorrect-match",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/python-3.5-with-incorrect-match",
|
logicalFixture: "python-with-incorrect-match/3.5.3/linux-amd64",
|
||||||
// expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
// Name: "python",
|
Name: "python",
|
||||||
// Version: "3.5.3",
|
Version: "3.5.3",
|
||||||
// PURL: "pkg:generic/python@3.5.3",
|
PURL: "pkg:generic/python@3.5.3",
|
||||||
// Locations: locations("python3.5"),
|
Locations: locations("python3.5"),
|
||||||
// Metadata: metadata("python-binary"),
|
Metadata: metadata("python-binary"),
|
||||||
// },
|
},
|
||||||
//},
|
},
|
||||||
|
{
|
||||||
// TODO: can't seem to get this lined up with the new binary pulled down... the original snippet also has content I can't account for
|
// TODO: find original binary...
|
||||||
//{
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// logicalFixture: "python/3.6/linux-amd64",
|
logicalFixture: "python/3.6.3/linux-amd64",
|
||||||
// expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
// Name: "python",
|
Name: "python",
|
||||||
// Version: "3.6.3",
|
Version: "3.6.3",
|
||||||
// PURL: "pkg:generic/python@3.6.3",
|
PURL: "pkg:generic/python@3.6.3",
|
||||||
// Locations: locations("python3.6"),
|
Locations: locations("python3.6"),
|
||||||
// Metadata: metadata("python-binary"),
|
Metadata: metadata("python-binary"),
|
||||||
// },
|
},
|
||||||
//},
|
},
|
||||||
|
{
|
||||||
// TODO: missing original binary
|
// TODO: find original binary...
|
||||||
//{
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// name: "positive-python-duplicates",
|
logicalFixture: "python-duplicates/3.8.16/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/python-duplicates",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "python",
|
||||||
// Name: "python",
|
Version: "3.8.16",
|
||||||
// Version: "3.8.16",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/python@3.8.16",
|
||||||
// PURL: "pkg:generic/python@3.8.16",
|
Locations: locations("dir/python3.8", "python3.8", "libpython3.8.so"),
|
||||||
// Locations: locations("dir/python3.8", "python3.8", "libpython3.8.so"),
|
Metadata: pkg.BinarySignature{
|
||||||
// Metadata: pkg.BinarySignature{
|
Matches: []pkg.ClassifierMatch{
|
||||||
// Matches: []pkg.ClassifierMatch{
|
match("python-binary", "dir/python3.8"),
|
||||||
// match("python-binary", "dir/python3.8"),
|
match("python-binary", "python3.8"),
|
||||||
// match("python-binary", "python3.8"),
|
match("python-binary-lib", "libpython3.8.so"),
|
||||||
// match("python-binary-lib", "libpython3.8.so"),
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
//},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
logicalFixture: "go/1.21.3/linux-amd64",
|
logicalFixture: "go/1.21.3/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
@ -522,18 +522,18 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("nodejs-binary"),
|
Metadata: metadata("nodejs-binary"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO: captured outside of the original binary
|
{
|
||||||
//{
|
// TODO: find original binary...
|
||||||
// name: "positive-go-hint",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/go-hint-1.15",
|
logicalFixture: "go-version-hint/1.15/any",
|
||||||
// expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
// Name: "go",
|
Name: "go",
|
||||||
// Version: "1.15",
|
Version: "1.15",
|
||||||
// PURL: "pkg:generic/go@1.15",
|
PURL: "pkg:generic/go@1.15",
|
||||||
// Locations: locations("VERSION"),
|
Locations: locations("VERSION"),
|
||||||
// Metadata: metadata("go-binary-hint"),
|
Metadata: metadata("go-binary-hint"),
|
||||||
// },
|
},
|
||||||
//},
|
},
|
||||||
{
|
{
|
||||||
// note: this is testing BUSYBOX which is typically through a link to "[" (in this case a symlink but in
|
// note: this is testing BUSYBOX which is typically through a link to "[" (in this case a symlink but in
|
||||||
// practice this is often a hard link).
|
// practice this is often a hard link).
|
||||||
@ -545,56 +545,55 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("busybox-binary", "[", "busybox"),
|
Metadata: metadata("busybox-binary", "[", "busybox"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO: need to get the original binaries
|
|
||||||
//{
|
|
||||||
// logicalFixture: "openjdk/1.8.0",
|
|
||||||
// expected: pkg.Package{
|
|
||||||
// Name: "java",
|
|
||||||
// Version: "1.8.0_352-b08",
|
|
||||||
// Type: "binary",
|
|
||||||
// PURL: "pkg:generic/java@1.8.0_352-b08",
|
|
||||||
// Locations: locations("java"),
|
|
||||||
// Metadata: metadata("java-binary-openjdk", "java"),
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
//{
|
|
||||||
// name: "positive-java-openjdk-lts",
|
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/openjdk-lts-11.0.17",
|
|
||||||
// expected: pkg.Package{
|
|
||||||
// Name: "java",
|
|
||||||
// Version: "11.0.17+8-LTS",
|
|
||||||
// Type: "binary",
|
|
||||||
// PURL: "pkg:generic/java@11.0.17+8-LTS",
|
|
||||||
// Locations: locations("java"),
|
|
||||||
// Metadata: metadata("java-binary-openjdk", "java"),
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
//{
|
|
||||||
// name: "positive-java-oracle",
|
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/oracle-java-19.0.1",
|
|
||||||
// expected: pkg.Package{
|
|
||||||
// Name: "java",
|
|
||||||
// Version: "19.0.1+10-21",
|
|
||||||
// Type: "binary",
|
|
||||||
// PURL: "pkg:generic/java@19.0.1+10-21",
|
|
||||||
// Locations: locations("java"),
|
|
||||||
// Metadata: metadata("java-binary-oracle", "java"),
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
//{
|
|
||||||
// name: "positive-java-oracle-macos",
|
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/oracle-macos-java-19.0.1",
|
|
||||||
// expected: pkg.Package{
|
|
||||||
// Name: "java",
|
|
||||||
// Version: "19.0.1+10-21",
|
|
||||||
// Type: "binary",
|
|
||||||
// PURL: "pkg:generic/java@19.0.1+10-21",
|
|
||||||
// Locations: locations("java"),
|
|
||||||
// Metadata: metadata("java-binary-oracle", "java"),
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
{
|
{
|
||||||
name: "positive-java-ibm",
|
logicalFixture: "java-jre-openjdk/1.8.0_352-b08/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "java",
|
||||||
|
Version: "1.8.0_352-b08",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/java@1.8.0_352-b08",
|
||||||
|
Locations: locations("java"),
|
||||||
|
Metadata: metadata("java-binary-openjdk", "java"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
logicalFixture: "java-jre-openjdk/11.0.17/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "java",
|
||||||
|
Version: "11.0.17+8-LTS",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/java@11.0.17+8-LTS",
|
||||||
|
Locations: locations("java"),
|
||||||
|
Metadata: metadata("java-binary-openjdk", "java"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// TODO: find original binary...
|
||||||
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
|
logicalFixture: "java-jre-oracle/19.0.1/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "java",
|
||||||
|
Version: "19.0.1+10-21",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/java@19.0.1+10-21",
|
||||||
|
Locations: locations("java"),
|
||||||
|
Metadata: metadata("java-binary-oracle", "java"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// TODO: find original binary...
|
||||||
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
|
logicalFixture: "java-jre-oracle/19.0.1/darwin",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "java",
|
||||||
|
Version: "19.0.1+10-21",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/java@19.0.1+10-21",
|
||||||
|
Locations: locations("java"),
|
||||||
|
Metadata: metadata("java-binary-oracle", "java"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
logicalFixture: "java-jre-ibm/1.8.0_391/linux-amd64",
|
logicalFixture: "java-jre-ibm/1.8.0_391/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
Name: "java",
|
Name: "java",
|
||||||
@ -605,43 +604,65 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("java-binary-ibm", "java"),
|
Metadata: metadata("java-binary-ibm", "java"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// TODO: need to get the original binaries
|
{
|
||||||
//{
|
logicalFixture: "rust-libstd/1.50.0/linux-amd64",
|
||||||
// name: "positive-rust-1.50.0-macos",
|
expected: pkg.Package{
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/rust-1.50.0",
|
Name: "rust",
|
||||||
// expected: pkg.Package{
|
Version: "1.50.0",
|
||||||
// Name: "rust",
|
Type: "binary",
|
||||||
// Version: "1.50.0",
|
PURL: "pkg:generic/rust@1.50.0",
|
||||||
// Type: "binary",
|
Locations: locations("libstd-6f77337c1826707d.so"),
|
||||||
// PURL: "pkg:generic/rust@1.50.0",
|
Metadata: metadata("rust-standard-library-linux"),
|
||||||
// Locations: locations("lib/rustlib/aarch64-apple-darwin/lib/libstd-f6f9eec1635e636a.dylib"),
|
},
|
||||||
// Metadata: metadata("rust-standard-library-macos"),
|
},
|
||||||
// },
|
{
|
||||||
//},
|
// TODO: find original binary...
|
||||||
//{
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// name: "positive-rust-1.67.1-macos",
|
logicalFixture: "rust-libstd/1.50.0/darwin",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/rust-1.67.1/toolchains/stable-aarch64-apple-darwin",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "rust",
|
||||||
// Name: "rust",
|
Version: "1.50.0",
|
||||||
// Version: "1.67.1",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/rust@1.50.0",
|
||||||
// PURL: "pkg:generic/rust@1.67.1",
|
Locations: locations("libstd-f6f9eec1635e636a.dylib"),
|
||||||
// Locations: locations("lib/libstd-16f2b65e77054c42.dylib"),
|
Metadata: metadata("rust-standard-library-macos"),
|
||||||
// Metadata: metadata("rust-standard-library-macos"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
{
|
||||||
//{
|
// TODO: find original binary...
|
||||||
// name: "positive-rust-1.67.1-linux",
|
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/rust-1.67.1/toolchains/stable-x86_64-unknown-linux-musl",
|
logicalFixture: "rust-libstd/1.67.1/darwin",
|
||||||
// expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
// Name: "rust",
|
Name: "rust",
|
||||||
// Version: "1.67.1",
|
Version: "1.67.1",
|
||||||
// Type: "binary",
|
Type: "binary",
|
||||||
// PURL: "pkg:generic/rust@1.67.1",
|
PURL: "pkg:generic/rust@1.67.1",
|
||||||
// Locations: locations("lib/libstd-86aefecbddda356d.so"),
|
Locations: locations("libstd-16f2b65e77054c42.dylib"),
|
||||||
// Metadata: metadata("rust-standard-library-linux"),
|
Metadata: metadata("rust-standard-library-macos"),
|
||||||
// },
|
},
|
||||||
//},
|
},
|
||||||
|
{
|
||||||
|
logicalFixture: "rust-libstd-musl/1.67.1/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "rust",
|
||||||
|
Version: "1.67.1",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/rust@1.67.1",
|
||||||
|
Locations: locations("libstd-86aefecbddda356d.so"),
|
||||||
|
Metadata: metadata("rust-standard-library-linux"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
logicalFixture: "rust-libstd/1.67.1/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "rust",
|
||||||
|
Version: "1.67.1",
|
||||||
|
Type: "binary",
|
||||||
|
PURL: "pkg:generic/rust@1.67.1",
|
||||||
|
Locations: locations("libstd-c6192dd4c4d410ac.so"),
|
||||||
|
Metadata: metadata("rust-standard-library-linux"),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// note: dynamic (non-snippet) test case
|
// note: dynamic (non-snippet) test case
|
||||||
|
|
||||||
@ -695,18 +716,17 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//{
|
{
|
||||||
// name: "positive-ruby-1.9.3p551",
|
logicalFixture: "ruby/1.9.3p551/linux-amd64",
|
||||||
// logicalFixture: "test-fixtures/classifiers/positive/ruby-1.9.3p551/linux-amd64",
|
expected: pkg.Package{
|
||||||
// expected: pkg.Package{
|
Name: "ruby",
|
||||||
// Name: "ruby",
|
Version: "1.9.3p551",
|
||||||
// Version: "1.9.3p551",
|
Type: "binary",
|
||||||
// Type: "binary",
|
PURL: "pkg:generic/ruby@1.9.3p551",
|
||||||
// PURL: "pkg:generic/ruby@1.9.3p551",
|
Locations: locations("ruby"),
|
||||||
// Locations: locations("ruby"),
|
Metadata: metadata("ruby-binary"),
|
||||||
// Metadata: metadata("ruby-binary"),
|
},
|
||||||
// },
|
},
|
||||||
//},
|
|
||||||
{
|
{
|
||||||
logicalFixture: "consul/1.15.2/linux-amd64",
|
logicalFixture: "consul/1.15.2/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
classifiers/dynamic
|
classifiers/dynamic
|
||||||
classifiers/bin
|
classifiers/bin
|
||||||
|
cache.fingerprint
|
||||||
@ -1,4 +1,4 @@
|
|||||||
.PHONY: default list download download-all fingerprint
|
.PHONY: default list download download-all cache.fingerprint
|
||||||
|
|
||||||
.DEFAULT_GOAL := default
|
.DEFAULT_GOAL := default
|
||||||
|
|
||||||
@ -13,9 +13,11 @@ download: ## download only binaries that are not covered by a snippet
|
|||||||
download-all: ## download all managed binaries
|
download-all: ## download all managed binaries
|
||||||
go run ./manager download
|
go run ./manager download
|
||||||
|
|
||||||
fingerprint: ## prints the sha256sum of the any input to the download command (to determine if there is a cache miss)
|
cache.fingerprint: ## prints the sha256sum of the any input to the download command (to determine if there is a cache miss)
|
||||||
@cat ./config.yaml | sha256sum | awk '{print $$1}'
|
@cat ./config.yaml | sha256sum | awk '{print $$1}' | tee cache.fingerprint
|
||||||
|
|
||||||
|
clean: ## clean up all downloaded binaries
|
||||||
|
rm -rf ./classifiers/bin
|
||||||
|
|
||||||
## Halp! #################################
|
## Halp! #################################
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Default values for length and prefix length
|
# Default values for length and prefix length
|
||||||
LENGTH=100
|
LENGTH=100
|
||||||
PREFIX_LENGTH=10
|
PREFIX_LENGTH=20
|
||||||
SEARCH_FOR=''
|
SEARCH_FOR=''
|
||||||
GROUP_NAME=''
|
GROUP_NAME=''
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
!*.so
|
|
||||||
!VERSION
|
|
||||||
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
# note: this SHOULD match as busybox 3.33.3
|
|
||||||
|
|
||||||
noise!BusyBox v3.33.3!noise
|
|
||||||
@ -1 +0,0 @@
|
|||||||
./[
|
|
||||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
go1.15-beta2
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,31 +0,0 @@
|
|||||||
The binary snippet was gathered with:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ cat ./original-mariadb | strings | grep '-MariaDB'
|
|
||||||
# assert you can see the value
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd ./original-mariadb | grep '\-MariaDB'
|
|
||||||
# get the address...
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd -s 0x003dd5c0 -l 40 ./original-mariadb
|
|
||||||
|
|
||||||
003dd5c0: 2900 4c69 6e75 7800 3130 2e36 2e31 352d ).Linux.10.6.15-
|
|
||||||
003dd5d0: 4d61 7269 6144 4200 7265 6164 6c69 6e65 MariaDB.readline
|
|
||||||
003dd5e0: 0078 3836 5f36 3400 .x86_64.
|
|
||||||
|
|
||||||
|
|
||||||
$ dd if=./original-mariadb of=mariadb bs=1 skip=$((0x003dd5c0)) count=40
|
|
||||||
|
|
||||||
40+0 records in
|
|
||||||
40+0 records out
|
|
||||||
40 bytes transferred in 0.000264 secs (151515 bytes/sec)
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd mariadb
|
|
||||||
|
|
||||||
00000000: 2900 4c69 6e75 7800 3130 2e36 2e31 352d ).Linux.10.6.15-
|
|
||||||
00000010: 4d61 7269 6144 4200 7265 6164 6c69 6e65 MariaDB.readline
|
|
||||||
00000020: 0078 3836 5f36 3400 .x86_64.
|
|
||||||
```
|
|
||||||
Binary file not shown.
@ -1,18 +0,0 @@
|
|||||||
### generated by script get-fixture-snippet.sh at Tue Dec 19 11:36:59 EST 2023 ###
|
|
||||||
# filename: memcached
|
|
||||||
# sha256: 176467412e0722ae1b2c1159555d33574653ebfa87e8591d88c1e6e416ab3019
|
|
||||||
# file info: ASCII text, with CRLF, LF line terminators
|
|
||||||
# base64(search): MS42LjE4
|
|
||||||
# start offset: 19
|
|
||||||
# length: 100
|
|
||||||
### start of binary snippet ###
|
|
||||||
|
|
||||||
listen
|
|
||||||
memcached 1.6.18
|
|
||||||
udp-port
|
|
||||||
memcached 1.6.18
|
|
||||||
Failed to allocate memory
|
|
||||||
%s,%s
|
|
||||||
--
|
|
||||||
bget
|
|
||||||
f
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
The binary snippet was gathered with:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ cat ./original-mysql | strings | grep '5.6.51'
|
|
||||||
# assert you can see the value
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd ./original-mysql | grep '5.6.51'
|
|
||||||
# get the address...
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd -s 0x008f13d0 -l 100 original-mysql
|
|
||||||
|
|
||||||
008f13d0: 2d62 6163 6b75 702d 7265 7374 6f72 6572 -backup-restorer
|
|
||||||
008f13e0: 2d6d 7973 716c 2d35 2e36 2f6d 7973 716c -mysql-5.6/mysql
|
|
||||||
008f13f0: 2d35 2e36 2e35 312f 636c 6965 6e74 2f63 -5.6.51/client/c
|
|
||||||
008f1400: 6f6d 706c 6574 696f 6e5f 6861 7368 2e63 ompletion_hash.c
|
|
||||||
008f1410: 6300 2f76 6172 2f76 6361 702f 6461 7461 c./var/vcap/data
|
|
||||||
008f1420: 2f63 6f6d 7069 6c65 2f64 6174 6162 6173 /compile/databas
|
|
||||||
008f1430: 652d 6261 e-ba
|
|
||||||
|
|
||||||
|
|
||||||
$ dd if=./original-mysql of=mysql bs=1 skip=$((0x008f13d0)) count=100
|
|
||||||
|
|
||||||
100+0 records in
|
|
||||||
100+0 records out
|
|
||||||
100 bytes transferred in 0.000642 secs (155763 bytes/sec)
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd mysql
|
|
||||||
|
|
||||||
00000000: 2d62 6163 6b75 702d 7265 7374 6f72 6572 -backup-restorer
|
|
||||||
00000010: 2d6d 7973 716c 2d35 2e36 2f6d 7973 716c -mysql-5.6/mysql
|
|
||||||
00000020: 2d35 2e36 2e35 312f 636c 6965 6e74 2f63 -5.6.51/client/c
|
|
||||||
00000030: 6f6d 706c 6574 696f 6e5f 6861 7368 2e63 ompletion_hash.c
|
|
||||||
00000040: 6300 2f76 6172 2f76 6361 702f 6461 7461 c./var/vcap/data
|
|
||||||
00000050: 2f63 6f6d 7069 6c65 2f64 6174 6162 6173 /compile/databas
|
|
||||||
00000060: 652d 6261 e-ba
|
|
||||||
```
|
|
||||||
Binary file not shown.
@ -1,40 +0,0 @@
|
|||||||
The binary snippet was gathered with:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ cat ./original-mysql | strings | grep '8.0.34'
|
|
||||||
# assert you can see the value
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd ./original-mysql | grep '8.0.34'
|
|
||||||
# get the address...
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd -s 0x0014cd20 -l 100 original-mysql
|
|
||||||
|
|
||||||
0014cd20: 2069 7320 616c 7265 6164 7920 6c6f 6164 is already load
|
|
||||||
0014cd30: 6564 0000 0000 0000 2e2e 2f2e 2e2f 6d79 ed......../../my
|
|
||||||
0014cd40: 7371 6c2d 382e 302e 3334 2f73 716c 2d63 sql-8.0.34/sql-c
|
|
||||||
0014cd50: 6f6d 6d6f 6e2f 636c 6965 6e74 5f70 6c75 ommon/client_plu
|
|
||||||
0014cd60: 6769 6e2e 6363 002f 7573 722f 6c6f 6361 gin.cc./usr/loca
|
|
||||||
0014cd70: 6c2f 6d79 7371 6c2f 6c69 622f 706c 7567 l/mysql/lib/plug
|
|
||||||
0014cd80: 696e 0049 in.I
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ dd if=./original-mysql of=mysql bs=1 skip=$((0x0014cd20)) count=100
|
|
||||||
|
|
||||||
100+0 records in
|
|
||||||
100+0 records out
|
|
||||||
100 bytes transferred in 0.000519 secs (192678 bytes/sec)
|
|
||||||
|
|
||||||
|
|
||||||
$ xxd mysql
|
|
||||||
|
|
||||||
00000000: 2069 7320 616c 7265 6164 7920 6c6f 6164 is already load
|
|
||||||
00000010: 6564 0000 0000 0000 2e2e 2f2e 2e2f 6d79 ed......../../my
|
|
||||||
00000020: 7371 6c2d 382e 302e 3334 2f73 716c 2d63 sql-8.0.34/sql-c
|
|
||||||
00000030: 6f6d 6d6f 6e2f 636c 6965 6e74 5f70 6c75 ommon/client_plu
|
|
||||||
00000040: 6769 6e2e 6363 002f 7573 722f 6c6f 6361 gin.cc./usr/loca
|
|
||||||
00000050: 6c2f 6d79 7371 6c2f 6c69 622f 706c 7567 l/mysql/lib/plug
|
|
||||||
00000060: 696e 0049 in.I
|
|
||||||
```
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
|||||||
# this should match node 19.2.1
|
|
||||||
node.js/v19.2.1
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 39 B |
Binary file not shown.
@ -1,5 +0,0 @@
|
|||||||
[null] Script: '%s'
|
|
||||||
%s,%s
|
|
||||||
X-Powered-By: PHP/8.2.1
|
|
||||||
index pointer
|
|
||||||
PHP_VERSION
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
[null] Script: '%s'
|
|
||||||
%s,%s
|
|
||||||
X-Powered-By: PHP/8.2.1
|
|
||||||
index pointer
|
|
||||||
PHP_VERSION
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
[null] Script: '%s'
|
|
||||||
%s,%s
|
|
||||||
X-Powered-By: PHP/8.2.1
|
|
||||||
index pointer
|
|
||||||
PHP_VERSION
|
|
||||||
Binary file not shown.
Binary file not shown.
@ -1,5 +0,0 @@
|
|||||||
byteaout
|
|
||||||
byteain
|
|
||||||
?PostgreSQL 9.5alpha1 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit
|
|
||||||
/tmp/buildd/postgresql-9.5-9.5~alpha1/build/../src/backend/utils/adt/windowfuncs.c
|
|
||||||
argument of ntile must be greater than zero
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,9 +0,0 @@
|
|||||||
super from singleton method that is defined to multiple classes is not supported; this will be fixed in 1.9.3 or later
|
|
||||||
/usr/local/lib/ruby/site_ruby/1.9.1
|
|
||||||
/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-linux
|
|
||||||
/usr/local/lib/ruby/vendor_ruby/1.9.1
|
|
||||||
/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
|
|
||||||
/usr/local/lib/ruby/1.9.1
|
|
||||||
/usr/local/lib/ruby/1.9.1/x86_64-linux
|
|
||||||
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
|
|
||||||
1.9.3
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,12 @@
|
|||||||
|
name: php
|
||||||
|
offset: unknown
|
||||||
|
length: unknown
|
||||||
|
snippetSha256: d39ac8dadf5ba868455c487f1d0bb4c8bec64006fd7e5d76e3e27a26e47e637f
|
||||||
|
fileSha256: unknown
|
||||||
|
|
||||||
|
### byte snippet to follow ###
|
||||||
|
%s'
|
||||||
|
%s,%s
|
||||||
|
X-Powered-By: PHP/8.2.1
|
||||||
|
index pointer
|
||||||
|
PHP_VERSION
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
name: php-fpm
|
||||||
|
offset: unknown
|
||||||
|
length: unknown
|
||||||
|
snippetSha256: d39ac8dadf5ba868455c487f1d0bb4c8bec64006fd7e5d76e3e27a26e47e637f
|
||||||
|
fileSha256: unknown
|
||||||
|
|
||||||
|
### byte snippet to follow ###
|
||||||
|
%s'
|
||||||
|
%s,%s
|
||||||
|
X-Powered-By: PHP/8.2.1
|
||||||
|
index pointer
|
||||||
|
PHP_VERSION
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
name: postgres
|
||||||
|
offset: unknown
|
||||||
|
length: unknown
|
||||||
|
snippetSha256: 8f8323161ded8fd737ba7157b36b794c55354e8a9b8b6c5aa07dab9c3468886c
|
||||||
|
fileSha256: unknown
|
||||||
|
|
||||||
|
### byte snippet to follow ###
|
||||||
|
t
|
||||||
|
byteain
|
||||||
|
?PostgreSQL 9.5alpha1 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -151,86 +151,47 @@ from-images:
|
|||||||
paths:
|
paths:
|
||||||
- /usr/local/bin/node
|
- /usr/local/bin/node
|
||||||
|
|
||||||
|
- name: java-jre-openjdk
|
||||||
# todo (from existing snippets)...
|
version: 1.8.0_352-b08
|
||||||
|
|
||||||
#
|
|
||||||
# - name: openjdk
|
|
||||||
# version: 1.8.0
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - name: openjdk
|
|
||||||
# version: 11.0.17
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - name: oracle-java
|
|
||||||
# version: 19.0.1
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - name: oracle-java #macos
|
|
||||||
# version: 19.0.1
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
|
|
||||||
- version: 5.12.5
|
|
||||||
images:
|
images:
|
||||||
- ref: perl:5.12.5@sha256:68169b63f0dc2fd481563ef02d4173979d981e43e5d36bb39af56a5959961c5e
|
# note: "openjdk" dockerhub repo is deprecated
|
||||||
|
- ref: amazoncorretto:8u352@sha256:392eb90b5f1455578f513e127c599aa4410af0c05b12b81dc7856ee316ecd5d9
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
paths:
|
paths:
|
||||||
- /usr/bin/perl
|
- /usr/lib/jvm/java-1.8.0-amazon-corretto/bin/java
|
||||||
|
|
||||||
- version: 5.20.0
|
- name: java-jre-openjdk
|
||||||
|
version: 11.0.17
|
||||||
images:
|
images:
|
||||||
- ref: perl:5.20.0@sha256:f1b8d36e0be0fd426c40e478fc84ea7603d712158001d72d1b3f929f4e1543f3
|
# note: "openjdk" dockerhub repo is deprecated
|
||||||
|
- ref: amazoncorretto:11.0.17@sha256:792e94e61407ef28d981a0b9a9aeb309690375a61a61f17808499ff16864d0a3
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
paths:
|
paths:
|
||||||
- /usr/bin/perl
|
- /usr/lib/jvm/java-11-amazon-corretto/bin/java
|
||||||
|
|
||||||
- version: 5.37.8
|
# TODO: this is not the original binary used in the test fixture
|
||||||
images:
|
# - version: 5.12.5
|
||||||
- ref: perl:5.37.8@sha256:6a432250d7bf0b736c58772a6a50e2bf9d1485cd70ac3af10eff6cfccde3957b
|
|
||||||
platform: linux/amd64
|
|
||||||
paths:
|
|
||||||
- /usr/bin/perl
|
|
||||||
|
|
||||||
# - name: php-apache
|
|
||||||
# version: 8.2.1
|
|
||||||
# images:
|
# images:
|
||||||
# - ref:
|
# - ref: perl:5.12.5@sha256:68169b63f0dc2fd481563ef02d4173979d981e43e5d36bb39af56a5959961c5e
|
||||||
# platform: linux/amd64
|
# platform: linux/amd64
|
||||||
# paths:
|
# paths:
|
||||||
# -
|
# - /usr/bin/perl
|
||||||
#
|
#
|
||||||
# - name: php-cli
|
# TODO: this is not the original binary used in the test fixture
|
||||||
# version: 8.2.1
|
# - version: 5.20.0
|
||||||
# images:
|
# images:
|
||||||
# - ref:
|
# - ref: perl:5.20.0@sha256:f1b8d36e0be0fd426c40e478fc84ea7603d712158001d72d1b3f929f4e1543f3
|
||||||
# platform: linux/amd64
|
# platform: linux/amd64
|
||||||
# paths:
|
# paths:
|
||||||
# -
|
# - /usr/bin/perl
|
||||||
#
|
#
|
||||||
# - name: php-fpm
|
# TODO: this is not the original binary used in the test fixture
|
||||||
# version: 8.2.1
|
# - version: 5.37.8
|
||||||
# images:
|
# images:
|
||||||
# - ref:
|
# - ref: perl:5.37.8@sha256:6a432250d7bf0b736c58772a6a50e2bf9d1485cd70ac3af10eff6cfccde3957b
|
||||||
# platform: linux/amd64
|
# platform: linux/amd64
|
||||||
# paths:
|
# paths:
|
||||||
# -
|
# - /usr/bin/perl
|
||||||
|
|
||||||
- version: 15.1
|
- version: 15.1
|
||||||
images:
|
images:
|
||||||
@ -246,13 +207,6 @@ from-images:
|
|||||||
paths:
|
paths:
|
||||||
- /usr/lib/postgresql/15/bin/postgres
|
- /usr/lib/postgresql/15/bin/postgres
|
||||||
|
|
||||||
# - version: 9.5alpha1 # postgresql
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
|
|
||||||
- version: 9.6.24
|
- version: 9.6.24
|
||||||
images:
|
images:
|
||||||
- ref: postgres:9.6.24@sha256:15055f7b681334cbf0212b58e510148b1b23973639e3904260fb41fa0761a103
|
- ref: postgres:9.6.24@sha256:15055f7b681334cbf0212b58e510148b1b23973639e3904260fb41fa0761a103
|
||||||
@ -260,128 +214,110 @@ from-images:
|
|||||||
paths:
|
paths:
|
||||||
- /usr/lib/postgresql/9.6/bin/postgres
|
- /usr/lib/postgresql/9.6/bin/postgres
|
||||||
|
|
||||||
# - name: python-with-incorrect-match
|
- name: python-shared-lib
|
||||||
# version: 3.5
|
version: 3.7.4
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
|
|
||||||
- name: python
|
|
||||||
version: 3.6
|
|
||||||
images:
|
images:
|
||||||
- ref: python:3.6.3@sha256:cdef88d8625cf50ca705b7abfe99e8eb33b889652a9389b017eb46a6d2f1aaf3
|
- ref: python:3.7.4@sha256:5be0532f833568d838b7b2d8726b66d0b8abe26f50a15b566aea4611d5951eac
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
paths:
|
paths:
|
||||||
- /usr/local/bin/python3.6
|
- /usr/local/lib/libpython3.7m.so.1.0
|
||||||
|
|
||||||
# - name: python-lib
|
- version: 2.8.23
|
||||||
# version: 3.7
|
images:
|
||||||
# images:
|
- ref: redis:2.8.23@sha256:e507029ca6a11b85f8628ff16d7ff73ae54582f16fd757e64431f5ca6d27a13c
|
||||||
# - ref:
|
platform: linux/amd64
|
||||||
# platform: linux/amd64
|
paths:
|
||||||
# paths:
|
- /usr/local/bin/redis-server
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: python-duplicates
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 2.8.23 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 4.0.11 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 5.0.0 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 6.0.16 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 7.0.0 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 7.0.14 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 7.2.3-amd64 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 7.2.3-arm64 # redis-server
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 1.9.3p551 # ruby
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 1.50.0 # ruby
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 1.67.1 # ruby
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 1.7.34 # traefik
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
# - version: 2.9.6 # traefik
|
|
||||||
# images:
|
|
||||||
# - ref:
|
|
||||||
# platform: linux/amd64
|
|
||||||
# paths:
|
|
||||||
# -
|
|
||||||
|
|
||||||
|
- version: 4.0.11
|
||||||
|
images:
|
||||||
|
- ref: redis:4.0.11@sha256:ee891094f0bb1a76d11cdca6e33c4fdce5cba1f13234c5896d341f6d741034b1
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/redis-server
|
||||||
|
|
||||||
|
- version: 5.0.0
|
||||||
|
images:
|
||||||
|
- ref: redis:5.0.0@sha256:481678b4b5ea1cb4e8d38ed6677b2da9b9e057cf7e1b6c988ba96651c6f6eff3
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/redis-server
|
||||||
|
|
||||||
|
- version: 6.0.16
|
||||||
|
images:
|
||||||
|
- ref: redis:6.0.16@sha256:4a32539b1cc25f98d8667d9854840d7bdd27596268ca1ec1e10b5391534c004b
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/redis-server
|
||||||
|
|
||||||
|
- version: 7.0.0
|
||||||
|
images:
|
||||||
|
- ref: redis:7.0.0@sha256:803ec2b3b74c0f95758bf680d7caa370fa8d3b6058b4d57d6485d06d8027a588
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/redis-server
|
||||||
|
|
||||||
|
- version: 7.0.14
|
||||||
|
images:
|
||||||
|
- ref: redis:7.0.14@sha256:f5b0eadaa031b40ca70ab2c6517995da56f763c3929264d7f69b72a94a1b48c1
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/redis-server
|
||||||
|
|
||||||
|
- version: 7.2.3
|
||||||
|
images:
|
||||||
|
- ref: redis:7.2.3@sha256:d4c84914b872521e215f77d8845914c2268a96b0e35bacd5691e1f5e1f88b500
|
||||||
|
platform: linux/amd64
|
||||||
|
- ref: redis:7.2.3@sha256:a0a0c38b31011b813cddf78d997f8ccba13019c27efd386984b0cfc1e4b618ff
|
||||||
|
platform: linux/arm64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/redis-server
|
||||||
|
|
||||||
|
- version: 1.9.3p551
|
||||||
|
images:
|
||||||
|
- ref: ruby:1.9.3-p551@sha256:56b4a74e4fc2492b3b857bc94454dfa910f61e823a4bfab275d279bfa218eb05
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/ruby
|
||||||
|
|
||||||
|
- name: rust-libstd
|
||||||
|
version: 1.50.0
|
||||||
|
images:
|
||||||
|
- ref: rust:1.50.0@sha256:a37b2a5ba365b9ad5a1b12ff924adb0c0cc27d994e076bbc488a91befb69bf0b
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.so
|
||||||
|
|
||||||
|
- name: rust-libstd
|
||||||
|
version: 1.67.1
|
||||||
|
images:
|
||||||
|
- ref: rust:1.67.1@sha256:80b9716cb59872769d49f5185a346e5f859081b02338e4aaaa04a8cc7fb884ae
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/rustup/toolchains/1.67.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-c6192dd4c4d410ac.so
|
||||||
|
|
||||||
|
- name: rust-libstd-musl
|
||||||
|
version: 1.67.1
|
||||||
|
images:
|
||||||
|
- ref: rust:1.67.1-alpine@sha256:555332e59c7513233b0f9b52e4fad2924e36128edcb0f80aa97fb34efee3da0e
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/rustup/toolchains/1.67.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-86aefecbddda356d.so
|
||||||
|
|
||||||
|
|
||||||
|
- version: 1.7.34
|
||||||
|
images:
|
||||||
|
- ref: traefik:1.7.34@sha256:d7bacaf9ca8d59b0e7c304920629d98bb98a545127ca4b10e16c8b252b9351b9
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /traefik
|
||||||
|
|
||||||
|
- version: 2.9.6
|
||||||
|
images:
|
||||||
|
- ref: traefik:v2.9.6@sha256:9e76f2ec1bc470ae73a7306acce18e6ca1dbb582e7366b31cbf439f631cda12c
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/traefik
|
||||||
|
|
||||||
|
|
||||||
# from the original dynamic fixtures...
|
# from the original dynamic fixtures...
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/cli/commands"
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/cli/commands"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// list all managed binaries (in ./bin, organized by 'name-version/platform/binary')
|
// list all managed binaries (in ./bin, organized by 'name-version/platform/binary')
|
||||||
|
|||||||
@ -2,14 +2,16 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/ui"
|
|
||||||
"github.com/anmitsu/go-shlex"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/anmitsu/go-shlex"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AddSnippet(appConfig config.Application) *cobra.Command {
|
func AddSnippet(appConfig config.Application) *cobra.Command {
|
||||||
@ -21,7 +23,6 @@ func AddSnippet(appConfig config.Application) *cobra.Command {
|
|||||||
Short: "capture snippets from binaries",
|
Short: "capture snippets from binaries",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
candidates, err := internal.ListAllBinaries(appConfig)
|
candidates, err := internal.ListAllBinaries(appConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to list binaries: %w", err)
|
return fmt.Errorf("unable to list binaries: %w", err)
|
||||||
@ -59,7 +60,7 @@ func AddSnippet(appConfig config.Application) *cobra.Command {
|
|||||||
|
|
||||||
cmd.Flags().StringVar(&searchPattern, "search-for", "", "the pattern to search for in the binary (defaults to the version)")
|
cmd.Flags().StringVar(&searchPattern, "search-for", "", "the pattern to search for in the binary (defaults to the version)")
|
||||||
cmd.Flags().IntVar(&length, "length", 100, "the length of the snippet to capture")
|
cmd.Flags().IntVar(&length, "length", 100, "the length of the snippet to capture")
|
||||||
cmd.Flags().IntVar(&prefixLength, "prefix-length", 10, "number of bytes before the search hit to capture")
|
cmd.Flags().IntVar(&prefixLength, "prefix-length", 20, "number of bytes before the search hit to capture")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,11 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Download(appConfig config.Application) *cobra.Command {
|
func Download(appConfig config.Application) *cobra.Command {
|
||||||
@ -16,7 +18,6 @@ func Download(appConfig config.Application) *cobra.Command {
|
|||||||
Use: "download",
|
Use: "download",
|
||||||
Short: "download binaries [name@version ...]",
|
Short: "download binaries [name@version ...]",
|
||||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
binaryFromImageCfg := appConfig.GetBinaryFromImage(arg, "")
|
binaryFromImageCfg := appConfig.GetBinaryFromImage(arg, "")
|
||||||
|
|||||||
@ -2,15 +2,16 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
"strings"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"strings"
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func List(appConfig config.Application) *cobra.Command {
|
func List(appConfig config.Application) *cobra.Command {
|
||||||
|
|
||||||
var showPaths bool
|
var showPaths bool
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@ -18,7 +19,6 @@ func List(appConfig config.Application) *cobra.Command {
|
|||||||
Short: "list managed binaries and managed/unmanaged snippets",
|
Short: "list managed binaries and managed/unmanaged snippets",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
return runList(appConfig, showPaths)
|
return runList(appConfig, showPaths)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -29,7 +29,6 @@ func List(appConfig config.Application) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runList(appConfig config.Application, showPaths bool) error {
|
func runList(appConfig config.Application, showPaths bool) error {
|
||||||
|
|
||||||
material, err := internal.ListAllEntries(appConfig)
|
material, err := internal.ListAllEntries(appConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -42,6 +41,8 @@ func runList(appConfig config.Application, showPaths bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const yes = "yes"
|
||||||
|
|
||||||
func renderCatalogerListTable(material map[internal.LogicalEntryKey]internal.EntryInfo, showPaths bool) string {
|
func renderCatalogerListTable(material map[internal.LogicalEntryKey]internal.EntryInfo, showPaths bool) string {
|
||||||
t := table.NewWriter()
|
t := table.NewWriter()
|
||||||
t.SetStyle(table.StyleLight)
|
t.SetStyle(table.StyleLight)
|
||||||
@ -54,7 +55,7 @@ func renderCatalogerListTable(material map[internal.LogicalEntryKey]internal.Ent
|
|||||||
|
|
||||||
isConfigured := ""
|
isConfigured := ""
|
||||||
if info.IsConfigured {
|
if info.IsConfigured {
|
||||||
isConfigured = "yes"
|
isConfigured = yes
|
||||||
}
|
}
|
||||||
|
|
||||||
bin := ""
|
bin := ""
|
||||||
@ -64,11 +65,11 @@ func renderCatalogerListTable(material map[internal.LogicalEntryKey]internal.Ent
|
|||||||
snippet = info.SnippetPath
|
snippet = info.SnippetPath
|
||||||
} else {
|
} else {
|
||||||
if info.BinaryPath != "" {
|
if info.BinaryPath != "" {
|
||||||
bin = "yes"
|
bin = yes
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.SnippetPath != "" {
|
if info.SnippetPath != "" {
|
||||||
snippet = "yes"
|
snippet = yes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Root(_ config.Application) *cobra.Command {
|
func Root(_ config.Application) *cobra.Command {
|
||||||
|
|||||||
@ -5,14 +5,16 @@ import (
|
|||||||
"debug/macho"
|
"debug/macho"
|
||||||
"debug/pe"
|
"debug/pe"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WriteSnippet(appConfig config.Application) *cobra.Command {
|
func WriteSnippet(appConfig config.Application) *cobra.Command {
|
||||||
@ -102,7 +104,7 @@ func runWriteSnippet(binaryPath string, offset, length int, snippetPath string)
|
|||||||
return fmt.Errorf("unable to marshal metadata: %w", err)
|
return fmt.Errorf("unable to marshal metadata: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
splitter := []byte(fmt.Sprintf("\n### byte snippet to follow ###\n"))
|
splitter := []byte("\n### byte snippet to follow ###\n")
|
||||||
|
|
||||||
var finalBuf []byte
|
var finalBuf []byte
|
||||||
finalBuf = append(finalBuf, metadataBytes...)
|
finalBuf = append(finalBuf, metadataBytes...)
|
||||||
@ -113,7 +115,7 @@ func runWriteSnippet(binaryPath string, offset, length int, snippetPath string)
|
|||||||
return fmt.Errorf("unable to create destination directory: %w", err)
|
return fmt.Errorf("unable to create destination directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(snippetPath, finalBuf, 0644); err != nil {
|
if err := os.WriteFile(snippetPath, finalBuf, 0600); err != nil {
|
||||||
return fmt.Errorf("unable to write snippet: %w", err)
|
return fmt.Errorf("unable to write snippet: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +197,11 @@ func getPlatform(binaryPath string) (string, error) {
|
|||||||
return "", fmt.Errorf("unable to determine platform for %q", binaryPath)
|
return "", fmt.Errorf("unable to determine platform for %q", binaryPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
amd64 = "amd64"
|
||||||
|
arm64 = "arm64"
|
||||||
|
)
|
||||||
|
|
||||||
func getPlatformElf(f *os.File) string {
|
func getPlatformElf(f *os.File) string {
|
||||||
elfFile, err := elf.NewFile(f)
|
elfFile, err := elf.NewFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -204,9 +211,9 @@ func getPlatformElf(f *os.File) string {
|
|||||||
var arch string
|
var arch string
|
||||||
switch elfFile.Machine {
|
switch elfFile.Machine {
|
||||||
case elf.EM_X86_64:
|
case elf.EM_X86_64:
|
||||||
arch = "amd64"
|
arch = amd64
|
||||||
case elf.EM_AARCH64:
|
case elf.EM_AARCH64:
|
||||||
arch = "arm64"
|
arch = arm64
|
||||||
// TODO...
|
// TODO...
|
||||||
default:
|
default:
|
||||||
arch = fmt.Sprintf("unknown-%x", elfFile.Machine)
|
arch = fmt.Sprintf("unknown-%x", elfFile.Machine)
|
||||||
@ -224,9 +231,9 @@ func getPlatformMac(f *os.File) string {
|
|||||||
var arch string
|
var arch string
|
||||||
switch machoFile.Cpu {
|
switch machoFile.Cpu {
|
||||||
case macho.CpuAmd64:
|
case macho.CpuAmd64:
|
||||||
arch = "amd64"
|
arch = amd64
|
||||||
case macho.CpuArm64:
|
case macho.CpuArm64:
|
||||||
arch = "arm64"
|
arch = arm64
|
||||||
// TODO...
|
// TODO...
|
||||||
default:
|
default:
|
||||||
arch = fmt.Sprintf("unknown-%x", machoFile.Cpu)
|
arch = fmt.Sprintf("unknown-%x", machoFile.Cpu)
|
||||||
@ -244,9 +251,9 @@ func getPlatformWindows(f *os.File) string {
|
|||||||
var arch string
|
var arch string
|
||||||
switch peFile.Machine {
|
switch peFile.Machine {
|
||||||
case pe.IMAGE_FILE_MACHINE_AMD64:
|
case pe.IMAGE_FILE_MACHINE_AMD64:
|
||||||
arch = "amd64"
|
arch = amd64
|
||||||
case pe.IMAGE_FILE_MACHINE_ARM64:
|
case pe.IMAGE_FILE_MACHINE_ARM64:
|
||||||
arch = "arm64"
|
arch = arm64
|
||||||
// TODO...
|
// TODO...
|
||||||
default:
|
default:
|
||||||
arch = fmt.Sprintf("unknown-%x", peFile.Machine)
|
arch = fmt.Sprintf("unknown-%x", peFile.Machine)
|
||||||
|
|||||||
@ -2,12 +2,13 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hashicorp/go-multierror"
|
|
||||||
"github.com/scylladb/go-set/strset"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-multierror"
|
||||||
|
"github.com/scylladb/go-set/strset"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Path = "config.yaml"
|
const Path = "config.yaml"
|
||||||
@ -96,7 +97,6 @@ func (c Application) Validate() error {
|
|||||||
if len(entry.PathsInImage) == 0 {
|
if len(entry.PathsInImage) == 0 {
|
||||||
err = multierror.Append(err, fmt.Errorf("missing paths for entry %d (%s)", i+1, key))
|
err = multierror.Append(err, fmt.Errorf("missing paths for entry %d (%s)", i+1, key))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,10 @@ package config
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BinaryFromImage struct {
|
type BinaryFromImage struct {
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/ui"
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DownloadFromImage(dest string, config config.BinaryFromImage) error {
|
func DownloadFromImage(dest string, config config.BinaryFromImage) error {
|
||||||
@ -19,9 +22,8 @@ func DownloadFromImage(dest string, config config.BinaryFromImage) error {
|
|||||||
if !isDownloadStale(config, hostPaths) {
|
if !isDownloadStale(config, hostPaths) {
|
||||||
t.Skip("already exists")
|
t.Skip("already exists")
|
||||||
return nil
|
return nil
|
||||||
} else {
|
|
||||||
t.Update("stale, updating...")
|
|
||||||
}
|
}
|
||||||
|
t.Update("stale, updating...")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := pullDockerImages(config.Images); err != nil {
|
if err := pullDockerImages(config.Images); err != nil {
|
||||||
@ -78,24 +80,62 @@ func pullDockerImages(images []config.Image) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type imageInspect struct {
|
||||||
|
OS string `json:"Os"`
|
||||||
|
Architecture string `json:"Architecture"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i imageInspect) Platform() string {
|
||||||
|
return fmt.Sprintf("%s/%s", i.OS, i.Architecture)
|
||||||
|
}
|
||||||
|
|
||||||
func pullDockerImage(imageReference, platform string) error {
|
func pullDockerImage(imageReference, platform string) error {
|
||||||
a := ui.Action{Msg: fmt.Sprintf("pull image %s (%s)", imageReference, platform)}
|
a := ui.Action{Msg: fmt.Sprintf("pull image %s (%s)", imageReference, platform)}
|
||||||
a.Start()
|
a.Start()
|
||||||
cmd := exec.Command("docker", "image", "inspect", imageReference)
|
|
||||||
if err := cmd.Run(); err == nil {
|
|
||||||
a.Skip(fmt.Sprintf("docker image already exists %q", imageReference))
|
|
||||||
|
|
||||||
|
matches, _, _ := checkArchitecturesMatch(imageReference, platform)
|
||||||
|
if matches {
|
||||||
|
a.Skip(fmt.Sprintf("docker image already exists %q", imageReference))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = exec.Command("docker", "pull", "--platform", platform, imageReference)
|
cmd := exec.Command("docker", "pull", "--platform", platform, imageReference)
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
a.Done(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
matches, gotPlatform, err := checkArchitecturesMatch(imageReference, platform)
|
||||||
|
if !matches && err == nil {
|
||||||
|
err = fmt.Errorf("image %q pulled but does not match expected platform %q != %q", imageReference, platform, gotPlatform)
|
||||||
|
}
|
||||||
|
|
||||||
a.Done(err)
|
a.Done(err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkArchitecturesMatch(imageReference, platform string) (bool, string, error) {
|
||||||
|
cmd := exec.Command("docker", "image", "inspect", imageReference)
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return false, "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var inspect []imageInspect
|
||||||
|
if err := json.Unmarshal(out, &inspect); err != nil {
|
||||||
|
return false, "", fmt.Errorf("unable to unmarshal image inspect: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(inspect) != 1 {
|
||||||
|
return false, "", fmt.Errorf("expected 1 image inspect, got %d", len(inspect))
|
||||||
|
}
|
||||||
|
gotPlatform := inspect[0].Platform()
|
||||||
|
|
||||||
|
return gotPlatform == platform, gotPlatform, nil
|
||||||
|
}
|
||||||
|
|
||||||
func copyBinariesFromDockerImages(config config.BinaryFromImage, destination string) (err error) {
|
func copyBinariesFromDockerImages(config config.BinaryFromImage, destination string) (err error) {
|
||||||
for _, image := range config.Images {
|
for _, image := range config.Images {
|
||||||
if err := copyBinariesFromDockerImage(config, destination, image); err != nil {
|
if err := copyBinariesFromDockerImage(config, destination, image); err != nil {
|
||||||
@ -116,7 +156,7 @@ func copyBinariesFromDockerImage(config config.BinaryFromImage, destination stri
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
cmd := exec.Command("docker", "rm", containerName)
|
cmd := exec.Command("docker", "rm", containerName)
|
||||||
cmd.Run()
|
cmd.Run() // nolint:errcheck
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for i, destinationPath := range config.AllStorePathsForImage(image, destination) {
|
for i, destinationPath := range config.AllStorePathsForImage(image, destination) {
|
||||||
@ -130,7 +170,6 @@ func copyBinariesFromDockerImage(config config.BinaryFromImage, destination stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func copyBinaryFromContainer(containerName, containerPath, destinationPath, fingerprint string) (err error) {
|
func copyBinaryFromContainer(containerName, containerPath, destinationPath, fingerprint string) (err error) {
|
||||||
|
|
||||||
a := ui.Action{Msg: fmt.Sprintf("extract %s", containerPath)}
|
a := ui.Action{Msg: fmt.Sprintf("extract %s", containerPath)}
|
||||||
a.Start()
|
a.Start()
|
||||||
|
|
||||||
@ -142,14 +181,15 @@ func copyBinaryFromContainer(containerName, containerPath, destinationPath, fing
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("docker", "cp", fmt.Sprintf("%s:%s", containerName, containerPath), destinationPath)
|
cmd := exec.Command("docker", "cp", fmt.Sprintf("%s:%s", containerName, containerPath), destinationPath) // nolint:gosec
|
||||||
|
// reason for gosec exception: this is for processing test fixtures only, not used in production
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// capture fingerprint file
|
// capture fingerprint file
|
||||||
fingerprintPath := destinationPath + ".fingerprint"
|
fingerprintPath := destinationPath + ".fingerprint"
|
||||||
if err := os.WriteFile(fingerprintPath, []byte(fingerprint), 0644); err != nil {
|
if err := os.WriteFile(fingerprintPath, []byte(fingerprint), 0600); err != nil {
|
||||||
return fmt.Errorf("unable to write fingerprint file: %w", err)
|
return fmt.Errorf("unable to write fingerprint file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,12 @@ package internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Entries map[LogicalEntryKey]EntryInfo
|
type Entries map[LogicalEntryKey]EntryInfo
|
||||||
@ -89,7 +90,6 @@ func ListAllBinaries(appConfig config.Application) (Entries, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ListAllEntries(appConfig config.Application) (Entries, error) {
|
func ListAllEntries(appConfig config.Application) (Entries, error) {
|
||||||
|
|
||||||
snippets, err := allFilePaths(appConfig.SnippetPath)
|
snippets, err := allFilePaths(appConfig.SnippetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to list snippets: %w", err)
|
return nil, fmt.Errorf("unable to list snippets: %w", err)
|
||||||
@ -155,7 +155,7 @@ func getLogicalKey(managedBinaryPath string) (*LogicalEntryKey, error) {
|
|||||||
// infer the logical key from the path alone: name/version/platform/filename
|
// infer the logical key from the path alone: name/version/platform/filename
|
||||||
|
|
||||||
items := SplitFilepath(managedBinaryPath)
|
items := SplitFilepath(managedBinaryPath)
|
||||||
if len(items) != 4 {
|
if len(items) < 4 {
|
||||||
return nil, fmt.Errorf("invalid managed binary path: %q", managedBinaryPath)
|
return nil, fmt.Errorf("invalid managed binary path: %q", managedBinaryPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ func getLogicalKey(managedBinaryPath string) (*LogicalEntryKey, error) {
|
|||||||
OrgName: items[0],
|
OrgName: items[0],
|
||||||
Version: items[1],
|
Version: items[1],
|
||||||
Platform: items[2],
|
Platform: items[2],
|
||||||
Filename: items[3],
|
Filename: filepath.Join(items[3:]...),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,9 +2,10 @@ package internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnippetMetadata struct {
|
type SnippetMetadata struct {
|
||||||
|
|||||||
@ -30,7 +30,6 @@ func (a Action) Skip(newMsg ...string) {
|
|||||||
func (a Action) Done(err error) {
|
func (a Action) Done(err error) {
|
||||||
goToPreviousLineStart()
|
goToPreviousLineStart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
fmt.Printf(" %s✗%s %s%s%s\n", red+bold, reset, red, a.Msg, reset)
|
fmt.Printf(" %s✗%s %s%s%s\n", red+bold, reset, red, a.Msg, reset)
|
||||||
|
|
||||||
var exitError *exec.ExitError
|
var exitError *exec.ExitError
|
||||||
|
|||||||
@ -2,10 +2,11 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/list"
|
"github.com/charmbracelet/bubbles/list"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var quitTextStyle = lipgloss.NewStyle().Margin(1, 0, 2, 4)
|
var quitTextStyle = lipgloss.NewStyle().Margin(1, 0, 2, 4)
|
||||||
|
|||||||
@ -2,9 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/cli"
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/cli"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/ui"
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/ui"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
package testutil
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal"
|
||||||
|
"github.com/anchore/syft/syft/pkg/cataloger/binary/test-fixtures/manager/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SnippetOrBinary returns the path to either the binary or the snippet for the given logical entry key.
|
// SnippetOrBinary returns the path to either the binary or the snippet for the given logical entry key.
|
||||||
@ -96,5 +98,4 @@ func validateSnippet(t *testing.T, binaryPath, snippetPath string) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, expected, metadata.FileSha256, "snippet shadows a binary with a different sha256")
|
require.Equal(t, expected, metadata.FileSha256, "snippet shadows a binary with a different sha256")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user