Class LocalOnlyXmlResolver
- Namespace
- EInvoice.Core.Validation
- Assembly
- EInvoice.Core.dll
An XML resolver that restricts URI resolution to files within a specific base directory. Prevents SSRF and path-traversal attacks during XSD schema loading.
public sealed class LocalOnlyXmlResolver : XmlResolver
- Inheritance
-
LocalOnlyXmlResolver
- Inherited Members
Constructors
LocalOnlyXmlResolver(string)
Creates a resolver that only allows access to files within basePath.
public LocalOnlyXmlResolver(string basePath)
Parameters
basePathstringThe root directory from which file access is permitted.
Methods
GetEntity(Uri, string?, Type?)
When overridden in a derived class, maps a URI to an object that contains the actual resource.
public override object? GetEntity(Uri absoluteUri, string? role, Type? ofObjectToReturn)
Parameters
absoluteUriUriThe URI returned from ResolveUri(Uri, string).
rolestringCurrently not used.
ofObjectToReturnTypeThe type of object to return. The current version only returns System.IO.Stream objects.
Returns
Exceptions
- XmlException
ofObjectToReturnis not aStreamtype.- UriFormatException
The specified URI is not an absolute URI.
- ArgumentNullException
absoluteUriis null.- Exception
There is a runtime error (for example, an interrupted server connection).