-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update trivy dependency and fix the code due to breaking changes
- Loading branch information
Showing
8 changed files
with
1,108 additions
and
1,128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Default | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.4' | ||
- name: Test | ||
run: go test ./... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# image-analyzer | ||
OCI images analyzer | ||
|
||
This repository exists for 2 reasons: | ||
- `github.com/castai/image-analyzer/image/daemon.Image` interface. | ||
- Having various analyzers bundled in a single module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package analyzer | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/aquasecurity/trivy/pkg/fanal/types" | ||
"github.com/sirupsen/logrus" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/castai/image-analyzer/image" | ||
) | ||
|
||
func TestArtifact(t *testing.T) { | ||
r := require.New(t) | ||
ctx := context.Background() | ||
log := logrus.New() | ||
log.SetLevel(logrus.DebugLevel) | ||
|
||
digest := "alpine@sha256:60eda2a7bc29a54fe6beae0d72312ea995eb3b8387535e8dbf6767fd1b765d34" // linux/amd64 digest | ||
img, err := image.NewFromRemote(ctx, digest, types.ImageOptions{}) | ||
r.NoError(err) | ||
|
||
artifact, err := NewArtifact(img, log, mockBlockCache{}, ArtifactOption{ | ||
Offline: true, | ||
Parallel: 1, | ||
}) | ||
r.NoError(err) | ||
|
||
ref, err := artifact.Inspect(ctx) | ||
r.NoError(err) | ||
r.NotNil(ref) | ||
r.NotNil(ref.BlobsInfo) | ||
r.Len(ref.BlobsInfo, 1) | ||
r.Len(ref.BlobsInfo[0].PackageInfos, 1) | ||
r.Len(ref.BlobsInfo[0].PackageInfos[0].Packages, 15) | ||
|
||
r.NotNil(ref.ConfigFile) | ||
r.Equal("amd64", ref.ConfigFile.Architecture) | ||
r.Equal("linux", ref.ConfigFile.OS) | ||
|
||
r.NotNil(ref.ArtifactInfo) | ||
r.Equal("amd64", ref.ArtifactInfo.Architecture) | ||
r.Equal("linux", ref.ArtifactInfo.OS) | ||
|
||
r.NotNil(ref.OsInfo) | ||
r.Equal("alpine", string(ref.OsInfo.Family)) | ||
} | ||
|
||
type mockBlockCache struct{} | ||
|
||
func (mockBlockCache) PutBlob(ctx context.Context, key string, blob []byte) error { | ||
return nil | ||
} | ||
|
||
func (mockBlockCache) GetBlob(ctx context.Context, key string) ([]byte, error) { | ||
return nil, ErrCacheNotFound | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.