mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 06:26:30 +01:00
chore: simplify and cleanup
Signed-off-by: Keith Zantow <keith.zantow@anchore.com>
This commit is contained in:
@@ -120,15 +120,12 @@ func (cfg Catalog) ToSearchConfig() cataloging.SearchConfig {
|
||||
}
|
||||
|
||||
func (cfg Catalog) ToArchiveConfig() cataloging.ArchiveSearchConfig {
|
||||
// exclusion patterns come from --exclude, narrowed to those that reach inside an archive. CreateSBOM
|
||||
// fills this field from the source only when empty, so this value wins.
|
||||
return cataloging.DefaultArchiveSearchConfig().
|
||||
WithIncludeIndexedArchives(cfg.Package.SearchIndexedArchives).
|
||||
WithIncludeUnindexedArchives(cfg.Package.SearchUnindexedArchives).
|
||||
WithMaxDepth(cfg.Package.NestedArchiveMaxDepth).
|
||||
WithMaxMemoryBytes(cfg.Package.NestedArchiveMaxMemoryBytes).
|
||||
WithMaxDiskBytes(cfg.Package.NestedArchiveMaxDiskBytes).
|
||||
WithExclusionPatterns(cataloging.ArchiveExclusionPatterns(cfg.Exclusions))
|
||||
WithMaxDiskBytes(cfg.Package.NestedArchiveMaxDiskBytes)
|
||||
}
|
||||
|
||||
func (cfg Catalog) ToRelationshipsConfig() cataloging.RelationshipsConfig {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -21,26 +20,6 @@ func Test_packageConfigDefaultsMatchArchiveSearchConfig(t *testing.T) {
|
||||
require.Zero(t, got.NestedArchiveMaxDepth, "nested archive cataloging must be off by default")
|
||||
}
|
||||
|
||||
func Test_packageConfigNamesNoArchiveExclusionSetting(t *testing.T) {
|
||||
// nested archive cataloging honors the scan's own --exclude patterns, so the application config must
|
||||
// name no archive-specific exclusion key. Asserted over the yaml tags rather than the Go field names:
|
||||
// the key is what a user writes and what a config dump shows.
|
||||
var keys []string
|
||||
typ := reflect.TypeOf(packageConfig{})
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
keys = append(keys, typ.Field(i).Tag.Get("yaml"))
|
||||
}
|
||||
|
||||
assert.Equal(t, []string{
|
||||
"search-unindexed-archives",
|
||||
"search-indexed-archives",
|
||||
"exclude-binary-overlap-by-ownership",
|
||||
"nested-archive-max-depth",
|
||||
"nested-archive-max-memory-bytes",
|
||||
"nested-archive-max-disk-bytes",
|
||||
}, keys)
|
||||
}
|
||||
|
||||
func Test_ToArchiveConfig(t *testing.T) {
|
||||
defaults := cataloging.DefaultArchiveSearchConfig()
|
||||
|
||||
@@ -71,18 +50,4 @@ func Test_ToArchiveConfig(t *testing.T) {
|
||||
assert.True(t, got.IncludeIndexedArchives)
|
||||
assert.True(t, got.IncludeUnindexedArchives)
|
||||
})
|
||||
|
||||
t.Run("--exclude patterns arrive already filtered to the in-scope subset, with no source involved", func(t *testing.T) {
|
||||
// every-boundary-populates-the-patterns: the CLI is one of the two boundaries filling
|
||||
// ExclusionPatterns, from Catalog.Exclusions, applying the same shape rule the library entry
|
||||
// point applies to what the source publishes - only an any-depth ("**/") pattern is in scope.
|
||||
// A root-anchored or one-level pattern is not, and no source is consulted: Catalog carries none.
|
||||
cfg := Catalog{Exclusions: []string{"./root-anchored", "**/*.rpm", "*/one-level", "**/vendor"}}
|
||||
assert.Equal(t, []string{"**/*.rpm", "**/vendor"}, cfg.ToArchiveConfig().ExclusionPatterns)
|
||||
})
|
||||
|
||||
t.Run("no --exclude patterns leaves the field empty", func(t *testing.T) {
|
||||
cfg := Catalog{}
|
||||
assert.Empty(t, cfg.ToArchiveConfig().ExclusionPatterns)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -186,8 +186,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
func (m UI) View() string {
|
||||
v := m.frame.View()
|
||||
// bubbletea erases the line the cursor rests on at exit, so end on a newline or a frame's last line
|
||||
// of content is lost
|
||||
// bubbletea erases the line the cursor rests on at exit, which would drop the frame's last line
|
||||
if !strings.HasSuffix(v, "\n") {
|
||||
return v + "\n"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user