Skip to content

Commit 6657021

Browse files
committed
feedback
1 parent c50b0e6 commit 6657021

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

valhalla/jawn/src/controllers/public/stripeController.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,25 @@ export class StripeController extends Controller {
151151
this.setStatus(400);
152152
throw new Error("Amount must not exceed 10000");
153153
}
154+
155+
// Validate returnUrl to prevent open redirect attacks
156+
if (body.returnUrl) {
157+
if (!body.returnUrl.startsWith('/')) {
158+
this.setStatus(400);
159+
throw new Error("returnUrl must be a relative path starting with /");
160+
}
161+
if (body.returnUrl.includes('..')) {
162+
this.setStatus(400);
163+
throw new Error("returnUrl contains invalid characters");
164+
}
165+
// Whitelist allowed paths
166+
const allowedPaths = ['/quickstart', '/credits', '/dashboard', '/settings'];
167+
if (!allowedPaths.some(path => body.returnUrl?.startsWith(path))) {
168+
this.setStatus(400);
169+
throw new Error("returnUrl must start with one of: " + allowedPaths.join(', '));
170+
}
171+
}
172+
154173
const result = await stripeManager.createCloudGatewayCheckoutSession(
155174
request.headers.origin ?? "",
156175
body.amount,
@@ -382,10 +401,10 @@ export class StripeController extends Controller {
382401
const stripeManager = new StripeManager(request.authParams);
383402
const result = await stripeManager.migrateToPro();
384403

385-
if (isError(result)) {
386-
console.error("Error migrating to pro", JSON.stringify(result.error));
404+
if (isError(result) || !result.data) {
405+
console.error("Error migrating to pro", JSON.stringify(result.error || "No data returned"));
387406
this.setStatus(400);
388-
throw new Error(result.error);
407+
throw new Error(result.error || "Failed to migrate to pro");
389408
}
390409

391410
return result.data;

web/components/templates/quickstart/quickstartPage.tsx

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
Zap,
2424
} from "lucide-react";
2525
import Link from "next/link";
26-
import { useRouter } from "next/router";
2726
import { useEffect, useState } from "react";
2827
import { useOrgOnboarding } from "../../../services/hooks/useOrgOnboarding";
2928
import { useOrg } from "../../layout/org/organizationContext";
@@ -72,11 +71,11 @@ const QuickstartPage = () => {
7271
const [testRequestId, setTestRequestId] = useState<string | null>(null);
7372
const [testError, setTestError] = useState<string | null>(null);
7473

75-
const { hasKeys, hasProviderKeys, updateOnboardingStatus } = useOrgOnboarding(
74+
const { hasKeys, hasProviderKeys } = useOrgOnboarding(
7675
org?.currentOrg?.id ?? "",
7776
);
7877

79-
const { data: creditData, isLoading: creditsLoading } = useCredits();
78+
const { data: creditData } = useCredits();
8079
const hasCredits = (creditData?.balance ?? 0) > 0;
8180
const hasBillingSetup = hasCredits || hasProviderKeys;
8281

@@ -92,7 +91,7 @@ const QuickstartPage = () => {
9291
if (hasKeys === false) {
9392
setQuickstartKey(undefined);
9493
}
95-
}, [hasKeys]);
94+
}, [hasKeys, setQuickstartKey]);
9695

9796
useEffect(() => {
9897
setToolHandler("quickstart-open-integration-guide", async () => {
@@ -222,32 +221,6 @@ const QuickstartPage = () => {
222221
isCompleted={isCompleted ?? false}
223222
link={step.link}
224223
rightContent={step.description}
225-
rightComponent={
226-
index === 0 ? (
227-
<div className="flex items-center gap-3 text-xs text-muted-foreground">
228-
<a
229-
href="/credits"
230-
target="_blank"
231-
rel="noopener noreferrer"
232-
className="flex items-center gap-1 transition-colors hover:text-foreground"
233-
onClick={(e) => e.stopPropagation()}
234-
>
235-
<span>Add credits</span>
236-
<MoveUpRight size={12} />
237-
</a>
238-
<a
239-
href="/settings/providers"
240-
target="_blank"
241-
rel="noopener noreferrer"
242-
className="flex items-center gap-1 transition-colors hover:text-foreground"
243-
onClick={(e) => e.stopPropagation()}
244-
>
245-
<span>Configure keys</span>
246-
<MoveUpRight size={12} />
247-
</a>
248-
</div>
249-
) : undefined
250-
}
251224
headerAction={
252225
index === 2 ? (
253226
<TooltipProvider>
@@ -339,7 +312,7 @@ const QuickstartPage = () => {
339312
</div>
340313

341314
{/* BYOK Option - Simple text link */}
342-
<div className="flex items-center justify-center pt-2">
315+
<div className="flex items-center justify-start pl-4 pt-4 pb-2">
343316
<button
344317
onClick={() => setIsProviderSheetOpen(true)}
345318
className="group flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"

0 commit comments

Comments
 (0)