Added new feature : display the file/folder and link of a SharingLink object in the permissions reports.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
namespace SharepointToolbox.Core.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Risk tier of a SharePoint sharing link, used to color-code the link-type badge
|
||||
/// in HTML reports.
|
||||
/// </summary>
|
||||
public enum SharingLinkRisk
|
||||
{
|
||||
Low, // Read-only, scoped (Org view, Direct, Existing, Review)
|
||||
Medium, // Org-wide edit
|
||||
High, // Anonymous (anyone with link, no auth)
|
||||
Unknown // Unrecognized type — neutral styling
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps the raw <c>linkType</c> segment of a <c>SharingLinks.{itemId}.{type}.{shareId}</c>
|
||||
/// group name to a human-readable label and a risk tier. The raw codes are SharePoint
|
||||
/// internals (OrganizationEdit / AnonymousView / Flexible / …); reports show the friendly
|
||||
/// label and tint the badge by tier.
|
||||
/// </summary>
|
||||
public static class SharingLinkLabels
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the friendly label and risk tier for a sharing-link type code.
|
||||
/// Unknown codes fall through with the raw value and <see cref="SharingLinkRisk.Unknown"/>.
|
||||
/// </summary>
|
||||
public static (string Label, SharingLinkRisk Risk) Describe(string? rawLinkType)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rawLinkType))
|
||||
return (string.Empty, SharingLinkRisk.Unknown);
|
||||
|
||||
return rawLinkType.Trim() switch
|
||||
{
|
||||
"OrganizationView" => ("Org link · View", SharingLinkRisk.Low),
|
||||
"OrganizationEdit" => ("Org link · Edit", SharingLinkRisk.Medium),
|
||||
"AnonymousView" => ("Anyone · View", SharingLinkRisk.High),
|
||||
"AnonymousEdit" => ("Anyone · Edit", SharingLinkRisk.High),
|
||||
"Flexible" => ("Custom link", SharingLinkRisk.Medium),
|
||||
"Direct" => ("Specific people", SharingLinkRisk.Low),
|
||||
"Existing" => ("Existing access", SharingLinkRisk.Low),
|
||||
"Review" => ("Review only", SharingLinkRisk.Low),
|
||||
"Embed" => ("Embedded link", SharingLinkRisk.Medium),
|
||||
_ => (rawLinkType, SharingLinkRisk.Unknown)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns inline-CSS colors (background, foreground) for a risk tier — matches the
|
||||
/// risk-card palette used elsewhere in the HTML reports.
|
||||
/// </summary>
|
||||
public static (string Background, string Foreground) Colors(SharingLinkRisk risk) => risk switch
|
||||
{
|
||||
SharingLinkRisk.Low => ("#D1FAE5", "#065F46"),
|
||||
SharingLinkRisk.Medium => ("#FEF3C7", "#92400E"),
|
||||
SharingLinkRisk.High => ("#FEE2E2", "#991B1B"),
|
||||
_ => ("#F3F4F6", "#374151"),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user