mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 22:12:28 +01:00
chore: revert custom index in favor of key_Split
Signed-off-by: Keith Zantow <keith.zantow@anchore.com>
This commit is contained in:
@@ -120,9 +120,8 @@ func (cfg Catalog) ToSearchConfig() cataloging.SearchConfig {
|
||||
}
|
||||
|
||||
func (cfg Catalog) ToArchiveConfig() cataloging.ArchiveSearchConfig {
|
||||
// the exclusion patterns come from the same --exclude flag that reaches the source, narrowed to
|
||||
// the ones whose shape reaches inside an archive. CreateSBOM fills the field from the source only
|
||||
// when it is empty, so this value wins.
|
||||
// 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).
|
||||
|
||||
@@ -26,18 +26,9 @@ note: enabling this may result in a performance impact since all discovered comp
|
||||
note: for now this only applies to the java package cataloger`)
|
||||
descriptions.Add(&o.ExcludeBinaryOverlapByOwnership, `allows users to exclude synthetic binary packages from the sbom
|
||||
these packages are removed if an overlap with a non-synthetic package is found`)
|
||||
descriptions.Add(&o.NestedArchiveMaxDepth, `maximum depth to recursively catalog nested archives, treating each archive as its own filesystem (0 = disabled, -1 = unlimited)
|
||||
when enabled, all archives (including java archives) are recursively cataloged by the archive cataloger
|
||||
and the java cataloger does not unarchive nested archives itself`)
|
||||
descriptions.Add(&o.NestedArchiveMaxMemoryBytes, `maximum bytes of nested archive content held in memory at once (0 = none, always overflow to disk; negative = unbounded)
|
||||
this is an in-use limit: it falls as each archive is released, so it bounds a scan's peak rather than its total
|
||||
content is held in memory while this limit admits it and overflowed to disk instead of being refused when it does not
|
||||
there is no separate setting for the size at which content overflows; this limit alone decides it
|
||||
only applies when nested-archive-max-depth is enabled`)
|
||||
descriptions.Add(&o.NestedArchiveMaxDiskBytes, `maximum bytes of nested archive content on disk at once, overflow content plus extracted entries (0 = none, nothing overflows; negative = unbounded)
|
||||
this is an in-use limit: it falls as each archive is released, so it bounds a scan's peak rather than its total
|
||||
an archive that would exceed it is skipped, since there is nowhere further to overflow
|
||||
only applies when nested-archive-max-depth is enabled`)
|
||||
descriptions.Add(&o.NestedArchiveMaxDepth, `maximum depth to recursively catalog nested archives (0 = disabled, -1 = unlimited)`)
|
||||
descriptions.Add(&o.NestedArchiveMaxMemoryBytes, `maximum bytes of nested archive content held in memory at once (0 = none, always overflow to disk; -1 = unbounded)`)
|
||||
descriptions.Add(&o.NestedArchiveMaxDiskBytes, `maximum bytes of nested archive content on disk at once (0 = none, nothing overflows; -1 = unbounded)`)
|
||||
}
|
||||
|
||||
func defaultPackageConfig() packageConfig {
|
||||
|
||||
@@ -11,8 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func Test_packageConfigDefaultsMatchArchiveSearchConfig(t *testing.T) {
|
||||
// the nested-archive settings must default to the values in syft/cataloging rather than
|
||||
// restating them, so a config round trip with nothing set is a no-op
|
||||
want := cataloging.DefaultArchiveSearchConfig()
|
||||
got := defaultPackageConfig()
|
||||
|
||||
@@ -24,9 +22,9 @@ func Test_packageConfigDefaultsMatchArchiveSearchConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
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 over the
|
||||
// Go field names, because the key is what a user writes and what a config dump shows.
|
||||
// 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++ {
|
||||
@@ -56,8 +54,8 @@ func Test_ToArchiveConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("every setting is threaded through", func(t *testing.T) {
|
||||
// a key that parses but is not carried into the archive config is invisible in a
|
||||
// config dump, so assert each one arrives
|
||||
// a key that parses but is not carried into the archive config is invisible in a config
|
||||
// dump, so assert each one arrives
|
||||
cfg := Catalog{Package: packageConfig{
|
||||
NestedArchiveMaxDepth: 3,
|
||||
NestedArchiveMaxMemoryBytes: 111,
|
||||
@@ -75,11 +73,10 @@ func Test_ToArchiveConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
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 that fills
|
||||
// ExclusionPatterns, from Catalog.Exclusions, applying the same shape rule the library
|
||||
// entry point applies to what the source publishes - only a pattern that reaches inside an
|
||||
// archive (any-depth, "**/") is in scope. A root-anchored or one-level pattern is not, and
|
||||
// no source is consulted to produce this: Catalog carries no source at all.
|
||||
// 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)
|
||||
})
|
||||
|
||||
@@ -50,13 +50,7 @@ func TestAllPackageCatalogersReachableInTasks(t *testing.T) {
|
||||
constructorCount += constructors.Size()
|
||||
}
|
||||
|
||||
// java has two archive catalogers - one that reads an archive file and one that reads an archive
|
||||
// already extracted to a filesystem - and the java archive slot in the task list yields whichever
|
||||
// the config selects, never both. So exactly one constructor has no task under the default config.
|
||||
const configSelectedAlternates = 1
|
||||
|
||||
assert.Equal(t, len(taskTagsByName)+configSelectedAlternates, constructorCount,
|
||||
"mismatch in number of cataloger constructors and task names")
|
||||
assert.Equal(t, len(taskTagsByName), constructorCount, "mismatch in number of cataloger constructors and task names")
|
||||
|
||||
exceptions := strset.New(
|
||||
// not reachable since they are deprecated
|
||||
|
||||
@@ -186,10 +186,8 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
func (m UI) View() string {
|
||||
v := m.frame.View()
|
||||
// always end on an empty line: bubbletea erases the line the cursor rests on when the program stops, so
|
||||
// a frame whose last line carries content loses it as the run finishes. Until now a log line in
|
||||
// the footer happened to supply that newline, which is why this only showed on sources that log
|
||||
// nothing at all.
|
||||
// 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
|
||||
if !strings.HasSuffix(v, "\n") {
|
||||
return v + "\n"
|
||||
}
|
||||
|
||||
@@ -14,18 +14,18 @@ var _ tea.Model = (*staticModel)(nil)
|
||||
|
||||
type staticModel string
|
||||
|
||||
func (m staticModel) Init() tea.Cmd { return nil }
|
||||
|
||||
func (m staticModel) Update(tea.Msg) (tea.Model, tea.Cmd) { return m, nil }
|
||||
|
||||
func (m staticModel) View() string { return string(m) }
|
||||
|
||||
func Test_UI_viewEndsOnAnEmptyLine(t *testing.T) {
|
||||
// bubbletea erases the line the cursor rests on when the program stops, so a view whose last line
|
||||
// carries content loses that line as the run finishes. Until a log line happened to be in the
|
||||
// footer, that is what dropped the last row of the cataloging tree on any source that logs nothing.
|
||||
// carries content loses it. Unless a log line happened to be in the footer, that dropped the last row
|
||||
// of the cataloging tree on any source that logs nothing.
|
||||
subject := New(io.Discard, false)
|
||||
subject.frame.(*frame.Frame).AppendModel(staticModel("first row\nlast row"))
|
||||
|
||||
require.Equal(t, "first row\nlast row\n", subject.View())
|
||||
}
|
||||
|
||||
func (m staticModel) Init() tea.Cmd { return nil }
|
||||
|
||||
func (m staticModel) Update(tea.Msg) (tea.Model, tea.Cmd) { return m, nil }
|
||||
|
||||
func (m staticModel) View() string { return string(m) }
|
||||
|
||||
Reference in New Issue
Block a user