Potential fix for code scanning alert no. 28: Incomplete URL substring sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
ARUNAVO RAY
2025-07-28 15:34:20 +05:30
committed by GitHub
parent 5797b9bba1
commit 3f704ebb23

View File

@@ -15,6 +15,14 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Textarea } from '@/components/ui/textarea';
import { MultiSelect } from '@/components/ui/multi-select';
function isTrustedIssuer(issuer: string, allowedHosts: string[]): boolean {
try {
const url = new URL(issuer);
return allowedHosts.some(host => url.hostname === host || url.hostname.endsWith(`.${host}`));
} catch {
return false; // Return false if the URL is invalid
}
}
interface SSOProvider {
id: string;
issuer: string;
@@ -509,7 +517,7 @@ export function SSOSettings() {
<AlertDescription>
<div className="space-y-2">
<p>Redirect URL: {window.location.origin}/api/auth/sso/callback/{providerForm.providerId || '{provider-id}'}</p>
{providerForm.issuer.includes('google.com') && (
{isTrustedIssuer(providerForm.issuer, ['google.com']) && (
<p className="text-xs text-muted-foreground">
Note: Google doesn't support the "offline_access" scope. Make sure to exclude it from the selected scopes.
</p>