ArchiveCopyRedaction
Namespace: Meshmakers.Octo.Runtime.Contracts.StreamData
The one place that decides what of a staging location may be shown (concept
concept-tenant-backup-native-archive-dump.md §5). A COPY statement carries the storage
credential — the S3 key pair in the URI, the sas_token or key in the WITH clause — so
every text derived from it (log line, exception message, trace attribute) goes through this class.
public static class ArchiveCopyRedaction
Inheritance Object → ArchiveCopyRedaction
Remarks:
The rules are fail-safe: a WITH option is shown only when it is on the short list of options known to
carry no secret, every other value is masked. The user info of a URI (everything up to the last @
behind the scheme) is dropped as a whole, because an S3 secret key may contain / and + and cannot be
told apart from the host by a URI parser. A query string or fragment is masked. Over-redaction is accepted
(a prefix that itself contains @ loses the part before it); under-redaction is not.
Fields
Mask
Replacement for every value that must not be shown.
public static string Mask;
Methods
IsNonSecretOption(String)
True when the value of the WITH option key may be shown.
public static bool IsNonSecretOption(string key)
Parameters
key String
Returns
RedactOptionValue(String, String)
The value of a WITH option as it may be shown: the value itself or ArchiveCopyRedaction.Mask.
public static string RedactOptionValue(string key, string value)
Parameters
key String
value String
Returns
RedactUri(String)
The location with the credential removed: scheme, host, bucket or container and prefix stay, the user info
becomes ***@, a query string or fragment becomes ?***. Never throws and never echoes the
input when it cannot be read.
public static string RedactUri(string uri)
Parameters
uri String
Returns
ExtractUriSecrets(String)
The values inside uri that are secrets: the whole user info, and — for the usual
key:secret form — each of its two parts, plus the whole query string or fragment and each of its
parameter values (a signed URL carries its signature there, and ArchiveCopyRedaction.RedactUri(String) masks it as a whole).
Each is also percent-decoded and percent-encoded, so a text that echoes only one of them or the other
spelling is still caught. Parts shorter than three characters are not searched for on their own.
internal static IEnumerable<string> ExtractUriSecrets(string uri)
Parameters
uri String
Returns
Spellings(String, Int32)
The value as written, percent-decoded and percent-encoded (each only once and when long enough).
internal static IEnumerable<string> Spellings(string value, int minLength)
Parameters
value String
minLength Int32