fix(azure-arg): real resourceGroup/location on non-compute rows + strip internal tags - #905
Merged
Merged
Conversation
…ip internal tags Non-compute Azure resources rendered resourceGroup:"default" and an AWS-style location:"us-east-1" in Resource Graph / resource-list / exportTemplate, because the discovery ARN builders hardcoded a "default" resource group and the walkers hardcoded the engine region. Thread the real per-resource resource group (from the ARM tags the wire handlers stamp) and region (from the Azure network metadata capability and the storage/database/disk attribute projections) into the Azure rows, mirroring how compute VMs already do it. Also strip internal cloudemu:-prefixed tags at the Azure wire boundary so they never leak. AWS/GCP are provider-gated/ignored, so their rows are byte-unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (A1)
Azure Resource Graph (
Microsoft.ResourceGraph/resources), the generic resource-list, andexportTemplatereported the wrongresourceGroupandlocationfor non-compute Azure resources:services/resourcediscovery/arn.gobuilt every non-compute Azure ARN with the literalazureDefaultResourceGroup = "default", so rows renderedresourceGroup: "default"regardless of where the resource actually lived.services/resourcediscovery/walkers.gohardcodedRegion: e.region(the engine default,us-east-1) for those same resources, so Azure rows rendered an AWS-stylelocation: "us-east-1".cloudemu:azureName(and the othercloudemu:*bookkeeping tags) leaked onto Azure rows — they were never stripped by the wire renderers.Compute VMs (
inst.ResourceGroup/inst.Region) and storage buckets (b.Region) already threaded real values; the other types did not.Fix
Thread the real per-resource resource group and region into the Azure rows, mirroring compute VMs, reading from where each type actually stores them:
cloudemu:azure*ResourceGroup); region from theAzureNetworkMetadatatype-asserted capability (GetAzureVNetMetadata/GetAzureNSGMetadata/GetAzureRouteTableMetadata) for VNet / NSG / route table.BucketAttributes/TableAttributesprojections (AccountAttributes.ResourceGroup/.Location).VolumeInfo.Location. Snapshots get the resource group from their ARM tag.*ARNbuilders now take aresourceGroupargument; the Azure branch folds it into the id, the AWS/GCP branches ignore it.StripInternalTagsinserver/azure/resourcegraphand applied it inresourceToWire(ARG + generic resource-list) and the resource-groupexportTemplatepath, socloudemu:*tags never leak while real user tags are preserved.Left as-is (region not persisted by the emulator, noted for follow-up)
Public IP, NAT gateway, subnet, network interface, snapshot, serverless function and monitoring-alarm rows keep the engine region for
location— those types do not store a per-resource region anywhere the walker can reach (the Azure wire handlers themselves fall back todefaultLocfor public IP). Their resource group is still fixed where an ARM tag exists (public IP / NAT gateway / snapshot). Faking a region was explicitly avoided.Blast radius — AWS/GCP unaffected
Every change is Azure-scoped or provider-gated:
azureRGFromTagsreturns""for non-Azure providers,azureNetLocationreturnse.regionwhen theAzureNetworkMetadatacapability is absent (AWS/GCP fail the type assertion), the AWS/GCP*ARNbranches ignore the newresourceGroupargument, andStripInternalTagsonly removes thecloudemu:prefix that no AWS/GCP tag carries.Verified green (byte-unchanged behavior):
server/aws/resourceexplorer2,server/aws/resourcegroupstaggingapi,server/aws/configserviceserver/gcp/cloudasset./server/aws/...and./server/gcp/...suitesTest
Added
server/azure/resourcegraph/azure_row_correctness_test.go: a real-SDK test that creates a VNet (via the livearmnetworkclient) underrg-prod/westus2and a VM (viaarmcompute), then queries through the livearmresourcegraphclient and asserts the VNet row reportsresourceGroup: "rg-prod"andlocation: "westus2"(notdefault/us-east-1), its id embeds the real group, and neither the VNet nor the VM row carries anycloudemu:*tag while the realenv=produser tag survives.Gates
go build ./...— cleango test ./services/resourcediscovery/... ./server/azure/resourcegraph/... ./server/azure/resourcegroups/...and all three providers' discovery paths — greengolangci-lint run ./services/resourcediscovery/... ./server/azure/resourcegraph/...— zero new issues (baseline pre-existing issues unchanged)