mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
Web views: - 34 views returned to request.META["HTTP_REFERER"] + "#tab": without a Referer they failed with a TypeError (500), and a Referer from another site was followed (open redirect). They return through _back(), which keeps a same-site Referer and otherwise opens the VM page at the tab. get_safe_redirect uses the same check. Rejected disk options also return to the VM's disks tab instead of the VM list. - migrate_instance returned silently when the target was the current compute or unreachable, so the web view logged "Instance is migrated" and the API answered "instance migrate is started". It now raises; the view reports the error and logs only a completed migration, and an unknown compute id is a 404 instead of a 500. The automatic migration after a clone skips a target that is the current compute. - add_owner and del_owner failed with a 500 without their ids, add_owner also when the user was already an owner, and del_owner deleted the given ownership record even when it belonged to another VM. Ids are validated, a record of another VM is a 404, and a repeated owner is reported. - Broad handlers that hid programming errors are narrowed: clone catches libvirt, value and OS errors (a lock timeout included), ownership lookups catch DoesNotExist. The DRBD status no longer needs its bare except: the VM name is escaped in the regex, which was the only thing that could fail there. API: - A libvirt error under /api/ is JSON with status 400, and a lock timeout 409, instead of the HTML error page. This lives in the existing ExceptionMiddleware, so existing settings need no change. - Volume create/delete on an inactive pool answer 409, and invalid volume data 400 with the serializer errors, instead of 200. The new tests cover every view that returns with _back() without a Referer and with a foreign one, the migrate failures on web and API, the owner ids, the API error format and the volume statuses; nine of the ten fail on the previous code. |
||
|---|---|---|
| .. | ||
| serializers.py | ||
| viewsets.py | ||