diff --git a/plugins/azure/fix_plugin_azure/resource/authorization.py b/plugins/azure/fix_plugin_azure/resource/authorization.py index fbf8941178..30fdd8f095 100644 --- a/plugins/azure/fix_plugin_azure/resource/authorization.py +++ b/plugins/azure/fix_plugin_azure/resource/authorization.py @@ -18,7 +18,7 @@ MicrosoftGraphGroup, MicrosoftGraphPrincipalTypes, ) -from fixlib.baseresources import BaseRole, ModelReference +from fixlib.baseresources import BaseRole, ModelReference, PhantomBaseResource from fixlib.graph import BySearchCriteria from fixlib.json_bender import Bender, S, ForallBend, Bend from fixlib.types import Json @@ -227,7 +227,7 @@ class AzurePermission: @define(eq=False, slots=False) -class AzureAuthorizationRoleDefinition(MicrosoftResource, BaseRole): +class AzureAuthorizationRoleDefinition(MicrosoftResource, BaseRole, PhantomBaseResource): kind: ClassVar[str] = "azure_authorization_role_definition" _kind_display: ClassVar[str] = "Azure Authorization Role Definition" _kind_service: ClassVar[Optional[str]] = service_name diff --git a/plugins/azure/fix_plugin_azure/resource/base.py b/plugins/azure/fix_plugin_azure/resource/base.py index ec21145ba7..8c3c9a24ec 100644 --- a/plugins/azure/fix_plugin_azure/resource/base.py +++ b/plugins/azure/fix_plugin_azure/resource/base.py @@ -478,8 +478,11 @@ class AzureUsageName: @define(eq=False, slots=False) -class AzureBaseUsage: +class AzureBaseUsage(PhantomBaseResource): kind: ClassVar[str] = "azure_usage" + _kind_display: ClassVar[str] = "Azure Usage" + _kind_service: ClassVar[Optional[str]] = "resources" + _kind_description: ClassVar[str] = "Azure Usage represents the usage of a resource in an Azure subscription. It provides information about the current value of the usage, the limit of usage, and the unit of measurement. Azure Usage is used to track resource consumption and enforce usage limits, helping users manage costs and optimize resource utilization." # fmt: skip mapping: ClassVar[Dict[str, Bender]] = { "name": S("name", "value"), # inherited by BaseResource - name already defined there "usage_name": S("name") >> Bend(AzureUsageName.mapping), diff --git a/plugins/azure/fix_plugin_azure/resource/cosmosdb.py b/plugins/azure/fix_plugin_azure/resource/cosmosdb.py index 93cdf7c368..35e4de2a4d 100644 --- a/plugins/azure/fix_plugin_azure/resource/cosmosdb.py +++ b/plugins/azure/fix_plugin_azure/resource/cosmosdb.py @@ -23,7 +23,7 @@ from fix_plugin_azure.resource.mysql import AzureServerDataEncryption from fix_plugin_azure.resource.network import AzureNetworkSubnet from fix_plugin_azure.utils import from_str_to_typed -from fixlib.baseresources import BaseDatabase, DatabaseInstanceStatus, EdgeType, ModelReference +from fixlib.baseresources import BaseDatabase, DatabaseInstanceStatus, EdgeType, ModelReference, PhantomBaseResource from fixlib.graph import BySearchCriteria from fixlib.json_bender import F, K, Bender, S, ForallBend, Bend, MapEnum, MapValue from fixlib.types import Json @@ -2042,7 +2042,7 @@ def collect_usages(cls, account_id: str, raw: List[Json], builder: GraphBuilder) @define(eq=False, slots=False) -class AzureCosmosDBLocation(CosmosDBLocationSetter, MicrosoftResource): +class AzureCosmosDBLocation(CosmosDBLocationSetter, MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_cosmos_db_location" _kind_display: ClassVar[str] = "Azure Cosmos DB Location" _kind_service: ClassVar[Optional[str]] = service_name diff --git a/plugins/azure/fix_plugin_azure/resource/machinelearning.py b/plugins/azure/fix_plugin_azure/resource/machinelearning.py index de7338df40..a01a305148 100644 --- a/plugins/azure/fix_plugin_azure/resource/machinelearning.py +++ b/plugins/azure/fix_plugin_azure/resource/machinelearning.py @@ -25,7 +25,7 @@ from fix_plugin_azure.resource.network import AzureNetworkSubnet, AzureNetworkVirtualNetwork from fix_plugin_azure.resource.storage import AzureStorageAccount from fix_plugin_azure.resource.web import AzureWebApp -from fixlib.baseresources import BaseInstanceType, ModelReference, BaseAIJob, BaseAIModel +from fixlib.baseresources import BaseInstanceType, ModelReference, BaseAIJob, BaseAIModel, PhantomBaseResource from fixlib.graph import BySearchCriteria from fixlib.json_bender import Bender, S, ForallBend, Bend, K from fixlib.types import Json @@ -1005,7 +1005,7 @@ def collect_versions() -> None: @define(eq=False, slots=False) -class AzureMachineLearningEnvironmentVersionBase(CheckVersionIsArchived, AzureProxyResource): +class AzureMachineLearningEnvironmentVersionBase(CheckVersionIsArchived, AzureProxyResource, PhantomBaseResource): kind: ClassVar[str] = "azure_machine_learning_environment_version_base" _kind_display: ClassVar[str] = "Azure Machine Learning Environment Version Base" _kind_service: ClassVar[Optional[str]] = service_name @@ -2224,7 +2224,7 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None: @define(eq=False, slots=False) -class AzureMachineLearningQuota(MicrosoftResource): +class AzureMachineLearningQuota(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_machine_learning_quota" _kind_display: ClassVar[str] = "Azure Machine Learning Quota" _kind_service: ClassVar[Optional[str]] = service_name diff --git a/plugins/azure/fix_plugin_azure/resource/network.py b/plugins/azure/fix_plugin_azure/resource/network.py index a7f93802f3..1af75b27bd 100644 --- a/plugins/azure/fix_plugin_azure/resource/network.py +++ b/plugins/azure/fix_plugin_azure/resource/network.py @@ -37,6 +37,7 @@ BaseTunnel, ModelReference, EdgeType, + PhantomBaseResource, ) from fixlib.json_bender import F, Bender, S, Bend, ForallBend, AsInt, StringToUnitNumber, Upper, Lower from fixlib.types import Json @@ -1119,7 +1120,7 @@ class AzureApplicationGatewayFirewallRuleGroup: @define(eq=False, slots=False) -class AzureNetworkApplicationGatewayFirewallRuleSet(MicrosoftResource): +class AzureNetworkApplicationGatewayFirewallRuleSet(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_network_application_gateway_firewall_rule_set" _kind_display: ClassVar[str] = "Azure Network Application Gateway Firewall Rule Set" _kind_service: ClassVar[Optional[str]] = service_name @@ -3465,7 +3466,7 @@ class AzureExpressRoutePortsLocationBandwidths: @define(eq=False, slots=False) -class AzureNetworkExpressRoutePortsLocation(MicrosoftResource): +class AzureNetworkExpressRoutePortsLocation(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_network_express_route_ports_location" _kind_display: ClassVar[str] = "Azure Network Express Route Ports Location" _kind_service: ClassVar[Optional[str]] = service_name @@ -4530,7 +4531,7 @@ class AzureNetworkVirtualApplianceSkuInstances: @define(eq=False, slots=False) -class AzureNetworkVirtualApplianceSku(MicrosoftResource): +class AzureNetworkVirtualApplianceSku(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_network_virtual_appliance_sku" _kind_display: ClassVar[str] = "Azure Network Virtual Appliance SKU" _kind_service: ClassVar[Optional[str]] = service_name @@ -4877,7 +4878,7 @@ class AzureNetworkRouteFilter(MicrosoftResource): @define(eq=False, slots=False) -class AzureNetworkSecurityPartnerProvider(MicrosoftResource): +class AzureNetworkSecurityPartnerProvider(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_network_security_partner_provider" _kind_display: ClassVar[str] = "Azure Network Security Partner Provider" _kind_service: ClassVar[Optional[str]] = service_name diff --git a/plugins/azure/fix_plugin_azure/resource/security.py b/plugins/azure/fix_plugin_azure/resource/security.py index e0dd85baac..a27c302b1e 100644 --- a/plugins/azure/fix_plugin_azure/resource/security.py +++ b/plugins/azure/fix_plugin_azure/resource/security.py @@ -5,7 +5,7 @@ from fix_plugin_azure.azure_client import AzureResourceSpec from fix_plugin_azure.resource.base import MicrosoftResource, AzureSystemData, GraphBuilder -from fixlib.baseresources import ModelReference +from fixlib.baseresources import ModelReference, PhantomBaseResource from fixlib.json_bender import Bender, S, Bend, ForallBend, F from fixlib.types import Json @@ -36,7 +36,7 @@ class AzureSecurityExtension: @define(eq=False, slots=False) -class AzureSecurityPricing(MicrosoftResource): +class AzureSecurityPricing(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_security_pricing" _kind_display: ClassVar[str] = "Azure Security Pricing" _kind_service: ClassVar[Optional[str]] = service_name @@ -92,7 +92,7 @@ class AzureAssessmentStatus: @define(eq=False, slots=False) -class AzureSecurityAssessment(MicrosoftResource): +class AzureSecurityAssessment(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_security_assessment" _kind_display: ClassVar[str] = "Azure Security Assessment" _kind_service: ClassVar[Optional[str]] = service_name diff --git a/plugins/azure/fix_plugin_azure/resource/storage.py b/plugins/azure/fix_plugin_azure/resource/storage.py index 8d47ffe699..d4a4e6ebcf 100644 --- a/plugins/azure/fix_plugin_azure/resource/storage.py +++ b/plugins/azure/fix_plugin_azure/resource/storage.py @@ -25,6 +25,7 @@ MetricName, MetricUnit, ModelReference, + PhantomBaseResource, ) from fixlib.json_bender import Bender, S, ForallBend, Bend from fixlib.types import Json @@ -188,7 +189,7 @@ class AzureStorageBlobContainer(MicrosoftResource, BaseBucket): @define(eq=False, slots=False) -class AzureStorageAccountDeleted(MicrosoftResource): +class AzureStorageAccountDeleted(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_storage_account_deleted" _kind_display: ClassVar[str] = "Azure Storage Account Deleted" _kind_service: ClassVar[Optional[str]] = service_name @@ -340,7 +341,7 @@ class AzureRestriction: @define(eq=False, slots=False) -class AzureStorageSku(MicrosoftResource): +class AzureStorageSku(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_storage_sku" _kind_display: ClassVar[str] = "Azure Storage SKU" _kind_service: ClassVar[Optional[str]] = service_name diff --git a/plugins/azure/test/collector_test.py b/plugins/azure/test/collector_test.py index 8c27407bd5..405b7f9c7d 100644 --- a/plugins/azure/test/collector_test.py +++ b/plugins/azure/test/collector_test.py @@ -31,6 +31,7 @@ def collector_with_graph( account=AzureSubscription(id="test", subscription_id="test"), credentials=credentials, core_feedback=CoreFeedback("test", "test", "test", Queue()), + filter_unused_resources=False, ) collector.graph = graph return collector @@ -44,11 +45,11 @@ def test_collect( azure_client: MicrosoftClient, ) -> None: subscription_collector = AzureSubscriptionCollector( - config, Cloud(id="azure"), azure_subscription, credentials, core_feedback + config, Cloud(id="azure"), azure_subscription, credentials, core_feedback, filter_unused_resources=False ) subscription_collector.collect() - assert len(subscription_collector.graph.nodes) == 588 - assert len(subscription_collector.graph.edges) == 977 + assert len(subscription_collector.graph.nodes) == 952 + assert len(subscription_collector.graph.edges) == 1341 graph_collector = MicrosoftGraphOrganizationCollector( config, Cloud(id="azure"), MicrosoftGraphOrganization(id="test", name="test"), credentials, core_feedback diff --git a/plugins/gcp/fix_plugin_gcp/resources/compute.py b/plugins/gcp/fix_plugin_gcp/resources/compute.py index 893543d315..5f5cd4ae3b 100644 --- a/plugins/gcp/fix_plugin_gcp/resources/compute.py +++ b/plugins/gcp/fix_plugin_gcp/resources/compute.py @@ -29,6 +29,7 @@ VolumeStatus, BaseInstance, InstanceStatus, + PhantomBaseResource, ) from fixlib.json_bender import Bender, S, Bend, ForallBend, MapDict, F, MapEnum, AsInt from fixlib.types import Json @@ -3705,7 +3706,7 @@ class GcpInterconnectLocationRegionInfo: @define(eq=False, slots=False) -class GcpInterconnectLocation(GcpResource): +class GcpInterconnectLocation(GcpResource, PhantomBaseResource): kind: ClassVar[str] = "gcp_interconnect_location" _kind_display: ClassVar[str] = "GCP Interconnect Location" _kind_description: ClassVar[str] = "A GCP Interconnect Location is a physical facility where Google Cloud Platform connects to external networks. It serves as a point of presence for establishing direct, private network connections between an organization's on-premises infrastructure and Google's network. This connection reduces latency, enhances security, and improves data transfer performance compared to public internet connections." # fmt: skip