Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-M365DSCExportContentForResource: Doesn't escape double quotes if string is inside an array #5161

Open
ricmestre opened this issue Oct 8, 2024 · 3 comments

Comments

@ricmestre
Copy link
Contributor

Description of the issue

In my solution I need to call ConvertTo-DSCObject and then inversely Get-M365DSCExportContentForResource, when calling the latter it's able to escape double quotes if they are simple strings but if they're inside an array then they are not escaped which will generate an error once I try to compile the new blueprint.

See the configuration below, I added a Test property which gets escaped properly when calling Get-M365DSCExportContentForResource, but the original property SubjectOrBodyMatchesPatterns since it's inside an array doesn't.

Microsoft 365 DSC Version

1.24.1002.1

Which workloads are affected

other

The DSC configuration

EXOTransportRule "EXOTransportRule-EXOTransportRule_1"
{                                                                                                                                                                                ApplyOME                                  = $False;
AttachmentHasExecutableContent            = $False;
AttachmentIsPasswordProtected             = $False;
AttachmentIsUnsupported                   = $False;
AttachmentProcessingLimitExceeded         = $False;
BetweenMemberOf1                          = @("SalesTeam@$OrganizationName");
BetweenMemberOf2                          = @("executives@$OrganizationName");
Credential                                = $Credscredential;
DeleteMessage                             = $False;
Enabled                                   = $True;
Ensure                                    = "Present";
ExceptIfAttachmentHasExecutableContent    = $False;
ExceptIfAttachmentIsPasswordProtected     = $False;
ExceptIfAttachmentIsUnsupported           = $False;
ExceptIfAttachmentProcessingLimitExceeded = $False;
ExceptIfFrom                              = @("AdeleV@$OrganizationName")
ExceptIfHasNoClassification               = $False;
ExceptIfSubjectContainsWords              = @("Press Release","Corporate Communication");
HasNoClassification                       = $False;
Mode                                      = "Enforce";
ModerateMessageByManager                  = $False;
Name                                      = "EXOTransportRule_1";
Priority                                  = 0;
Quarantine                                = $False;
RecipientAddressType                      = "Resolved";
RejectMessageEnhancedStatusCode           = "5.7.1";
RejectMessageReasonText                   = "Messages sent between the Sales and Brokerage departments are strictly prohibited.";
RemoveOME                                 = $False;
RemoveOMEv2                               = $False;
RemoveRMSAttachmentEncryption             = $False;
ResourceInstanceName                      = "EXOTransportRule-EXOTransportRule_1";
ResourceName                              = "EXOTransportRule";
RouteMessageOutboundRequireTls            = $False;
RuleErrorAction                           = "Ignore";
RuleSubType                               = "None";
SenderAddressLocation                     = "Header";
StopRuleProcessing                        = $False;
SubjectOrBodyMatchesPatterns              = @("<script type="application/adaptivecard\+json">");
Test                                      = "<script type=`"application/adaptivecard\+json`">";                                                                          }

Verbose logs showing the problem

N/A

Environment Information + PowerShell Version

Win11/PS5.1
@ricmestre
Copy link
Contributor Author

@FabienTschanz I was looking at your change microsoft/ReverseDSC#37 and looking at the code there it looks like the same treatment is missing for String[] starting here:

https:/microsoft/ReverseDSC/blob/e3bf08d5b0d22a95103fd02ea942843583d70b07/ReverseDSC.Core.psm1#L224

@FabienTschanz
Copy link
Contributor

@ricmestre I'll take a look at it later. Got my hands busy with the replacement for #5073 🙃

@ricmestre
Copy link
Contributor Author

No issue, I raised microsoft/ReverseDSC#38 to fix this

@NikCharlebois Could you please check this ReverseDSC PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants