jfrog / jfrog/jfrog-cli-security

`jf audit --mvn` tries to resolve a `-SNAPSHOT` version from `releaseRepo`

Open
#496 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
13
Forks
50
Avg merge
3d 48m
Merged PRs (30d)
26

Description

Describe the bug

We're using jf mvn-config to set --repo-resolve-releases ${_myprojectkey}-maven-releases-vir --repo-resolve-snapshots ${_myprojectkey}-maven-snapshots-vir

When running the jf audit --mvn command we see in the logs it's trying to use the releases repo to download a -SNAPSHOT artifact.

Current behavior

jf cli is trying to download a -SNAPSHOT version from the -releases repo:

20:39:18 [Info] Calculating Maven dependencies...
20:39:39 [Info] [INFO] Downloading from artifactory: https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir/com/github/gzm55/maven/project-settings-extension/0.2.4/project-settings-extension-0.2.4.pom
[INFO] Downloaded from artifactory: https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir/com/github/gzm55/maven/project-settings-extension/0.2.4/project-settings-extension-0.2.4.pom (2.0 kB at 404 B/s)
[INFO] Downloading from artifactory: https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir/com/github/gzm55/maven/project-settings-extension/0.2.4/project-settings-extension-0.2.4.jar
[INFO] Downloaded from artifactory: https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir/com/github/gzm55/maven/project-settings-extension/0.2.4/project-settings-extension-0.2.4.jar (12 kB at 12 kB/s)
[INFO] Scanning for projects...
[INFO] Downloading from artifactory: https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir/com/${_mycompany}/riptide/springboot/riptide-spring-boot-parent/3.4.0-SNAPSHOT/maven-metadata.xml
[INFO] Downloading from artifactory: https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir/com/${_mycompany}/riptide/springboot/riptide-spring-boot-parent/3.4.0-SNAPSHOT/riptide-spring-boot-parent-3.4.0-SNAPSHOT.pom
Error: ] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.${_mycompany}.riptide.notificationbuddy:nb-parent:3.4.0-SNAPSHOT: The following artifacts could not be resolved: com.${_mycompany}.riptide.springboot:riptide-spring-boot-parent:pom:3.4.0-SNAPSHOT (absent): Could not find artifact com.${_mycompany}.riptide.springboot:riptide-spring-boot-parent:pom:3.4.0-SNAPSHOT in artifactory (https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir) and 'parent.relativePath' points at wrong local POM @ line 12, column 11
 @
Error:  The build could not read 1 project -> [Help 1]
Error:
Error:    The project com.${_mycompany}.riptide.notificationbuddy:nb-parent:3.4.0-SNAPSHOT (/home/runner/_work/riptide_notification-buddy-parent/riptide_notification-buddy-parent/pom.xml) has 1 error
Error:      Non-resolvable parent POM for com.${_mycompany}.riptide.notificationbuddy:nb-parent:3.4.0-SNAPSHOT: The following artifacts could not be resolved: com.${_mycompany}.riptide.springboot:riptide-spring-boot-parent:pom:3.4.0-SNAPSHOT (absent): Could not find artifact com.${_mycompany}.riptide.springboot:riptide-spring-boot-parent:pom:3.4.0-SNAPSHOT in artifactory (https://edgeuswest1${_mycompany}.jfrog.io/artifactory/${_myprojectkey}-maven-releases-vir) and 'parent.relativePath' points at wrong local POM @ line 12, column 11 -> [Help 2]
Error:
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
Error:  Re-run Maven using the -X switch to enable full debug logging.
Error:
Error:  For more information about the errors and possible solutions, please read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Error:  [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Reproduction steps

In our GitHub action workflow we're configuring the jfrog conf like this:

jf config add jfrog-central --url https://central${_mycompany}.jfrog.io --interactive=false --overwrite=true --user=$_myemail --password=$_myidentitytoken
jf config add jfrog-core-edge --url https://edgeuswest1${_mycompany}.jfrog.io --interactive=false --overwrite=true --user=$_myemail --password=$_myidentitytoken
jf mvn-config \
    --server-id-resolve jfrog-core-edge \
    --server-id-deploy jfrog-central \
    --repo-resolve-releases ${_myprojectkey}-maven-releases-vir \
    --repo-resolve-snapshots ${_myprojectkey}-maven-snapshots-vir \
    --repo-deploy-releases ${_myprojectkey}-maven-np-releases-loc \
    --repo-deploy-snapshots ${_myprojectkey}-maven-np-snapshots-loc

Then running:

cat .jfrog/projects/maven.yaml
jf config show
jf config use jfrog-core-edge
jf rt ping
jf config use jfrog-central
jf rt ping
jf audit --mvn --extended-table=true --format=simple-json --project=${_myprojectkey}
Expected behavior

JF should follow Naming convention of Maven coordinates which defines -SNAPSHOT as exactly what it says:

Unstable versions (SNAPSHOT)
SNAPSHOTs are artifacts built in between releases. They may be built from a particular commit or from code that isn't even committed to the source repository. They are a snapshot of the project at a particular point in time, generally used for testing. Unlike release versions, snapshot artifacts can and do change over time.

Usually the snapshot has the version of the next anticipated release followed by -SNAPSHOT, e.g. 1.0.1-SNAPSHOT.

Maven treats artifacts with such versions in a special way during deployment and stores them in the snapshotRepository if one is defined in the POM file.

I would expect the artifact coordinates to get parsed and since I have a -SNAPSHOT version it should use the repo i've configured with jf mvn-config --repo-resolve-snapshots <snapshot repo name>

JFrog CLI version

2.7.7.0

Operating system type and version

linux-amd64

JFrog Artifactory version

No response

JFrog Xray version

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing jf audit --mvn with the shown jf mvn-config settings and inspect .jfrog/projects/maven.yaml. Trace how the audit command handles Maven release and snapshot repositories, then verify that a -SNAPSHOT dependency is resolved from the configured snapshot repository rather than the releases repository.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.