Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where the course structure API was exposing lesson AI-generated bootstrap text (_initial_content post meta) to unauthorized users. The fix adds a capability check to ensure only users with edit_lesson permission can see this content.
Key Changes:
- Added capability check in
prepare_lesson()to restrictinitialContentvisibility to authorized users - Updated PHPCS configuration to whitelist
edit_lessonandedit_lessonscapabilities
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
includes/class-sensei-course-structure.php |
Added current_user_can('edit_lesson') check before returning initialContent to prevent unauthorized access |
phpcs.xml.dist |
Whitelisted edit_lesson and edit_lessons capabilities for PHPCS validation |
changelog/fix-course-structure-exposing-lesson-initial-content |
Added changelog entry documenting the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves SEN-28
Proposed Changes
The course structure API returns the lesson AI-generated text (the
_initial_contentpost meta) to unauthorized users. This text is generated when using Sensei Pro to generate the course and lesson content. Note that the meta is never updated with the real lesson content, so this is not a security issue.Testing Instructions
curl https://sensei.test/wp-json/sensei-internal/v1/course-structure/[COURSE POST ID]?context=viewinitialContentfrom the response is empty.Pre-Merge Checklist