Skip to content

Commit

Permalink
Separate DSC configuration parser check for ARM processor (#21395)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkontyko committed Apr 22, 2024
1 parent 4bcc3f4 commit fe38405
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/System.Management.Automation/engine/parser/Parser.cs
Expand Up @@ -2984,8 +2984,8 @@ private StatementAst ConfigurationStatementRule(IEnumerable<AttributeAst> custom
Runspaces.Runspace.DefaultRunspace = localRunspace;
}

// Configuration is not supported on ARM or in ConstrainedLanguage
if (PsUtils.IsRunningOnProcessorArchitectureARM() || Runspace.DefaultRunspace?.ExecutionContext?.LanguageMode == PSLanguageMode.ConstrainedLanguage)
// Configuration is not supported in ConstrainedLanguage
if (Runspace.DefaultRunspace?.ExecutionContext?.LanguageMode == PSLanguageMode.ConstrainedLanguage)
{
if (SystemPolicy.GetSystemLockdownPolicy() != SystemEnforcementMode.Audit)
{
Expand All @@ -3004,6 +3004,17 @@ private StatementAst ConfigurationStatementRule(IEnumerable<AttributeAst> custom
dropIntoDebugger: true);
}

// Configuration is not supported on ARM64
if (PsUtils.IsRunningOnProcessorArchitectureARM())
{
ReportError(
configurationToken.Extent,
nameof(ParserStrings.ConfigurationNotAllowedOnArm64),
ParserStrings.ConfigurationNotAllowedOnArm64,
configurationToken.Kind.Text());
return null;
}

// Configuration is not supported on WinPE
if (Utils.IsWinPEHost())
{
Expand Down
3 changes: 3 additions & 0 deletions src/System.Management.Automation/resources/ParserStrings.resx
Expand Up @@ -1370,4 +1370,7 @@ ModuleVersion : Version of module to import. If used, ModuleName must represent
<data name="WDACGetSteppablePipelineLogMessage" xml:space="preserve">
<value>Creating a steppable pipeline from a script block may require evaluating some expressions within the script block. The expression evaluation will silently fail and return 'null' in Constrained Language mode, unless the expression represents a constant value.</value>
</data>
<data name="ConfigurationNotAllowedOnArm64" xml:space="preserve">
<value>Configuration keyword is not supported on ARM64 processors.</value>
</data>
</root>

0 comments on commit fe38405

Please sign in to comment.