Change edit app form to page redirect#650
Open
iandjx wants to merge 2 commits into
Open
Conversation
…. Remove unused states and components from Apps page, and update edit page to use ChatAppForm2. Enhance navigation with back button in edit view.
| <main className='text-foreground flex flex-col gap-2'> | ||
| <div className='flex gap-2 mb-2 text-sm'> | ||
| <h4 className='text-gray-700 font-semibold'>Apps</h4> | ||
| <Link href={`/${resourceSlug}/apps`}> |
Check warning
Code scanning / CodeQL
Client-side URL redirect Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we should avoid using user input directly in the URL redirection. Instead, we can maintain a list of authorized redirects and choose from that list based on the user input. This ensures that only safe and predefined URLs are used for redirection.
- Create a list of authorized redirects.
- Validate the
resourceSlugagainst this list before constructing the URL. - If the
resourceSlugis not in the list, handle the error appropriately (e.g., redirect to a default safe page or show an error message).
Suggested changeset
1
webapp/src/components/ChatAppForm2.tsx
| @@ -92,2 +92,4 @@ | ||
| const { resourceSlug } = router.query; | ||
| const authorizedSlugs = ['validSlug1', 'validSlug2', 'validSlug3']; // Add your authorized slugs here | ||
| const isValidSlug = authorizedSlugs.includes(resourceSlug); | ||
|
|
||
| @@ -311,5 +313,11 @@ | ||
| <div className='flex gap-2 mb-2 text-sm'> | ||
| <Link href={`/${resourceSlug}/apps`}> | ||
| <h4 className='text-gray-700 font-semibold cursor-pointer'>Apps</h4> | ||
| </Link> | ||
| {isValidSlug ? ( | ||
| <Link href={`/${resourceSlug}/apps`}> | ||
| <h4 className='text-gray-700 font-semibold cursor-pointer'>Apps</h4> | ||
| </Link> | ||
| ) : ( | ||
| <Link href="/default/apps"> {/* Redirect to a default safe page */} | ||
| <h4 className='text-gray-700 font-semibold cursor-pointer'>Apps</h4> | ||
| </Link> | ||
| )} | ||
| <span className='text-gray-500'>></span> |
Copilot is powered by AI and may make mistakes. Always verify output.
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against b07905a |
Contributor
|
@iandjx there seems to be a few things that have been flagged on this PR. can you take a look please |
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.
Uh oh!
There was an error while loading. Please reload this page.