Skip to content
Tracon

PatternContentGuardOptions

Namespace Tracon · Assembly Tracon.Core.dll

Settings for the built-in pattern-based guard.

public sealed class PatternContentGuardOptions
Inheritance
object ← PatternContentGuardOptions
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Read from the Tracon:ContentGuard:Pattern configuration section.

This class deliberately has no Enabled flag. The no-surprises rule’s gate is the registration itself: AddTracon does not register the built-in guard, so in a default setup the inspection wrapper is never added to the pipeline and the cost is exactly zero. Adding an Enabled flag would require the guard to be registered but turned off; then the claim “if no guard is registered the cost is zero” would become unmeasurable.

If you need to keep the guard running but temporarily disable it, empty PatternContentGuardOptions.DeniedTerms and set PatternContentGuardOptions.MaskedPii to PiiPatterns.None: the guard then sees no rule and returns ContentGuardResult.Allow on the first inspection.

public PatternContentGuardOptions()

The configuration section name.

public const string SectionName = "Tracon:ContentGuard:Pattern"

string

Denied terms. A match produces ContentGuardAction.Block.

public IList<string> DeniedTerms { get; }

IList<string>

The comparison is case-insensitive and searches for a word fragment (IndexOf); it is not a regex, so a value the consumer writes carries no ReDoS risk.

The text written in place of a masked match. Default [redacted].

public string MaskReplacement { get; set; }

string

The built-in PII patterns to turn on. A match produces ContentGuardAction.Mask. Default PiiPatterns.None.

public PiiPatterns MaskedPii { get; set; }

PiiPatterns

In configuration, a comma-separated list of names ("Email,CreditCard"). An empty value leaves the setting unset. A value that is not such a list stops the application at startup with an Options.OptionsValidationException that names the value as written; one misspelled name used to turn masking off for the whole list without a word.

A value with a bit that no PiiPatterns member defines (for example (PiiPatterns)64) stops the application too, whether it comes from configuration or from code. A value set in code after binding replaces the configured one, so it also clears a configuration error.