cartography 0.112.0__py3-none-any.whl → 0.114.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cartography might be problematic. Click here for more details.

Files changed (82) hide show
  1. cartography/_version.py +2 -2
  2. cartography/cli.py +8 -0
  3. cartography/config.py +4 -0
  4. cartography/data/indexes.cypher +0 -31
  5. cartography/intel/aws/apigatewayv2.py +116 -0
  6. cartography/intel/aws/iam.py +741 -492
  7. cartography/intel/aws/organizations.py +7 -8
  8. cartography/intel/aws/permission_relationships.py +4 -16
  9. cartography/intel/aws/resources.py +2 -0
  10. cartography/intel/azure/__init__.py +16 -0
  11. cartography/intel/azure/app_service.py +105 -0
  12. cartography/intel/azure/functions.py +124 -0
  13. cartography/intel/entra/__init__.py +31 -0
  14. cartography/intel/entra/app_role_assignments.py +277 -0
  15. cartography/intel/entra/applications.py +4 -238
  16. cartography/intel/entra/federation/__init__.py +0 -0
  17. cartography/intel/entra/federation/aws_identity_center.py +77 -0
  18. cartography/intel/entra/service_principals.py +217 -0
  19. cartography/intel/gcp/__init__.py +136 -436
  20. cartography/intel/gcp/clients.py +65 -0
  21. cartography/intel/gcp/compute.py +18 -44
  22. cartography/intel/gcp/crm/__init__.py +0 -0
  23. cartography/intel/gcp/crm/folders.py +108 -0
  24. cartography/intel/gcp/crm/orgs.py +65 -0
  25. cartography/intel/gcp/crm/projects.py +109 -0
  26. cartography/intel/gcp/dns.py +82 -169
  27. cartography/intel/gcp/gke.py +72 -113
  28. cartography/intel/gcp/iam.py +66 -54
  29. cartography/intel/gcp/storage.py +75 -159
  30. cartography/intel/github/__init__.py +41 -0
  31. cartography/intel/github/commits.py +423 -0
  32. cartography/intel/github/repos.py +73 -39
  33. cartography/models/aws/apigatewayv2/__init__.py +0 -0
  34. cartography/models/aws/apigatewayv2/apigatewayv2.py +53 -0
  35. cartography/models/aws/iam/access_key.py +103 -0
  36. cartography/models/aws/iam/account_role.py +24 -0
  37. cartography/models/aws/iam/federated_principal.py +60 -0
  38. cartography/models/aws/iam/group.py +60 -0
  39. cartography/models/aws/iam/group_membership.py +26 -0
  40. cartography/models/aws/iam/inline_policy.py +78 -0
  41. cartography/models/aws/iam/managed_policy.py +51 -0
  42. cartography/models/aws/iam/policy_statement.py +57 -0
  43. cartography/models/aws/iam/role.py +83 -0
  44. cartography/models/aws/iam/root_principal.py +52 -0
  45. cartography/models/aws/iam/service_principal.py +30 -0
  46. cartography/models/aws/iam/sts_assumerole_allow.py +38 -0
  47. cartography/models/aws/iam/user.py +54 -0
  48. cartography/models/azure/__init__.py +0 -0
  49. cartography/models/azure/app_service.py +59 -0
  50. cartography/models/azure/function_app.py +59 -0
  51. cartography/models/entra/entra_user_to_aws_sso.py +41 -0
  52. cartography/models/entra/service_principal.py +104 -0
  53. cartography/models/gcp/compute/subnet.py +74 -0
  54. cartography/models/gcp/crm/__init__.py +0 -0
  55. cartography/models/gcp/crm/folders.py +98 -0
  56. cartography/models/gcp/crm/organizations.py +21 -0
  57. cartography/models/gcp/crm/projects.py +100 -0
  58. cartography/models/gcp/dns.py +109 -0
  59. cartography/models/gcp/gke.py +69 -0
  60. cartography/models/gcp/iam.py +3 -0
  61. cartography/models/gcp/storage/__init__.py +0 -0
  62. cartography/models/gcp/storage/bucket.py +119 -0
  63. cartography/models/github/commits.py +63 -0
  64. {cartography-0.112.0.dist-info → cartography-0.114.0.dist-info}/METADATA +7 -5
  65. {cartography-0.112.0.dist-info → cartography-0.114.0.dist-info}/RECORD +69 -39
  66. cartography/data/jobs/cleanup/aws_import_account_access_key_cleanup.json +0 -17
  67. cartography/data/jobs/cleanup/aws_import_groups_cleanup.json +0 -13
  68. cartography/data/jobs/cleanup/aws_import_principals_cleanup.json +0 -30
  69. cartography/data/jobs/cleanup/aws_import_roles_cleanup.json +0 -13
  70. cartography/data/jobs/cleanup/aws_import_users_cleanup.json +0 -8
  71. cartography/data/jobs/cleanup/gcp_compute_vpc_subnet_cleanup.json +0 -35
  72. cartography/data/jobs/cleanup/gcp_crm_folder_cleanup.json +0 -23
  73. cartography/data/jobs/cleanup/gcp_crm_organization_cleanup.json +0 -17
  74. cartography/data/jobs/cleanup/gcp_crm_project_cleanup.json +0 -23
  75. cartography/data/jobs/cleanup/gcp_dns_cleanup.json +0 -29
  76. cartography/data/jobs/cleanup/gcp_gke_cluster_cleanup.json +0 -17
  77. cartography/data/jobs/cleanup/gcp_storage_bucket_cleanup.json +0 -29
  78. cartography/intel/gcp/crm.py +0 -355
  79. {cartography-0.112.0.dist-info → cartography-0.114.0.dist-info}/WHEEL +0 -0
  80. {cartography-0.112.0.dist-info → cartography-0.114.0.dist-info}/entry_points.txt +0 -0
  81. {cartography-0.112.0.dist-info → cartography-0.114.0.dist-info}/licenses/LICENSE +0 -0
  82. {cartography-0.112.0.dist-info → cartography-0.114.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,54 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.nodes import ExtraNodeLabels
7
+ from cartography.models.core.relationships import CartographyRelProperties
8
+ from cartography.models.core.relationships import CartographyRelSchema
9
+ from cartography.models.core.relationships import LinkDirection
10
+ from cartography.models.core.relationships import make_target_node_matcher
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class AWSUserNodeProperties(CartographyNodeProperties):
16
+ # Required unique identifier
17
+ id: PropertyRef = PropertyRef("arn")
18
+ arn: PropertyRef = PropertyRef("arn", extra_index=True)
19
+
20
+ # Automatic fields (set by cartography)
21
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
22
+
23
+ # Business fields from AWS IAM users
24
+ userid: PropertyRef = PropertyRef("userid")
25
+ name: PropertyRef = PropertyRef("name")
26
+ path: PropertyRef = PropertyRef("path")
27
+ createdate: PropertyRef = PropertyRef("createdate")
28
+ passwordlastused: PropertyRef = PropertyRef("passwordlastused")
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class AWSUserToAWSAccountRelProperties(CartographyRelProperties):
33
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class AWSUserToAWSAccountRel(CartographyRelSchema):
38
+ target_node_label: str = "AWSAccount"
39
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
40
+ {
41
+ "id": PropertyRef("AWS_ID", set_in_kwargs=True),
42
+ }
43
+ )
44
+ direction: LinkDirection = LinkDirection.INWARD
45
+ rel_label: str = "RESOURCE"
46
+ properties: AWSUserToAWSAccountRelProperties = AWSUserToAWSAccountRelProperties()
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class AWSUserSchema(CartographyNodeSchema):
51
+ label: str = "AWSUser"
52
+ properties: AWSUserNodeProperties = AWSUserNodeProperties()
53
+ sub_resource_relationship: AWSUserToAWSAccountRel = AWSUserToAWSAccountRel()
54
+ extra_node_labels: ExtraNodeLabels = ExtraNodeLabels(["AWSPrincipal"])
File without changes
@@ -0,0 +1,59 @@
1
+ import logging
2
+ from dataclasses import dataclass
3
+
4
+ from cartography.models.core.common import PropertyRef
5
+ from cartography.models.core.nodes import CartographyNodeProperties
6
+ from cartography.models.core.nodes import CartographyNodeSchema
7
+ from cartography.models.core.relationships import CartographyRelProperties
8
+ from cartography.models.core.relationships import CartographyRelSchema
9
+ from cartography.models.core.relationships import LinkDirection
10
+ from cartography.models.core.relationships import make_target_node_matcher
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ # --- Node Definitions ---
17
+ @dataclass(frozen=True)
18
+ class AzureAppServiceProperties(CartographyNodeProperties):
19
+ id: PropertyRef = PropertyRef("id")
20
+ name: PropertyRef = PropertyRef("name")
21
+ kind: PropertyRef = PropertyRef("kind")
22
+ location: PropertyRef = PropertyRef("location")
23
+ state: PropertyRef = PropertyRef("state")
24
+ default_host_name: PropertyRef = PropertyRef("default_host_name")
25
+ https_only: PropertyRef = PropertyRef("https_only")
26
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
27
+
28
+
29
+ # --- Relationship Definitions ---
30
+ @dataclass(frozen=True)
31
+ class AzureAppServiceToSubscriptionRelProperties(CartographyRelProperties):
32
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
33
+
34
+
35
+ @dataclass(frozen=True)
36
+ class AzureAppServiceToSubscriptionRel(CartographyRelSchema):
37
+ target_node_label: str = "AzureSubscription"
38
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
39
+ {"id": PropertyRef("AZURE_SUBSCRIPTION_ID", set_in_kwargs=True)},
40
+ )
41
+ direction: LinkDirection = LinkDirection.INWARD
42
+ rel_label: str = "RESOURCE"
43
+ properties: AzureAppServiceToSubscriptionRelProperties = (
44
+ AzureAppServiceToSubscriptionRelProperties()
45
+ )
46
+
47
+
48
+ # --- Main Schema ---
49
+ @dataclass(frozen=True)
50
+ class AzureAppServiceSchema(CartographyNodeSchema):
51
+ """
52
+ The schema for an Azure App Service.
53
+ """
54
+
55
+ label: str = "AzureAppService"
56
+ properties: AzureAppServiceProperties = AzureAppServiceProperties()
57
+ sub_resource_relationship: AzureAppServiceToSubscriptionRel = (
58
+ AzureAppServiceToSubscriptionRel()
59
+ )
@@ -0,0 +1,59 @@
1
+ import logging
2
+ from dataclasses import dataclass
3
+
4
+ from cartography.models.core.common import PropertyRef
5
+ from cartography.models.core.nodes import CartographyNodeProperties
6
+ from cartography.models.core.nodes import CartographyNodeSchema
7
+ from cartography.models.core.relationships import CartographyRelProperties
8
+ from cartography.models.core.relationships import CartographyRelSchema
9
+ from cartography.models.core.relationships import LinkDirection
10
+ from cartography.models.core.relationships import make_target_node_matcher
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ # --- Node Definitions ---
17
+ @dataclass(frozen=True)
18
+ class AzureFunctionAppProperties(CartographyNodeProperties):
19
+ id: PropertyRef = PropertyRef("id")
20
+ name: PropertyRef = PropertyRef("name")
21
+ kind: PropertyRef = PropertyRef("kind")
22
+ location: PropertyRef = PropertyRef("location")
23
+ state: PropertyRef = PropertyRef("state")
24
+ default_host_name: PropertyRef = PropertyRef("default_host_name")
25
+ https_only: PropertyRef = PropertyRef("https_only")
26
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
27
+
28
+
29
+ # --- Relationship Definitions ---
30
+ @dataclass(frozen=True)
31
+ class AzureFunctionAppToSubscriptionRelProperties(CartographyRelProperties):
32
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
33
+
34
+
35
+ @dataclass(frozen=True)
36
+ class AzureFunctionAppToSubscriptionRel(CartographyRelSchema):
37
+ target_node_label: str = "AzureSubscription"
38
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
39
+ {"id": PropertyRef("AZURE_SUBSCRIPTION_ID", set_in_kwargs=True)},
40
+ )
41
+ direction: LinkDirection = LinkDirection.INWARD
42
+ rel_label: str = "RESOURCE"
43
+ properties: AzureFunctionAppToSubscriptionRelProperties = (
44
+ AzureFunctionAppToSubscriptionRelProperties()
45
+ )
46
+
47
+
48
+ # --- Main Schema ---
49
+ @dataclass(frozen=True)
50
+ class AzureFunctionAppSchema(CartographyNodeSchema):
51
+ """
52
+ The schema for an Azure Function App.
53
+ """
54
+
55
+ label: str = "AzureFunctionApp"
56
+ properties: AzureFunctionAppProperties = AzureFunctionAppProperties()
57
+ sub_resource_relationship: AzureFunctionAppToSubscriptionRel = (
58
+ AzureFunctionAppToSubscriptionRel()
59
+ )
@@ -0,0 +1,41 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.relationships import CartographyRelProperties
5
+ from cartography.models.core.relationships import CartographyRelSchema
6
+ from cartography.models.core.relationships import LinkDirection
7
+ from cartography.models.core.relationships import make_source_node_matcher
8
+ from cartography.models.core.relationships import make_target_node_matcher
9
+ from cartography.models.core.relationships import SourceNodeMatcher
10
+ from cartography.models.core.relationships import TargetNodeMatcher
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class EntraUserToAWSSSOUserRelProperties(CartographyRelProperties):
15
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
16
+ _sub_resource_label: PropertyRef = PropertyRef(
17
+ "_sub_resource_label", set_in_kwargs=True
18
+ )
19
+ _sub_resource_id: PropertyRef = PropertyRef("_sub_resource_id", set_in_kwargs=True)
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class EntraUserToAWSSSOUserMatchLink(CartographyRelSchema):
24
+ target_node_label: str = "AWSSSOUser"
25
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
26
+ {
27
+ "user_name": PropertyRef("aws_user_name"),
28
+ "identity_store_id": PropertyRef("identity_store_id"),
29
+ }
30
+ )
31
+ source_node_label: str = "EntraUser"
32
+ source_node_matcher: SourceNodeMatcher = make_source_node_matcher(
33
+ {
34
+ "user_principal_name": PropertyRef("entra_user_principal_name"),
35
+ }
36
+ )
37
+ direction: LinkDirection = LinkDirection.OUTWARD
38
+ rel_label: str = "CAN_SIGN_ON_TO"
39
+ properties: EntraUserToAWSSSOUserRelProperties = (
40
+ EntraUserToAWSSSOUserRelProperties()
41
+ )
@@ -0,0 +1,104 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class EntraServicePrincipalNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ app_id: PropertyRef = PropertyRef("app_id")
18
+ display_name: PropertyRef = PropertyRef("display_name")
19
+ reply_urls: PropertyRef = PropertyRef("reply_urls")
20
+ aws_identity_center_instance_id: PropertyRef = PropertyRef(
21
+ "aws_identity_center_instance_id"
22
+ )
23
+ account_enabled: PropertyRef = PropertyRef("account_enabled")
24
+ service_principal_type: PropertyRef = PropertyRef("service_principal_type")
25
+ app_owner_organization_id: PropertyRef = PropertyRef("app_owner_organization_id")
26
+ login_url: PropertyRef = PropertyRef("login_url")
27
+ preferred_single_sign_on_mode: PropertyRef = PropertyRef(
28
+ "preferred_single_sign_on_mode"
29
+ )
30
+ preferred_token_signing_key_thumbprint: PropertyRef = PropertyRef(
31
+ "preferred_token_signing_key_thumbprint"
32
+ )
33
+ sign_in_audience: PropertyRef = PropertyRef("sign_in_audience")
34
+ tags: PropertyRef = PropertyRef("tags")
35
+ token_encryption_key_id: PropertyRef = PropertyRef("token_encryption_key_id")
36
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
37
+
38
+
39
+ @dataclass(frozen=True)
40
+ class EntraServicePrincipalToTenantRelProperties(CartographyRelProperties):
41
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
42
+
43
+
44
+ @dataclass(frozen=True)
45
+ class EntraServicePrincipalToTenantRel(CartographyRelSchema):
46
+ target_node_label: str = "EntraTenant"
47
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
48
+ {"id": PropertyRef("TENANT_ID", set_in_kwargs=True)},
49
+ )
50
+ direction: LinkDirection = LinkDirection.INWARD
51
+ rel_label: str = "RESOURCE"
52
+ properties: EntraServicePrincipalToTenantRelProperties = (
53
+ EntraServicePrincipalToTenantRelProperties()
54
+ )
55
+
56
+
57
+ @dataclass(frozen=True)
58
+ class ServicePrincipalToApplicationRelProperties(CartographyRelProperties):
59
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
60
+
61
+
62
+ @dataclass(frozen=True)
63
+ class ServicePrincipalToApplicationRel(CartographyRelSchema):
64
+ target_node_label: str = "EntraApplication"
65
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
66
+ {"app_id": PropertyRef("app_id")},
67
+ )
68
+ direction: LinkDirection = LinkDirection.INWARD
69
+ rel_label: str = "SERVICE_PRINCIPAL"
70
+ properties: ServicePrincipalToApplicationRelProperties = (
71
+ ServicePrincipalToApplicationRelProperties()
72
+ )
73
+
74
+
75
+ @dataclass(frozen=True)
76
+ class ServicePrincipalToAWSIdentityCenterRelProperties(CartographyRelProperties):
77
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
78
+
79
+
80
+ @dataclass(frozen=True)
81
+ class ServicePrincipalToAWSIdentityCenterRel(CartographyRelSchema):
82
+ target_node_label: str = "AWSIdentityCenter"
83
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
84
+ {"identity_store_id": PropertyRef("aws_identity_center_instance_id")},
85
+ )
86
+ direction: LinkDirection = LinkDirection.OUTWARD
87
+ rel_label: str = "FEDERATES_TO"
88
+ properties: ServicePrincipalToAWSIdentityCenterRelProperties = (
89
+ ServicePrincipalToAWSIdentityCenterRelProperties()
90
+ )
91
+
92
+
93
+ @dataclass(frozen=True)
94
+ class EntraServicePrincipalSchema(CartographyNodeSchema):
95
+ label: str = "EntraServicePrincipal"
96
+ properties: EntraServicePrincipalNodeProperties = (
97
+ EntraServicePrincipalNodeProperties()
98
+ )
99
+ sub_resource_relationship: EntraServicePrincipalToTenantRel = (
100
+ EntraServicePrincipalToTenantRel()
101
+ )
102
+ other_relationships: OtherRelationships = OtherRelationships(
103
+ [ServicePrincipalToApplicationRel(), ServicePrincipalToAWSIdentityCenterRel()]
104
+ )
@@ -0,0 +1,74 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class GCPSubnetNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("partial_uri", extra_index=True)
17
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
18
+ partial_uri: PropertyRef = PropertyRef("partial_uri")
19
+ self_link: PropertyRef = PropertyRef("self_link")
20
+ name: PropertyRef = PropertyRef("name", extra_index=True)
21
+ project_id: PropertyRef = PropertyRef("project_id")
22
+ region: PropertyRef = PropertyRef("region")
23
+ gateway_address: PropertyRef = PropertyRef("gateway_address")
24
+ ip_cidr_range: PropertyRef = PropertyRef("ip_cidr_range")
25
+ private_ip_google_access: PropertyRef = PropertyRef("private_ip_google_access")
26
+ vpc_partial_uri: PropertyRef = PropertyRef("vpc_partial_uri")
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class GCPSubnetToProjectRelProperties(CartographyRelProperties):
31
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class GCPSubnetToProjectRel(CartographyRelSchema):
36
+ target_node_label: str = "GCPProject"
37
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
38
+ {
39
+ "id": PropertyRef("PROJECT_ID", set_in_kwargs=True),
40
+ }
41
+ )
42
+ direction: LinkDirection = LinkDirection.INWARD
43
+ rel_label: str = "RESOURCE"
44
+ properties: GCPSubnetToProjectRelProperties = GCPSubnetToProjectRelProperties()
45
+
46
+
47
+ @dataclass(frozen=True)
48
+ class GCPSubnetToVpcRelProperties(CartographyRelProperties):
49
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
50
+
51
+
52
+ @dataclass(frozen=True)
53
+ class GCPSubnetToVpcRel(CartographyRelSchema):
54
+ target_node_label: str = "GCPVpc"
55
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
56
+ {
57
+ "id": PropertyRef("vpc_partial_uri"),
58
+ }
59
+ )
60
+ direction: LinkDirection = LinkDirection.INWARD
61
+ rel_label: str = "HAS"
62
+ properties: GCPSubnetToVpcRelProperties = GCPSubnetToVpcRelProperties()
63
+
64
+
65
+ @dataclass(frozen=True)
66
+ class GCPSubnetSchema(CartographyNodeSchema):
67
+ label: str = "GCPSubnet"
68
+ properties: GCPSubnetNodeProperties = GCPSubnetNodeProperties()
69
+ sub_resource_relationship: GCPSubnetToProjectRel = GCPSubnetToProjectRel()
70
+ other_relationships: OtherRelationships = OtherRelationships(
71
+ [
72
+ GCPSubnetToVpcRel(),
73
+ ]
74
+ )
File without changes
@@ -0,0 +1,98 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class GCPFolderNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef(
17
+ "name"
18
+ ) # Use full folder name as ID (e.g., "folders/1414")
19
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
20
+ foldername: PropertyRef = PropertyRef("name")
21
+ displayname: PropertyRef = PropertyRef("displayName")
22
+ lifecyclestate: PropertyRef = PropertyRef("lifecycleState")
23
+ parent_org: PropertyRef = PropertyRef(
24
+ "parent_org"
25
+ ) # Will be set to org ID if parent is org
26
+ parent_folder: PropertyRef = PropertyRef(
27
+ "parent_folder"
28
+ ) # Will be set to folder ID if parent is folder
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class GCPFolderToOrgParentRelProperties(CartographyRelProperties):
33
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class GCPFolderToOrgParentRel(CartographyRelSchema):
38
+ """Relationship when folder's parent is an organization"""
39
+
40
+ target_node_label: str = "GCPOrganization"
41
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
42
+ {"id": PropertyRef("parent_org")},
43
+ )
44
+ direction: LinkDirection = LinkDirection.OUTWARD
45
+ rel_label: str = "PARENT"
46
+ properties: GCPFolderToOrgParentRelProperties = GCPFolderToOrgParentRelProperties()
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class GCPFolderToFolderParentRelProperties(CartographyRelProperties):
51
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
52
+
53
+
54
+ @dataclass(frozen=True)
55
+ class GCPFolderToFolderParentRel(CartographyRelSchema):
56
+ """Relationship when folder's parent is another folder"""
57
+
58
+ target_node_label: str = "GCPFolder"
59
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
60
+ {"id": PropertyRef("parent_folder")},
61
+ )
62
+ direction: LinkDirection = LinkDirection.OUTWARD
63
+ rel_label: str = "PARENT"
64
+ properties: GCPFolderToFolderParentRelProperties = (
65
+ GCPFolderToFolderParentRelProperties()
66
+ )
67
+
68
+
69
+ @dataclass(frozen=True)
70
+ class GCPFolderToOrganizationRelProperties(CartographyRelProperties):
71
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class GCPFolderToOrganizationRel(CartographyRelSchema):
76
+ target_node_label: str = "GCPOrganization"
77
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
78
+ {"id": PropertyRef("ORG_RESOURCE_NAME", set_in_kwargs=True)},
79
+ )
80
+ direction: LinkDirection = LinkDirection.INWARD
81
+ rel_label: str = "RESOURCE"
82
+ properties: GCPFolderToOrganizationRelProperties = (
83
+ GCPFolderToOrganizationRelProperties()
84
+ )
85
+
86
+
87
+ @dataclass(frozen=True)
88
+ class GCPFolderSchema(CartographyNodeSchema):
89
+ label: str = "GCPFolder"
90
+ properties: GCPFolderNodeProperties = GCPFolderNodeProperties()
91
+ # Organization owns the folder as a resource
92
+ sub_resource_relationship: GCPFolderToOrganizationRel = GCPFolderToOrganizationRel()
93
+ other_relationships: OtherRelationships = OtherRelationships(
94
+ [
95
+ GCPFolderToOrgParentRel(),
96
+ GCPFolderToFolderParentRel(),
97
+ ]
98
+ )
@@ -0,0 +1,21 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class GCPOrganizationNodeProperties(CartographyNodeProperties):
10
+ id: PropertyRef = PropertyRef("id")
11
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
12
+ orgname: PropertyRef = PropertyRef("name")
13
+ displayname: PropertyRef = PropertyRef("displayName")
14
+ lifecyclestate: PropertyRef = PropertyRef("lifecycleState")
15
+
16
+
17
+ @dataclass(frozen=True)
18
+ class GCPOrganizationSchema(CartographyNodeSchema):
19
+ label: str = "GCPOrganization"
20
+ properties: GCPOrganizationNodeProperties = GCPOrganizationNodeProperties()
21
+ # sub_resource_relationship is None by default - Organizations are top-level resources
@@ -0,0 +1,100 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class GCPProjectNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("projectId")
17
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
18
+ projectnumber: PropertyRef = PropertyRef("projectNumber", extra_index=True)
19
+ displayname: PropertyRef = PropertyRef("name")
20
+ lifecyclestate: PropertyRef = PropertyRef("lifecycleState")
21
+ parent_org: PropertyRef = PropertyRef(
22
+ "parent_org"
23
+ ) # Will be set to org ID if parent is org
24
+ parent_folder: PropertyRef = PropertyRef(
25
+ "parent_folder"
26
+ ) # Will be set to folder ID if parent is folder
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class GCPProjectToOrgParentRelProperties(CartographyRelProperties):
31
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class GCPProjectToOrgParentRel(CartographyRelSchema):
36
+ """Relationship when project's parent is an organization"""
37
+
38
+ target_node_label: str = "GCPOrganization"
39
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
40
+ {"id": PropertyRef("parent_org")},
41
+ )
42
+ direction: LinkDirection = LinkDirection.OUTWARD
43
+ rel_label: str = "PARENT"
44
+ properties: GCPProjectToOrgParentRelProperties = (
45
+ GCPProjectToOrgParentRelProperties()
46
+ )
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class GCPProjectToFolderParentRelProperties(CartographyRelProperties):
51
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
52
+
53
+
54
+ @dataclass(frozen=True)
55
+ class GCPProjectToFolderParentRel(CartographyRelSchema):
56
+ """Relationship when project's parent is a folder"""
57
+
58
+ target_node_label: str = "GCPFolder"
59
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
60
+ {"id": PropertyRef("parent_folder")},
61
+ )
62
+ direction: LinkDirection = LinkDirection.OUTWARD
63
+ rel_label: str = "PARENT"
64
+ properties: GCPProjectToFolderParentRelProperties = (
65
+ GCPProjectToFolderParentRelProperties()
66
+ )
67
+
68
+
69
+ @dataclass(frozen=True)
70
+ class GCPProjectToOrganizationRelProperties(CartographyRelProperties):
71
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class GCPProjectToOrganizationRel(CartographyRelSchema):
76
+ target_node_label: str = "GCPOrganization"
77
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
78
+ {"id": PropertyRef("ORG_RESOURCE_NAME", set_in_kwargs=True)},
79
+ )
80
+ direction: LinkDirection = LinkDirection.INWARD
81
+ rel_label: str = "RESOURCE"
82
+ properties: GCPProjectToOrganizationRelProperties = (
83
+ GCPProjectToOrganizationRelProperties()
84
+ )
85
+
86
+
87
+ @dataclass(frozen=True)
88
+ class GCPProjectSchema(CartographyNodeSchema):
89
+ label: str = "GCPProject"
90
+ properties: GCPProjectNodeProperties = GCPProjectNodeProperties()
91
+ # Organization owns the project as a resource
92
+ sub_resource_relationship: GCPProjectToOrganizationRel = (
93
+ GCPProjectToOrganizationRel()
94
+ )
95
+ other_relationships: OtherRelationships = OtherRelationships(
96
+ [
97
+ GCPProjectToOrgParentRel(),
98
+ GCPProjectToFolderParentRel(),
99
+ ]
100
+ )