mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
fix Windows file paths in local go mod cache (#2654)
Previously, the file resolver was created from incorrect calls (path.Join instead of filepath.Join) which resulted Go license searches always missing on Windows. Use filepath.* functions when initializing the Go config, and when the unindexed file resolver is being created. Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
parent
1892f24002
commit
b2ca5fbf89
@ -8,6 +8,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -61,11 +62,11 @@ func NewFromUnindexedDirectoryFS(fs afero.Fs, dir string, base string) file.Writ
|
|||||||
}
|
}
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !path.IsAbs(dir) {
|
if !filepath.IsAbs(dir) {
|
||||||
dir = path.Clean(path.Join(wd, dir))
|
dir = filepath.Clean(filepath.Join(wd, dir))
|
||||||
}
|
}
|
||||||
if base != "" && !path.IsAbs(base) {
|
if base != "" && !filepath.IsAbs(base) {
|
||||||
base = path.Clean(path.Join(wd, base))
|
base = filepath.Clean(filepath.Join(wd, base))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UnindexedDirectory{
|
return UnindexedDirectory{
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package golang
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
@ -75,11 +75,11 @@ func DefaultCatalogerConfig() CatalogerConfig {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("unable to determine user home dir: %v", err)
|
log.Debug("unable to determine user home dir: %v", err)
|
||||||
} else {
|
} else {
|
||||||
goPath = path.Join(homeDir, "go")
|
goPath = filepath.Join(homeDir, "go")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if goPath != "" {
|
if goPath != "" {
|
||||||
g.LocalModCacheDir = path.Join(goPath, "pkg", "mod")
|
g.LocalModCacheDir = filepath.Join(goPath, "pkg", "mod")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return g
|
return g
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user