I want to find the managers in a permission. For that, I read the details of a permission to extract the users with the right "m".
The problem is that it seems to work only for some permissions but not all.
I don't know in which cases it works or not.
Can you confirm the problem ? Or do I use the librairie in a bad way ?
Do you have any solutions ?
Describe the bug
For some of ours permissions, the function "pyart.permissions.get(permission_name)" abort in error, whereas artifactory/api/security/permissions/permission_name return the result.
To Reproduce
pyart = pyArtifactory(url=V_url_artif_formatpyart, auth=(V_username, V_password), api_version=1)
perm_detail_test = pyart.permissions.get('permission_name')
logger.debug("Accès au détail de la permission : %s", perm_detail_test)
curl -u login:pwd "https://artifactory-url/artifactory/api/security/permissions/permission_name"
(but I don't know which permissions to chose)
Expected behavior
I want to display the users with their rights for a permission name.
Screenshots
NA
Environment:
OS : server on Linux, client on Windows.
python 3.8.4
Pyartifactory 1.12.0
Artifactory 7.55.3
Additional context
The request with the library :
pyart = pyArtifactory(url=V_url_artif_formatpyart, auth=(V_username, V_password), api_version=1)
perm_detail_test = pyart.permissions.get('generic-local-perms')
logger.debug("Accès au détail de la permission : %s", perm_detail_test)
perm_detail_test = pyart.permissions.get('my_test_perm')
logger.debug("Accès au détail de la permission : %s", perm_detail_test)
Result for the permission generic-local-perms (that works) :
2023-06-12 14:17:51 [DEBUG] _make_request. https://artifactory-url:443 "GET /artifactory/api/security/permissions/generic-local-perms HTTP/1.1" 200 None (connectionpool.py:456)
2023-06-12 14:17:51 [DEBUG] get. Permission generic-local-perms found (objects.py:228)
2023-06-12 14:17:51 [DEBUG] main. Accès au détail de la permission : name='generic-local-perms' includesPattern='**' excludesPattern='' repositories=['generic-local'] principals=PrincipalsPermission(users={'user1': [<PermissionEnum.read: 'r'>, <PermissionEnum.delete: 'd'>, <PermissionEnum.deploy: 'w'>, <PermissionEnum.admin: 'm'>, <PermissionEnum.annotate: 'n'>]}, groups=None) (test-artif_lib-v1-4.py:346)
Result for the permission my_test_perm (that doesn't work) :
2023-06-12 14:17:51 [DEBUG] _make_request. https://artifactory-url:443 "GET /artifactory/api/security/permissions/my_test_perm HTTP/1.1" 200 None (connectionpool.py:456)
2023-06-12 14:17:51 [DEBUG] get. Permission my_test_perm found (objects.py:228)
Traceback (most recent call last):
File "test-artif_lib-v1-4.py", line 408, in
main()
File "test-artif_lib-v1-4.py", line 347, in main
perm_detail_test = pyart.permissions.get('my_test_perm')
File "/myrep/.venv/lib/python3.8/site-packages/pyartifactory/objects.py", line 230, in get
Permission(**response.json())
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for Permission
principals -> users -> usra -> 1
value is not a valid enumeration member; permitted: 'm', 'd', 'w', 'n', 'r' (type=type_error.enum; enum_values=[<PermissionEnum.admin: 'm'>, <PermissionEnum.delete: 'd'>, <PermissionEnum.deploy: 'w'>, <PermissionEnum.annotate: 'n'>, <PermissionEnum.read: 'r'>])
Hello @usinelogicielle ,
This issue happens because there is a new permission type that was added: mxm=managedXrayMeta. I'll add it to the PermissionEnum to fix this.
Hi,
I want to find the managers in a permission. For that, I read the details of a permission to extract the users with the right "m".
The problem is that it seems to work only for some permissions but not all. I don't know in which cases it works or not.
Can you confirm the problem ? Or do I use the librairie in a bad way ? Do you have any solutions ?
Describe the bug For some of ours permissions, the function "pyart.permissions.get(permission_name)" abort in error, whereas artifactory/api/security/permissions/permission_name return the result.
To Reproduce pyart = pyArtifactory(url=V_url_artif_formatpyart, auth=(V_username, V_password), api_version=1) perm_detail_test = pyart.permissions.get('permission_name') logger.debug("Accès au détail de la permission : %s", perm_detail_test) curl -u login:pwd "https://artifactory-url/artifactory/api/security/permissions/permission_name" (but I don't know which permissions to chose)
Expected behavior I want to display the users with their rights for a permission name.
Screenshots NA
Environment:
Additional context
The request with the library :
pyart = pyArtifactory(url=V_url_artif_formatpyart, auth=(V_username, V_password), api_version=1) perm_detail_test = pyart.permissions.get('generic-local-perms') logger.debug("Accès au détail de la permission : %s", perm_detail_test)
perm_detail_test = pyart.permissions.get('my_test_perm') logger.debug("Accès au détail de la permission : %s", perm_detail_test) Result for the permission generic-local-perms (that works) : 2023-06-12 14:17:51 [DEBUG] _make_request. https://artifactory-url:443 "GET /artifactory/api/security/permissions/generic-local-perms HTTP/1.1" 200 None (connectionpool.py:456) 2023-06-12 14:17:51 [DEBUG] get. Permission generic-local-perms found (objects.py:228) 2023-06-12 14:17:51 [DEBUG] main. Accès au détail de la permission : name='generic-local-perms' includesPattern='**' excludesPattern='' repositories=['generic-local'] principals=PrincipalsPermission(users={'user1': [<PermissionEnum.read: 'r'>, <PermissionEnum.delete: 'd'>, <PermissionEnum.deploy: 'w'>, <PermissionEnum.admin: 'm'>, <PermissionEnum.annotate: 'n'>]}, groups=None) (test-artif_lib-v1-4.py:346)
Result for the permission my_test_perm (that doesn't work) : 2023-06-12 14:17:51 [DEBUG] _make_request. https://artifactory-url:443 "GET /artifactory/api/security/permissions/my_test_perm HTTP/1.1" 200 None (connectionpool.py:456) 2023-06-12 14:17:51 [DEBUG] get. Permission my_test_perm found (objects.py:228) Traceback (most recent call last): File "test-artif_lib-v1-4.py", line 408, in
main()
File "test-artif_lib-v1-4.py", line 347, in main
perm_detail_test = pyart.permissions.get('my_test_perm')
File "/myrep/.venv/lib/python3.8/site-packages/pyartifactory/objects.py", line 230, in get
Permission(**response.json())
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for Permission
principals -> users -> usra -> 1
value is not a valid enumeration member; permitted: 'm', 'd', 'w', 'n', 'r' (type=type_error.enum; enum_values=[<PermissionEnum.admin: 'm'>, <PermissionEnum.delete: 'd'>, <PermissionEnum.deploy: 'w'>, <PermissionEnum.annotate: 'n'>, <PermissionEnum.read: 'r'>])
The same request with the API : curl -u login:pwd "https://artifactory-url/artifactory/api/security/permissions/my_test_perm"
The result (it works) : { "name" : "my_test_perm", "includesPattern" : "**", "excludesPattern" : "", "repositories" : [ "docker-7g-local", "docker-local", "conda-local", "docker-local", "pip-dev-local", "pip-local" ], "principals" : { "users" : { "usra" : [ "r", "mxm", "d", "w", "m", "n" ] } } }