in src/Analyzer.Cli/CommandLineParser.cs [157:202]
private int AnalyzeTemplateCommandHandler(
FileInfo templateFilePath,
FileInfo parametersFilePath,
FileInfo configFilePath,
ReportFormat reportFormat,
FileInfo outputFilePath,
bool includeNonSecurityRules,
bool verbose,
FileInfo customJsonRulesPath)
{
// Check that template file paths exist
if (!templateFilePath.Exists)
{
Console.Error.WriteLine("Invalid template file path: {0}", templateFilePath);
return (int)ExitCode.ErrorInvalidPath;
}
var setupResult = SetupAnalysis(configFilePath, directoryToAnalyze: null, reportFormat, outputFilePath, includeNonSecurityRules, verbose, customJsonRulesPath);
if (setupResult != ExitCode.Success)
{
return (int)setupResult;
}
// Verify the file is a valid template
if (!TemplateDiscovery.IsValidTemplate(templateFilePath))
{
logger.LogError("File is not a valid ARM Template. File path: {templateFilePath}", templateFilePath.FullName);
FinishAnalysis();
return (int)ExitCode.ErrorInvalidARMTemplate;
}
IEnumerable<TemplateAndParams> pairsToAnalyze =
parametersFilePath != null
? new[] { new TemplateAndParams(templateFilePath, parametersFilePath) }
: TemplateDiscovery.FindParameterFilesForTemplate(templateFilePath);
var exitCodes = new List<ExitCode>();
foreach (var templateAndParameters in pairsToAnalyze)
{
exitCodes.Add(AnalyzeTemplate(templateAndParameters));
}
FinishAnalysis();
return (int)AnalyzeExitCodes(exitCodes);
}