-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input Validation for API URL #637
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider implementing the following changes to improve the code.
@Kaos599 can you fix the linting issues, we use black and flake8 |
@sauravpanda I have made changes that should resolve all flake8 linting issues (E302, E305, and F722). Before merging also assign this PR with the hacktoberfest label. |
🔍 Code Review Summary✅ All Clear: This commit looks good! 👍 Overview
Test Cases3 file need updates to their tests. Run
Useful Commands
|
@sauravpanda. Sorry for the previous issue. I have revised the code to fit Flake8 and Black's Compliance.
|
Validate PR Request Inputs
Improve input validation for GitHub PR requests.
PRRequestModel
to validate owner, repo, and PR number inputs.validate_pr_request
wrapper function to validate the inputs.get_pr_info
andget_pr_files
functions to use the validated data.Ensures that the provided inputs for owner, repo, and PR number are valid, reducing the risk of errors and improving the overall robustness of the code.
Original Description
# Enhance PR Input Validation**
Improve input validation for pull request data using Pydantic.
PRRequestModel
for structured input validation.validate_pr_request
function to encapsulate validation logic.get_pr_info
andget_pr_files
functions to use validated data.**
Increases robustness of the code by ensuring valid inputs before making API calls.
Original Description
# Enhance PR Input Validation**
**
Improve input validation for pull request data using Pydantic.
PRRequestModel
for structured input validation.validate_pr_request
function to encapsulate validation logic.get_pr_info
andget_pr_files
to utilize validated data.ValidationError
.**
**
Increases robustness of the code by ensuring valid input before making API calls.
Original Description
# Validate PR Request Inputs**
**
**
Improve input validation for GitHub PR requests.
PRRequestModel
to validate theowner
,repo
, andpr_number
inputs.validate_pr_request
wrapper function to validate the inputs before making the API calls.get_pr_info
andget_pr_files
functions to use the validated inputs.**
**
**
This change ensures that the input parameters for the GitHub PR requests are properly validated, reducing the risk of errors and improving the overall robustness of the code.
Original Description
- Introduced pydantic model `PRRequestModel` to validate `owner`, `repo`, and `pr_number` inputs before constructing GitHub API URLs - Enforced input rules: - `owner` should match GitHub username conventions (1-39 alphanumeric characters) - `repo` should follow GitHub repo naming conventions (1-100 characters, allowing '.', '_', '-') - `pr_number` should be a positive integer - Updated `get_pr_info` and `get_pr_files` functions to use validated inputs, ensuring only compliant values are used in API requests - Added error handling in `main` function to catch `ValidationError` and provide clear feedback on invalid inputs - Improved security by sanitizing inputs, mitigating the risk of URL manipulation leading to API abuse and unauthorized access