-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix CodeQL Alert for SSRF #2197
Fix CodeQL Alert for SSRF #2197
Conversation
Could you add a test for this functionality, i.e., making sure that the URL is properly formatted? Also, we are not currently performing validation on some of these fields, such as |
@@ -7,6 +7,7 @@ | |||
import pytest | |||
from django.http.response import HttpResponse | |||
from django.urls import reverse | |||
from rest_framework.status import HTTP_400_BAD_REQUEST |
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.
If we are using imports from rest_framework.status
here, why would we define them as constants here:
ocw-studio/external_resources/constants.py
Lines 4 to 10 in d6d5cd1
HTTP_BAD_REQUEST = 400 | |
HTTP_UNAUTHORIZED = 401 | |
HTTP_PAYMENT_REQUIRED = 402 | |
HTTP_FORBIDDEN = 403 | |
HTTP_TOO_MANY_REQUESTS = 429 | |
HTTP_REQUEST_TIMEOUT = 408 | |
HTTP_SERVICE_UNAVAILABLE = 503 |
rest_framework.status
as well.
Also, commit messages should ideally contain a summary of what the commit addresses, rather than a more generic message.
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.
@pt2302 I agree with you on this. I'd have changed it if it had been in the same module and scope of work. Changing the constants and testing things again for external resources module for any breaking change, should be done in separate refactoring ticket in my opinion.
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.
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.
Looks good to me!
What are the relevant tickets?
closes #2175 and closes #2172
Description (What does it do?)
Limited the use of input url. Format for the subscribe url is pre-defined and only token will be used from the message.
How can this be tested?
The scope of this ticket is to test that url was formatted correctly after using the pre-defined url format
AWS_ACCOUNT_ID
andAWS_REGION
"Authorization: Bearer <settings.API_BEARER_TOKEN>" and "Content-Type: application/json":
200
status_code. Which would indicate that url was formatted correctly.