Table of Contents

Class UriValidator

Namespace
Geotab.Checkmate.ObjectModel
Assembly
Geotab.Checkmate.ObjectModel.dll

A collection of common methods used to validate and work with System.Uris.

public static class UriValidator
Inheritance
UriValidator
Inherited Members

Methods

IsExternalUriForbiddenAsync(Uri)

Checks that a System.Uri points to an external resource. Prevents a SSRF attack.

public static Task<bool> IsExternalUriForbiddenAsync(Uri path)

Parameters

path Uri

The System.Uri to check.

Returns

Task<bool>

A Task representing the asynchronous operation.

Exceptions

SocketException

According to MS docs this is thrown when the provided address/host name cannot be resolved.

IsReservedIPv4Address(IPAddress)

Detects all private/reserved IPv4 addresses. The latest RFC (as of Oct 2018) is https://tools.ietf.org/html/rfc6890 with a small update here https://tools.ietf.org/html/rfc8190. This is summarized here https://en.wikipedia.org/wiki/Reserved_IP_addresses.

public static bool IsReservedIPv4Address(IPAddress ip)

Parameters

ip IPAddress

The IPAddress to inspect.

Returns

bool

true if the IP address is in a reserved range, false otherwise.