mirror of
https://github.com/anchore/syft.git
synced 2026-10-27 12:32:26 +01:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d54d20a563 | ||
|
|
abfd244dc5 | ||
|
|
8e9d1d5e91 |
@@ -55,7 +55,7 @@ jobs:
|
||||
echo "GLOW=GLOW_LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||
id: latest-versions
|
||||
|
||||
- uses: tibdex/github-app-token@v2
|
||||
- uses: tibdex/github-app-token@v1
|
||||
id: generate-token
|
||||
with:
|
||||
app_id: ${{ secrets.TOKEN_APP_ID }}
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
- run: |
|
||||
make generate-cpe-dictionary-index
|
||||
|
||||
- uses: tibdex/github-app-token@v2
|
||||
- uses: tibdex/github-app-token@v1
|
||||
id: generate-token
|
||||
with:
|
||||
app_id: ${{ secrets.TOKEN_APP_ID }}
|
||||
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||
id: latest-version
|
||||
|
||||
- uses: tibdex/github-app-token@v2
|
||||
- uses: tibdex/github-app-token@v1
|
||||
id: generate-token
|
||||
with:
|
||||
app_id: ${{ secrets.TOKEN_APP_ID }}
|
||||
|
||||
@@ -70,7 +70,7 @@ all: static-analysis test ## Run all linux-based checks (linting, license check,
|
||||
static-analysis: check-go-mod-tidy lint check-licenses check-json-schema-drift ## Run all static analysis checks
|
||||
|
||||
.PHONY: test
|
||||
test: unit integration validate-cyclonedx-schema benchmark cli ## Run all tests (currently unit, integration, linux compare, and cli tests)
|
||||
test: unit race integration validate-cyclonedx-schema benchmark cli ## Run all tests (currently unit, integration, linux compare, and cli tests)
|
||||
|
||||
|
||||
## Bootstrapping targets #################################
|
||||
@@ -147,9 +147,14 @@ check-json-schema-drift:
|
||||
.PHONY: unit
|
||||
unit: $(TEMP_DIR) fixtures ## Run unit tests (with coverage)
|
||||
$(call title,Running unit tests)
|
||||
go test -coverprofile $(TEMP_DIR)/unit-coverage-details.txt $(shell go list ./... | grep -v anchore/syft/test)
|
||||
go test -race -coverprofile $(TEMP_DIR)/unit-coverage-details.txt $(shell go list ./... | grep -v anchore/syft/test)
|
||||
@.github/scripts/coverage.py $(COVERAGE_THRESHOLD) $(TEMP_DIR)/unit-coverage-details.txt
|
||||
|
||||
.PHONY: race
|
||||
race:
|
||||
$(call title,Running main with race detector enabled)
|
||||
go run -race cmd/syft/main.go alpine:latest
|
||||
|
||||
.PHONY: integration
|
||||
integration: ## Run integration tests
|
||||
$(call title,Running integration tests)
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
const powerUserExample = ` {{.appName}} {{.command}} <image>
|
||||
DEPRECATED - THIS COMMAND WILL BE REMOVED in v1.0.0
|
||||
Template outputs are not supported.
|
||||
Only image sources are supported (e.g. docker: , podman: , docker-archive: , oci: , etc.), the directory source (dir:) is not supported, template outputs are not supported.
|
||||
All behavior is controlled via application configuration and environment variables (see https://github.com/anchore/syft#configuration)
|
||||
`
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ func (m *Handler) handleAttestationStarted(e partybus.Event) []tea.Model {
|
||||
return nil
|
||||
}
|
||||
|
||||
stage := progress.Stage{}
|
||||
stage := progress.NewAtomicStage("")
|
||||
|
||||
tsk := m.newTaskProgress(
|
||||
taskprogress.Title{
|
||||
@@ -79,7 +79,7 @@ func (m *Handler) handleAttestationStarted(e partybus.Event) []tea.Model {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &stage,
|
||||
Stager: stage,
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -94,7 +94,7 @@ func (m *Handler) handleAttestationStarted(e partybus.Event) []tea.Model {
|
||||
|
||||
return []tea.Model{
|
||||
tsk,
|
||||
newLogFrame(newBackgroundLineReader(m.Running, reader, &stage), prog, borderStyle),
|
||||
newLogFrame(newBackgroundLineReader(m.Running, reader, stage), prog, borderStyle),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func newLogFrame(reader *backgroundLineReader, prog progress.Progressable, borde
|
||||
}
|
||||
}
|
||||
|
||||
func newBackgroundLineReader(wg *sync.WaitGroup, reader io.Reader, stage *progress.Stage) *backgroundLineReader {
|
||||
func newBackgroundLineReader(wg *sync.WaitGroup, reader io.Reader, stage *progress.AtomicStage) *backgroundLineReader {
|
||||
r := &backgroundLineReader{
|
||||
limit: 7,
|
||||
lock: &sync.RWMutex{},
|
||||
@@ -131,7 +131,7 @@ func newBackgroundLineReader(wg *sync.WaitGroup, reader io.Reader, stage *progre
|
||||
return r
|
||||
}
|
||||
|
||||
func (l *backgroundLineReader) read(reader io.Reader, stage *progress.Stage) {
|
||||
func (l *backgroundLineReader) read(reader io.Reader, stage *progress.AtomicStage) {
|
||||
s := bufio.NewScanner(reader)
|
||||
|
||||
for s.Scan() {
|
||||
@@ -146,9 +146,9 @@ func (l *backgroundLineReader) read(reader io.Reader, stage *progress.Stage) {
|
||||
if len(fields) == 2 {
|
||||
present = fmt.Sprintf("transparency log index: %s", fields[1])
|
||||
}
|
||||
stage.Current = present
|
||||
stage.Set(present)
|
||||
} else if strings.Contains(text, "WARNING: skipping transparency log upload") {
|
||||
stage.Current = "transparency log upload skipped"
|
||||
stage.Set("transparency log upload skipped")
|
||||
}
|
||||
|
||||
// only show the last X lines of the shell output
|
||||
|
||||
@@ -33,9 +33,7 @@ func TestHandler_handleFetchImage(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
@@ -58,9 +56,7 @@ func TestHandler_handleFetchImage(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
|
||||
@@ -33,9 +33,7 @@ func TestHandler_handleFileDigestsCatalogerStarted(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
@@ -57,9 +55,7 @@ func TestHandler_handleFileDigestsCatalogerStarted(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
|
||||
@@ -33,9 +33,7 @@ func TestHandler_handleFileIndexingStarted(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
@@ -58,9 +56,7 @@ func TestHandler_handleFileIndexingStarted(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
|
||||
@@ -33,9 +33,7 @@ func TestHandler_handleFileMetadataCatalogerStarted(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
@@ -57,9 +55,7 @@ func TestHandler_handleFileMetadataCatalogerStarted(t *testing.T) {
|
||||
progress.Stager
|
||||
}{
|
||||
Progressable: prog,
|
||||
Stager: &progress.Stage{
|
||||
Current: "current",
|
||||
},
|
||||
Stager: progress.NewAtomicStage("current"),
|
||||
}
|
||||
|
||||
return partybus.Event{
|
||||
|
||||
@@ -25,9 +25,7 @@ func TestHandler_handleSecretsCatalogerStarted(t *testing.T) {
|
||||
{
|
||||
name: "cataloging in progress",
|
||||
eventFn: func(t *testing.T) partybus.Event {
|
||||
stage := &progress.Stage{
|
||||
Current: "current",
|
||||
}
|
||||
stage := progress.NewAtomicStage("current")
|
||||
secretsDiscovered := progress.NewManual(-1)
|
||||
secretsDiscovered.Set(64)
|
||||
prog := progress.NewManual(72)
|
||||
@@ -47,9 +45,7 @@ func TestHandler_handleSecretsCatalogerStarted(t *testing.T) {
|
||||
{
|
||||
name: "cataloging complete",
|
||||
eventFn: func(t *testing.T) partybus.Event {
|
||||
stage := &progress.Stage{
|
||||
Current: "current",
|
||||
}
|
||||
stage := progress.NewAtomicStage("current")
|
||||
secretsDiscovered := progress.NewManual(-1)
|
||||
secretsDiscovered.Set(64)
|
||||
prog := progress.NewManual(72)
|
||||
|
||||
@@ -17,7 +17,7 @@ require (
|
||||
github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04
|
||||
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b
|
||||
github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501
|
||||
github.com/anchore/stereoscope v0.0.0-20230907152702-057dda3667e7
|
||||
github.com/anchore/stereoscope v0.0.0-20230829142608-334c2222e137
|
||||
// we are hinting brotli to latest due to warning when installing archiver v3:
|
||||
// go: warning: github.com/andybalholm/brotli@v1.0.1: retracted by module author: occasional panics and data corruption
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
|
||||
@@ -106,8 +106,8 @@ github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b h1:e1bmaoJfZV
|
||||
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b/go.mod h1:Bkc+JYWjMCF8OyZ340IMSIi2Ebf3uwByOk6ho4wne1E=
|
||||
github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501 h1:AV7qjwMcM4r8wFhJq3jLRztew3ywIyPTRapl2T1s9o8=
|
||||
github.com/anchore/packageurl-go v0.1.1-0.20230104203445-02e0a6721501/go.mod h1:Blo6OgJNiYF41ufcgHKkbCKF2MDOMlrqhXv/ij6ocR4=
|
||||
github.com/anchore/stereoscope v0.0.0-20230907152702-057dda3667e7 h1:mbYk+Cvvlfr/kRUz7LqATmjOT4+mV0YufNtj3aqU2fw=
|
||||
github.com/anchore/stereoscope v0.0.0-20230907152702-057dda3667e7/go.mod h1:bEbCTAbTx/Ot+kSWVfXgInyU+88+0gP+G8L+LPgrunw=
|
||||
github.com/anchore/stereoscope v0.0.0-20230829142608-334c2222e137 h1:ZuiAV3lYKbGPkZR42UpoKecp/9aFU38CZSjaxjXCMYc=
|
||||
github.com/anchore/stereoscope v0.0.0-20230829142608-334c2222e137/go.mod h1:jkylrnuv++srUa2rsqCnG0n1ShD+0k2Xa6YtoNoRjAY=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
|
||||
@@ -43,7 +43,7 @@ func (i *Cataloger) Catalog(resolver file.Resolver, coordinates ...file.Coordina
|
||||
|
||||
stage, prog := digestsCatalogingProgress(int64(len(locations)))
|
||||
for _, location := range locations {
|
||||
stage.Current = location.RealPath
|
||||
stage.Set(location.RealPath)
|
||||
result, err := i.catalogLocation(resolver, location)
|
||||
|
||||
if errors.Is(err, ErrUndigestableFile) {
|
||||
@@ -91,8 +91,8 @@ func (i *Cataloger) catalogLocation(resolver file.Resolver, location file.Locati
|
||||
return digests, nil
|
||||
}
|
||||
|
||||
func digestsCatalogingProgress(locations int64) (*progress.Stage, *progress.Manual) {
|
||||
stage := &progress.Stage{}
|
||||
func digestsCatalogingProgress(locations int64) (*progress.AtomicStage, *progress.Manual) {
|
||||
stage := progress.NewAtomicStage("")
|
||||
prog := progress.NewManual(locations)
|
||||
|
||||
bus.Publish(partybus.Event{
|
||||
|
||||
@@ -38,7 +38,7 @@ func (i *Cataloger) Catalog(resolver file.Resolver, coordinates ...file.Coordina
|
||||
|
||||
stage, prog := metadataCatalogingProgress(int64(len(locations)))
|
||||
for location := range locations {
|
||||
stage.Current = location.RealPath
|
||||
stage.Set(location.RealPath)
|
||||
metadata, err := resolver.FileMetadataByLocation(location)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -52,8 +52,8 @@ func (i *Cataloger) Catalog(resolver file.Resolver, coordinates ...file.Coordina
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func metadataCatalogingProgress(locations int64) (*progress.Stage, *progress.Manual) {
|
||||
stage := &progress.Stage{}
|
||||
func metadataCatalogingProgress(locations int64) (*progress.AtomicStage, *progress.Manual) {
|
||||
stage := progress.NewAtomicStage("")
|
||||
prog := progress.NewManual(locations)
|
||||
|
||||
bus.Publish(partybus.Event{
|
||||
|
||||
@@ -47,7 +47,7 @@ func (i *Cataloger) Catalog(resolver file.Resolver) (map[file.Coordinates][]file
|
||||
locations := internal2.AllRegularFiles(resolver)
|
||||
stage, prog, secretsDiscovered := secretsCatalogingProgress(int64(len(locations)))
|
||||
for _, location := range locations {
|
||||
stage.Current = location.RealPath
|
||||
stage.Set(location.RealPath)
|
||||
result, err := i.catalogLocation(resolver, location)
|
||||
if internal.IsErrPathPermission(err) {
|
||||
log.Debugf("secrets cataloger skipping - %+v", err)
|
||||
@@ -139,8 +139,8 @@ type Monitor struct {
|
||||
progress.Progressable
|
||||
}
|
||||
|
||||
func secretsCatalogingProgress(locations int64) (*progress.Stage, *progress.Manual, *progress.Manual) {
|
||||
stage := &progress.Stage{}
|
||||
func secretsCatalogingProgress(locations int64) (*progress.AtomicStage, *progress.Manual, *progress.Manual) {
|
||||
stage := progress.NewAtomicStage("")
|
||||
secretsDiscovered := &progress.Manual{}
|
||||
prog := progress.NewManual(locations)
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ func (r *directoryIndexer) build() (filetree.Reader, filetree.IndexReader, error
|
||||
return r.tree, r.index, indexAllRoots(r.path, r.indexTree)
|
||||
}
|
||||
|
||||
func indexAllRoots(root string, indexer func(string, *progress.Stage) ([]string, error)) error {
|
||||
func indexAllRoots(root string, indexer func(string, *progress.AtomicStage) ([]string, error)) error {
|
||||
// why account for multiple roots? To cover cases when there is a symlink that references above the root path,
|
||||
// in which case we need to additionally index where the link resolves to. it's for this reason why the filetree
|
||||
// must be relative to the root of the filesystem (and not just relative to the given path).
|
||||
@@ -95,7 +95,7 @@ loop:
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *directoryIndexer) indexTree(root string, stager *progress.Stage) ([]string, error) {
|
||||
func (r *directoryIndexer) indexTree(root string, stager *progress.AtomicStage) ([]string, error) {
|
||||
log.WithFields("path", root).Trace("indexing filetree")
|
||||
|
||||
var roots []string
|
||||
@@ -138,10 +138,9 @@ func (r *directoryIndexer) indexTree(root string, stager *progress.Stage) ([]str
|
||||
|
||||
err = filepath.Walk(root,
|
||||
func(path string, info os.FileInfo, err error) error {
|
||||
stager.Current = path
|
||||
stager.Set(path)
|
||||
|
||||
newRoot, err := r.indexPath(path, info, err)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -173,7 +172,7 @@ func isRealPath(root string) (bool, error) {
|
||||
return rootParent == realRootParent, nil
|
||||
}
|
||||
|
||||
func (r *directoryIndexer) indexBranch(root string, stager *progress.Stage) ([]string, error) {
|
||||
func (r *directoryIndexer) indexBranch(root string, stager *progress.AtomicStage) ([]string, error) {
|
||||
rootRealPath, err := filepath.EvalSymlinks(root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -200,7 +199,7 @@ func (r *directoryIndexer) indexBranch(root string, stager *progress.Stage) ([]s
|
||||
targetPath = p
|
||||
}
|
||||
|
||||
stager.Current = targetPath
|
||||
stager.Set(targetPath)
|
||||
|
||||
lstat, err := os.Lstat(targetPath)
|
||||
newRoot, err := r.indexPath(targetPath, lstat, err)
|
||||
@@ -465,8 +464,8 @@ func requireFileInfo(_ string, info os.FileInfo, _ error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func indexingProgress(path string) (*progress.Stage, *progress.Manual) {
|
||||
stage := &progress.Stage{}
|
||||
func indexingProgress(path string) (*progress.AtomicStage, *progress.Manual) {
|
||||
stage := progress.NewAtomicStage("")
|
||||
prog := progress.NewManual(-1)
|
||||
|
||||
bus.Publish(partybus.Event{
|
||||
|
||||
@@ -22,7 +22,7 @@ type indexerMock struct {
|
||||
additionalRoots map[string][]string
|
||||
}
|
||||
|
||||
func (m *indexerMock) indexer(s string, _ *progress.Stage) ([]string, error) {
|
||||
func (m *indexerMock) indexer(s string, _ *progress.AtomicStage) ([]string, error) {
|
||||
m.observedRoots = append(m.observedRoots, s)
|
||||
return m.additionalRoots[s], nil
|
||||
}
|
||||
|
||||
@@ -475,7 +475,6 @@
|
||||
"fast-csv": "cpe:2.3:a:c2fo:fast-csv:*:*:*:*:*:node.js:*:*",
|
||||
"fast-http": "cpe:2.3:a:fast-http_project:fast-http:*:*:*:*:*:node.js:*:*",
|
||||
"fast-http-cli": "cpe:2.3:a:fast-http-cli_project:fast-http-cli:*:*:*:*:*:node.js:*:*",
|
||||
"fastest-json-copy": "cpe:2.3:a:fastest-json-copy_project:fastest-json-copy:*:*:*:*:*:node.js:*:*",
|
||||
"ffmepg": "cpe:2.3:a:ffmepg_project:ffmepg:*:*:*:*:*:node.js:*:*",
|
||||
"ffmpegdotjs": "cpe:2.3:a:ffmpegdotjs_project:ffmpegdotjs:*:*:*:*:*:node.js:*:*",
|
||||
"fibjs": "cpe:2.3:a:fibjs_project:fibjs:*:*:*:*:*:node.js:*:*",
|
||||
|
||||
Reference in New Issue
Block a user