Skip to content

fix(arm): do not treat numeric object keys as array indexes in references - #11763

Open
nikpivkin wants to merge 1 commit into
aquasecurity:mainfrom
nikpivkin:fix/arm-node-ref-numeric-keys
Open

nikpivkin wants to merge 1 commit into
aquasecurity:mainfrom
nikpivkin:fix/arm-node-ref-numeric-keys

Conversation

@nikpivkin

Copy link
Copy Markdown
Contributor

Description

The ARM parser treated every numeric token in a reference as an array index, so object keys that look like numbers were shown in brackets. A resource with the symbolic name "1" in languageVersion 2.0 got the reference resources[1] instead of resources.1, and the tag "2024" got tags[2024] instead of tags.2024.

Now the parser takes the kind of each level from the JSON decoder, so only array elements go in brackets.

Template:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "languageVersion": "2.0",
  "contentVersion": "1.0.0.0",
  "resources": {
    "1": {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2022-09-01",
      "name": "acc",
      "location": "eastus",
      "kind": "StorageV2",
      "properties": {
        "supportsHttpsTrafficOnly": false
      }
    }
  }
}

Before

Trivy v0.74.0:

$ trivy config -q --misconfig-scanners azure-arm .
...
 azuredeploy.json:13
   via azuredeploy.json:12-14 (resources[1].properties)
    via azuredeploy.json:6-15 (resources[1])
     via azuredeploy.json:1-17 ()
      via azuredeploy.json:0 ()

After

$ trivy config -q --misconfig-scanners azure-arm .
...
 azuredeploy.json:13
   via azuredeploy.json:12-14 (resources.1.properties)
    via azuredeploy.json:6-15 (resources.1)
     via azuredeploy.json:1-17 ()
      via azuredeploy.json:0 ()

The last two links in the chain are removed in #11761.

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@nikpivkin nikpivkin added the autoready Automatically mark PR as ready for review when all checks pass label Nov 26, 2026
@nikpivkin
nikpivkin force-pushed the fix/arm-node-ref-numeric-keys branch from 7a87679 to 48a66ec Compare November 26, 2026 17:39
@github-actions
github-actions Bot marked this pull request as ready for review November 26, 2026 18:17
@github-actions github-actions Bot removed the autoready Automatically mark PR as ready for review when all checks pass label Nov 26, 2026
@nikpivkin
nikpivkin requested a review from afdesk November 27, 2026 10:28

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant