From 58c02659bd61647833c89eec5350973e7cd43536 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] [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_activedirectory.go # internal/inventory/azurefetcher/fetcher_activedirectory_test.go # internal/inventory/azurefetcher/fetcher_resource_graph.go # internal/inventory/azurefetcher/fetcher_resource_graph_test.go # internal/inventory/azurefetcher/fetcher_storage.go # internal/inventory/azurefetcher/fetcher_storage_test.go # internal/resources/fetching/fetchers/azure/assets_fetcher.go --- .../inventory/azurefetcher/fetcher_account.go | 2 +- .../azurefetcher/fetcher_account_test.go | 4 +- .../azurefetcher/fetcher_activedirectory.go | 96 ++++++++++++++++++- .../fetcher_activedirectory_test.go | 50 +++++++++- .../azurefetcher/fetcher_resource_graph.go | 34 ++++--- .../fetcher_resource_graph_test.go | 25 ++++- .../inventory/azurefetcher/fetcher_storage.go | 6 ++ .../azurefetcher/fetcher_storage_test.go | 72 +++++++++++++- .../fetchers/azure/assets_enricher_mysql.go | 2 +- .../azure/assets_enricher_mysql_test.go | 4 +- .../fetching/fetchers/azure/assets_fetcher.go | 17 ++++ .../providers/azurelib/inventory/asset.go | 4 +- 12 files changed, 287 insertions(+), 29 deletions(-) diff --git a/internal/inventory/azurefetcher/fetcher_account.go b/internal/inventory/azurefetcher/fetcher_account.go index 4293b5bb5f..b65159cbbb 100644 --- a/internal/inventory/azurefetcher/fetcher_account.go +++ b/internal/inventory/azurefetcher/fetcher_account.go @@ -78,7 +78,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", }), ) } diff --git a/internal/inventory/azurefetcher/fetcher_account_test.go b/internal/inventory/azurefetcher/fetcher_account_test.go index 5344cf41f0..20737d5723 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", }), ), } @@ -79,7 +79,7 @@ func TestAccountFetcher_Fetch_Subscriptions(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure Entra", }), ), } diff --git a/internal/inventory/azurefetcher/fetcher_activedirectory.go b/internal/inventory/azurefetcher/fetcher_activedirectory.go index ad837e3a01..0d1dba995c 100644 --- a/internal/inventory/azurefetcher/fetcher_activedirectory.go +++ b/internal/inventory/azurefetcher/fetcher_activedirectory.go @@ -73,8 +73,102 @@ func (f *activedirectoryFetcher) fetchServicePrincipals(ctx context.Context, ass inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: tenantId, - ServiceName: "Azure", + ServiceName: "Azure Entra", }), +<<<<<<< HEAD +======= + inventory.WithTags(item.GetTags()), + ) + } +} + +func (f *activedirectoryFetcher) fetchDirectoryRoles(ctx context.Context, assetChan chan<- inventory.AssetEvent) { + f.logger.Info("Fetching Directory Roles") + defer f.logger.Info("Fetching Directory Roles - Finished") + + items, err := f.provider.ListDirectoryRoles(ctx) + if err != nil { + f.logger.Errorf("Could not fetch Directory Roles: %v", err) + } + + for _, item := range items { + assetChan <- inventory.NewAssetEvent( + inventory.AssetClassificationAzureRoleDefinition, + pointers.Deref(item.GetId()), + pickName(pointers.Deref(item.GetDisplayName()), pointers.Deref(item.GetId())), + inventory.WithRawAsset( + item.GetBackingStore().Enumerate(), + ), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: f.tenantID, + ServiceName: "Azure Entra", + }), + inventory.WithUser(inventory.User{ + ID: pointers.Deref(item.GetId()), + Name: pointers.Deref(item.GetDisplayName()), + }), + ) + } +} + +func (f *activedirectoryFetcher) fetchGroups(ctx context.Context, assetChan chan<- inventory.AssetEvent) { + f.logger.Info("Fetching Groups") + defer f.logger.Info("Fetching Groups - Finished") + + items, err := f.provider.ListGroups(ctx) + if err != nil { + f.logger.Errorf("Could not fetch Groups: %v", err) + } + + for _, item := range items { + assetChan <- inventory.NewAssetEvent( + inventory.AssetClassificationAzureEntraGroup, + pointers.Deref(item.GetId()), + pickName(pointers.Deref(item.GetDisplayName()), pointers.Deref(item.GetId())), + inventory.WithRawAsset( + item.GetBackingStore().Enumerate(), + ), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: f.tenantID, + ServiceName: "Azure Entra", + }), + inventory.WithGroup(inventory.Group{ + ID: pointers.Deref(item.GetId()), + Name: pointers.Deref(item.GetDisplayName()), + }), + ) + } +} + +func (f *activedirectoryFetcher) fetchUsers(ctx context.Context, assetChan chan<- inventory.AssetEvent) { + f.logger.Info("Fetching Users") + defer f.logger.Info("Fetching Users - Finished") + + items, err := f.provider.ListUsers(ctx) + if err != nil { + f.logger.Errorf("Could not fetch Users: %v", err) + } + + for _, item := range items { + assetChan <- inventory.NewAssetEvent( + inventory.AssetClassificationAzureEntraUser, + pointers.Deref(item.GetId()), + pickName(pointers.Deref(item.GetDisplayName()), pointers.Deref(item.GetId())), + inventory.WithRawAsset( + item.GetBackingStore().Enumerate(), + ), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: f.tenantID, + ServiceName: "Azure Entra", + }), + inventory.WithUser(inventory.User{ + ID: pointers.Deref(item.GetId()), + Name: pointers.Deref(item.GetDisplayName()), + }), +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) ) } } diff --git a/internal/inventory/azurefetcher/fetcher_activedirectory_test.go b/internal/inventory/azurefetcher/fetcher_activedirectory_test.go index 2df31b9ec8..9a4a03e432 100644 --- a/internal/inventory/azurefetcher/fetcher_activedirectory_test.go +++ b/internal/inventory/azurefetcher/fetcher_activedirectory_test.go @@ -65,9 +65,57 @@ func TestActiveDirectoryFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: appOwnerOrganizationId.String(), - ServiceName: "Azure", + ServiceName: "Azure Entra", }), ), +<<<<<<< HEAD +======= + inventory.NewAssetEvent( + inventory.AssetClassificationAzureRoleDefinition, + "id", + "dn", + inventory.WithRawAsset(values), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: "id", + ServiceName: "Azure Entra", + }), + inventory.WithUser(inventory.User{ + ID: "id", + Name: "dn", + }), + ), + inventory.NewAssetEvent( + inventory.AssetClassificationAzureEntraGroup, + "id", + "dn", + inventory.WithRawAsset(values), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: "id", + ServiceName: "Azure Entra", + }), + inventory.WithGroup(inventory.Group{ + ID: "id", + Name: "dn", + }), + ), + inventory.NewAssetEvent( + inventory.AssetClassificationAzureEntraUser, + "id", + "dn", + inventory.WithRawAsset(values), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: "id", + ServiceName: "Azure Entra", + }), + inventory.WithUser(inventory.User{ + ID: "id", + Name: "dn", + }), + ), +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) } // setup diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph.go b/internal/inventory/azurefetcher/fetcher_resource_graph.go index 9ee4f44cbf..676731bf6c 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph.go @@ -46,29 +46,30 @@ func newResourceGraphFetcher(logger *clog.Logger, provider resourceGraphProvider 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)) }), ) } diff --git a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go index 00dc89f25d..69fde7e8b6 100644 --- a/internal/inventory/azurefetcher/fetcher_resource_graph_test.go +++ b/internal/inventory/azurefetcher/fetcher_resource_graph_test.go @@ -51,7 +51,7 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure App Services", }), ), inventory.NewAssetEvent( @@ -62,9 +62,30 @@ func TestResourceGraphFetcher_Fetch(t *testing.T) { inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, AccountID: "", - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), +<<<<<<< HEAD +======= + inventory.NewAssetEvent( + inventory.AssetClassificationAzureVirtualMachine, + vm.Id, + vm.DisplayName, + inventory.WithRawAsset(vm), + inventory.WithCloud(inventory.Cloud{ + Provider: inventory.AzureCloudProvider, + AccountID: "", + ServiceName: "Azure Virtual Machines", + MachineType: "xlarge", + InstanceID: "/vm", + }), + inventory.WithHost(inventory.Host{ + ID: vm.Id, + Name: "localhost", + Type: "xlarge", + }), + ), +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) } // setup diff --git a/internal/inventory/azurefetcher/fetcher_storage.go b/internal/inventory/azurefetcher/fetcher_storage.go index cce4dc5efd..c46fdeead6 100644 --- a/internal/inventory/azurefetcher/fetcher_storage.go +++ b/internal/inventory/azurefetcher/fetcher_storage.go @@ -108,8 +108,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)) }), ) } diff --git a/internal/inventory/azurefetcher/fetcher_storage_test.go b/internal/inventory/azurefetcher/fetcher_storage_test.go index 6b03f5a03b..1f99d53049 100644 --- a/internal/inventory/azurefetcher/fetcher_storage_test.go +++ b/internal/inventory/azurefetcher/fetcher_storage_test.go @@ -54,13 +54,53 @@ func TestStorageFetcher_Fetch(t *testing.T) { expected := []inventory.AssetEvent{ inventory.NewAssetEvent( +<<<<<<< HEAD +======= + inventory.AssetClassificationAzureStorageBlobContainer, + azureBlobContainer.Id, + azureBlobContainer.Name, + inventory.WithRawAsset(azureBlobContainer), + inventory.WithCloud(inventory.Cloud{ + AccountID: "", + Provider: inventory.AzureCloudProvider, + ServiceName: "Azure Storage", + }), + ), + inventory.NewAssetEvent( +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) inventory.AssetClassificationAzureStorageBlobService, azureBlobService.Id, azureBlobService.Name, inventory.WithRawAsset(azureBlobService), inventory.WithCloud(inventory.Cloud{ +<<<<<<< HEAD +======= + AccountID: "", Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", + }), + ), + inventory.NewAssetEvent( + inventory.AssetClassificationAzureStorageFileService, + azureFileService.Id, + azureFileService.Name, + inventory.WithRawAsset(azureFileService), + inventory.WithCloud(inventory.Cloud{ + AccountID: "", + Provider: inventory.AzureCloudProvider, + ServiceName: "Azure Storage", + }), + ), + inventory.NewAssetEvent( + inventory.AssetClassificationAzureStorageFileShare, + azureFileShare.Id, + azureFileShare.Name, + inventory.WithRawAsset(azureFileShare), + inventory.WithCloud(inventory.Cloud{ + AccountID: "", +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) + Provider: inventory.AzureCloudProvider, + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -70,7 +110,7 @@ func TestStorageFetcher_Fetch(t *testing.T) { inventory.WithRawAsset(azureQueueService), inventory.WithCloud(inventory.Cloud{ Provider: inventory.AzureCloudProvider, - ServiceName: "Azure", + ServiceName: "Azure Storage", }), ), inventory.NewAssetEvent( @@ -79,8 +119,34 @@ func TestStorageFetcher_Fetch(t *testing.T) { azureQueue.Name, inventory.WithRawAsset(azureQueue), inventory.WithCloud(inventory.Cloud{ +<<<<<<< HEAD +======= + AccountID: "", + Provider: inventory.AzureCloudProvider, + ServiceName: "Azure Storage", + }), + ), + inventory.NewAssetEvent( + inventory.AssetClassificationAzureStorageTable, + azureTable.Id, + azureTable.Name, + inventory.WithRawAsset(azureTable), + inventory.WithCloud(inventory.Cloud{ + AccountID: "", + Provider: inventory.AzureCloudProvider, + ServiceName: "Azure Storage", + }), + ), + inventory.NewAssetEvent( + inventory.AssetClassificationAzureStorageTableService, + azureTableService.Id, + azureTableService.Name, + inventory.WithRawAsset(azureTableService), + inventory.WithCloud(inventory.Cloud{ + AccountID: "", +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) 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 717dadf76e..4ba803aca3 100644 --- a/internal/resources/fetching/fetchers/azure/assets_fetcher.go +++ b/internal/resources/fetching/fetchers/azure/assets_fetcher.go @@ -59,6 +59,7 @@ func newPair(subType string, tpe string) typePair { } var AzureAssetTypeToTypePair = map[string]typePair{ +<<<<<<< HEAD inventory.ClassicStorageAccountAssetType: newPair(fetching.AzureClassicStorageAccountType, fetching.CloudStorage), inventory.DiskAssetType: newPair(fetching.AzureDiskType, fetching.CloudCompute), inventory.DocumentDBDatabaseAccountAssetType: newPair(fetching.AzureDocumentDBDatabaseAccountType, fetching.CloudDatabase), @@ -74,6 +75,22 @@ var AzureAssetTypeToTypePair = map[string]typePair{ inventory.VaultAssetType: newPair(fetching.AzureVaultType, fetching.KeyManagement), inventory.RoleDefinitionsType: newPair(fetching.AzureRoleDefinitionType, fetching.CloudIdentity), +======= + inventory.ClassicStorageAccountAssetType: {fetching.AzureClassicStorageAccountType, fetching.CloudStorage}, + inventory.DiskAssetType: {fetching.AzureDiskType, fetching.CloudCompute}, + inventory.DocumentDBDatabaseAccountAssetType: {fetching.AzureDocumentDBDatabaseAccountType, 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}, + inventory.SQLServersAssetType: {fetching.AzureSQLServerType, fetching.CloudDatabase}, + inventory.StorageAccountAssetType: {fetching.AzureStorageAccountType, fetching.CloudStorage}, + inventory.VirtualMachineAssetType: {fetching.AzureVMType, fetching.CloudCompute}, + inventory.WebsitesAssetType: {fetching.AzureWebSiteType, fetching.CloudCompute}, + inventory.VaultAssetType: {fetching.AzureVaultType, fetching.KeyManagement}, + inventory.RoleDefinitionsType: {fetching.AzureRoleDefinitionType, fetching.CloudIdentity}, +>>>>>>> 7e3234f1 ([Asset Inventory][Azure] Fix Azure service names (cloud.service.name) (#3466)) // This asset type is used only for enrichment purposes, but is sent to OPA layer, producing no findings. inventory.NetworkSecurityGroupAssetType: newPair(fetching.AzureNetworkSecurityGroupType, fetching.MonitoringIdentity), } diff --git a/internal/resources/providers/azurelib/inventory/asset.go b/internal/resources/providers/azurelib/inventory/asset.go index 32eb7cb067..f89c30febb 100644 --- a/internal/resources/providers/azurelib/inventory/asset.go +++ b/internal/resources/providers/azurelib/inventory/asset.go @@ -34,9 +34,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"