Add PII redaction POC for secure LLM prompting.
Implements detect-redact-sanitize pipeline with regex, domain rules, and ONNX NER before the LLM boundary, plus NUnit tests and Xenovex push documentation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using PiiRedaction.Core.Models;
|
||||
|
||||
namespace PiiRedaction.Core.Tests.TestSupport;
|
||||
|
||||
public static class NerEntityBuilder
|
||||
{
|
||||
public static IReadOnlyList<PiiEntity> BuildFromScenario(PromptScenario scenario)
|
||||
{
|
||||
var entities = new List<PiiEntity>();
|
||||
|
||||
foreach (var (type, value) in scenario.ExpectedTypes.Zip(scenario.MustNotContainInSanitized))
|
||||
{
|
||||
if (type != PiiEntityType.Person)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var searchStart = 0;
|
||||
while ((searchStart = scenario.Prompt.IndexOf(value, searchStart, StringComparison.Ordinal)) >= 0)
|
||||
{
|
||||
entities.Add(new PiiEntity(
|
||||
PiiEntityType.Person,
|
||||
value,
|
||||
searchStart,
|
||||
value.Length,
|
||||
PiiDetectionSource.Ner));
|
||||
searchStart += value.Length;
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user