Azure / template-analyzer

Template scanner for security misconfiguration and best practices
MIT License
127 stars 39 forks source link

[BUG] PowerShell execution fails in version 0.3.0 #288

Closed uzma-k closed 2 years ago

uzma-k commented 2 years ago

Describe the bug

Getting below error when running - TemplateAnalyzer.exe analyze-template sample.bicep Error: An exception occurred while analyzing a template Exception details: Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzerException: Error while evaluating rules. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. File name: 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at System.Reflection.RuntimeAssembly.GetExportedTypes() at System.Reflection.Assembly.get_ExportedTypes() at System.Management.Automation.Runspaces.PSSnapInHelpers.GetAssemblyTypes(Assembly assembly, String name) at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection(Assembly assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, String helpFile, Dictionary2& cmdlets, Dictionary2& aliases, Dictionary2& providers) at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzePSSnapInAssembly(Assembly assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Dictionary2& cmdlets, Dictionary2& aliases, Dictionary2& providers, String& helpFile) at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning) at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault() at PSRule.Host.HostState.CreateSessionState() at PSRule.Pipeline.PipelineContext.GetRunspace() at PSRule.Runtime.RunspaceContext.GetPowerShell() at PSRule.Host.HostHelper.GetPSLanguageBlocks(RunspaceContext context, Source[] sources) at PSRule.Host.HostHelper.GetLanguageBlock(RunspaceContext context, Source[] sources) at PSRule.Host.HostHelper.GetRuleBlockGraph(Source[] source, RunspaceContext context) at PSRule.Pipeline.InvokeRulePipeline..ctor(PipelineContext context, Source[] source, IPipelineWriter writer, RuleOutcome outcome) at PSRule.Pipeline.InvokePipelineBuilderBase.Build(IPipelineWriter writer) at Microsoft.Azure.Templates.Analyzer.RuleEngines.PowerShellEngine.PowerShellRuleEngine.AnalyzeTemplate(TemplateContext templateContext) at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeTemplate(String template, String templateFilePath, String parameters) --- End of inner exception stack trace --- at Microsoft.Azure.Templates.Analyzer.Core.TemplateAnalyzer.AnalyzeTemplate(String template, String templateFilePath, String parameters) at Microsoft.Azure.Templates.Analyzer.Cli.CommandLineParser.AnalyzeTemplate(FileInfo templateFilePath, FileInfo parametersFilePath)

Expected behavior

run successfully

Reproduction Steps

TemplateAnalyzer.exe analyze-template sample.bicep (any bicep file)

Environment

No response

JohnathonMohr commented 2 years ago

Thanks for reporting @uzma-k. We are aware of this issue and are actively working on bringing a fix.

JohnathonMohr commented 2 years ago

This is now resolved in Release 0.3.1