Skip to content

AttachmentTypeGuard

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Validates an attachment candidate against size and media-type allow lists.

public sealed class AttachmentTypeGuard

objectAttachmentTypeGuard

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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.

AttachmentTypeGuard(IOptions<AgentPrismOptions>)

Section titled “ AttachmentTypeGuard(IOptions<AgentPrismOptions>)”

Initializes a validator from configuration.

public AttachmentTypeGuard(IOptions<AgentPrismOptions> options)

options IOptions<AgentPrismOptions>

The AgentPrism options.

ArgumentNullException

options is null.

Gets the configured attachment size limit.

public long MaxBytes { get; }

long

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)

data ReadOnlySpan<byte>

The raw content to validate.

AttachmentValidationResult

The validated type when valid; otherwise, the reason.