Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1609147 - [REST API] all VMs in VM Pool are returned to a pool user regardless of actual VM ownership
[REST API] all VMs in VM Pool are returned to a pool user regardless of actua...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine (Show other bugs)
4.2.4
Unspecified Unspecified
high Severity high
: ovirt-4.2.6
: ---
Assigned To: Arik
Liran Rotenberg
: ZStream
Depends On:
Blocks: 1608093
  Show dependency treegraph
 
Reported: 2018-07-27 02:50 EDT by Michal Skrivanek
Modified: 2018-09-04 09:42 EDT (History)
17 users (show)

See Also:
Fixed In Version: ovirt-engine-4.2.6.4
Doc Type: Bug Fix
Doc Text:
Previously, users were able to see all the virtual machines in a pool, rather than only those virtual machines to which they are assigned. In this release, users will only see the virtual machines to which they are assigned.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-09-04 09:41:42 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Virt
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 93586 master ABANDONED restapi: VM list for ovirt-web-ui 2018-08-15 04:17 EDT
oVirt gerrit 93753 master MERGED core: filter unattached vms from pools for vm portal 2018-08-16 09:00 EDT
oVirt gerrit 93785 ovirt-engine-4.2 MERGED core: filter unattached vms from pools for vm portal 2018-08-17 05:58 EDT
Github oVirt/ovirt-web-ui/issues/680 None None None 2018-07-27 02:50 EDT
Red Hat Product Errata RHBA-2018:2623 None None None 2018-09-04 09:42 EDT

  None (edit)
Description Michal Skrivanek 2018-07-27 02:50:32 EDT
If VM is taken from a pool by another user it is still listed for all other users with a UserRole permission on the pool.
Normally permissions are inherited but VM Pool is a special case, user can have a permission for the pool but that user doesn't own a VM from that pool allocated by another user.
This blocks https://github.com/oVirt/ovirt-web-ui/issues/680 in VM Portal.

The BackendVmsResource doesn't implement similar logic to the old User Portal's GetAllVmsAndVmPoolsQuery for user API requests.
Comment 1 Shmuel Melamud 2018-08-08 11:42:12 EDT
For verification:

Execute GET /api/vms;max=8?search=SORTBY%20NAME%20ASC REST API query. This query is used by ovirt-web-ui to get a list of VMs.

Before the fix this query returned a list of all VMs, including pooled VMs.

After the fix this query returns a list of all VMs, including only those pooled VMs that are owned by the user.
Comment 2 Ori Liel 2018-08-13 03:23:49 EDT
Why change the behavior of GET /api/vms;max=8?search=SORTBY%20NAME%20ASC?

It does what it's supposed to, which is getting all vms sorted by name in ascending order with maximum 8 results with no filtering. Returning only pooled VMs that are owned by the user implies filtering, but the request does not call for filtering, so I think we would actually be creating a bug.

If ovirt-web-ui needs a particular subset of VMS (namely all regular VMs plus only user-owned pooled VMs) it should use the API differently, not change the API's behavior.

Since we are dealing with VMs, intersecting the results in the API layer would be very costly and so it makes sense to have a designated query. But that query should be activated differently, not by 'hijacking' GET /api/vms;max=8?search=SORTBY%20NAME%20ASC? IMO
Comment 3 Arik 2018-08-14 10:58:49 EDT
(In reply to Ori Liel from comment #2)
> Why change the behavior of GET /api/vms;max=8?search=SORTBY%20NAME%20ASC?
> 
> It does what it's supposed to, which is getting all vms sorted by name in
> ascending order with maximum 8 results with no filtering. Returning only
> pooled VMs that are owned by the user implies filtering, but the request
> does not call for filtering, so I think we would actually be creating a bug.
> 
> If ovirt-web-ui needs a particular subset of VMS (namely all regular VMs
> plus only user-owned pooled VMs) it should use the API differently, not
> change the API's behavior.
> 
> Since we are dealing with VMs, intersecting the results in the API layer
> would be very costly and so it makes sense to have a designated query. But
> that query should be activated differently, not by 'hijacking' GET
> /api/vms;max=8?search=SORTBY%20NAME%20ASC? IMO

+1
Comment 4 Michal Skrivanek 2018-08-15 05:30:27 EDT
Ori, please take a look at alternative implementation in https://gerrit.ovirt.org/#/c/93753/
Comment 5 Liran Rotenberg 2018-08-23 04:16:26 EDT
Verified on:
ovirt-engine-4.2.6.4-0.0.master.20180821115903.git1327b2f.el7.noarch

Steps:
1. Create a new user to the engine.
2. Set UserRole permission(system/cluster) to the user created in step 1.
3. Create a VM Pool with 4 VMs.
4. Allocate a VM from the pool to the user.
5. Check with REST API:
GET https://{engine-fqdn}/ovirt-engine/api/vms;max=16?search=SORTBY%20NAME%20ASC


Result:
The user sees only one VM allocated to him from the pool.
Comment 8 Raz Tamir 2018-08-28 15:30:41 EDT
QE verification bot: the bug was verified upstream
Comment 10 errata-xmlrpc 2018-09-04 09:41:42 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:2623

Note You need to log in before you can comment on or make changes to this bug.