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

[BUG] Nested template in ARM template gives wrong line number when referenced as Bicep module #307

Open
nonik0 opened this issue Nov 14, 2022 · 1 comment
Labels
bug Something isn't working revisit No immediate plans to schedule the work due to resource constraints

Comments

@nonik0
Copy link
Contributor

nonik0 commented Nov 14, 2022

Describe the bug

When an ARM template with a nested template is referenced from a Bicep template as a module, any results from the nested ARM template will have incorrect line numbers.

Expected behavior

Template-Analyzer should be able to give correct line numbers for results in nested ARM templates that are referenced from Bicep templates.

Reproduction Steps

  1. Create an ARM template that has a nested template, e.g. use one from tests like SimpleNestedFail.json.
  2. Create a Bicep module that references the ARM template with a nested template, e.g.
module armTemplate './{armTemplateFileName}' = {
    name: 'nestedTemplate'
    scope: resourceGroup('my-rg')
    params: {}
}
  1. Scan with template-analyzer and verify that line numbers for specific results in nested ARM template are incorrect.

Environment

No response

@nonik0 nonik0 added bug Something isn't working 🔍 needs-triage labels Nov 14, 2022
@larspmohr larspmohr added revisit No immediate plans to schedule the work due to resource constraints and removed 🔍 needs-triage labels Nov 16, 2022
@nonik0
Copy link
Contributor Author

nonik0 commented Nov 19, 2022

In order to fix this issue, the tool will need to recreate a populated TemplateContext that reflects what JsonSourceLocationResolver would have when processing a nested template, complete with the JObjects of the extracted nested templates, etc. Will likely need to refactor the nested template processing code in AnalyzeAllIncludedTemplates in a shared class that TemplateAnalyzer and BicepLocationProcessor can used to process a nested ARM template.

Additionally, BicepLocationResolver needs to use a TemplateContext to match the context of the nested template, so there will need to be a way to determine what nested template is in scope from the JSON path as well before resolving the line number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working revisit No immediate plans to schedule the work due to resource constraints
Projects
None yet
Development

No branches or pull requests

2 participants