[Bug]: content-length-guardrail policy accepts a non-string streamingJsonPath at API creation

Đang mở Phù hợp với người mới
#4,330 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/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ệ
go, yaml
Lĩnh vực
api, backend

Hướng nghiên cứu

Tìm lược đồ chính sách content-length-guardrail và so sánh các tham số phản hồi của lược đồ với tham số chuỗi streamingJsonPath được ghi lại trong tài liệu và ví dụ word-count-guardrail. Kiểm tra bộ kiểm thử tích hợp được nhắc đến trong wso2/gateway-controllers#415 để hiểu hành vi tạo API hiện tại. Hoàn tất khi quá trình tạo API từ chối giá trị streamingJsonPath không phải chuỗi bằng HTTP 400, nhất quán với jsonPath.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Area/Policies Aspect/Configuration Severity/Minor Type/Bug
Please select the area the issue is related to

Gateway

Please select the aspect the issue is related to

Aspect/Configuration (Config files, settings, env vars, defaults)

Description

The content-length-guardrail documentation lists streamingJsonPath as a string parameter of the response configuration. The policy reads it and refuses a value that is not a string. Its schema does not declare the parameter, so a wrong value passes API creation and fails at runtime instead.

The API is created, and every request to the operation then gets HTTP 500. A typo in this parameter breaks the operation instead of failing the deployment. jsonPath is declared as a string, and a non-string jsonPath is rejected at creation as expected.

The other seven policies in the repository that read streamingJsonPath all declare it in their schema, for example word-count-guardrail:

streamingJsonPath:
  type: string

The integration suite in wso2/gateway-controllers#415 asserts the current behaviour.

Steps to Reproduce
  1. Create a REST API with an operation that attaches the policy with a non-string streamingJsonPath:
    {"name":"content-length-guardrail","version":"v1","params":{"response":{"enabled":true,"min":1,"max":10,"streamingJsonPath":5}}}
    
  2. The API is created.
  3. Every request to that operation gets HTTP 500. An operation on the same API with a valid configuration still works.
  4. Repeat with "jsonPath": 5. API creation fails with HTTP 400, as expected.
Severity Level of the Issue

Severity/Minor (Non-critical functionality. Can be fixed in future releases)

Environment Details (with versions)
  • Policy: content-length-guardrail v1.1.0, wso2/gateway-controllers main (4f1520a8)
  • Gateway versions: 1.1.0 (patched), 1.2.0 and latest (main-59dcd51)
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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của wso2/api-platform

Tất cả issue của wso2/api-platform

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.