AI-Studio/app/MindWork AI Studio/Dialogs/PromptInjectionAlertDialog.razor

133 lines
6.0 KiB
Plaintext

@using AIStudio.Tools.Security
@inherits MSGComponentBase
<MudDialog MaxWidth="MaxWidth.Medium" FullWidth="true">
<DialogContent>
@if (Result is not null)
{
<MudPaper Class="pa-6 mb-4" Elevation="0" Style="background:#fff3e0; border:1px solid #ffcc80;">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="3">
<MudAvatar Size="Size.Large"
Color="Color.Warning"
Variant="Variant.Filled">
<MudIcon Icon="@Icons.Material.Filled.GppMaybe"/>
</MudAvatar>
<MudStack Spacing="0">
<MudJustifiedText Typo="Typo.h5">
@T("Security warning")
</MudJustifiedText>
<MudJustifiedText Typo="Typo.body2">
@T("AI Studio has reliably detected and blocked the suspicious content. Your applications and data remain protected. Please review the content you uploaded.")
</MudJustifiedText>
</MudStack>
</MudStack>
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Class="mt-4" Style="border:1px solid #ffcc80;">
<Content>
<MudJustifiedText Typo="Typo.body2" Color="Color.Dark">
@T("Typical attacks on AI systems (e.g. prompt injection) hide instructions within untrusted content to trick an AI model into ignoring its intended rules or performing unintended actions.")
</MudJustifiedText>
</Content>
</MudAlert>
</MudPaper>
<MudDivider />
<MudStack Row="true" Justify="Justify.Center" Class="my-2">
<MudButton Variant="Variant.Text"
EndIcon="@(showPromptInjectionInformation ? Icons.Material.Filled.ExpandLess : Icons.Material.Filled.ExpandMore)"
OnClick="@TogglePromptInjectionInformation">
@(showPromptInjectionInformation
? T("Hide more information")
: T("More information"))
</MudButton>
</MudStack>
<MudCollapse Expanded="@showPromptInjectionInformation">
<MudPaper Outlined="true"
Class="pa-4 mb-4">
<MudGrid>
<MudItem xs="12" md="3">
<MudStack>
<MudIcon Icon="@Icons.Material.Filled.Source" />
<MudJustifiedText Typo="Typo.subtitle2">
@T("Source type")
</MudJustifiedText>
<MudJustifiedText Typo="Typo.body2">
@this.GetSourceKindLabel(Result.Source.Kind)
</MudJustifiedText>
</MudStack>
</MudItem>
<MudItem xs="12" md="4">
<MudStack>
<MudIcon Icon="@Icons.Material.Outlined.Description"/>
<MudJustifiedText Typo="Typo.subtitle2">
@T("Content source")
</MudJustifiedText>
<MudJustifiedText Typo="Typo.body2"
Style="word-break:break-all;">
@Result.Source.Label
</MudJustifiedText>
</MudStack>
</MudItem>
<MudItem xs="12" md="5">
<MudStack>
<MudIcon Icon="@Icons.Material.Outlined.WarningAmber"/>
<MudJustifiedText Typo="Typo.subtitle2">
@T("Detected content")
</MudJustifiedText>
@foreach (var finding in Result.Findings)
{
<MudStack Spacing="0">
<MudJustifiedText Typo="Typo.body2">
<b>
@($"{this.GetFindingCategoryLabel(finding.Category)}")
</b>
</MudJustifiedText>
<MudJustifiedText Typo="Typo.body2" Class="ml-4 mt-1">
@finding.Snippet
</MudJustifiedText>
</MudStack>
}
</MudStack>
</MudItem>
</MudGrid>
</MudPaper>
<MudPaper Class="pa-4 mt-2"
Style="background:#fafafa;">
<MudJustifiedText Typo="Typo.body2" Class="mb-3">
@T("Prompt injection is a method used to manipulate AI systems such as chatbots. An attacker places misleading instructions in content so that the AI treats them as legitimate. This can cause the AI to ignore safeguards, expose private information, or generate harmful content.")
</MudJustifiedText>
<MudLink Href="@PromptInjectionGuardService.WIKI_URL"
Target="_blank">
@PromptInjectionGuardService.WIKI_URL
</MudLink>
</MudPaper>
</MudCollapse>
}
</DialogContent>
<DialogActions>
<MudButton Variant="Variant.Filled"
Color="Color.Default"
OnClick="@Close">
@T("Close")
</MudButton>
</DialogActions>
</MudDialog>