-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Add educational video submission feature #3803
base: main
Are you sure you want to change the base?
Conversation
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/OWASP-BLT/BLT?shareId=XXXX-XXXX-XXXX-XXXX).
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨ |
…ng sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
def fetch_video_data(video_url): | ||
parsed_url = urlparse(video_url) | ||
host = parsed_url.hostname | ||
if host and (host.endswith("youtube.com") or host == "youtu.be"): |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
youtube.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to ensure that the URL host is strictly validated against a list of allowed hosts. Instead of using host.endswith("youtube.com")
, we should check if the host is exactly "youtube.com" or "www.youtube.com". This will prevent malicious URLs from bypassing the check.
- Modify the
fetch_video_data
function to use a stricter check for YouTube URLs. - Update the condition to check if the host is exactly "youtube.com" or "www.youtube.com".
-
Copy modified line R574
@@ -573,3 +573,3 @@ | ||
host = parsed_url.hostname | ||
if host and (host.endswith("youtube.com") or host == "youtu.be"): | ||
if host and (host in ["youtube.com", "www.youtube.com", "youtu.be"]): | ||
return fetch_youtube_video_data(video_url) |
host = parsed_url.hostname | ||
if host and (host.endswith("youtube.com") or host == "youtu.be"): | ||
return fetch_youtube_video_data(video_url) | ||
elif host and host.endswith("vimeo.com"): |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
vimeo.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to ensure that the hostname check is more stringent. Instead of using host.endswith("vimeo.com")
, we should check that the hostname is exactly vimeo.com
or a subdomain of vimeo.com
. This can be done by ensuring that the hostname ends with .vimeo.com
or is exactly vimeo.com
.
- Modify the check on line 576 to ensure that the hostname is either
vimeo.com
or ends with.vimeo.com
. - No new methods or imports are needed to implement this change.
-
Copy modified line R576
@@ -575,3 +575,3 @@ | ||
return fetch_youtube_video_data(video_url) | ||
elif host and host.endswith("vimeo.com"): | ||
elif host and (host == "vimeo.com" or host.endswith(".vimeo.com")): | ||
return fetch_vimeo_video_data(video_url) |
User description
For more details, open the Copilot Workspace session.
PR Type
Enhancement, Tests
Description
Added a feature to submit educational videos.
Implemented backend validation for YouTube/Vimeo URLs.
Integrated APIs to fetch video metadata and validate educational content.
Created a new database model for storing educational videos.
Changes walkthrough 📝
education.html
Add educational video submission form
website/templates/education/education.html
forms.py
Create video submission form class
website/forms.py
0219_add_educational_video_model.py
Add migration for EducationalVideo model
website/migrations/0219_add_educational_video_model.py
EducationalVideo
model.status.
models.py
Define EducationalVideo model
website/models.py
EducationalVideo
model.education.py
Add video submission backend logic
website/views/education.py
add_video
view for handling submissions.urls.py
Add URL route for video submission
blt/urls.py
add_video
view.