From 8c6ed3d7c16e5910b0afd3416e1a07d55f92f7aa Mon Sep 17 00:00:00 2001 From: MaineK00n Date: Sun, 19 Sep 2021 17:01:25 +0900 Subject: [PATCH] feat(analyzer): support AlmaLinux and Rocky Linux (#193) --- analyzer/analyzer_test.go | 4 + analyzer/const.go | 2 + analyzer/os/const.go | 6 ++ analyzer/os/redhatbase/alma.go | 59 +++++++++++++ analyzer/os/redhatbase/alma_test.go | 52 +++++++++++ analyzer/os/redhatbase/redhatbase.go | 4 + analyzer/os/redhatbase/rocky.go | 59 +++++++++++++ analyzer/os/redhatbase/rocky_test.go | 52 +++++++++++ .../testdata/alma/almalinux-release | 1 + .../redhatbase/testdata/rocky/rocky-release | 1 + artifact/image/image_test.go | 86 +++++++++---------- artifact/local/fs_test.go | 14 +-- 12 files changed, 290 insertions(+), 50 deletions(-) create mode 100644 analyzer/os/redhatbase/alma.go create mode 100644 analyzer/os/redhatbase/alma_test.go create mode 100644 analyzer/os/redhatbase/rocky.go create mode 100644 analyzer/os/redhatbase/rocky_test.go create mode 100644 analyzer/os/redhatbase/testdata/alma/almalinux-release create mode 100644 analyzer/os/redhatbase/testdata/rocky/rocky-release diff --git a/analyzer/analyzer_test.go b/analyzer/analyzer_test.go index 44789ec87..790f4aacb 100644 --- a/analyzer/analyzer_test.go +++ b/analyzer/analyzer_test.go @@ -462,6 +462,8 @@ func TestAnalyzer_AnalyzerVersions(t *testing.T) { "bundler": 1, "cargo": 1, "centos": 1, + "rocky": 1, + "alma": 1, "composer": 1, "debian": 1, "dpkg": 2, @@ -496,6 +498,8 @@ func TestAnalyzer_AnalyzerVersions(t *testing.T) { "bundler": 1, "cargo": 1, "centos": 1, + "rocky": 1, + "alma": 1, "composer": 1, "debian": 1, "dpkg": 2, diff --git a/analyzer/const.go b/analyzer/const.go index bcd874eb5..7bddf87b1 100644 --- a/analyzer/const.go +++ b/analyzer/const.go @@ -11,6 +11,8 @@ const ( TypeDebian Type = "debian" TypePhoton Type = "photon" TypeCentOS Type = "centos" + TypeRocky Type = "rocky" + TypeAlma Type = "alma" TypeFedora Type = "fedora" TypeOracle Type = "oracle" TypeRedHatBase Type = "redhat" diff --git a/analyzer/os/const.go b/analyzer/os/const.go index 5532b20e3..b7321ab66 100644 --- a/analyzer/os/const.go +++ b/analyzer/os/const.go @@ -15,6 +15,12 @@ const ( // CentOS is done CentOS = "centos" + // Rocky is done + Rocky = "rocky" + + // Alma is done + Alma = "alma" + // Fedora is done Fedora = "fedora" diff --git a/analyzer/os/redhatbase/alma.go b/analyzer/os/redhatbase/alma.go new file mode 100644 index 000000000..7b7fa004e --- /dev/null +++ b/analyzer/os/redhatbase/alma.go @@ -0,0 +1,59 @@ +package redhatbase + +import ( + "bufio" + "bytes" + "os" + "strings" + + "github.com/aquasecurity/fanal/analyzer" + + aos "github.com/aquasecurity/fanal/analyzer/os" + "github.com/aquasecurity/fanal/types" + "github.com/aquasecurity/fanal/utils" + "golang.org/x/xerrors" +) + +const almaAnalyzerVersion = 1 + +func init() { + analyzer.RegisterAnalyzer(&almaOSAnalyzer{}) +} + +type almaOSAnalyzer struct{} + +func (a almaOSAnalyzer) Analyze(target analyzer.AnalysisTarget) (*analyzer.AnalysisResult, error) { + scanner := bufio.NewScanner(bytes.NewBuffer(target.Content)) + for scanner.Scan() { + line := scanner.Text() + result := redhatRe.FindStringSubmatch(strings.TrimSpace(line)) + if len(result) != 3 { + return nil, xerrors.New("alma: invalid almalinux-release") + } + + switch strings.ToLower(result[1]) { + case "alma", "almalinux", "alma linux": + return &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.Alma, Name: result[2]}, + }, nil + } + } + + return nil, xerrors.Errorf("alma: %w", aos.AnalyzeOSError) +} + +func (a almaOSAnalyzer) Required(filePath string, _ os.FileInfo) bool { + return utils.StringInSlice(filePath, a.requiredFiles()) +} + +func (a almaOSAnalyzer) requiredFiles() []string { + return []string{"etc/almalinux-release"} +} + +func (a almaOSAnalyzer) Type() analyzer.Type { + return analyzer.TypeAlma +} + +func (a almaOSAnalyzer) Version() int { + return almaAnalyzerVersion +} diff --git a/analyzer/os/redhatbase/alma_test.go b/analyzer/os/redhatbase/alma_test.go new file mode 100644 index 000000000..798f05049 --- /dev/null +++ b/analyzer/os/redhatbase/alma_test.go @@ -0,0 +1,52 @@ +package redhatbase + +import ( + "os" + "testing" + + "github.com/aquasecurity/fanal/analyzer" + "github.com/aquasecurity/fanal/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_almaOSAnalyzer_Analyze(t *testing.T) { + tests := []struct { + name string + inputFile string + want *analyzer.AnalysisResult + wantErr string + }{ + { + name: "happy path", + inputFile: "testdata/alma/almalinux-release", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: "alma", Name: "8.4"}, + }, + }, + { + name: "sad path", + inputFile: "testdata/not_redhatbase/empty", + wantErr: "alma: unable to analyze OS information", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + a := almaOSAnalyzer{} + b, err := os.ReadFile(tt.inputFile) + require.NoError(t, err) + + got, err := a.Analyze(analyzer.AnalysisTarget{ + FilePath: "etc/almalinux-release", + Content: b, + }) + if tt.wantErr != "" { + require.Error(t, err) + assert.Contains(t, err.Error(), tt.wantErr) + return + } + require.NoError(t, err) + assert.Equal(t, tt.want, got) + }) + } +} diff --git a/analyzer/os/redhatbase/redhatbase.go b/analyzer/os/redhatbase/redhatbase.go index 66ccb0c91..55d86a5ac 100644 --- a/analyzer/os/redhatbase/redhatbase.go +++ b/analyzer/os/redhatbase/redhatbase.go @@ -51,6 +51,10 @@ func (a redhatOSAnalyzer) parseRelease(content []byte) (types.OS, error) { switch strings.ToLower(result[1]) { case "centos", "centos linux": return types.OS{Family: aos.CentOS, Name: result[2]}, nil + case "rocky", "rocky linux": + return types.OS{Family: aos.Rocky, Name: result[2]}, nil + case "alma", "almalinux", "alma linux": + return types.OS{Family: aos.Alma, Name: result[2]}, nil case "oracle", "oracle linux", "oracle linux server": return types.OS{Family: aos.Oracle, Name: result[2]}, nil case "fedora", "fedora linux": diff --git a/analyzer/os/redhatbase/rocky.go b/analyzer/os/redhatbase/rocky.go new file mode 100644 index 000000000..fcb6d24de --- /dev/null +++ b/analyzer/os/redhatbase/rocky.go @@ -0,0 +1,59 @@ +package redhatbase + +import ( + "bufio" + "bytes" + "os" + "strings" + + "github.com/aquasecurity/fanal/analyzer" + + aos "github.com/aquasecurity/fanal/analyzer/os" + "github.com/aquasecurity/fanal/types" + "github.com/aquasecurity/fanal/utils" + "golang.org/x/xerrors" +) + +const rockyAnalyzerVersion = 1 + +func init() { + analyzer.RegisterAnalyzer(&rockyOSAnalyzer{}) +} + +type rockyOSAnalyzer struct{} + +func (a rockyOSAnalyzer) Analyze(target analyzer.AnalysisTarget) (*analyzer.AnalysisResult, error) { + scanner := bufio.NewScanner(bytes.NewBuffer(target.Content)) + for scanner.Scan() { + line := scanner.Text() + result := redhatRe.FindStringSubmatch(strings.TrimSpace(line)) + if len(result) != 3 { + return nil, xerrors.New("rocky: invalid rocky-release") + } + + switch strings.ToLower(result[1]) { + case "rocky", "rocky linux": + return &analyzer.AnalysisResult{ + OS: &types.OS{Family: aos.Rocky, Name: result[2]}, + }, nil + } + } + + return nil, xerrors.Errorf("rocky: %w", aos.AnalyzeOSError) +} + +func (a rockyOSAnalyzer) Required(filePath string, _ os.FileInfo) bool { + return utils.StringInSlice(filePath, a.requiredFiles()) +} + +func (a rockyOSAnalyzer) requiredFiles() []string { + return []string{"etc/rocky-release"} +} + +func (a rockyOSAnalyzer) Type() analyzer.Type { + return analyzer.TypeRocky +} + +func (a rockyOSAnalyzer) Version() int { + return rockyAnalyzerVersion +} diff --git a/analyzer/os/redhatbase/rocky_test.go b/analyzer/os/redhatbase/rocky_test.go new file mode 100644 index 000000000..d0e9ae657 --- /dev/null +++ b/analyzer/os/redhatbase/rocky_test.go @@ -0,0 +1,52 @@ +package redhatbase + +import ( + "os" + "testing" + + "github.com/aquasecurity/fanal/analyzer" + "github.com/aquasecurity/fanal/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_rockyOSAnalyzer_Analyze(t *testing.T) { + tests := []struct { + name string + inputFile string + want *analyzer.AnalysisResult + wantErr string + }{ + { + name: "happy path", + inputFile: "testdata/rocky/rocky-release", + want: &analyzer.AnalysisResult{ + OS: &types.OS{Family: "rocky", Name: "8.4"}, + }, + }, + { + name: "sad path", + inputFile: "testdata/not_redhatbase/empty", + wantErr: "rocky: unable to analyze OS information", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + a := rockyOSAnalyzer{} + b, err := os.ReadFile(tt.inputFile) + require.NoError(t, err) + + got, err := a.Analyze(analyzer.AnalysisTarget{ + FilePath: "etc/rocky-release", + Content: b, + }) + if tt.wantErr != "" { + require.Error(t, err) + assert.Contains(t, err.Error(), tt.wantErr) + return + } + require.NoError(t, err) + assert.Equal(t, tt.want, got) + }) + } +} diff --git a/analyzer/os/redhatbase/testdata/alma/almalinux-release b/analyzer/os/redhatbase/testdata/alma/almalinux-release new file mode 100644 index 000000000..078ddf097 --- /dev/null +++ b/analyzer/os/redhatbase/testdata/alma/almalinux-release @@ -0,0 +1 @@ +AlmaLinux release 8.4 (Electric Cheetah) \ No newline at end of file diff --git a/analyzer/os/redhatbase/testdata/rocky/rocky-release b/analyzer/os/redhatbase/testdata/rocky/rocky-release new file mode 100644 index 000000000..e79c56654 --- /dev/null +++ b/analyzer/os/redhatbase/testdata/rocky/rocky-release @@ -0,0 +1 @@ +Rocky Linux release 8.4 (Green Obsidian) \ No newline at end of file diff --git a/artifact/image/image_test.go b/artifact/image/image_test.go index 156655eb3..99ed2d874 100644 --- a/artifact/image/image_test.go +++ b/artifact/image/image_test.go @@ -41,17 +41,17 @@ func TestArtifact_Inspect(t *testing.T) { missingBlobsExpectation: cache.ArtifactCacheMissingBlobsExpectation{ Args: cache.ArtifactCacheMissingBlobsArgs{ ArtifactID: "sha256:59c4082ceb491faefd44cf9a006dd24c8f57b44b438f081251c90ea1367ca043", - BlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + BlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, Returns: cache.ArtifactCacheMissingBlobsReturns{ MissingArtifact: true, - MissingBlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + MissingBlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, }, putBlobExpectations: []cache.ArtifactCachePutBlobExpectation{ { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1", + BlobID: "sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -105,7 +105,7 @@ func TestArtifact_Inspect(t *testing.T) { Name: "../../test/testdata/alpine-311.tar.gz", Type: types.ArtifactContainerImage, ID: "sha256:59c4082ceb491faefd44cf9a006dd24c8f57b44b438f081251c90ea1367ca043", - BlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + BlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, ImageMetadata: types.ImageMetadata{ ID: "sha256:a187dde48cd289ac374ad8539930628314bc581a481cdb41409c9289419ddb72", DiffIDs: []string{ @@ -152,25 +152,25 @@ func TestArtifact_Inspect(t *testing.T) { Args: cache.ArtifactCacheMissingBlobsArgs{ ArtifactID: "sha256:b79b48d9023d85be348e989163bb5f78bf9d0a9e6004a656dba50841ff212693", BlobIDs: []string{ - "sha256:845f9567629f21809cae60a6b24e1020360e6121dfa8cda46ce82502cdcd9d26", - "sha256:fb3b90795e0c4bec58bb02110db18ea5e20687f0788a8ea5a51a45f2ac88157b", - "sha256:e0707721f6ffe8ab14b5b1da484a802825cf968c8c58624d73bf00443f717b3f", - "sha256:42c1a5bbb04b0e060ce8f44087436c71068de03d5a86f04ef020190c6e9e07fe", + "sha256:0203a9d8a0a2ee515ae3d9d211372316791654f6d4b7f9f00a3c0906be054e93", + "sha256:02af4fbed4ea7e8021770ab6846c6183e763b45b0adb0215ef2377689d2d501b", + "sha256:ee974db343198546d609c78a705989ab295c06475d0ff0fd392f2a4970f040de", + "sha256:7ca1744c7455a336ec8c430c8f0e3091f6fac3b2130ce9a40f88e7c0becf47e6", }, }, Returns: cache.ArtifactCacheMissingBlobsReturns{ MissingBlobIDs: []string{ - "sha256:845f9567629f21809cae60a6b24e1020360e6121dfa8cda46ce82502cdcd9d26", - "sha256:fb3b90795e0c4bec58bb02110db18ea5e20687f0788a8ea5a51a45f2ac88157b", - "sha256:e0707721f6ffe8ab14b5b1da484a802825cf968c8c58624d73bf00443f717b3f", - "sha256:42c1a5bbb04b0e060ce8f44087436c71068de03d5a86f04ef020190c6e9e07fe", + "sha256:0203a9d8a0a2ee515ae3d9d211372316791654f6d4b7f9f00a3c0906be054e93", + "sha256:02af4fbed4ea7e8021770ab6846c6183e763b45b0adb0215ef2377689d2d501b", + "sha256:ee974db343198546d609c78a705989ab295c06475d0ff0fd392f2a4970f040de", + "sha256:7ca1744c7455a336ec8c430c8f0e3091f6fac3b2130ce9a40f88e7c0becf47e6", }, }, }, putBlobExpectations: []cache.ArtifactCachePutBlobExpectation{ { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:845f9567629f21809cae60a6b24e1020360e6121dfa8cda46ce82502cdcd9d26", + BlobID: "sha256:0203a9d8a0a2ee515ae3d9d211372316791654f6d4b7f9f00a3c0906be054e93", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -204,7 +204,7 @@ func TestArtifact_Inspect(t *testing.T) { }, { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:fb3b90795e0c4bec58bb02110db18ea5e20687f0788a8ea5a51a45f2ac88157b", + BlobID: "sha256:02af4fbed4ea7e8021770ab6846c6183e763b45b0adb0215ef2377689d2d501b", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -234,7 +234,7 @@ func TestArtifact_Inspect(t *testing.T) { }, { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:e0707721f6ffe8ab14b5b1da484a802825cf968c8c58624d73bf00443f717b3f", + BlobID: "sha256:ee974db343198546d609c78a705989ab295c06475d0ff0fd392f2a4970f040de", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -264,7 +264,7 @@ func TestArtifact_Inspect(t *testing.T) { { // Gemfile.lock will not be scanned. Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:42c1a5bbb04b0e060ce8f44087436c71068de03d5a86f04ef020190c6e9e07fe", + BlobID: "sha256:7ca1744c7455a336ec8c430c8f0e3091f6fac3b2130ce9a40f88e7c0becf47e6", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -279,10 +279,10 @@ func TestArtifact_Inspect(t *testing.T) { Type: types.ArtifactContainerImage, ID: "sha256:b79b48d9023d85be348e989163bb5f78bf9d0a9e6004a656dba50841ff212693", BlobIDs: []string{ - "sha256:845f9567629f21809cae60a6b24e1020360e6121dfa8cda46ce82502cdcd9d26", - "sha256:fb3b90795e0c4bec58bb02110db18ea5e20687f0788a8ea5a51a45f2ac88157b", - "sha256:e0707721f6ffe8ab14b5b1da484a802825cf968c8c58624d73bf00443f717b3f", - "sha256:42c1a5bbb04b0e060ce8f44087436c71068de03d5a86f04ef020190c6e9e07fe", + "sha256:0203a9d8a0a2ee515ae3d9d211372316791654f6d4b7f9f00a3c0906be054e93", + "sha256:02af4fbed4ea7e8021770ab6846c6183e763b45b0adb0215ef2377689d2d501b", + "sha256:ee974db343198546d609c78a705989ab295c06475d0ff0fd392f2a4970f040de", + "sha256:7ca1744c7455a336ec8c430c8f0e3091f6fac3b2130ce9a40f88e7c0becf47e6", }, ImageMetadata: types.ImageMetadata{ ID: "sha256:58701fd185bda36cab0557bb6438661831267aa4a9e0b54211c4d5317a48aff4", @@ -360,25 +360,25 @@ func TestArtifact_Inspect(t *testing.T) { Args: cache.ArtifactCacheMissingBlobsArgs{ ArtifactID: "sha256:b79b48d9023d85be348e989163bb5f78bf9d0a9e6004a656dba50841ff212693", BlobIDs: []string{ - "sha256:e2f9b96c990f1728a35c3ee50b1503d1ebd98a552dcd513ad1e8a6ced387d571", - "sha256:0b017d9694d652e2ae11d75fde3b586b3bb4ce3c732795cd6fa16038cb994260", - "sha256:de7f32e44188db730d3348a282e8976ebfc4914db8e7b636f66c80f311b1536e", - "sha256:27626ea3e23a93678c0437d31d72b3151da666e276f0115bdd1c5cc8f731edfe", + "sha256:f964ce5cb9cb1721515e117ce12e9166e71a251f58c34b4752ffe19b9bf7846e", + "sha256:9629d21a44aafadb938fe26a48d9eb75a92a590f43d38ade3da44c965472dc39", + "sha256:9811da603662e8806d723b2bafc1fcbae8292596f3ed78a49abfed7da0c26559", + "sha256:5437593858561686d969e14d2fa4b7badf3a7d82f4cd688d0c067b94b505f131", }, }, Returns: cache.ArtifactCacheMissingBlobsReturns{ MissingBlobIDs: []string{ - "sha256:e2f9b96c990f1728a35c3ee50b1503d1ebd98a552dcd513ad1e8a6ced387d571", - "sha256:0b017d9694d652e2ae11d75fde3b586b3bb4ce3c732795cd6fa16038cb994260", - "sha256:de7f32e44188db730d3348a282e8976ebfc4914db8e7b636f66c80f311b1536e", - "sha256:27626ea3e23a93678c0437d31d72b3151da666e276f0115bdd1c5cc8f731edfe", + "sha256:f964ce5cb9cb1721515e117ce12e9166e71a251f58c34b4752ffe19b9bf7846e", + "sha256:9629d21a44aafadb938fe26a48d9eb75a92a590f43d38ade3da44c965472dc39", + "sha256:9811da603662e8806d723b2bafc1fcbae8292596f3ed78a49abfed7da0c26559", + "sha256:5437593858561686d969e14d2fa4b7badf3a7d82f4cd688d0c067b94b505f131", }, }, }, putBlobExpectations: []cache.ArtifactCachePutBlobExpectation{ { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:e2f9b96c990f1728a35c3ee50b1503d1ebd98a552dcd513ad1e8a6ced387d571", + BlobID: "sha256:f964ce5cb9cb1721515e117ce12e9166e71a251f58c34b4752ffe19b9bf7846e", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -388,7 +388,7 @@ func TestArtifact_Inspect(t *testing.T) { }, { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:0b017d9694d652e2ae11d75fde3b586b3bb4ce3c732795cd6fa16038cb994260", + BlobID: "sha256:9629d21a44aafadb938fe26a48d9eb75a92a590f43d38ade3da44c965472dc39", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -398,7 +398,7 @@ func TestArtifact_Inspect(t *testing.T) { }, { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:de7f32e44188db730d3348a282e8976ebfc4914db8e7b636f66c80f311b1536e", + BlobID: "sha256:9811da603662e8806d723b2bafc1fcbae8292596f3ed78a49abfed7da0c26559", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -409,7 +409,7 @@ func TestArtifact_Inspect(t *testing.T) { }, { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:27626ea3e23a93678c0437d31d72b3151da666e276f0115bdd1c5cc8f731edfe", + BlobID: "sha256:5437593858561686d969e14d2fa4b7badf3a7d82f4cd688d0c067b94b505f131", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -424,10 +424,10 @@ func TestArtifact_Inspect(t *testing.T) { Type: types.ArtifactContainerImage, ID: "sha256:b79b48d9023d85be348e989163bb5f78bf9d0a9e6004a656dba50841ff212693", BlobIDs: []string{ - "sha256:e2f9b96c990f1728a35c3ee50b1503d1ebd98a552dcd513ad1e8a6ced387d571", - "sha256:0b017d9694d652e2ae11d75fde3b586b3bb4ce3c732795cd6fa16038cb994260", - "sha256:de7f32e44188db730d3348a282e8976ebfc4914db8e7b636f66c80f311b1536e", - "sha256:27626ea3e23a93678c0437d31d72b3151da666e276f0115bdd1c5cc8f731edfe", + "sha256:f964ce5cb9cb1721515e117ce12e9166e71a251f58c34b4752ffe19b9bf7846e", + "sha256:9629d21a44aafadb938fe26a48d9eb75a92a590f43d38ade3da44c965472dc39", + "sha256:9811da603662e8806d723b2bafc1fcbae8292596f3ed78a49abfed7da0c26559", + "sha256:5437593858561686d969e14d2fa4b7badf3a7d82f4cd688d0c067b94b505f131", }, ImageMetadata: types.ImageMetadata{ ID: "sha256:58701fd185bda36cab0557bb6438661831267aa4a9e0b54211c4d5317a48aff4", @@ -493,7 +493,7 @@ func TestArtifact_Inspect(t *testing.T) { missingBlobsExpectation: cache.ArtifactCacheMissingBlobsExpectation{ Args: cache.ArtifactCacheMissingBlobsArgs{ ArtifactID: "sha256:59c4082ceb491faefd44cf9a006dd24c8f57b44b438f081251c90ea1367ca043", - BlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + BlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, Returns: cache.ArtifactCacheMissingBlobsReturns{ Err: xerrors.New("MissingBlobs failed"), @@ -507,16 +507,16 @@ func TestArtifact_Inspect(t *testing.T) { missingBlobsExpectation: cache.ArtifactCacheMissingBlobsExpectation{ Args: cache.ArtifactCacheMissingBlobsArgs{ ArtifactID: "sha256:59c4082ceb491faefd44cf9a006dd24c8f57b44b438f081251c90ea1367ca043", - BlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + BlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, Returns: cache.ArtifactCacheMissingBlobsReturns{ - MissingBlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + MissingBlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, }, putBlobExpectations: []cache.ArtifactCachePutBlobExpectation{ { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1", + BlobID: "sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", @@ -562,17 +562,17 @@ func TestArtifact_Inspect(t *testing.T) { missingBlobsExpectation: cache.ArtifactCacheMissingBlobsExpectation{ Args: cache.ArtifactCacheMissingBlobsArgs{ ArtifactID: "sha256:59c4082ceb491faefd44cf9a006dd24c8f57b44b438f081251c90ea1367ca043", - BlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + BlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, Returns: cache.ArtifactCacheMissingBlobsReturns{ MissingArtifact: true, - MissingBlobIDs: []string{"sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1"}, + MissingBlobIDs: []string{"sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29"}, }, }, putBlobExpectations: []cache.ArtifactCachePutBlobExpectation{ { Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:6b282bc9d53ed867accf7259fba5b37ec3b98d6c7dcf2b2bd81f4aadd649a3b1", + BlobID: "sha256:609d3e92df961c3a66d0bdb61f07946aac7614489ef96d6dee7c2e833fbc5f29", BlobInfo: types.BlobInfo{ SchemaVersion: 1, Digest: "", diff --git a/artifact/local/fs_test.go b/artifact/local/fs_test.go index 4cc07f7f1..e21aae54c 100644 --- a/artifact/local/fs_test.go +++ b/artifact/local/fs_test.go @@ -38,7 +38,7 @@ func TestArtifact_Inspect(t *testing.T) { }, putBlobExpectation: cache.ArtifactCachePutBlobExpectation{ Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:65ba863789c188a8592f1c2bcf3679eddecb11f24c68919be2e554dde3f0ccb6", + BlobID: "sha256:b452b832b5b35485b18fc7d80baacfd4fc812cd3b07d7d02727330f7076a999c", BlobInfo: types.BlobInfo{ SchemaVersion: types.BlobJSONSchemaVersion, DiffID: "sha256:0f88c2f4a441514ebd105e81527af76af15bed17d91c17ba3637397f8c4f1925", @@ -61,9 +61,9 @@ func TestArtifact_Inspect(t *testing.T) { want: types.ArtifactReference{ Name: "host", Type: types.ArtifactFilesystem, - ID: "sha256:65ba863789c188a8592f1c2bcf3679eddecb11f24c68919be2e554dde3f0ccb6", + ID: "sha256:b452b832b5b35485b18fc7d80baacfd4fc812cd3b07d7d02727330f7076a999c", BlobIDs: []string{ - "sha256:65ba863789c188a8592f1c2bcf3679eddecb11f24c68919be2e554dde3f0ccb6", + "sha256:b452b832b5b35485b18fc7d80baacfd4fc812cd3b07d7d02727330f7076a999c", }, }, }, @@ -75,7 +75,7 @@ func TestArtifact_Inspect(t *testing.T) { disabledAnalyzers: []analyzer.Type{analyzer.TypeAlpine, analyzer.TypeApk}, putBlobExpectation: cache.ArtifactCachePutBlobExpectation{ Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:407f890daa0ac7bb41857e7c0618b5bfeffe3a9022a89a8d5bec543ebc8849fd", + BlobID: "sha256:0c144e61b3867b1b6ef5d58620f08e9434fbd30e731094e92feb25060dee03b4", BlobInfo: types.BlobInfo{ SchemaVersion: types.BlobJSONSchemaVersion, DiffID: "sha256:3404e98968ad338dc60ef74c0dd5bdd893478415cd2296b0c265a5650b3ae4d6", @@ -86,9 +86,9 @@ func TestArtifact_Inspect(t *testing.T) { want: types.ArtifactReference{ Name: "host", Type: types.ArtifactFilesystem, - ID: "sha256:407f890daa0ac7bb41857e7c0618b5bfeffe3a9022a89a8d5bec543ebc8849fd", + ID: "sha256:0c144e61b3867b1b6ef5d58620f08e9434fbd30e731094e92feb25060dee03b4", BlobIDs: []string{ - "sha256:407f890daa0ac7bb41857e7c0618b5bfeffe3a9022a89a8d5bec543ebc8849fd", + "sha256:0c144e61b3867b1b6ef5d58620f08e9434fbd30e731094e92feb25060dee03b4", }, }, }, @@ -99,7 +99,7 @@ func TestArtifact_Inspect(t *testing.T) { }, putBlobExpectation: cache.ArtifactCachePutBlobExpectation{ Args: cache.ArtifactCachePutBlobArgs{ - BlobID: "sha256:65ba863789c188a8592f1c2bcf3679eddecb11f24c68919be2e554dde3f0ccb6", + BlobID: "sha256:b452b832b5b35485b18fc7d80baacfd4fc812cd3b07d7d02727330f7076a999c", BlobInfo: types.BlobInfo{ SchemaVersion: types.BlobJSONSchemaVersion, DiffID: "sha256:0f88c2f4a441514ebd105e81527af76af15bed17d91c17ba3637397f8c4f1925",