Desktop alerts when suspicious unicode characters found in Recipe (#4080)

This commit is contained in:
Amed Rodriguez
2025-08-19 14:05:46 -07:00
committed by GitHub
parent 33bf5a44ed
commit 4f4e8ace33
11 changed files with 256 additions and 15 deletions
+2
View File
@@ -200,6 +200,7 @@ function BaseChatContent({
recipeAccepted,
handleRecipeAccept,
handleRecipeCancel,
hasSecurityWarnings,
} = useRecipeManager(messages, location.state);
// Reset recipe usage tracking when recipe changes
@@ -573,6 +574,7 @@ function BaseChatContent({
description: recipeConfig?.description,
instructions: recipeConfig?.instructions || undefined,
}}
hasSecurityWarnings={hasSecurityWarnings}
/>
{/* Recipe Parameter Modal */}
@@ -18,6 +18,7 @@ interface RecipeWarningModalProps {
description?: string;
instructions?: string;
};
hasSecurityWarnings?: boolean;
}
export function RecipeWarningModal({
@@ -25,18 +26,39 @@ export function RecipeWarningModal({
onConfirm,
onCancel,
recipeDetails,
hasSecurityWarnings = false,
}: RecipeWarningModalProps) {
return (
<Dialog open={isOpen} onOpenChange={(open) => !open && onCancel()}>
<DialogContent className="sm:max-w-[80vw] max-h-[80vh] flex flex-col p-0">
<DialogHeader className="flex-shrink-0 p-6 pb-0">
<DialogTitle> New Recipe Warning</DialogTitle>
<DialogTitle>
{hasSecurityWarnings ? '⚠️ Security Warning' : '⚠️ New Recipe Warning'}
</DialogTitle>
<DialogDescription>
You are about to execute a recipe that you haven't run before. Only proceed if you trust
the source of this recipe.
{!hasSecurityWarnings &&
"You are about to execute a recipe that you haven't run before. "}
Only proceed if you trust the source of this recipe.
</DialogDescription>
</DialogHeader>
{hasSecurityWarnings && (
<div className="px-6">
<div className="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4">
<div className="flex items-start">
<div className="ml-3">
<div className="mt-2 text-sm text-yellow-700 dark:text-yellow-300">
<p>
This recipe contains hidden characters that will be ignored for your safety,
as they could be used for malicious purposes.
</p>
</div>
</div>
</div>
</div>
</div>
)}
<div className="flex-1 overflow-y-auto p-6 pt-4">
<div className="bg-background-muted p-4 rounded-lg">
<h3 className="font-medium mb-3 text-text-standard">Recipe Preview:</h3>