[Bug]: [API Portal] REST API accepts view handles that are not URL-safe
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, openapi
- Lĩnh vực
- api
Hướng nghiên cứu
Start with addView in portals/api-portal/src/services/apiMetadataService.js near line 1606, which copies req.body.id into handle unvalidated. Then check ViewCreateRequest.id in portals/api-portal/resources/openapi/api-portal-openapi-spec-v0.9.yaml near line 7926 and add a pattern matching the Settings UI rule. Done when POST with uppercase, spaced or slashed handles returns 400 and nothing is stored, and the same rule applies in updateView. Existing invalid views are a separate decision.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Please select the area the issue is related to
Developer Portal
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
POST /api-portal/api/v0.9/views stores the view handle (id) exactly as sent, without validating it. Handles with uppercase letters, spaces or slashes are accepted with 201.
The handle becomes part of the view's URL (/views/<handle>/...), so it must be URL-safe. The Settings UI enforces this with "Handle must be lowercase letters, numbers and hyphens only.", but the REST API doesn't, so scripts and other API clients can create views the UI would refuse.
Expected: each invalid handle is refused with 400, and nothing is stored.
Actual: each invalid handle gets 201 and can be read back with 200.
| Handle sent | Problem | POST /views |
GET /views/<encoded handle> |
|---|---|---|---|
Manual-Upper-View |
Not lowercase | 201 |
200 |
manual-spaced view |
Contains a space | 201 |
200 |
manual-slash/apis |
Contains a slash | 201 |
200 |
Impact
- A slash reads as another URL path segment, and a space has to be encoded, so these handles don't work as normal view URLs.
- Mixed-case handles are inconsistent with the lowercase handles the portal generates.
- The Settings form validates the handle on save, so it refuses to save a view with an invalid handle until the handle is changed.
Cause
addViewcopiesreq.body.idintohandlewithout validation (portals/api-portal/src/services/apiMetadataService.js:1606).ViewCreateRequest.idhas nopatternand is documented as "stored as-is", so the OpenAPI request validator allows it (portals/api-portal/resources/openapi/api-portal-openapi-spec-v0.9.yaml:7926).
Suggested fix
- Add a
patterntoViewCreateRequest.idthat matches the rule the UI enforces, and remove "stored as-is" from its description. - Apply the same rule to handle changes in
updateViewand to any other path that creates views. - Decide separately how to handle views already stored with invalid handles.
Steps to Reproduce
-
Get a bearer token for an administrator and set
BASEto the portal's REST API, for examplehttps://localhost:9543/api-portal/api/v0.9. -
Create a view with a valid handle as a control. It returns
201.curl -sk -w '\nHTTP %{http_code}\n' -X POST "$BASE/views" \ -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' \ -d '{"id":"manual-valid-view","displayName":"Valid View"}' -
Create a view with an uppercase handle. It returns
201;400is expected.curl -sk -w '\nHTTP %{http_code}\n' -X POST "$BASE/views" \ -H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' \ -d '{"id":"Manual-Upper-View","displayName":"Refused View"}' -
Read it back. It returns
200;404is expected.curl -sk -w '\nHTTP %{http_code}\n' "$BASE/views/Manual-Upper-View" -H "Authorization: Bearer $ADMIN_TOKEN" -
Repeat steps 3 and 4 with
manual-spaced view(read back asmanual-spaced%20view) andmanual-slash/apis(read back asmanual-slash%2Fapis). The results are the same.
Severity Level of the Issue
Severity/Minor (Non-critical functionality. Can be fixed in future releases)
Environment Details (with versions)
- API Portal
1.1.0-m6-SNAPSHOT, built locally from source - Platform API
0.17.0-SNAPSHOT, for sign-in - SQLite, running with Docker Compose on macOS
- Ngôn ngữ chính
- Go
- Star
- 85
- Fork
- 137
- Merge trung bình
- 1 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 247
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của wso2/api-platform
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
wso2/api-platform#4369 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsĐang mởArea/Policies Aspect/Other Severity/Trivial Type/Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
wso2/api-platform#4355 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Area/Gateway Aspect/API Severity/Minor Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
wso2/api-platform#4348 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Aspect/AI Aspect/API. Severity/Major
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
wso2/api-platform#4343 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: content-length-guardrail policy accepts a non-string streamingJsonPath at API creationĐang mởArea/Policies Aspect/Configuration Severity/Minor Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
wso2/api-platform#4330 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của wso2/api-platform
Issue tương tự
-
benchmark
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
mozilla-ai/cq#601 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation migration
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày