cartography 0.111.0rc1__py3-none-any.whl → 0.113.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 (81) hide show
  1. cartography/_version.py +2 -2
  2. cartography/cli.py +57 -0
  3. cartography/config.py +24 -0
  4. cartography/data/indexes.cypher +0 -6
  5. cartography/data/jobs/analysis/keycloak_inheritance.json +30 -0
  6. cartography/intel/aws/apigateway.py +128 -17
  7. cartography/intel/aws/apigatewayv2.py +116 -0
  8. cartography/intel/aws/ec2/instances.py +3 -1
  9. cartography/intel/aws/ec2/network_interfaces.py +1 -1
  10. cartography/intel/aws/ec2/vpc_peerings.py +262 -125
  11. cartography/intel/aws/resources.py +2 -0
  12. cartography/intel/azure/__init__.py +35 -32
  13. cartography/intel/azure/subscription.py +2 -2
  14. cartography/intel/azure/tenant.py +39 -30
  15. cartography/intel/azure/util/credentials.py +49 -174
  16. cartography/intel/entra/__init__.py +47 -1
  17. cartography/intel/entra/applications.py +220 -170
  18. cartography/intel/entra/groups.py +41 -22
  19. cartography/intel/entra/ou.py +28 -20
  20. cartography/intel/entra/users.py +24 -18
  21. cartography/intel/gcp/__init__.py +32 -11
  22. cartography/intel/gcp/compute.py +47 -12
  23. cartography/intel/gcp/dns.py +82 -169
  24. cartography/intel/gcp/iam.py +66 -54
  25. cartography/intel/gcp/storage.py +75 -159
  26. cartography/intel/github/repos.py +19 -10
  27. cartography/intel/github/util.py +12 -0
  28. cartography/intel/keycloak/__init__.py +153 -0
  29. cartography/intel/keycloak/authenticationexecutions.py +322 -0
  30. cartography/intel/keycloak/authenticationflows.py +77 -0
  31. cartography/intel/keycloak/clients.py +187 -0
  32. cartography/intel/keycloak/groups.py +126 -0
  33. cartography/intel/keycloak/identityproviders.py +94 -0
  34. cartography/intel/keycloak/organizations.py +163 -0
  35. cartography/intel/keycloak/realms.py +61 -0
  36. cartography/intel/keycloak/roles.py +202 -0
  37. cartography/intel/keycloak/scopes.py +73 -0
  38. cartography/intel/keycloak/users.py +70 -0
  39. cartography/intel/keycloak/util.py +47 -0
  40. cartography/intel/kubernetes/__init__.py +26 -0
  41. cartography/intel/kubernetes/eks.py +402 -0
  42. cartography/intel/kubernetes/rbac.py +133 -0
  43. cartography/models/aws/apigateway/apigatewayintegration.py +79 -0
  44. cartography/models/aws/apigateway/apigatewaymethod.py +74 -0
  45. cartography/models/aws/apigatewayv2/__init__.py +0 -0
  46. cartography/models/aws/apigatewayv2/apigatewayv2.py +53 -0
  47. cartography/models/aws/ec2/vpc_peering.py +157 -0
  48. cartography/models/azure/principal.py +44 -0
  49. cartography/models/azure/tenant.py +20 -0
  50. cartography/models/gcp/dns.py +109 -0
  51. cartography/models/gcp/iam.py +3 -0
  52. cartography/models/gcp/storage/__init__.py +0 -0
  53. cartography/models/gcp/storage/bucket.py +119 -0
  54. cartography/models/keycloak/__init__.py +0 -0
  55. cartography/models/keycloak/authenticationexecution.py +160 -0
  56. cartography/models/keycloak/authenticationflow.py +54 -0
  57. cartography/models/keycloak/client.py +177 -0
  58. cartography/models/keycloak/group.py +101 -0
  59. cartography/models/keycloak/identityprovider.py +89 -0
  60. cartography/models/keycloak/organization.py +116 -0
  61. cartography/models/keycloak/organizationdomain.py +73 -0
  62. cartography/models/keycloak/realm.py +173 -0
  63. cartography/models/keycloak/role.py +126 -0
  64. cartography/models/keycloak/scope.py +73 -0
  65. cartography/models/keycloak/user.py +51 -0
  66. cartography/models/kubernetes/clusterrolebindings.py +40 -0
  67. cartography/models/kubernetes/groups.py +107 -0
  68. cartography/models/kubernetes/oidc.py +51 -0
  69. cartography/models/kubernetes/rolebindings.py +40 -0
  70. cartography/models/kubernetes/users.py +105 -0
  71. cartography/sync.py +2 -0
  72. cartography/util.py +10 -0
  73. {cartography-0.111.0rc1.dist-info → cartography-0.113.0.dist-info}/METADATA +9 -5
  74. {cartography-0.111.0rc1.dist-info → cartography-0.113.0.dist-info}/RECORD +78 -41
  75. cartography/data/jobs/cleanup/aws_import_vpc_peering_cleanup.json +0 -45
  76. cartography/data/jobs/cleanup/gcp_dns_cleanup.json +0 -29
  77. cartography/data/jobs/cleanup/gcp_storage_bucket_cleanup.json +0 -29
  78. {cartography-0.111.0rc1.dist-info → cartography-0.113.0.dist-info}/WHEEL +0 -0
  79. {cartography-0.111.0rc1.dist-info → cartography-0.113.0.dist-info}/entry_points.txt +0 -0
  80. {cartography-0.111.0rc1.dist-info → cartography-0.113.0.dist-info}/licenses/LICENSE +0 -0
  81. {cartography-0.111.0rc1.dist-info → cartography-0.113.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,79 @@
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 APIGatewayIntegrationNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ httpmethod: PropertyRef = PropertyRef("httpMethod")
18
+ integration_http_method: PropertyRef = PropertyRef("integrationHttpMethod")
19
+ resource_id: PropertyRef = PropertyRef("resourceId")
20
+ api_id: PropertyRef = PropertyRef("apiId")
21
+ type: PropertyRef = PropertyRef("type")
22
+ uri: PropertyRef = PropertyRef("uri")
23
+ connection_type: PropertyRef = PropertyRef("connectionType")
24
+ connection_id: PropertyRef = PropertyRef("connectionId")
25
+ credentials: PropertyRef = PropertyRef("credentials")
26
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class APIGatewayIntegrationToAPIGatewayResourceRelRelProperties(
31
+ CartographyRelProperties
32
+ ):
33
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class APIGatewayIntegrationToAPIGatewayResourceRel(CartographyRelSchema):
38
+ target_node_label: str = "APIGatewayResource"
39
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
40
+ {"id": PropertyRef("resourceId")},
41
+ )
42
+ direction: LinkDirection = LinkDirection.INWARD
43
+ rel_label: str = "HAS_INTEGRATION"
44
+ properties: APIGatewayIntegrationToAPIGatewayResourceRelRelProperties = (
45
+ APIGatewayIntegrationToAPIGatewayResourceRelRelProperties()
46
+ )
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class APIGatewayIntegrationToAWSAccountRelRelProperties(CartographyRelProperties):
51
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
52
+
53
+
54
+ @dataclass(frozen=True)
55
+ # (:APIGatewayIntegration)<-[:RESOURCE]-(:AWSAccount)
56
+ class APIGatewayIntegrationToAWSAccountRel(CartographyRelSchema):
57
+ target_node_label: str = "AWSAccount"
58
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
59
+ {"id": PropertyRef("AWS_ID", set_in_kwargs=True)},
60
+ )
61
+ direction: LinkDirection = LinkDirection.INWARD
62
+ rel_label: str = "RESOURCE"
63
+ properties: APIGatewayIntegrationToAWSAccountRelRelProperties = (
64
+ APIGatewayIntegrationToAWSAccountRelRelProperties()
65
+ )
66
+
67
+
68
+ @dataclass(frozen=True)
69
+ class APIGatewayIntegrationSchema(CartographyNodeSchema):
70
+ label: str = "APIGatewayIntegration"
71
+ properties: APIGatewayIntegrationNodeProperties = (
72
+ APIGatewayIntegrationNodeProperties()
73
+ )
74
+ sub_resource_relationship: APIGatewayIntegrationToAWSAccountRel = (
75
+ APIGatewayIntegrationToAWSAccountRel()
76
+ )
77
+ other_relationships: OtherRelationships = OtherRelationships(
78
+ [APIGatewayIntegrationToAPIGatewayResourceRel()],
79
+ )
@@ -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 APIGatewayMethodNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ httpmethod: PropertyRef = PropertyRef("httpMethod")
18
+ resource_id: PropertyRef = PropertyRef("resourceId")
19
+ api_id: PropertyRef = PropertyRef("apiId")
20
+ authorization_type: PropertyRef = PropertyRef("authorizationType")
21
+ authorizer_id: PropertyRef = PropertyRef("authorizerId")
22
+ request_validator_id: PropertyRef = PropertyRef("requestValidatorId")
23
+ operation_name: PropertyRef = PropertyRef("operationName")
24
+ api_key_required: PropertyRef = PropertyRef("apiKeyRequired")
25
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ class APIGatewayMethodToAPIGatewayResourceRelRelProperties(CartographyRelProperties):
30
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class APIGatewayMethodToAPIGatewayResourceRel(CartographyRelSchema):
35
+ target_node_label: str = "APIGatewayResource"
36
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
37
+ {"id": PropertyRef("resourceId")},
38
+ )
39
+ direction: LinkDirection = LinkDirection.INWARD
40
+ rel_label: str = "HAS_METHOD"
41
+ properties: APIGatewayMethodToAPIGatewayResourceRelRelProperties = (
42
+ APIGatewayMethodToAPIGatewayResourceRelRelProperties()
43
+ )
44
+
45
+
46
+ @dataclass(frozen=True)
47
+ class APIGatewayMethodToAWSAccountRelRelProperties(CartographyRelProperties):
48
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
49
+
50
+
51
+ @dataclass(frozen=True)
52
+ # (:APIGatewayMethod)<-[:RESOURCE]-(:AWSAccount)
53
+ class APIGatewayMethodToAWSAccountRel(CartographyRelSchema):
54
+ target_node_label: str = "AWSAccount"
55
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
56
+ {"id": PropertyRef("AWS_ID", set_in_kwargs=True)},
57
+ )
58
+ direction: LinkDirection = LinkDirection.INWARD
59
+ rel_label: str = "RESOURCE"
60
+ properties: APIGatewayMethodToAWSAccountRelRelProperties = (
61
+ APIGatewayMethodToAWSAccountRelRelProperties()
62
+ )
63
+
64
+
65
+ @dataclass(frozen=True)
66
+ class APIGatewayMethodSchema(CartographyNodeSchema):
67
+ label: str = "APIGatewayMethod"
68
+ properties: APIGatewayMethodNodeProperties = APIGatewayMethodNodeProperties()
69
+ sub_resource_relationship: APIGatewayMethodToAWSAccountRel = (
70
+ APIGatewayMethodToAWSAccountRel()
71
+ )
72
+ other_relationships: OtherRelationships = OtherRelationships(
73
+ [APIGatewayMethodToAPIGatewayResourceRel()],
74
+ )
File without changes
@@ -0,0 +1,53 @@
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 TargetNodeMatcher
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class APIGatewayV2APINodeProperties(CartographyNodeProperties):
15
+ id: PropertyRef = PropertyRef("id", extra_index=True)
16
+ name: PropertyRef = PropertyRef("name")
17
+ protocoltype: PropertyRef = PropertyRef("protocolType")
18
+ routeselectionexpression: PropertyRef = PropertyRef("routeSelectionExpression")
19
+ apikeyselectionexpression: PropertyRef = PropertyRef("apiKeySelectionExpression")
20
+ apiendpoint: PropertyRef = PropertyRef("apiEndpoint")
21
+ version: PropertyRef = PropertyRef("version")
22
+ createddate: PropertyRef = PropertyRef("createdDate")
23
+ description: PropertyRef = PropertyRef("description")
24
+ region: PropertyRef = PropertyRef("region", set_in_kwargs=True)
25
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ class APIGatewayV2APIToAWSAccountRelProperties(CartographyRelProperties):
30
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ # (:APIGatewayV2API)<-[:RESOURCE]-(:AWSAccount)
35
+ class APIGatewayV2APIToAWSAccountRel(CartographyRelSchema):
36
+ target_node_label: str = "AWSAccount"
37
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
38
+ {"id": PropertyRef("AWS_ID", set_in_kwargs=True)},
39
+ )
40
+ direction: LinkDirection = LinkDirection.INWARD
41
+ rel_label: str = "RESOURCE"
42
+ properties: APIGatewayV2APIToAWSAccountRelProperties = (
43
+ APIGatewayV2APIToAWSAccountRelProperties()
44
+ )
45
+
46
+
47
+ @dataclass(frozen=True)
48
+ class APIGatewayV2APISchema(CartographyNodeSchema):
49
+ label: str = "APIGatewayV2API"
50
+ properties: APIGatewayV2APINodeProperties = APIGatewayV2APINodeProperties()
51
+ sub_resource_relationship: APIGatewayV2APIToAWSAccountRel = (
52
+ APIGatewayV2APIToAWSAccountRel()
53
+ )
@@ -0,0 +1,157 @@
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 VPCPeeringNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("VpcPeeringConnectionId")
17
+ allow_dns_resolution_from_remote_vpc: PropertyRef = PropertyRef(
18
+ "AllowDnsResolutionFromRemoteVpc",
19
+ )
20
+ allow_egress_from_local_classic_link_to_remote_vpc: PropertyRef = PropertyRef(
21
+ "AllowEgressFromLocalClassicLinkToRemoteVpc",
22
+ )
23
+ allow_egress_from_local_vpc_to_remote_classic_link: PropertyRef = PropertyRef(
24
+ "AllowEgressFromLocalVpcToRemoteClassicLink",
25
+ )
26
+ requester_region: PropertyRef = PropertyRef("RequesterRegion")
27
+ accepter_region: PropertyRef = PropertyRef("AccepterRegion")
28
+ status_code: PropertyRef = PropertyRef("StatusCode")
29
+ status_message: PropertyRef = PropertyRef("StatusMessage")
30
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class PeeringToAccepterVpcRelProperties(CartographyRelProperties):
35
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
36
+
37
+
38
+ @dataclass(frozen=True)
39
+ class PeeringToAccepterVpcRel(CartographyRelSchema):
40
+ target_node_label: str = "AWSVpc"
41
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
42
+ {"id": PropertyRef("AccepterVpcId")},
43
+ )
44
+ direction: LinkDirection = LinkDirection.OUTWARD
45
+ rel_label: str = "ACCEPTER_VPC"
46
+ properties: PeeringToAccepterVpcRelProperties = PeeringToAccepterVpcRelProperties()
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class PeeringToRequesterVpcRelProperties(CartographyRelProperties):
51
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
52
+
53
+
54
+ @dataclass(frozen=True)
55
+ class PeeringToRequesterVpcRel(CartographyRelSchema):
56
+ target_node_label: str = "AWSVpc"
57
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
58
+ {"id": PropertyRef("RequesterVpcId")},
59
+ )
60
+ direction: LinkDirection = LinkDirection.OUTWARD
61
+ rel_label: str = "REQUESTER_VPC"
62
+ properties: PeeringToRequesterVpcRelProperties = (
63
+ PeeringToRequesterVpcRelProperties()
64
+ )
65
+
66
+
67
+ @dataclass(frozen=True)
68
+ class PeeringToAccepterCidrRelProperties(CartographyRelProperties):
69
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
70
+
71
+
72
+ @dataclass(frozen=True)
73
+ class PeeringToAccepterCidrRel(CartographyRelSchema):
74
+ target_node_label: str = "AWSCidrBlock"
75
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
76
+ {"id": PropertyRef("ACCEPTER_CIDR_BLOCK_IDS", one_to_many=True)},
77
+ )
78
+ direction: LinkDirection = LinkDirection.OUTWARD
79
+ rel_label: str = "ACCEPTER_CIDR"
80
+ properties: PeeringToAccepterCidrRelProperties = (
81
+ PeeringToAccepterCidrRelProperties()
82
+ )
83
+
84
+
85
+ @dataclass(frozen=True)
86
+ class PeeringToRequesterCidrRelProperties(CartographyRelProperties):
87
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
88
+
89
+
90
+ @dataclass(frozen=True)
91
+ class PeeringToRequesterCidrRel(CartographyRelSchema):
92
+ target_node_label: str = "AWSCidrBlock"
93
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
94
+ {"id": PropertyRef("REQUESTER_CIDR_BLOCK_IDS", one_to_many=True)},
95
+ )
96
+ direction: LinkDirection = LinkDirection.OUTWARD
97
+ rel_label: str = "REQUESTER_CIDR"
98
+ properties: PeeringToRequesterCidrRelProperties = (
99
+ PeeringToRequesterCidrRelProperties()
100
+ )
101
+
102
+
103
+ @dataclass(frozen=True)
104
+ class PeeringConnectionToAWSAccountRelProperties(CartographyRelProperties):
105
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
106
+
107
+
108
+ @dataclass(frozen=True)
109
+ class PeeringConnectionToAWSAccountRel(CartographyRelSchema):
110
+ target_node_label: str = "AWSAccount"
111
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
112
+ {"id": PropertyRef("AWS_ID", set_in_kwargs=True)}
113
+ )
114
+ direction: LinkDirection = LinkDirection.INWARD
115
+ rel_label: str = "RESOURCE"
116
+ properties: PeeringConnectionToAWSAccountRelProperties = (
117
+ PeeringConnectionToAWSAccountRelProperties()
118
+ )
119
+
120
+
121
+ # Composite Node Pattern: AWSAccount as known by VPC Peering
122
+ @dataclass(frozen=True)
123
+ class AWSAccountVPCPeeringNodeProperties(CartographyNodeProperties):
124
+ id: PropertyRef = PropertyRef("id")
125
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
126
+
127
+
128
+ @dataclass(frozen=True)
129
+ class AWSAccountVPCPeeringSchema(CartographyNodeSchema):
130
+ """
131
+ Composite schema to represent AWS Accounts as known by VPC Peering.
132
+ Targets the same 'AWSAccount' label as the primary AWS account schema,
133
+ allowing MERGE operations to combine properties from both sources.
134
+ """
135
+
136
+ label: str = "AWSAccount" # Same label as primary AWSAccount schema
137
+ properties: AWSAccountVPCPeeringNodeProperties = (
138
+ AWSAccountVPCPeeringNodeProperties()
139
+ )
140
+ # No sub_resource_relationship - accounts are top-level entities
141
+
142
+
143
+ @dataclass(frozen=True)
144
+ class AWSPeeringConnectionSchema(CartographyNodeSchema):
145
+ label: str = "AWSPeeringConnection"
146
+ properties: VPCPeeringNodeProperties = VPCPeeringNodeProperties()
147
+ sub_resource_relationship: PeeringConnectionToAWSAccountRel = (
148
+ PeeringConnectionToAWSAccountRel()
149
+ )
150
+ other_relationships: OtherRelationships = OtherRelationships(
151
+ [
152
+ PeeringToAccepterVpcRel(),
153
+ PeeringToRequesterVpcRel(),
154
+ PeeringToAccepterCidrRel(),
155
+ PeeringToRequesterCidrRel(),
156
+ ],
157
+ )
@@ -0,0 +1,44 @@
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
+ @dataclass(frozen=True)
17
+ class AzurePrincipalProperties(CartographyNodeProperties):
18
+ id: PropertyRef = PropertyRef("id")
19
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class AzurePrincipalToTenantRelProperties(CartographyRelProperties):
24
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ class AzurePrincipalToTenantRel(CartographyRelSchema):
29
+ target_node_label: str = "AzureTenant"
30
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
31
+ {"id": PropertyRef("TENANT_ID", set_in_kwargs=True)},
32
+ )
33
+ direction: LinkDirection = LinkDirection.INWARD
34
+ rel_label: str = "RESOURCE"
35
+ properties: AzurePrincipalToTenantRelProperties = (
36
+ AzurePrincipalToTenantRelProperties()
37
+ )
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class AzurePrincipalSchema(CartographyNodeSchema):
42
+ label: str = "AzurePrincipal"
43
+ properties: AzurePrincipalProperties = AzurePrincipalProperties()
44
+ sub_resource_relationship: AzurePrincipalToTenantRel = AzurePrincipalToTenantRel()
@@ -0,0 +1,20 @@
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
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+
11
+ @dataclass(frozen=True)
12
+ class AzureTenantProperties(CartographyNodeProperties):
13
+ id: PropertyRef = PropertyRef("id")
14
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
15
+
16
+
17
+ @dataclass(frozen=True)
18
+ class AzureTenantSchema(CartographyNodeSchema):
19
+ label: str = "AzureTenant"
20
+ properties: AzureTenantProperties = AzureTenantProperties()
@@ -0,0 +1,109 @@
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 OtherRelationships
12
+ from cartography.models.core.relationships import TargetNodeMatcher
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class GCPDNSZoneNodeProperties(CartographyNodeProperties):
17
+ id: PropertyRef = PropertyRef("id", extra_index=True)
18
+ name: PropertyRef = PropertyRef("name", extra_index=True)
19
+ dns_name: PropertyRef = PropertyRef("dns_name")
20
+ description: PropertyRef = PropertyRef("description")
21
+ visibility: PropertyRef = PropertyRef("visibility")
22
+ kind: PropertyRef = PropertyRef("kind")
23
+ nameservers: PropertyRef = PropertyRef("nameservers")
24
+ created_at: PropertyRef = PropertyRef("created_at")
25
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ class GCPDNSZoneToProjectRelProperties(CartographyRelProperties):
30
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ # (:GCPProject)-[:RESOURCE]->(:GCPDNSZone)
35
+ class GCPDNSZoneToProjectRel(CartographyRelSchema):
36
+ target_node_label: str = "GCPProject"
37
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
38
+ {"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)}
39
+ )
40
+ direction: LinkDirection = LinkDirection.INWARD
41
+ rel_label: str = "RESOURCE"
42
+ properties: GCPDNSZoneToProjectRelProperties = GCPDNSZoneToProjectRelProperties()
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ class GCPDNSZoneSchema(CartographyNodeSchema):
47
+ label: str = "GCPDNSZone"
48
+ properties: GCPDNSZoneNodeProperties = GCPDNSZoneNodeProperties()
49
+ extra_node_labels: ExtraNodeLabels = ExtraNodeLabels(["DNSZone"])
50
+ sub_resource_relationship: GCPDNSZoneToProjectRel = GCPDNSZoneToProjectRel()
51
+
52
+
53
+ @dataclass(frozen=True)
54
+ class GCPRecordSetNodeProperties(CartographyNodeProperties):
55
+ id: PropertyRef = PropertyRef("id", extra_index=True)
56
+ name: PropertyRef = PropertyRef("name", extra_index=True)
57
+ type: PropertyRef = PropertyRef("type")
58
+ ttl: PropertyRef = PropertyRef("ttl")
59
+ data: PropertyRef = PropertyRef("data")
60
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
61
+
62
+
63
+ @dataclass(frozen=True)
64
+ class GCPRecordSetToProjectRelProperties(CartographyRelProperties):
65
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
66
+
67
+
68
+ @dataclass(frozen=True)
69
+ # (:GCPProject)-[:RESOURCE]->(:GCPRecordSet)
70
+ class GCPRecordSetToProjectRel(CartographyRelSchema):
71
+ target_node_label: str = "GCPProject"
72
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
73
+ {"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)}
74
+ )
75
+ direction: LinkDirection = LinkDirection.INWARD
76
+ rel_label: str = "RESOURCE"
77
+ properties: GCPRecordSetToProjectRelProperties = (
78
+ GCPRecordSetToProjectRelProperties()
79
+ )
80
+
81
+
82
+ @dataclass(frozen=True)
83
+ class GCPRecordSetToZoneRelProperties(CartographyRelProperties):
84
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
85
+
86
+
87
+ @dataclass(frozen=True)
88
+ # (:GCPDNSZone)-[:HAS_RECORD]->(:GCPRecordSet)
89
+ class GCPRecordSetToZoneRel(CartographyRelSchema):
90
+ target_node_label: str = "GCPDNSZone"
91
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
92
+ {"id": PropertyRef("zone_id")}
93
+ )
94
+ direction: LinkDirection = LinkDirection.INWARD
95
+ rel_label: str = "HAS_RECORD"
96
+ properties: GCPRecordSetToZoneRelProperties = GCPRecordSetToZoneRelProperties()
97
+
98
+
99
+ @dataclass(frozen=True)
100
+ class GCPRecordSetSchema(CartographyNodeSchema):
101
+ label: str = "GCPRecordSet"
102
+ properties: GCPRecordSetNodeProperties = GCPRecordSetNodeProperties()
103
+ extra_node_labels: ExtraNodeLabels = ExtraNodeLabels(["DNSRecord"])
104
+ sub_resource_relationship: GCPRecordSetToProjectRel = GCPRecordSetToProjectRel()
105
+ other_relationships: OtherRelationships = OtherRelationships(
106
+ [
107
+ GCPRecordSetToZoneRel(),
108
+ ]
109
+ )
@@ -4,6 +4,7 @@ from dataclasses import dataclass
4
4
  from cartography.models.core.common import PropertyRef
5
5
  from cartography.models.core.nodes import CartographyNodeProperties
6
6
  from cartography.models.core.nodes import CartographyNodeSchema
7
+ from cartography.models.core.nodes import ExtraNodeLabels
7
8
  from cartography.models.core.relationships import CartographyRelProperties
8
9
  from cartography.models.core.relationships import CartographyRelSchema
9
10
  from cartography.models.core.relationships import LinkDirection
@@ -61,6 +62,8 @@ class GCPServiceAccountSchema(CartographyNodeSchema):
61
62
  label: str = "GCPServiceAccount"
62
63
  properties: GCPServiceAccountNodeProperties = GCPServiceAccountNodeProperties()
63
64
  sub_resource_relationship: GCPPrincipalToProject = GCPPrincipalToProject()
65
+ # Service accounts are principals; add shared label for cross-module queries
66
+ extra_node_labels: ExtraNodeLabels = ExtraNodeLabels(["GCPPrincipal"])
64
67
 
65
68
 
66
69
  @dataclass(frozen=True)
File without changes
@@ -0,0 +1,119 @@
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 GCPBucketNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id", extra_index=True)
17
+ # Preserve legacy field for compatibility with existing queries
18
+ bucket_id: PropertyRef = PropertyRef("bucket_id")
19
+ project_number: PropertyRef = PropertyRef("project_number")
20
+ self_link: PropertyRef = PropertyRef("self_link")
21
+ kind: PropertyRef = PropertyRef("kind")
22
+ location: PropertyRef = PropertyRef("location")
23
+ location_type: PropertyRef = PropertyRef("location_type")
24
+ meta_generation: PropertyRef = PropertyRef("meta_generation")
25
+ storage_class: PropertyRef = PropertyRef("storage_class")
26
+ time_created: PropertyRef = PropertyRef("time_created")
27
+ retention_period: PropertyRef = PropertyRef("retention_period")
28
+ iam_config_bucket_policy_only: PropertyRef = PropertyRef(
29
+ "iam_config_bucket_policy_only"
30
+ )
31
+ owner_entity: PropertyRef = PropertyRef("owner_entity")
32
+ owner_entity_id: PropertyRef = PropertyRef("owner_entity_id")
33
+ versioning_enabled: PropertyRef = PropertyRef("versioning_enabled")
34
+ log_bucket: PropertyRef = PropertyRef("log_bucket")
35
+ requester_pays: PropertyRef = PropertyRef("requester_pays")
36
+ default_kms_key_name: PropertyRef = PropertyRef("default_kms_key_name")
37
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class GCPBucketToProjectRelProperties(CartographyRelProperties):
42
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ # (:GCPProject)-[:RESOURCE]->(:GCPBucket)
47
+ class GCPBucketToProjectRel(CartographyRelSchema):
48
+ target_node_label: str = "GCPProject"
49
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
50
+ {"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)}
51
+ )
52
+ direction: LinkDirection = LinkDirection.INWARD
53
+ rel_label: str = "RESOURCE"
54
+ properties: GCPBucketToProjectRelProperties = GCPBucketToProjectRelProperties()
55
+
56
+
57
+ @dataclass(frozen=True)
58
+ class GCPBucketSchema(CartographyNodeSchema):
59
+ label: str = "GCPBucket"
60
+ properties: GCPBucketNodeProperties = GCPBucketNodeProperties()
61
+ sub_resource_relationship: GCPBucketToProjectRel = GCPBucketToProjectRel()
62
+
63
+
64
+ @dataclass(frozen=True)
65
+ class GCPBucketLabelNodeProperties(CartographyNodeProperties):
66
+ id: PropertyRef = PropertyRef("id", extra_index=True)
67
+ key: PropertyRef = PropertyRef("key", extra_index=True)
68
+ value: PropertyRef = PropertyRef("value")
69
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
70
+
71
+
72
+ @dataclass(frozen=True)
73
+ class GCPBucketLabelToProjectRelProperties(CartographyRelProperties):
74
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
75
+
76
+
77
+ @dataclass(frozen=True)
78
+ # (:GCPProject)-[:RESOURCE]->(:GCPBucketLabel)
79
+ class GCPBucketLabelToProjectRel(CartographyRelSchema):
80
+ target_node_label: str = "GCPProject"
81
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
82
+ {"id": PropertyRef("PROJECT_ID", set_in_kwargs=True)}
83
+ )
84
+ direction: LinkDirection = LinkDirection.INWARD
85
+ rel_label: str = "RESOURCE"
86
+ properties: GCPBucketLabelToProjectRelProperties = (
87
+ GCPBucketLabelToProjectRelProperties()
88
+ )
89
+
90
+
91
+ @dataclass(frozen=True)
92
+ class GCPBucketLabelToBucketRelProperties(CartographyRelProperties):
93
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
94
+
95
+
96
+ @dataclass(frozen=True)
97
+ # (:GCPBucket)-[:LABELED]->(:GCPBucketLabel)
98
+ class GCPBucketLabelToBucketRel(CartographyRelSchema):
99
+ target_node_label: str = "GCPBucket"
100
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
101
+ {"id": PropertyRef("bucket_id")}
102
+ )
103
+ direction: LinkDirection = LinkDirection.INWARD
104
+ rel_label: str = "LABELED"
105
+ properties: GCPBucketLabelToBucketRelProperties = (
106
+ GCPBucketLabelToBucketRelProperties()
107
+ )
108
+
109
+
110
+ @dataclass(frozen=True)
111
+ class GCPBucketLabelSchema(CartographyNodeSchema):
112
+ label: str = "GCPBucketLabel"
113
+ properties: GCPBucketLabelNodeProperties = GCPBucketLabelNodeProperties()
114
+ sub_resource_relationship: GCPBucketLabelToProjectRel = GCPBucketLabelToProjectRel()
115
+ other_relationships: OtherRelationships = OtherRelationships(
116
+ [
117
+ GCPBucketLabelToBucketRel(),
118
+ ]
119
+ )