Leading/trailing spaces are allowed in string fields for some API endpoints
- Ngôn ngữ chính
- Java
- Star
- 3.1k
- Fork
- 1.4k
- Merge trung bình
- 6 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 32
Mô tả
### problem
Currently, some API endpoints allow saving string fields with leading or trailing spaces. This behavior can lead to inconsistent data and unexpected UI/API issues.
For example, when creating or updating certain resources (e.g. volumes, templates, ISOs), values with spaces at the beginning or end of the string are accepted and stored successfully, while they should instead be rejected with a validation error.
Here is the list of API endpoints where the issue occurs for the name and description fields:
- registerIso / updateIso
- createVolume / updateVolume / uploadVolume
- registerTemplate / updateTemplate
- updateNetwork / createNetwork / createNetworkACL / updateNetworkACLList
- createVPC / updateVPC
- createVpnCustomerGateway / createVpnGateway / createVpnCustomerGateway
Please also check other endpoints where this issue might occur, as similar validation problems may exist elsewhere.
### versions
CloudStack 4.20.2.0
### The steps to reproduce the bug
1. Call one of the affected endpoints (for example: ISO creation or update).
2. Provide string fields with leading or trailing spaces.
3. Observe that the request is accepted and the data is stored.
```
{
"listisosresponse": {
"count": 1,
"iso": [
{
"id": "fee7a4be-b9cd-41d9-81c9-e948332e605b",
"name": " test name ",
"displaytext": " text ",
"isready": true,
"url": "my_url",
....
}
]
}
}
```
### What to do about it?
The API should not allow leading or trailing spaces in string fields. It would be preferable to introduce this validation globally for all string fields across the API
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách lần theo quá trình validation của các API entry point được liệt kê, sử dụng registerIso hoặc updateIso để tái hiện việc chấp nhận khoảng trắng ở đầu và cuối. Kiểm tra các endpoint volume, template, network, VPC và VPN được nêu tên khác để tìm hành vi tương tự; được coi là hoàn tất khi các trường string bị ảnh hưởng từ chối các giá trị như vậy bằng một validation error, bao gồm cả mọi endpoint bổ sung được tìm thấy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- api, backend, cloud
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100