jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
538 stars 236 forks source link

jfrog rt permission-target-update does replaces instead of update #1115

Open u2mejc opened 3 years ago

u2mejc commented 3 years ago

Describe the bug The command jfrog rt permission-target-update replaces the existing permission with the contents of the json template file, deleting any resource attributes not included. As the jfrog CLI doesn't have a built in command to read / get existing permissions, it's not possible to use only the jfrog cli in an automation script today.

The API docs more aptly describe this usage create or replace, here: https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-CreateorReplacePermissionTarget

To Reproduce

  1. No CLI to download existing permission json object.
    1. jfrog rt permission-target-get command: No help topic for 'permission-target-get'
  2. Use jfrog rt permission-target-template to create template of one new repo to add to an existing permission.
  3. Observe after using jfrog rt permission-target-update, that instead of appending to update the object, it's been replaced, and all attributes previously in the permission have been lost.

Expected behavior

Screenshots If applicable, add screenshots to help explain your problem.

Versions

Suggested Resolutions

  1. Rename the command: s/permission-target-update/permission-target-replace and add functionality to read or get existing permissions - or -
  2. Update the command so that the json blobs are merged client side on permission-target-update.
ronnyfriedland commented 4 months ago

Hi, are there any news about this ticket?

We are using JFrog CLI and are very disappointed about the missing feature to retrieve permission target.

Our workaround now is

  1. use the HTTP Rest API to get the current permission target (/api/v2/security/permissions/)
  2. reformat the response data to match the cli template format
  3. update the permission target (add/remove permissions)
  4. save the new permission target using the cli again (permission-target-update).

This cannot be the intended usage by JFrog.