mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 15:06:36 +01:00
feat: report unknowns in sbom (#2998)
Signed-off-by: Keith Zantow <kzantow@gmail.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:
co-authored by
Alex Goodman
parent
4d7ed9f749
commit
ccbee94b87
+24
-3
@@ -15,6 +15,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/anchore/stereoscope/pkg/imagetest"
|
||||
)
|
||||
|
||||
@@ -267,11 +269,15 @@ func getSyftCommand(t testing.TB, args ...string) *exec.Cmd {
|
||||
}
|
||||
|
||||
func getSyftBinaryLocation(t testing.TB) string {
|
||||
if os.Getenv("SYFT_BINARY_LOCATION") != "" {
|
||||
const envKey = "SYFT_BINARY_LOCATION"
|
||||
if os.Getenv(envKey) != "" {
|
||||
// SYFT_BINARY_LOCATION is the absolute path to the snapshot binary
|
||||
return os.Getenv("SYFT_BINARY_LOCATION")
|
||||
return os.Getenv(envKey)
|
||||
}
|
||||
return getSyftBinaryLocationByOS(t, runtime.GOOS)
|
||||
loc := getSyftBinaryLocationByOS(t, runtime.GOOS)
|
||||
buildBinary(t, loc)
|
||||
_ = os.Setenv(envKey, loc)
|
||||
return loc
|
||||
}
|
||||
|
||||
func getSyftBinaryLocationByOS(t testing.TB, goOS string) string {
|
||||
@@ -291,6 +297,21 @@ func getSyftBinaryLocationByOS(t testing.TB, goOS string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func buildBinary(t testing.TB, loc string) {
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, os.Chdir(repoRoot(t)))
|
||||
defer func() {
|
||||
require.NoError(t, os.Chdir(wd))
|
||||
}()
|
||||
t.Log("Building syft...")
|
||||
c := exec.Command("go", "build", "-o", loc, "./cmd/syft")
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
c.Stdin = os.Stdin
|
||||
require.NoError(t, c.Run())
|
||||
}
|
||||
|
||||
func repoRoot(t testing.TB) string {
|
||||
t.Helper()
|
||||
root, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
|
||||
|
||||
Reference in New Issue
Block a user