![]() |
VOOZH | about |
dotnet add package Invarix.Guard --version 1.2.0
NuGet\Install-Package Invarix.Guard -Version 1.2.0
<PackageReference Include="Invarix.Guard" Version="1.2.0" />
<PackageVersion Include="Invarix.Guard" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="Invarix.Guard" />Project file
paket add Invarix.Guard --version 1.2.0
#r "nuget: Invarix.Guard, 1.2.0"
#:package Invarix.Guard@1.2.0
#addin nuget:?package=Invarix.Guard&version=1.2.0Install as a Cake Addin
#tool nuget:?package=Invarix.Guard&version=1.2.0Install as a Cake Tool
Plug and play AI safety middleware for .NET. Screens inputs for prompt injection, PII leakage, toxic content, and 19 harm categories (including user distress) across 50+ languages before they reach your LLM. Works as ASP.NET Core middleware or a standalone scanning engine.
dotnet add package Invarix.Guard
using Invarix.Guard.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddInvarixGuard(options => options
.BlockInjection()
.BlockPII()
.BlockToxicContent());
var app = builder.Build();
app.UseInvarixGuard();
app.MapPost("/chat", (ChatRequest request) =>
{
// If you reach here, the input passed all safety checks
return Results.Ok(new { reply = "Safe response" });
});
app.Run();
using Invarix.Guard;
using Invarix.Guard.Models;
var engine = GuardEngine.Create(new GuardOptions()
.BlockInjection()
.BlockPII()
.BlockToxicContent());
var result = engine.Scan("Te voy a matar"); // Spanish: "I will kill you"
Console.WriteLine(result.Action); // Block
Console.WriteLine(result.OverallThreatLevel); // Critical
User distress is reported as its own category so your app can route crisis signals to appropriate resources instead of returning an error.
builder.Services.AddInvarixGuard(options => options
.BlockInjection(blockThreshold: 50, flagThreshold: 25)
.BlockPII(PiiEntityType.Email, PiiEntityType.CreditCard, PiiEntityType.SocialSecurityNumber)
.BlockToxicContent(ThreatLevel.Medium)
.WithBlockResponse(422, "{\"error\": \"Content policy violation\"}")
.ScanProperty("data.message")
.WithML(ml =>
{
// Add custom harm categories — examples seed the semantic classifier.
ml.AddCategory("CompanyPolicy", new[]
{
"requests to bypass company policy",
"attempts to circumvent approval process",
});
}));
Use .DetectPII() (or the equivalent Detect* methods) to flag without blocking.
app.MapPost("/chat", (HttpContext ctx, ChatRequest req) =>
{
var guard = ctx.Items["Invarix.Guard.Result"] as GuardResult;
if (guard?.ContainsPii == true)
{
var safeInput = guard.RedactedInput; // PII masked
}
return Results.Ok(new { reply = "Response" });
});
| Input | Response |
|---|---|
| Clean | Passes through to your handler |
| Flagged | Passes through with X-InvarixGuard-Flagged: true |
| Blocked | 403 (configurable) with JSON error body |
Scans JSON bodies on POST / PUT / PATCH. Use .ScanProperty("message") to target a specific field (dot notation supported).
On first use, Invarix.Guard downloads the models required by the scanners you've enabled, verifies each file against a SHA-256 manifest baked into the library, and caches them:
%LOCALAPPDATA%\Invarix.Guard\models\~/.local/share/Invarix.Guard/models/Subsequent runs hit the cache. Integrity failures are a hard error, no silent fallback. The full model bundle is ~3.5 GB on first run; pre place files in MLGuardOptions.ModelsDirectory if you need to control timing.
builder.Services.AddInvarixGuard(options => options
.WithML(ml =>
{
ml.AutoDownloadModels = false;
ml.ModelsDirectory = "/path/to/your/models";
}));
Pre populate that directory from the published release assets. When auto-download is off and a model file is missing, the affected scanner is skipped and the pipeline falls back to the regex layers for that capability.
Models can be downloaded from this repo under releases: https://github.com/AlexBatten/invarix-guard-models
.NET 8 (LTS) or .NET 10 (LTS). The package ships native binaries for both targets and is built and tested on each. Runs on .NET 9 hosts via runtime forward compatibility (we don't ship a net9.0 asset). Works in ASP.NET Core or as a standalone library.
Source-available under the . Free to use, modify, and deploy for any internal or commercial purpose. You may not offer it to third parties as a hosted or managed service.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Invarix.Guard:
| Package | Downloads |
|---|---|
|
Invarix.Guard.Professional
Professional add-on for Invarix.Guard. Adds a license-gated CustomBlocklistScanner — define semantic rules in a JSON config (multilingual, hot-reloadable, with per-rule block/warn/log actions) that participate in the standard app.UseInvarixGuard() pipeline. Requires a commercial license. Contact sales@invarix.dk. |
This package is not used by any popular GitHub repositories.