mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
fix: logging for remote network calls (#3140)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
@@ -251,6 +251,7 @@ func getModule(proxies []string, moduleName, moduleVersion string) (urlPrefix st
|
||||
case "file":
|
||||
p := filepath.Join(u.Path, moduleName, "@v", moduleVersion)
|
||||
urlPrefix = path.Join("file://", p) + "/"
|
||||
log.WithFields("path", p).Info("looking for go module in filesystem")
|
||||
fsys = os.DirFS(p)
|
||||
}
|
||||
if fsys != nil {
|
||||
@@ -264,6 +265,7 @@ func getModuleProxy(proxy string, moduleName string, moduleVersion string) (modu
|
||||
u := fmt.Sprintf("%s/%s/@v/%s.zip", proxy, moduleName, moduleVersion)
|
||||
|
||||
// get the module zip
|
||||
log.WithFields("url", u).Info("downloading go module from proxy")
|
||||
resp, err := http.Get(u) //nolint:gosec
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
@@ -334,6 +336,8 @@ func getModuleRepository(moduleName string, moduleVersion string) (string, fs.FS
|
||||
f := memfs.New()
|
||||
buf := &bytes.Buffer{}
|
||||
repoURL := fmt.Sprintf("https://%s", repoName)
|
||||
|
||||
log.WithFields("repoURL", repoURL, "ref", cloneRefName).Info("cloning go module repository")
|
||||
r, err := git.Clone(memory.NewStorage(), f, &git.CloneOptions{
|
||||
URL: repoURL,
|
||||
ReferenceName: cloneRefName,
|
||||
|
||||
@@ -178,13 +178,13 @@ func formatNpmRegistryURL(baseURL, packageName, version string) (requestURL stri
|
||||
return requestURL, nil
|
||||
}
|
||||
|
||||
func getLicenseFromNpmRegistry(basURL, packageName, version string) (string, error) {
|
||||
func getLicenseFromNpmRegistry(baseURL, packageName, version string) (string, error) {
|
||||
// "https://registry.npmjs.org/%s/%s", packageName, version
|
||||
requestURL, err := formatNpmRegistryURL(basURL, packageName, version)
|
||||
requestURL, err := formatNpmRegistryURL(baseURL, packageName, version)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to format npm request for pkg:version %s%s; %w", packageName, version, err)
|
||||
}
|
||||
log.Tracef("trying to fetch remote package %s", requestURL)
|
||||
log.WithFields("url", requestURL).Info("downloading javascript package from npm")
|
||||
|
||||
npmRequest, err := http.NewRequest(http.MethodGet, requestURL, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user