feat: combine go module file and go source discovery into single cataloger (#4127)

---------
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Christopher Angelo Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Christopher Angelo Phillips
2025-08-26 19:35:44 +00:00
committed by GitHub
co-authored by Alex Goodman
parent 170c4c41f4
commit 13ffeeb3d0
26 changed files with 4518 additions and 62 deletions
@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"sort"
"strings"
"sync"
@@ -16,6 +17,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
stereofile "github.com/anchore/stereoscope/pkg/file"
"github.com/anchore/stereoscope/pkg/imagetest"
"github.com/anchore/syft/internal/cmptest"
"github.com/anchore/syft/internal/licenses"
@@ -130,11 +132,14 @@ func (p *CatalogTester) FromFile(t *testing.T, path string) *CatalogTester {
return p
}
absPath, err := filepath.Abs(path)
require.NoError(t, err)
fixture, err := os.Open(path)
require.NoError(t, err)
p.reader = file.LocationReadCloser{
Location: file.NewLocation(fixture.Name()),
Location: file.NewVirtualLocationFromDirectory(fixture.Name(), fixture.Name(), *stereofile.NewFileReference(stereofile.Path(absPath))),
ReadCloser: fixture,
}
return p