fix: logging for remote network calls (#3140)

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow 2024-08-20 11:45:33 -04:00 committed by GitHub
parent 511cc9c2d5
commit 95b4a88256
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 5 deletions

View file

@ -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",

View file

@ -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,

View file

@ -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 {