From a49097a063daf23e39ab57b75daa7cf850f49828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Sobo=C5=84?= Date: Mon, 25 Aug 2025 13:38:25 +0200 Subject: [PATCH 1/4] [Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466) * update test cases * update Azure service names * apply review remarks * rename FlexibleMySQLDBAssetType * rename MySQLDBAssetType * gofmt (cherry picked from commit 7e3234f165a18b911183ad4fd878de5a6a9e327f) # Conflicts: # internal/inventory/azurefetcher/fetcher_resource_graph.go # internal/inventory/azurefetcher/fetcher_resource_graph_test.go # internal/inventory/azurefetcher/fetcher_storage.go --- .../inventory/azurefetcher/fetcher_account.go | 2 +- .../azurefetcher/fetcher_account_test.go | 4 +-- .../azurefetcher/fetcher_activedirectory.go | 14 +++----- .../fetcher_activedirectory_test.go | 8 ++--- .../azurefetcher/fetcher_resource_graph.go | 34 +++++++++++-------- .../fetcher_resource_graph_test.go | 10 ++++-- .../inventory/azurefetcher/fetcher_storage.go | 6 ++++ .../azurefetcher/fetcher_storage_test.go | 16 ++++----- .../fetchers/azure/assets_enricher_mysql.go | 2 +- .../azure/assets_enricher_mysql_test.go | 4 +-- .../fetching/fetchers/azure/assets_fetcher.go | 4 +-- .../providers/azurelib/inventory/asset.go | 4 +-- 12 files changed, 60 insertions(+), 48 deletions(-) diff --git a/internal/inventory/azurefetcher/fetcher_account.go b/internal/inventory/azurefetcher/fetcher_account.go index f3481caa50..77b2aa46e1 100644 --- a/internal/inventory/azurefetcher/fetcher_account.go +++ b/internal/inventory/azurefetcher/fetcher_account.go @@ -80,7 +80,7 @@ func (f *accountFetcher) fetch(ctx context.Context, resourceName string, functio inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: item.TenantId, - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithLabelsFromAny(item.Tags), inventory.WithOrganization(inventory.Organization{ diff --git a/internal/inventory/azurefetcher/fetcher_account_test.go b/internal/inventory/azurefetcher/fetcher_account_test.go index ad734718cf..584ab866bc 100644 --- a/internal/inventory/azurefetcher/fetcher_account_test.go +++ b/internal/inventory/azurefetcher/fetcher_account_test.go @@ -46,7 +46,7 @@ func TestAccountFetcher_Fetch_Tenants(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithOrganization(inventory.Organization{ ID: "", @@ -82,7 +82,7 @@ func TestAccountFetcher_Fetch_Subscriptions(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithOrganization(inventory.Organization{ ID: "", diff --git a/internal/inventory/azurefetcher/fetcher_activedirectory.go b/internal/inventory/azurefetcher/fetcher_activedirectory.go index bc78b6a310..dd2958c020 100644 --- a/internal/inventory/azurefetcher/fetcher_activedirectory.go +++ b/internal/inventory/azurefetcher/fetcher_activedirectory.go @@ -81,7 +81,7 @@ func (f *activedirectoryFetcher) fetchServicePrincipals(ctx context.Context, ass inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: tenantId, - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithTags(item.GetTags()), ) @@ -108,7 +108,7 @@ func (f *activedirectoryFetcher) fetchDirectoryRoles(ctx context.Context, assetC inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: f.tenantID, - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithUser(inventory.User{ ID: pointers.Deref(item.GetId()), @@ -128,11 +128,6 @@ func (f *activedirectoryFetcher) fetchGroups(ctx context.Context, assetChan chan } for _, item := range items { - // TODO(kuba): How to test this without being able to test Groups? - // var labels map[string]string - // for _, l := range item.GetAssignedLabels() { - // fmt.Println(l) - // } assetChan <- inventory.NewAssetEvent( inventory.AssetClassificationAzureEntraGroup, pointers.Deref(item.GetId()), @@ -143,13 +138,12 @@ func (f *activedirectoryFetcher) fetchGroups(ctx context.Context, assetChan chan inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: f.tenantID, - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithGroup(inventory.Group{ ID: pointers.Deref(item.GetId()), Name: pointers.Deref(item.GetDisplayName()), }), - // inventory.WithLabels(labels), ) } } @@ -174,7 +168,7 @@ func (f *activedirectoryFetcher) fetchUsers(ctx context.Context, assetChan chan< inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: f.tenantID, - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithUser(inventory.User{ ID: pointers.Deref(item.GetId()), diff --git a/internal/inventory/azurefetcher/fetcher_activedirectory_test.go b/internal/inventory/azurefetcher/fetcher_activedirectory_test.go index b381c288a0..f5538af64d 100644 --- a/internal/inventory/azurefetcher/fetcher_activedirectory_test.go +++ b/internal/inventory/azurefetcher/fetcher_activedirectory_test.go @@ -86,7 +86,7 @@ func TestActiveDirectoryFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: appOwnerOrganizationId.String(), - ServiceName: "Azure", + ServiceName: "Azure Entra", }), ), inventory.NewAssetEvent( @@ -97,7 +97,7 @@ func TestActiveDirectoryFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "id", - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithUser(inventory.User{ ID: "id", @@ -112,7 +112,7 @@ func TestActiveDirectoryFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "id", - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithGroup(inventory.Group{ ID: "id", @@ -127,7 +127,7 @@ func TestActiveDirectoryFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "id", - ServiceName: "Azure", + ServiceName: "Azure Entra", }), inventory.WithUser(inventory.User{ ID: "id", diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph.go b/internal/inventory/azurefetcher/fetcher_resource_graph.go index 831393afdb..1578ab7e26 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph.go @@ -50,29 +50,30 @@ func newResourceGraphFetcher(logger *clog.Logger, tenantID string, provider reso func (f *resourceGraphFetcher) Fetch(ctx context.Context, assetChan chan<- inventory.AssetEvent) { resourcesToFetch := []struct { name string + serviceName string azureGroup string azureType string classification inventory.AssetClassification }{ - {"App Services", azurelib.AssetGroupResources, azurelib.WebsitesAssetType, inventory.AssetClassificationAzureAppService}, - {"Container Registries", azurelib.AssetGroupResources, azurelib.ContainerRegistryAssetType, inventory.AssetClassificationAzureContainerRegistry}, - {"Cosmos DB Accounts", azurelib.AssetGroupResources, azurelib.DocumentDBDatabaseAccountAssetType, inventory.AssetClassificationAzureCosmosDBAccount}, - {"Cosmos DB SQL Databases", azurelib.AssetGroupResources, azurelib.CosmosDBForSQLDatabaseAssetType, inventory.AssetClassificationAzureCosmosDBSQLDatabase}, - {"Disks", azurelib.AssetGroupResources, azurelib.DiskAssetType, inventory.AssetClassificationAzureDisk}, - {"Elastic Pools", azurelib.AssetGroupResources, azurelib.ElasticPoolAssetType, inventory.AssetClassificationAzureElasticPool}, - {"MySQL Flexible Servers", azurelib.AssetGroupResources, azurelib.FlexibleMySQLDBAssetType, inventory.AssetClassificationAzureSQLServer}, - {"Resource Groups", azurelib.AssetGroupResourceContainers, azurelib.ResouceGroupAssetType, inventory.AssetClassificationAzureResourceGroup}, - {"SQL Databases", azurelib.AssetGroupResources, azurelib.MySQLDatabaseAssetType, inventory.AssetClassificationAzureSQLDatabase}, - {"Snapshots", azurelib.AssetGroupResources, azurelib.SnapshotAssetType, inventory.AssetClassificationAzureSnapshot}, - {"Storage Accounts", azurelib.AssetGroupResources, azurelib.StorageAccountAssetType, inventory.AssetClassificationAzureStorageAccount}, - {"Virtual Machines", azurelib.AssetGroupResources, azurelib.VirtualMachineAssetType, inventory.AssetClassificationAzureVirtualMachine}, + {"App Services", "Azure App Services", azurelib.AssetGroupResources, azurelib.WebsitesAssetType, inventory.AssetClassificationAzureAppService}, + {"Container Registries", "Azure Container Registries", azurelib.AssetGroupResources, azurelib.ContainerRegistryAssetType, inventory.AssetClassificationAzureContainerRegistry}, + {"Cosmos DB Accounts", "Azure Cosmos DB", azurelib.AssetGroupResources, azurelib.DocumentDBDatabaseAccountAssetType, inventory.AssetClassificationAzureCosmosDBAccount}, + {"Cosmos DB SQL Databases", "Azure Cosmos DB", azurelib.AssetGroupResources, azurelib.CosmosDBForSQLDatabaseAssetType, inventory.AssetClassificationAzureCosmosDBSQLDatabase}, + {"Disks", "Azure Storage", azurelib.AssetGroupResources, azurelib.DiskAssetType, inventory.AssetClassificationAzureDisk}, + {"Elastic Pools", "Azure SQL Elastic Pools", azurelib.AssetGroupResources, azurelib.ElasticPoolAssetType, inventory.AssetClassificationAzureElasticPool}, + {"MySQL Flexible Servers", "Azure SQL Servers", azurelib.AssetGroupResources, azurelib.FlexibleMySQLDBServerAssetType, inventory.AssetClassificationAzureSQLServer}, + {"Resource Groups", "Azure Management", azurelib.AssetGroupResourceContainers, azurelib.ResouceGroupAssetType, inventory.AssetClassificationAzureResourceGroup}, + {"SQL Databases", "Azure SQL Databases", azurelib.AssetGroupResources, azurelib.MySQLDatabaseAssetType, inventory.AssetClassificationAzureSQLDatabase}, + {"Snapshots", "Azure Storage", azurelib.AssetGroupResources, azurelib.SnapshotAssetType, inventory.AssetClassificationAzureSnapshot}, + {"Storage Accounts", "Azure Storage", azurelib.AssetGroupResources, azurelib.StorageAccountAssetType, inventory.AssetClassificationAzureStorageAccount}, + {"Virtual Machines", "Azure Virtual Machines", azurelib.AssetGroupResources, azurelib.VirtualMachineAssetType, inventory.AssetClassificationAzureVirtualMachine}, } for _, r := range resourcesToFetch { - f.fetch(ctx, r.name, r.azureGroup, r.azureType, r.classification, assetChan) + f.fetch(ctx, r.name, r.serviceName, r.azureGroup, r.azureType, r.classification, assetChan) } } -func (f *resourceGraphFetcher) fetch(ctx context.Context, resourceName, resourceGroup, resourceType string, classification inventory.AssetClassification, assetChan chan<- inventory.AssetEvent) { +func (f *resourceGraphFetcher) fetch(ctx context.Context, resourceName, serviceName, resourceGroup, resourceType string, classification inventory.AssetClassification, assetChan chan<- inventory.AssetEvent) { f.logger.Infof("Fetching %s", resourceName) defer f.logger.Infof("Fetching %s - Finished", resourceName) @@ -91,7 +92,12 @@ func (f *resourceGraphFetcher) fetch(ctx context.Context, resourceName, resource inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: item.TenantId, +<<<<<<< HEAD ServiceName: "Azure", +======= + ProjectID: item.SubscriptionId, + ServiceName: serviceName, +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) }), inventory.WithLabelsFromAny(item.Tags), ) diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go index 95c0f1417a..17e1ff430c 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go @@ -69,7 +69,7 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure App Services", }), ), inventory.NewAssetEvent( @@ -80,7 +80,7 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -91,7 +91,13 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", +<<<<<<< HEAD ServiceName: "Azure", +======= + ServiceName: "Azure Virtual Machines", + MachineType: "xlarge", + InstanceID: "/vm", +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) }), inventory.WithHost(inventory.Host{ ID: vm.Id, diff --git a/internal/inventory/azurefetcher/fetcher_storage.go b/internal/inventory/azurefetcher/fetcher_storage.go index b1310b493a..53cbc9b418 100644 --- a/internal/inventory/azurefetcher/fetcher_storage.go +++ b/internal/inventory/azurefetcher/fetcher_storage.go @@ -120,8 +120,14 @@ func (f *storageFetcher) fetch(ctx context.Context, storageAccounts []azurelib.A inventory.WithRawAsset(item), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, +<<<<<<< HEAD AccountID: item.TenantId, ServiceName: "Azure", +======= + AccountID: pickName(item.TenantId, f.tenantID), + ServiceName: "Azure Storage", + ProjectID: item.SubscriptionId, +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) }), inventory.WithLabelsFromAny(item.Tags), ) diff --git a/internal/inventory/azurefetcher/fetcher_storage_test.go b/internal/inventory/azurefetcher/fetcher_storage_test.go index e8272b9593..88b75ef632 100644 --- a/internal/inventory/azurefetcher/fetcher_storage_test.go +++ b/internal/inventory/azurefetcher/fetcher_storage_test.go @@ -85,7 +85,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureBlobContainer), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -95,7 +95,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureBlobService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -105,7 +105,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureFileService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -115,7 +115,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureFileShare), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -125,7 +125,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureQueueService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -135,7 +135,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureQueue), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -145,7 +145,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureTable), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -155,7 +155,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureTableService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), } diff --git a/internal/resources/fetching/fetchers/azure/assets_enricher_mysql.go b/internal/resources/fetching/fetchers/azure/assets_enricher_mysql.go index 620c808be8..7bcbaf4842 100644 --- a/internal/resources/fetching/fetchers/azure/assets_enricher_mysql.go +++ b/internal/resources/fetching/fetchers/azure/assets_enricher_mysql.go @@ -33,7 +33,7 @@ type mysqlAssetEnricher struct { func (e mysqlAssetEnricher) Enrich(ctx context.Context, _ cycle.Metadata, assets []inventory.AzureAsset) error { var errAgg error for i, a := range assets { - if a.Type != inventory.FlexibleMySQLDBAssetType { + if a.Type != inventory.FlexibleMySQLDBServerAssetType { continue } diff --git a/internal/resources/fetching/fetchers/azure/assets_enricher_mysql_test.go b/internal/resources/fetching/fetchers/azure/assets_enricher_mysql_test.go index 4f4b62c954..73160fbb04 100644 --- a/internal/resources/fetching/fetchers/azure/assets_enricher_mysql_test.go +++ b/internal/resources/fetching/fetchers/azure/assets_enricher_mysql_test.go @@ -116,7 +116,7 @@ func mockFlexMysqlTLSVersionConfig(id, tlsVersion string) inventory.AzureAsset { SubscriptionId: "subId", ResourceGroup: "group", Name: "tls_version", - Type: inventory.FlexibleMySQLDBAssetType + "/configuration", + Type: inventory.FlexibleMySQLDBServerAssetType + "/configuration", Properties: map[string]any{ "name": "tls_version", "source": "system-default", @@ -132,6 +132,6 @@ func mockFlexibleMysqlAsset(id string, name string) inventory.AzureAsset { SubscriptionId: "subId", ResourceGroup: "group", Name: name, - Type: inventory.FlexibleMySQLDBAssetType, + Type: inventory.FlexibleMySQLDBServerAssetType, } } diff --git a/internal/resources/fetching/fetchers/azure/assets_fetcher.go b/internal/resources/fetching/fetchers/azure/assets_fetcher.go index 768e7cb133..cf45bb1516 100644 --- a/internal/resources/fetching/fetchers/azure/assets_fetcher.go +++ b/internal/resources/fetching/fetchers/azure/assets_fetcher.go @@ -55,8 +55,8 @@ var AzureAssetTypeToTypePair = map[string]typePair{ inventory.ClassicStorageAccountAssetType: {fetching.AzureClassicStorageAccountType, fetching.CloudStorage}, inventory.DiskAssetType: {fetching.AzureDiskType, fetching.CloudCompute}, inventory.DocumentDBDatabaseAccountAssetType: {fetching.AzureDocumentDBDatabaseAccountType, fetching.CloudDatabase}, - inventory.MySQLDBAssetType: {fetching.AzureMySQLDBType, fetching.CloudDatabase}, - inventory.FlexibleMySQLDBAssetType: {fetching.AzureFlexibleMySQLDBType, fetching.CloudDatabase}, + inventory.MySQLDBServerAssetType: {fetching.AzureMySQLDBType, fetching.CloudDatabase}, + inventory.FlexibleMySQLDBServerAssetType: {fetching.AzureFlexibleMySQLDBType, fetching.CloudDatabase}, inventory.NetworkWatchersFlowLogAssetType: {fetching.AzureNetworkWatchersFlowLogType, fetching.MonitoringIdentity}, inventory.FlexiblePostgreSQLDBAssetType: {fetching.AzureFlexiblePostgreSQLDBType, fetching.CloudDatabase}, inventory.PostgreSQLDBAssetType: {fetching.AzurePostgreSQLDBType, fetching.CloudDatabase}, diff --git a/internal/resources/providers/azurelib/inventory/asset.go b/internal/resources/providers/azurelib/inventory/asset.go index 23265c3e28..958fe8b910 100644 --- a/internal/resources/providers/azurelib/inventory/asset.go +++ b/internal/resources/providers/azurelib/inventory/asset.go @@ -35,9 +35,9 @@ const ( DiskAssetType = "microsoft.compute/disks" DocumentDBDatabaseAccountAssetType = "microsoft.documentdb/databaseaccounts" ElasticPoolAssetType = "microsoft.sql/servers/elasticpools" - FlexibleMySQLDBAssetType = "microsoft.dbformysql/flexibleservers" + FlexibleMySQLDBServerAssetType = "microsoft.dbformysql/flexibleservers" FlexiblePostgreSQLDBAssetType = "microsoft.dbforpostgresql/flexibleservers" - MySQLDBAssetType = "microsoft.dbformysql/servers" + MySQLDBServerAssetType = "microsoft.dbformysql/servers" MySQLDatabaseAssetType = "microsoft.sql/servers/databases" NetworkSecurityGroupAssetType = "microsoft.network/networksecuritygroups" NetworkWatchersAssetType = "microsoft.network/networkwatchers" From 272b17ba7b8803ce4704ce7f01f58d1d94af923f Mon Sep 17 00:00:00 2001 From: kubasobon Date: Mon, 1 Sep 2025 11:25:14 +0200 Subject: [PATCH 2/4] resolve conflicts --- internal/inventory/azurefetcher/fetcher_resource_graph.go | 4 ---- .../inventory/azurefetcher/fetcher_resource_graph_test.go | 4 ---- internal/inventory/azurefetcher/fetcher_storage.go | 5 ----- 3 files changed, 13 deletions(-) diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph.go b/internal/inventory/azurefetcher/fetcher_resource_graph.go index 1578ab7e26..cb68aa4d8e 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph.go @@ -92,12 +92,8 @@ func (f *resourceGraphFetcher) fetch(ctx context.Context, resourceName, serviceN inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: item.TenantId, -<<<<<<< HEAD - ServiceName: "Azure", -======= ProjectID: item.SubscriptionId, ServiceName: serviceName, ->>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) }), inventory.WithLabelsFromAny(item.Tags), ) diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go index 17e1ff430c..66643763bb 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go @@ -91,13 +91,9 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", -<<<<<<< HEAD - ServiceName: "Azure", -======= ServiceName: "Azure Virtual Machines", MachineType: "xlarge", InstanceID: "/vm", ->>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) }), inventory.WithHost(inventory.Host{ ID: vm.Id, diff --git a/internal/inventory/azurefetcher/fetcher_storage.go b/internal/inventory/azurefetcher/fetcher_storage.go index 53cbc9b418..c6474c7091 100644 --- a/internal/inventory/azurefetcher/fetcher_storage.go +++ b/internal/inventory/azurefetcher/fetcher_storage.go @@ -120,14 +120,9 @@ func (f *storageFetcher) fetch(ctx context.Context, storageAccounts []azurelib.A inventory.WithRawAsset(item), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, -<<<<<<< HEAD - AccountID: item.TenantId, - ServiceName: "Azure", -======= AccountID: pickName(item.TenantId, f.tenantID), ServiceName: "Azure Storage", ProjectID: item.SubscriptionId, ->>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) }), inventory.WithLabelsFromAny(item.Tags), ) From 750987c92af0b224cfd16e53566ff3e7dd3569e3 Mon Sep 17 00:00:00 2001 From: kubasobon Date: Mon, 1 Sep 2025 11:53:09 +0200 Subject: [PATCH 3/4] update tests --- .../inventory/azurefetcher/fetcher_resource_graph_test.go | 2 -- internal/inventory/azurefetcher/fetcher_storage_test.go | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go index 66643763bb..6108015d22 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go @@ -92,8 +92,6 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { Provider: inventory.AzureCloudProvider, AccountID: "", ServiceName: "Azure Virtual Machines", - MachineType: "xlarge", - InstanceID: "/vm", }), inventory.WithHost(inventory.Host{ ID: vm.Id, diff --git a/internal/inventory/azurefetcher/fetcher_storage_test.go b/internal/inventory/azurefetcher/fetcher_storage_test.go index 88b75ef632..dbf3a6ac11 100644 --- a/internal/inventory/azurefetcher/fetcher_storage_test.go +++ b/internal/inventory/azurefetcher/fetcher_storage_test.go @@ -85,6 +85,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureBlobContainer), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -95,6 +96,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureBlobService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -105,6 +107,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureFileService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -115,6 +118,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureFileShare), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -125,6 +129,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureQueueService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -135,6 +140,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureQueue), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -145,6 +151,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureTable), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), @@ -155,6 +162,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureTableService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, + AccountID: "", ServiceName: "Azure Storage", }), ), From 5a3657ec869191dd873cb39283fc33c08c958b19 Mon Sep 17 00:00:00 2001 From: kubasobon Date: Mon, 1 Sep 2025 12:13:55 +0200 Subject: [PATCH 4/4] make linter happy --- internal/inventory/azurefetcher/fetcher_storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/inventory/azurefetcher/fetcher_storage.go b/internal/inventory/azurefetcher/fetcher_storage.go index c6474c7091..18baec2ad1 100644 --- a/internal/inventory/azurefetcher/fetcher_storage.go +++ b/internal/inventory/azurefetcher/fetcher_storage.go @@ -28,7 +28,7 @@ import ( type storageFetcher struct { logger *clog.Logger - tenantID string //nolint:unused + tenantID string provider storageProvider }