AttachmentTypeGuard
AgentPrism.Core.dllValidates an attachment candidate against size and media-type allow lists.
public sealed class AttachmentTypeGuardInheritance
Section titled “Inheritance”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”The client-provided Content-Type is not evidence. The type is derived
from the signature in the first bytes (magic bytes); the supplied value is
informational, like a file extension, and is ignored.
Executable content types, such as application/x-msdownload, are
deliberately absent from the allow list and no magic-byte rule produces
them. Such a file is always rejected.
Constructors
Section titled “Constructors”AttachmentTypeGuard(IOptions<AgentPrismOptions>)
Section titled “ AttachmentTypeGuard(IOptions<AgentPrismOptions>)”Initializes a validator from configuration.
public AttachmentTypeGuard(IOptions<AgentPrismOptions> options)Parameters
Section titled “Parameters”options IOptions<AgentPrismOptions>
The AgentPrism options.
Exceptions
Section titled “Exceptions”options is null.
Properties
Section titled “Properties”MaxBytes
Section titled “ MaxBytes”Gets the configured attachment size limit.
public long MaxBytes { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”Validate(ReadOnlySpan<byte>)
Section titled “ Validate(ReadOnlySpan<byte>)”Validates that content is non-empty, within the size limit, and has a magic byte signature matching an allowed type.
public AttachmentValidationResult Validate(ReadOnlySpan<byte> data)Parameters
Section titled “Parameters”data ReadOnlySpan<byte>
The raw content to validate.
Returns
Section titled “Returns”The validated type when valid; otherwise, the reason.