Skip to content

Fix issues in throttling policy import API#13560

Merged
PasanT9 merged 1 commit into
wso2:masterfrom
PasanT9:fix-112
Jan 23, 2026
Merged

Fix issues in throttling policy import API#13560
PasanT9 merged 1 commit into
wso2:masterfrom
PasanT9:fix-112

Conversation

@PasanT9

@PasanT9 PasanT9 commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

$subject

@wso2-engineering wso2-engineering Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
  • Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.

✅ Before merging this pull request:

  • Review all AI-generated comments for accuracy and relevance.
  • Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Comment Accepted (Y/N) Reason
#### Log Improvement Suggestion No: 1
#### Log Improvement Suggestion No: 2

@coderabbitai

coderabbitai Bot commented Jan 23, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds support for the .yml file extension as an alternative YAML format and introduces file validation and security checks in the policy import service to restrict uploads to YAML and JSON files only, with canonical path validation to prevent path traversal attacks.

Changes

Cohort / File(s) Summary
File Extension Support
components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/importexport/ImportExportConstants.java
Added new constant YML_EXTENSION = ".yml" to support .yml file extension alongside existing .yaml extension
Import Validation & Security
components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/ThrottlingApiServiceImpl.java
Added validation in getImportedPolicy() method: validates non-empty file name, enforces YAML (.yaml/.yml) and JSON file types only, determines file type, and performs canonical path validation to prevent path traversal attacks

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is completely empty (shows only '$subject' placeholder), providing no information about the changeset. Add a detailed description explaining the validation checks, security improvements, and the purpose of the new YML_EXTENSION constant.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding validation and security checks to the throttling policy import API, with a supplementary constant for YAML file extension support.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PasanT9 PasanT9 merged commit 49a6427 into wso2:master Jan 23, 2026
11 of 12 checks passed

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants