mirror of
https://github.com/anchore/syft.git
synced 2026-10-11 21:57:22 +02:00
test(snap): bound the kernel changelog bomb fixture by ratio, not a fixed 1MB (#5352)
Same issue as #5350: go1.27's compress/flate encodes this 512MB fixture to just over 1MB, so the fixture sanity check tripped before the bound was exercised. The line bound itself is fine. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -330,7 +330,9 @@ func TestParseKernelChangelog_gzipBombStaysBounded(t *testing.T) {
|
||||
remaining -= n
|
||||
}
|
||||
require.NoError(t, gw.Close())
|
||||
require.Less(t, gz.Len(), 1024*1024, "compressed payload should be tiny relative to what it expands to")
|
||||
// compress/flate output for this input varies by Go version (about 510KB on go1.26, 1MB on go1.27), so
|
||||
// bound the fixture by ratio rather than a fixed size
|
||||
require.Less(t, gz.Len(), expanded/100, "compressed payload should be tiny relative to what it expands to")
|
||||
|
||||
// prove the fixture is a bomb: the same stream read without a line bound costs its full size
|
||||
unbounded := testutils.MeasureAlloc(t, func() {
|
||||
|
||||
Reference in New Issue
Block a user