From 95b4a88256bddebb91831250f28f602f8c36552a Mon Sep 17 00:00:00 2001 From: Keith Zantow Date: Tue, 20 Aug 2024 11:45:33 -0400 Subject: [PATCH] fix: logging for remote network calls (#3140) Signed-off-by: Keith Zantow --- internal/spdxlicense/license_list.go | 15 +++++++++++++-- syft/pkg/cataloger/golang/licenses.go | 4 ++++ syft/pkg/cataloger/javascript/package.go | 6 +++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/internal/spdxlicense/license_list.go b/internal/spdxlicense/license_list.go index 18e2a88cacc..05a78d95cfd 100644 --- a/internal/spdxlicense/license_list.go +++ b/internal/spdxlicense/license_list.go @@ -1,9 +1,9 @@ // Code generated by go generate; DO NOT EDIT. -// This file was generated by robots at 2024-05-23 08:47:23.204981 -0400 EDT m=+0.050881068 +// This file was generated by robots at 2024-08-20 11:33:49.349625 -0400 EDT m=+0.383911876 // using data from https://spdx.org/licenses/licenses.json package spdxlicense -const Version = "3.24.0" +const Version = "3.25.0" var licenseIDs = map[string]string{ "0bsd": "0BSD", @@ -501,6 +501,8 @@ var licenseIDs = map[string]string{ "dldezero2.0": "DL-DE-ZERO-2.0", "dldezero2.0.0": "DL-DE-ZERO-2.0", "doc": "DOC", + "docbookschema": "DocBook-Schema", + "docbookxml": "DocBook-XML", "dotseqn": "Dotseqn", "drl1": "DRL-1.0", "drl1.0": "DRL-1.0", @@ -714,6 +716,7 @@ var licenseIDs = map[string]string{ "gutmann": "Gutmann", "haskellreport": "HaskellReport", "hdparm": "hdparm", + "hidapi": "HIDAPI", "hippocratic2": "Hippocratic-2.1", "hippocratic2.1": "Hippocratic-2.1", "hippocratic2.1.0": "Hippocratic-2.1", @@ -740,6 +743,7 @@ var licenseIDs = map[string]string{ "hpndmarkuskuhn": "HPND-Markus-Kuhn", "hpndmerchantabilityvariant": "HPND-merchantability-variant", "hpndmitdisclaimer": "HPND-MIT-disclaimer", + "hpndnetrek": "HPND-Netrek", "hpndpbmplus": "HPND-Pbmplus", "hpndsellmitdisclaimerxserver": "HPND-sell-MIT-disclaimer-xserver", "hpndsellregexpr": "HPND-sell-regexpr", @@ -1165,6 +1169,7 @@ var licenseIDs = map[string]string{ "rsamd": "RSA-MD", "rscpl": "RSCPL", "ruby": "Ruby", + "rubypty": "Ruby-pty", "saxpath": "Saxpath", "saxpd": "SAX-PD", "saxpd2": "SAX-PD-2.0", @@ -1265,6 +1270,9 @@ var licenseIDs = map[string]string{ "tuberlin2": "TU-Berlin-2.0", "tuberlin2.0": "TU-Berlin-2.0", "tuberlin2.0.0": "TU-Berlin-2.0", + "ubuntufont1": "Ubuntu-font-1.0", + "ubuntufont1.0": "Ubuntu-font-1.0", + "ubuntufont1.0.0": "Ubuntu-font-1.0", "ucar": "UCAR", "ucl1": "UCL-1.0", "ucl1.0": "UCL-1.0", @@ -1315,8 +1323,11 @@ var licenseIDs = map[string]string{ "x11.0": "X11", "x11.0.0": "X11", "x11.0.0distributemodificationsvariant": "X11-distribute-modifications-variant", + "x11.0.0swapped": "X11-swapped", "x11.0distributemodificationsvariant": "X11-distribute-modifications-variant", + "x11.0swapped": "X11-swapped", "x11distributemodificationsvariant": "X11-distribute-modifications-variant", + "x11swapped": "X11-swapped", "xdebug1": "Xdebug-1.03", "xdebug1.03": "Xdebug-1.03", "xdebug1.03.0": "Xdebug-1.03", diff --git a/syft/pkg/cataloger/golang/licenses.go b/syft/pkg/cataloger/golang/licenses.go index f532463147e..0b02c6581c1 100644 --- a/syft/pkg/cataloger/golang/licenses.go +++ b/syft/pkg/cataloger/golang/licenses.go @@ -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, diff --git a/syft/pkg/cataloger/javascript/package.go b/syft/pkg/cataloger/javascript/package.go index 57df406b1f1..19114c99f55 100644 --- a/syft/pkg/cataloger/javascript/package.go +++ b/syft/pkg/cataloger/javascript/package.go @@ -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 {