Skip to content

RTECO-1352 - Fix jf setup docker login when using --url - #460

Merged
fluxxBot merged 6 commits into
jfrog:mainfrom
Edenb2131:RTECO-1352-fix-setup-docker-empty-registry
Jun 3, 2026
Merged

fluxxBot merged 6 commits into
jfrog:mainfrom
Edenb2131:RTECO-1352-fix-setup-docker-empty-registry

Conversation

@Edenb2131

@Edenb2131 Edenb2131 commented May 26, 2026 •

Copy link
Copy Markdown
Contributor
  • All tests passed. New table-driven tests added for the affected helper.
  • All static analysis checks passed locally (gofmt, go vet).
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.

Summary

jf setup docker (and jf setup podman) fail immediately when invoked with --url. The CLI calls docker login "", the daemon resolves the empty registry to Docker Hub, and the user sees failed to login to container registry: docker login failed for: .

Reproduces on both SaaS and self-hosted — CLI-only defect, independent of Artifactory version. Tracked as RTECO-1352.

Reproduction

jf setup docker --url https://<tenant>.jfrog.io/artifactory \
  --user <user> --access-token <token> --repo <docker-virtual-repo>

Root cause

configureContainer derived the registry host from sc.serverDetails.GetUrl(). But createServerDetailsFromFlags (jfrog-cli) clears details.Url for the Rt command domain after copying it into ArtifactoryUrl:

case commonCliUtils.Rt:
    details.ArtifactoryUrl = details.Url
...
details.Url = ""

So on the --url path, GetUrl() returns "", url.Parse("") yields an empty URL, and ContainerManagerLogin is called with an empty registry — the daemon then defaults to Docker Hub.

The bug only manifests on --url. The --server-id path worked because saved configs populate Url from disk.

Fix

Extract a deriveContainerRegistryHost helper that:

  • Reads GetArtifactoryUrl() first (populated on the --url path), falls back to GetUrl() (populated on --server-id).
  • Returns parsedURL.Host directly — docker login takes only host[:port].
  • Returns an explicit "server URL is empty; provide --url or --server-id" when both are empty, instead of silently redirecting to Docker Hub.

Tests

12 table-driven subtests in TestDeriveContainerRegistryHost covering: --url path, --server-id fallback, both-set precedence, ports, http scheme, self-hosted IP (with and without port), IPv6, subdomain registry method, embedded-credentials guard, no-scheme typo, both-empty. All pass.

Backward compatibility

No public API or flag changes. --server-id success path unchanged. The only user-visible change is a clearer error in the both-URLs-empty case.

Depends on:

  1. jfrog-cli - RTECO-1352 - Fix jf setup docker login when using --url jfrog-cli#3517

@Edenb2131
Edenb2131 requested review from a team, agrasth, bhanurp, fluxxBot, itsmeleela and udaykb2 May 26, 2026 09:41
@fluxxBot fluxxBot added bug Something isn't working safe to test Approve running integration tests on a pull request labels May 27, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label May 27, 2026
Comment thread artifactory/commands/setup/setup.go Resolved
Comment thread artifactory/commands/setup/setup.go Resolved
…used

jf setup docker fails when invoked with --url because configureContainer
reads ServerDetails.GetUrl(), which createServerDetailsFromFlags clears for
the Rt command domain after copying it into ArtifactoryUrl. The empty string
passed to docker login resolves to Docker Hub and returns a misleading 401.

Read GetArtifactoryUrl() with GetUrl() fallback for the --server-id path,
take parsedURL.Host directly, and return an explicit error when both URLs
are empty. Reproduces on SaaS and self-hosted equally.
@Edenb2131
Edenb2131 force-pushed the RTECO-1352-fix-setup-docker-empty-registry branch from eb5970c to 331df92 Compare May 27, 2026 12:17
@Edenb2131
Edenb2131 requested a review from fluxxBot May 31, 2026 07:31
@Edenb2131 Edenb2131 changed the title RTECO-1352 - Fix setup docker registry host derivation when --url is used RTECO-1352 - Fix jf setup docker login when using --url Jun 1, 2026
fluxxBot
fluxxBot previously approved these changes Jun 1, 2026
@fluxxBot fluxxBot added the safe to test Approve running integration tests on a pull request label Jun 1, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Jun 1, 2026
gosec G101 (Potential hardcoded credentials: Password in URL) flagged the
test case that verifies userinfo is stripped from the URL when deriving
the docker registry host. The flagged string is a test fixture, not a
real credential. Add an inline #nosec G101 directive with an explanatory
comment.
@bhanurp bhanurp added the safe to test Approve running integration tests on a pull request label Jun 2, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Jun 2, 2026
@bhanurp bhanurp added the safe to test Approve running integration tests on a pull request label Jun 2, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Jun 2, 2026
@fluxxBot fluxxBot added the safe to test Approve running integration tests on a pull request label Jun 3, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🚨 Frogbot scanned this pull request and found the below:

