microsoft/Microsoft365DSC

[SCSensitivityLabel] How to handle Unicode characters in Comments property (and a few others)

ykuijs opened this issue · 2 comments

ykuijs commented

Description of the issue

When exporting the SCSensitivityLabel resource, the Comment (and a few others) property sometimes contains Unicode characters: For example "-" (Unicode 0x2013) or '”' (Unicode 0x201c/0x201d). This can cause issues with the DSC Parser.

Note: The Comment and Tooltip field in the below example contain the incorrect dash.

I am now looking at a possible solution to add a function to test for Unicode characters and convert these to known ASCII characters. Currently I am wondering where to implement this function:

  1. In the Get method, so the retrieved information from M365 is always stripped from Unicode characters.
    • This option means we have to check each string value for Unicode characters and replace them.
    • The Test method uses the Get method, so all Unicode characters in values retrieved from M365 are automatically stripped. The Test method therefore is never impacted by the characters.
    • This option makes most sense to me. But wondering if I might overlook something.
  2. In the Export method, so the export will always be stripped from Unicode characters.
    • This is the simplest to implement: We can simply check the generated script block string for Unicode characters and replace any discovered characters.
    • This will mean that when using the import to deploy the config, DSC will always see the current config as not in the desired state.
  3. Update DSC Parser to fix the component that is affected.
    • Since DSC Parser is currently affected, we can fix just that component. This does sound like solving a symptom instead of fixing the underlying issue.

@NikCharlebois, @andikrueger, @ricmestre, @William-Francillette What is your opinion?

Microsoft 365 DSC Version

Dev

Which workloads are affected

Security & Compliance Center

The DSC configuration

SCSensitivityLabel "SCSensitivityLabel-TestLabel"
{
    AdvancedSettings                               = @(
        MSFT_SCLabelSetting
        {
            Key   = 'color'
            Value = '#EAA300'
        }
        MSFT_SCLabelSetting
        {
            Key   = 'isparent'
            Value = 'False'
        }
    );
    ApplicationId                                  = $ConfigurationData.NonNodeData.ApplicationId;
    ApplyContentMarkingHeaderAlignment             = "Center";
    ApplyContentMarkingHeaderEnabled               = $True;
    ApplyContentMarkingHeaderFontColor             = "#000000";
    ApplyContentMarkingHeaderFontSize              = "10";
    ApplyContentMarkingHeaderMargin                = "5";
    ApplyContentMarkingHeaderText                  = "Not public";
    CertificateThumbprint                          = $ConfigurationData.NonNodeData.CertificateThumbprint;
    Comment                                        = "This is a test – standard label";
    ContentType                                    = @("File, Email","Site, UnifiedGroup","Teamwork");
    DisplayName                                    = "Not public";
    Ensure                                         = "Present";
    LocaleSettings                                 = @(
        MSFT_SCLabelLocaleSettings
        {
            LocaleKey = 'tooltip'
            LabelSettings  = @(
                MSFT_SCLabelSetting
                {
                    Key   = 'default'
                    Value = 'This is a test – standard label'
                }
            )
        }
    );
    Name                                           = "TestLabel";
    Priority                                       = 7;
    SiteAndGroupExternalSharingControlType         = "Disabled";
    SiteAndGroupProtectionAllowAccessToGuestUsers  = $False;
    SiteAndGroupProtectionAllowEmailFromGuestUsers = $True;
    SiteAndGroupProtectionAllowFullAccess          = $False;
    SiteAndGroupProtectionAllowLimitedAccess       = $False;
    SiteAndGroupProtectionBlockAccess              = $False;
    SiteAndGroupProtectionEnabled                  = $True;
    SiteAndGroupProtectionPrivacy                  = "unspecified";
    TenantId                                       = $OrganizationName;
    Tooltip                                        = "This is a test – standard label";
}

Verbose logs showing the problem

No response

Environment Information + PowerShell Version

No response

I would be more inclined to the 3rd option because the issue could affect more than a single resource so implementing the fix in DSC Parser will ensure the problem doesn't reoccur on any resource and would also work for any location/regional settings

Apologies for bombing this thread, but obviously someone is able to use this resource properly. 😉

Can I ask y'all to take a quick glance at #4809 please?
We REALLY need some help. thanks!