fix: treat zero archive limits as the default

`ArchiveSearchConfig{MaxDepth: 2}` is the natural literal, but zero memory and zero disk meant "forbid both", so every archive was truncated to nothing and only unknowns came out.

- `MaxMemoryBytes` / `MaxDiskBytes` of `0` now mean the default, negative is still unbounded
- the limiter keeps its own zero-forbids semantics internally; it's just no longer reachable from config
- tests that relied on zero to force spilling now pass `archive.Limits` directly, and the two "both limits zero" tests are gone since that config no longer exists

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2026-09-24 11:14:23 -04:00
parent fe4a9a287a
commit a4a1d7afa7
7 changed files with 77 additions and 104 deletions
+2 -2
View File
@@ -27,11 +27,11 @@ type ArchiveSearchConfig struct {
MaxDepth int `yaml:"max-depth" json:"max-depth" mapstructure:"max-depth"`
// MaxMemoryBytes bounds the archive content held in memory at once; content that does not fit is
// written to disk. Zero writes everything to disk, negative is unbounded.
// written to disk. Zero means DefaultArchiveMaxMemoryBytes, negative is unbounded.
MaxMemoryBytes int64 `yaml:"max-memory-bytes" json:"max-memory-bytes" mapstructure:"max-memory-bytes"`
// MaxDiskBytes bounds the archive content written to disk at once; an archive whose content does
// not fit is skipped or truncated. Zero writes nothing to disk, negative is unbounded.
// not fit is skipped or truncated. Zero means DefaultArchiveMaxDiskBytes, negative is unbounded.
MaxDiskBytes int64 `yaml:"max-disk-bytes" json:"max-disk-bytes" mapstructure:"max-disk-bytes"`
}
+2 -1
View File
@@ -148,7 +148,8 @@ func (c *CreateSBOMConfig) WithFilesConfig(cfg filecataloging.Config) *CreateSBO
}
// WithArchiveConfig sets how archives are cataloged: how deep to recurse into nested archives (MaxDepth
// 0, the default, does not recurse) and how much extracted content the scan may hold at once.
// 0, the default, does not recurse) and how much extracted content the scan may hold at once (a zero
// limit means the default).
func (c *CreateSBOMConfig) WithArchiveConfig(cfg cataloging.ArchiveSearchConfig) *CreateSBOMConfig {
c.Archive = cfg
return c
+2 -2
View File
@@ -10,9 +10,9 @@ configs: # AUTO-GENERATED - config structs and their fields
- key: MaxDepth
description: 'MaxDepth is how many levels of nested archives to catalog: 0 disables it, negative is unbounded.'
- key: MaxMemoryBytes
description: MaxMemoryBytes bounds the archive content held in memory at once; content that does not fit is written to disk. Zero writes everything to disk, negative is unbounded.
description: MaxMemoryBytes bounds the archive content held in memory at once; content that does not fit is written to disk. Zero means DefaultArchiveMaxMemoryBytes, negative is unbounded.
- key: MaxDiskBytes
description: MaxDiskBytes bounds the archive content written to disk at once; an archive whose content does not fit is skipped or truncated. Zero writes nothing to disk, negative is unbounded.
description: MaxDiskBytes bounds the archive content written to disk at once; an archive whose content does not fit is skipped or truncated. Zero means DefaultArchiveMaxDiskBytes, negative is unbounded.
- key: UseNetwork
description: UseNetwork enables network operations for java package metadata enrichment, such as fetching parent POMs and license information.
app_key: java.use-network