📗 Scan Summary

  • Frogbot scanned for vulnerabilities and found 1 issues
Scan Category Status Security Issues
Software Composition Analysis ✅ Done Not Found
Contextual Analysis ✅ Done -
Static Application Security Testing (SAST) ✅ Done
1 Issues Found 1 Low
Secrets ✅ Done -
Infrastructure as Code (IaC) ✅ Done Not Found

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor
mainArtifactPath

at artifactory/commands/flexpack/maven.go (line 525)

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
low
Low
Untrusted stored input used in file paths, allowing access to unintended files.
Full description

Vulnerability Details

Rule ID: go-stored-path-traversal

Overview

Stored Path Traversal is a type of vulnerability that arises when user-controlled
input, such as file names or paths, is stored by the application and later used
without proper validation or sanitization to perform file operations. This can
allow an attacker to traverse directories and access or overwrite sensitive files
on the filesystem, potentially compromising the security and integrity of the
application or system.

Vulnerable example

func serveFile(w http.ResponseWriter, r *http.Request) {
    row := db.QueryRow("SELECT file_path FROM files WHERE id = 12")
    row.Scan(&filePath)
    http.ServeFile(w, r, filePath)
}

In this example, the serveFile function serves a file based on the file query
parameter provided by the user. However, in a real-world scenario, the filePath
variable might be retrieved from a stored source, such as a database or configuration
file, instead of being directly obtained from the request URL. The vulnerability
arises if the stored filePath is not properly validated or sanitized before being
used to serve files. Attackers could manipulate the stored filePath to perform
directory traversal attacks, potentially accessing sensitive files outside the
intended directory structure.

Remediation

To mitigate stored path traversal vulnerabilities, it is essential to validate
and sanitize user-controlled input before using it to construct file paths or
perform file operations. In this example, we can validate the file name to ensure
it does not contain directory traversal sequences before serving the file.

func serveFile(w http.ResponseWriter, r *http.Request) {
    row := db.QueryRow("SELECT file_path FROM files WHERE id = ?", r.URL.Query().Get("id"))
    row.Scan(&filePath)
+    // Validate file path to prevent directory traversal
+    if strings.Contains(filePath, "..") {
+        http.Error(w, "Invalid file path", http.StatusBadRequest)
+        return
+    }
    http.ServeFile(w, r, filePath)
}
Code Flows
Vulnerable data flow analysis result

↘️ os.ReadFile(pomPath) (at artifactory/commands/flexpack/maven.go line 554)

↘️ pomData (at artifactory/commands/flexpack/maven.go line 554)

↘️ pomData (at artifactory/commands/flexpack/maven.go line 560)

↘️ xml.Unmarshal(pomData, &pom) (at artifactory/commands/flexpack/maven.go line 560)

↘️ pom (at artifactory/commands/flexpack/maven.go line 568)

↘️ pom.Packaging (at artifactory/commands/flexpack/maven.go line 568)

↘️ getPackagingType(workingDir) (at artifactory/commands/flexpack/maven.go line 515)

↘️ packagingType (at artifactory/commands/flexpack/maven.go line 522)

↘️ fmt.Sprintf("%s-%s.%s", artifactId, version, packagingType) (at artifactory/commands/flexpack/maven.go line 522)

↘️ mainArtifactName (at artifactory/commands/flexpack/maven.go line 523)

↘️ filepath.Join(targetDir, mainArtifactName) (at artifactory/commands/flexpack/maven.go line 523)

↘️ mainArtifactPath (at artifactory/commands/flexpack/maven.go line 525)




