Skip to content

Change edit app form to page redirect#650

Open
iandjx wants to merge 2 commits into
developfrom
fix/649-app-edit-sheet-narrow
Open

Change edit app form to page redirect#650
iandjx wants to merge 2 commits into
developfrom
fix/649-app-edit-sheet-narrow

Conversation

@iandjx

@iandjx iandjx commented Mar 20, 2025

Copy link
Copy Markdown
Contributor
  • Simplified navigation with back button and improved routing.
  • Removed unused components, states, and imports for better maintainability.
  • Enhanced UI consistency and streamlined app editing workflow.

…. Remove unused states and components from Apps page, and update edit page to use ChatAppForm2. Enhance navigation with back button in edit view.
@iandjx iandjx changed the title Refactor ChatAppForm2 component and clean up imports in related files… Change edit app form to page redirect Mar 20, 2025
@iandjx
iandjx changed the base branch from master to develop March 20, 2025 13:52
<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

Untrusted URL redirection depends on a
user-provided value
.

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.

  1. Create a list of authorized redirects.
  2. Validate the resourceSlug against this list before constructing the URL.
  3. If the resourceSlug is 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

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/webapp/src/components/ChatAppForm2.tsx b/webapp/src/components/ChatAppForm2.tsx
--- a/webapp/src/components/ChatAppForm2.tsx
+++ b/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'>&gt;</span>
EOF
@@ -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'>&gt;</span>
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread webapp/src/pages/[resourceSlug]/app/[appId]/edit.tsx Fixed
Comment thread webapp/src/pages/[resourceSlug]/app/[appId]/edit.tsx Fixed
Comment thread webapp/src/pages/[resourceSlug]/app/[appId]/edit.tsx Fixed
Comment thread webapp/src/pages/[resourceSlug]/apps.tsx Fixed
@github-actions

github-actions Bot commented Mar 20, 2025

Copy link
Copy Markdown

File Coverage
All files 96%
src/lib/utils/validationutils.ts 95%

Minimum allowed coverage is 80%

Generated by 🐒 cobertura-action against b07905a

@ragyabraham

Copy link
Copy Markdown
Contributor

@iandjx there seems to be a few things that have been flagged on this PR. can you take a look please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants