From 841edae1a8d89bf3b58a2c7d9dcd4862b85fd897 Mon Sep 17 00:00:00 2001 From: agrasth Date: Tue, 25 Aug 2026 14:32:41 +0530 Subject: [PATCH 1/2] Fix npmnpmrcproject fixture: scope legacy auth keys to the registry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit npm 12 hard-rejects the bare (unscoped) `email` and `_auth` auth config keys with ERR_INVALID_AUTH — a validation change from npm's own auth-config cleanup, not a jfrog-cli npm command bug. Every npm 12.x compatibility test failed at the very first `npm install` call in TestNpmNativeSyntax/npm_i_with_npmrc_project because the fixture's .npmrc still used the old unscoped format: _auth=YWRtaW46QVBFG1ZkZFMzN3NCakJiaRFVBThVb0JlZzFl email=ddd@dd.dd npm's own error message names the fix: scope both keys to the registry, matching how the existing _authToken line is already scoped: //NO-NO-REPO/:_auth=YWRtaW46QVBFG1ZkZFMzN3NCakJiaRFVBThVb0JlZzFl //NO-NO-REPO/:email=ddd@dd.dd Verified locally with the exact npm 12.0.0 that failed in CI — `npm install --dry-run` against the fixed .npmrc no longer raises ERR_INVALID_AUTH (it fails only on ENOTFOUND for the fixture's fake NO-NO-REPO host, which is expected and unrelated: the real test always redirects to a live Artifactory instance via jfrog-cli). --- testdata/npm/npmnpmrcproject/.npmrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/npm/npmnpmrcproject/.npmrc b/testdata/npm/npmnpmrcproject/.npmrc index b38227afb..e6f4636fd 100755 --- a/testdata/npm/npmnpmrcproject/.npmrc +++ b/testdata/npm/npmnpmrcproject/.npmrc @@ -1,7 +1,7 @@ @jfrog:registry=http://NO-NO-REPO/ registry=http://NO-NO-REPO/ -_auth=YWRtaW46QVBFG1ZkZFMzN3NCakJiaRFVBThVb0JlZzFl always-auth=true -email=ddd@dd.dd +//NO-NO-REPO/:_auth=YWRtaW46QVBFG1ZkZFMzN3NCakJiaRFVBThVb0JlZzFl +//NO-NO-REPO/:email=ddd@dd.dd # jfrog-ignore - not a real token //NO-NO-REPO/:_authToken=eyJ2ZXIiOzfsdhiOiIyR3A5cDlUYW44NmpaTkxDNlBpa0lmWTU1Uk9Kc1pfNGlFUnRQLVsdfhZmFjdG9yeUBsdhjZDc2MGJmOC0wNjI0LTQwYTYtOGEyMS0zOTViMzg1OWQzNzVcL3VzZXJzXC9hZG1pbiIsInNjcCI6Im1lbWJlci1vZi1ncm91cHM6KiBhcGk6KiIsImF1ZCI6ImpmLWFydGlmYWN0b3J5QGNkNzYwYmY4LTA2MjQtNDBhNisdhmpmLWFydGlmYWN0b3J5QGNkNzYwYmY4LTA2MjQtNDBhNi04YTIxLTM5NWIzODU5ZDM3NSIsImlhdCI6MTUxMzI0MjcxMywianRpIjoiNWZiYmY1ZDAtYjUzNC00ZWMxLWE3NDItZTRiMjNmZDA4YTI5In0.pwNys1ek1v7BtjESjlEMgiVLAdD60vwh1EWvuoGSaxAvu1ppW1fwCJmNjJ69HJbA58tq-AfkusKhr7juoIw2TaIsikyrnrDHv1ELaFupAxDMkDfx4w1GQO3dMzWYDAYoVfeaImpdXQ3_pKemR5eLiRiqJrtEfj52OfIFyVPOuBTvtoqDe8-DvFNFz0TyUAfbLvya8S9I6KGr2mxR4v8eir4me8zp0lPBm7oIKL_tfgr5uP9naTrUg5Ydfkc-vhwU0jK-45R3RQPbpW-NE78yy17TVJuxgE0s2OtMWmLpvr3FJaPCJ5VGPtRexJFbN_7BhR2tl02Wys41lk6pqSpRlA \ No newline at end of file From 3fce6b123b76a02e379633d63781348dcd5e030f Mon Sep 17 00:00:00 2001 From: agrasth Date: Tue, 25 Aug 2026 14:55:28 +0530 Subject: [PATCH 2/2] Fix CI lint: migrate reverse-proxy test helper off deprecated Director golangci-lint (staticcheck SA1019) started failing on this PR's CI run because master recently bumped to Go 1.26, which deprecates httputil.ReverseProxy.Director in favor of Rewrite (available since Go 1.20). Unrelated to the npm fixture change in this PR, but it blocks the CI gate regardless, so fixing it here. Direct translation: Rewrite receives a *httputil.ProxyRequest whose .Out field is a pre-cloned copy of the incoming request, so the closure only needs to set the same three fields Director set directly on the request (Host, URL.Host, URL.Scheme). Defining a custom Rewrite func means none of the automatic default behavior (X-Forwarded-For, etc.) kicks in, matching Director's original no-defaults behavior exactly -- this is a mechanical migration with no functional change. Verified with the exact CI lint invocation (golangci-lint 2.13.1, same flag set) against both the changed package and the full repo: 0 issues. --- utils/tests/proxy/server/server.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utils/tests/proxy/server/server.go b/utils/tests/proxy/server/server.go index 40a3a5fe6..81757892a 100644 --- a/utils/tests/proxy/server/server.go +++ b/utils/tests/proxy/server/server.go @@ -47,16 +47,21 @@ func getReverseProxyHandler(targetUrl string) (*httputil.ReverseProxy, error) { return nil, err } origHost := target.Host - d := func(req *http.Request) { - req.URL.Host = origHost - req.Host = origHost - req.URL.Scheme = target.Scheme + // Rewrite replaces the deprecated Director (Go 1.26, staticcheck SA1019). + // pr.Out is a clone of pr.In that ReverseProxy sends upstream; unlike a + // nil Rewrite's defaults, defining this func means no other header + // rewriting happens automatically (X-Forwarded-For, etc.) -- matching + // Director's behavior exactly, since Director never set defaults either. + rewrite := func(pr *httputil.ProxyRequest) { + pr.Out.URL.Host = origHost + pr.Out.Host = origHost + pr.Out.URL.Scheme = target.Scheme } tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } proxyErrLogger := log.New(os.Stdout, "PROXY-LOGGER", log.Ldate|log.Ltime|log.Lshortfile) - p := &httputil.ReverseProxy{Director: d, Transport: tr, ErrorLog: proxyErrLogger} + p := &httputil.ReverseProxy{Rewrite: rewrite, Transport: tr, ErrorLog: proxyErrLogger} return p, nil }