@fluxxBot
fluxxBot merged commit 17ea3d8 into jfrog:main Jun 3, 2026
79 of 82 checks passed
Edenb2131 pushed a commit to Edenb2131/jfrog-cli that referenced this pull request Jun 3, 2026
Adds an end-to-end test in jfrog-cli that exercises `jf setup docker
--url=...`, the exact failure path of RTECO-1352. The fix landed in
jfrog/jfrog-cli-artifactory#460; this bumps the dependency to include
it and adds the test as a regression guard.

The test runs with --url + --access-token (no saved config) and asserts
that the temp docker config gets an auth entry keyed by the Artifactory
registry hostname. Before the fix the command resolved to Docker Hub
and returned a 401.
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
jfrog-cli 2.107.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What changed in v2.107.0

> Auto-generated from 2 repositories · 2026-06-03  
> Comparing `v2.106.0` → `v2.107.0`

> ℹ️  No changes in: build-info-go, gofrog, jfrog-cli-core, jfrog-cli-security, jfrog-client-go

### ✨ New Features

- **[jfrog-cli-artifactory]** RTECO-1079 - Implement search for plugins [#474](jfrog/jfrog-cli-artifactory#474) (@udaykb2)
- **[jfrog-cli-artifactory]** RTECO-1079 - Add prompt to install & update for version [#475](jfrog/jfrog-cli-artifactory#475) (@udaykb2)

### 🐛 Bug Fixes

- **[jfrog-cli]** RTECO-1352 - Fix jf setup docker login when using --url [#3517](jfrog/jfrog-cli#3517) (@Edenb2131)
- **[jfrog-cli-artifactory]** Fix - Change GOPROXY [#477](jfrog/jfrog-cli-artifactory#477) (@udaykb2)
- **[jfrog-cli-artifactory]** RTECO-1352 - Fix jf setup docker login when using --url [#460](jfrog/jfrog-cli-artifactory#460) (@Edenb2131)

### 🔧 Internal Changes

- **[jfrog-cli-artifactory]** RTECO-1079 - Update agents commands help [#478](jfrog/jfrog-cli-artifactory#478) (@udaykb2)

### 📦 Other Changes

- **[jfrog-cli]** Rteco 1299 jfrog artifactory ecomatrix cli e2e [#3523](jfrog/jfrog-cli#3523) (@naveenku-jfrog)
- **[jfrog-cli]** Make sure to use cyclonedx-go 0.10.0 [#3525](jfrog/jfrog-cli#3525) (@attiasas)
- **[jfrog-cli]** RTECO-1299 - Retry failed jfrog-cli-workflows runs via rerun-failed-jobs API [#3529](jfrog/jfrog-cli#3529) (@naveenku-jfrog)
- **[jfrog-cli-artifactory]** RTECO-1079 - Remove updating plugins during publish [#471](jfrog/jfrog-cli-artifactory#471) (@udaykb2)
- **[jfrog-cli-artifactory]** RTECO-1079 - Consistent plugin identification [#473](jfrog/jfrog-cli-artifactory#473) (@udaykb2)
- **[jfrog-cli-artifactory]** RTECO-1079 - Make version & slug consistent [#472](jfrog/jfrog-cli-artifactory#472) (@udaykb2)
- **[jfrog-cli-artifactory]** RTECO-1079 - Change the semver error response [#479](jfrog/jfrog-cli-artifactory#479) (@udaykb2)
- **[jfrog-cli-artifactory]** RTECO-1079 - Use consistent env naming [#480](jfrog/jfrog-cli-artifactory#480) (@udaykb2)

---

### 📊 Summary

| Repository | Changes |
|---|---|
| [jfrog-cli-artifactory](https://github.com/jfrog/jfrog-cli-artifactory) | 10 |
| [jfrog-cli](https://github.com/jfrog/jfrog-cli) | 4 |
| **Total** | **14** |

### 🔗 Module Version Changes

| Module | From | To |
|---|---|---|
| [jfrog-cli-artifactory](https://github.com/jfrog/jfrog-cli-artifactory) | `v0.8.1-0.20260601110159-16e27949b870` | `v0.8.1-0.20260603105750-3886c0f01286` |
</pre>
  <p>View the full release notes at <a href="https://github.com/jfrog/jfrog-cli/releases/tag/v2.107.0">https://github.com/jfrog/jfrog-cli/releases/tag/v2.107.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!10364

This branch had an error being deployed

1 failed deployment
frogbot — e7f28764 Deployed Jun 3, 2026 by fluxxBot via scan-pull-request #1246
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants