cartography 0.111.0__py3-none-any.whl → 0.112.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.
- cartography/_version.py +2 -2
- cartography/cli.py +11 -0
- cartography/config.py +8 -0
- cartography/data/indexes.cypher +0 -2
- cartography/intel/aws/apigateway.py +126 -17
- cartography/intel/aws/ec2/instances.py +3 -1
- cartography/intel/aws/ec2/network_interfaces.py +1 -1
- cartography/intel/aws/ec2/vpc_peerings.py +262 -125
- cartography/intel/azure/__init__.py +35 -32
- cartography/intel/azure/subscription.py +2 -2
- cartography/intel/azure/tenant.py +39 -30
- cartography/intel/azure/util/credentials.py +49 -174
- cartography/intel/entra/__init__.py +47 -1
- cartography/intel/entra/applications.py +220 -170
- cartography/intel/entra/groups.py +41 -22
- cartography/intel/entra/ou.py +28 -20
- cartography/intel/entra/users.py +24 -18
- cartography/intel/gcp/__init__.py +25 -8
- cartography/intel/gcp/compute.py +47 -12
- cartography/intel/kubernetes/__init__.py +26 -0
- cartography/intel/kubernetes/eks.py +402 -0
- cartography/intel/kubernetes/rbac.py +133 -0
- cartography/models/aws/apigateway/apigatewayintegration.py +79 -0
- cartography/models/aws/apigateway/apigatewaymethod.py +74 -0
- cartography/models/aws/ec2/vpc_peering.py +157 -0
- cartography/models/azure/principal.py +44 -0
- cartography/models/azure/tenant.py +20 -0
- cartography/models/kubernetes/clusterrolebindings.py +40 -0
- cartography/models/kubernetes/groups.py +107 -0
- cartography/models/kubernetes/oidc.py +51 -0
- cartography/models/kubernetes/rolebindings.py +40 -0
- cartography/models/kubernetes/users.py +105 -0
- cartography/util.py +2 -0
- {cartography-0.111.0.dist-info → cartography-0.112.0.dist-info}/METADATA +8 -5
- {cartography-0.111.0.dist-info → cartography-0.112.0.dist-info}/RECORD +39 -31
- cartography/data/jobs/cleanup/aws_import_vpc_peering_cleanup.json +0 -45
- {cartography-0.111.0.dist-info → cartography-0.112.0.dist-info}/WHEEL +0 -0
- {cartography-0.111.0.dist-info → cartography-0.112.0.dist-info}/entry_points.txt +0 -0
- {cartography-0.111.0.dist-info → cartography-0.112.0.dist-info}/licenses/LICENSE +0 -0
- {cartography-0.111.0.dist-info → cartography-0.112.0.dist-info}/top_level.txt +0 -0
|
@@ -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
|
+
)
|
|
@@ -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()
|
|
@@ -21,6 +21,8 @@ class KubernetesClusterRoleBindingNodeProperties(CartographyNodeProperties):
|
|
|
21
21
|
role_name: PropertyRef = PropertyRef("role_name")
|
|
22
22
|
role_kind: PropertyRef = PropertyRef("role_kind")
|
|
23
23
|
service_account_ids: PropertyRef = PropertyRef("service_account_ids")
|
|
24
|
+
user_ids: PropertyRef = PropertyRef("user_ids")
|
|
25
|
+
group_ids: PropertyRef = PropertyRef("group_ids")
|
|
24
26
|
role_id: PropertyRef = PropertyRef("role_id")
|
|
25
27
|
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
26
28
|
|
|
@@ -81,6 +83,42 @@ class KubernetesClusterRoleBindingToClusterRoleRel(CartographyRelSchema):
|
|
|
81
83
|
)
|
|
82
84
|
|
|
83
85
|
|
|
86
|
+
@dataclass(frozen=True)
|
|
87
|
+
class KubernetesClusterRoleBindingToUserRelProperties(CartographyRelProperties):
|
|
88
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@dataclass(frozen=True)
|
|
92
|
+
class KubernetesClusterRoleBindingToUserRel(CartographyRelSchema):
|
|
93
|
+
target_node_label: str = "KubernetesUser"
|
|
94
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
95
|
+
{"id": PropertyRef("user_ids", one_to_many=True)}
|
|
96
|
+
)
|
|
97
|
+
direction: LinkDirection = LinkDirection.OUTWARD
|
|
98
|
+
rel_label: str = "SUBJECT"
|
|
99
|
+
properties: KubernetesClusterRoleBindingToUserRelProperties = (
|
|
100
|
+
KubernetesClusterRoleBindingToUserRelProperties()
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@dataclass(frozen=True)
|
|
105
|
+
class KubernetesClusterRoleBindingToGroupRelProperties(CartographyRelProperties):
|
|
106
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass(frozen=True)
|
|
110
|
+
class KubernetesClusterRoleBindingToGroupRel(CartographyRelSchema):
|
|
111
|
+
target_node_label: str = "KubernetesGroup"
|
|
112
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
113
|
+
{"id": PropertyRef("group_ids", one_to_many=True)}
|
|
114
|
+
)
|
|
115
|
+
direction: LinkDirection = LinkDirection.OUTWARD
|
|
116
|
+
rel_label: str = "SUBJECT"
|
|
117
|
+
properties: KubernetesClusterRoleBindingToGroupRelProperties = (
|
|
118
|
+
KubernetesClusterRoleBindingToGroupRelProperties()
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
84
122
|
@dataclass(frozen=True)
|
|
85
123
|
class KubernetesClusterRoleBindingSchema(CartographyNodeSchema):
|
|
86
124
|
label: str = "KubernetesClusterRoleBinding"
|
|
@@ -93,6 +131,8 @@ class KubernetesClusterRoleBindingSchema(CartographyNodeSchema):
|
|
|
93
131
|
other_relationships: OtherRelationships = OtherRelationships(
|
|
94
132
|
[
|
|
95
133
|
KubernetesClusterRoleBindingToServiceAccountRel(),
|
|
134
|
+
KubernetesClusterRoleBindingToUserRel(),
|
|
135
|
+
KubernetesClusterRoleBindingToGroupRel(),
|
|
96
136
|
KubernetesClusterRoleBindingToClusterRoleRel(),
|
|
97
137
|
]
|
|
98
138
|
)
|
|
@@ -0,0 +1,107 @@
|
|
|
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 KubernetesGroupNodeProperties(CartographyNodeProperties):
|
|
16
|
+
id: PropertyRef = PropertyRef("id")
|
|
17
|
+
name: PropertyRef = PropertyRef("name")
|
|
18
|
+
cluster_name: PropertyRef = PropertyRef("cluster_name")
|
|
19
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class KubernetesGroupToClusterRelProperties(CartographyRelProperties):
|
|
24
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class KubernetesGroupToClusterRel(CartographyRelSchema):
|
|
29
|
+
target_node_label: str = "KubernetesCluster"
|
|
30
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
31
|
+
{"id": PropertyRef("CLUSTER_ID", set_in_kwargs=True)}
|
|
32
|
+
)
|
|
33
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
34
|
+
rel_label: str = "RESOURCE"
|
|
35
|
+
properties: KubernetesGroupToClusterRelProperties = (
|
|
36
|
+
KubernetesGroupToClusterRelProperties()
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class KubernetesGroupToOktaGroupRelProperties(CartographyRelProperties):
|
|
42
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(frozen=True)
|
|
46
|
+
class KubernetesGroupToAWSRoleRelProperties(CartographyRelProperties):
|
|
47
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
class KubernetesGroupToAWSUserRelProperties(CartographyRelProperties):
|
|
52
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass(frozen=True)
|
|
56
|
+
class KubernetesGroupToOktaGroupRel(CartographyRelSchema):
|
|
57
|
+
target_node_label: str = "OktaGroup"
|
|
58
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
59
|
+
{"name": PropertyRef("name")}
|
|
60
|
+
)
|
|
61
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
62
|
+
rel_label: str = "MAPS_TO"
|
|
63
|
+
properties: KubernetesGroupToOktaGroupRelProperties = (
|
|
64
|
+
KubernetesGroupToOktaGroupRelProperties()
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass(frozen=True)
|
|
69
|
+
class KubernetesGroupToAWSRoleRel(CartographyRelSchema):
|
|
70
|
+
target_node_label: str = "AWSRole"
|
|
71
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
72
|
+
{"arn": PropertyRef("aws_role_arn")}
|
|
73
|
+
)
|
|
74
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
75
|
+
rel_label: str = "MAPS_TO"
|
|
76
|
+
properties: KubernetesGroupToAWSRoleRelProperties = (
|
|
77
|
+
KubernetesGroupToAWSRoleRelProperties()
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass(frozen=True)
|
|
82
|
+
class KubernetesGroupToAWSUserRel(CartographyRelSchema):
|
|
83
|
+
target_node_label: str = "AWSUser"
|
|
84
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
85
|
+
{"arn": PropertyRef("aws_user_arn")}
|
|
86
|
+
)
|
|
87
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
88
|
+
rel_label: str = "MAPS_TO"
|
|
89
|
+
properties: KubernetesGroupToAWSUserRelProperties = (
|
|
90
|
+
KubernetesGroupToAWSUserRelProperties()
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@dataclass(frozen=True)
|
|
95
|
+
class KubernetesGroupSchema(CartographyNodeSchema):
|
|
96
|
+
label: str = "KubernetesGroup"
|
|
97
|
+
properties: KubernetesGroupNodeProperties = KubernetesGroupNodeProperties()
|
|
98
|
+
sub_resource_relationship: KubernetesGroupToClusterRel = (
|
|
99
|
+
KubernetesGroupToClusterRel()
|
|
100
|
+
)
|
|
101
|
+
other_relationships: OtherRelationships = OtherRelationships(
|
|
102
|
+
[
|
|
103
|
+
KubernetesGroupToOktaGroupRel(),
|
|
104
|
+
KubernetesGroupToAWSRoleRel(),
|
|
105
|
+
KubernetesGroupToAWSUserRel(),
|
|
106
|
+
]
|
|
107
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
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 KubernetesOIDCProviderNodeProperties(CartographyNodeProperties):
|
|
15
|
+
id: PropertyRef = PropertyRef("id")
|
|
16
|
+
issuer_url: PropertyRef = PropertyRef("issuer_url")
|
|
17
|
+
cluster_name: PropertyRef = PropertyRef("cluster_name")
|
|
18
|
+
k8s_platform: PropertyRef = PropertyRef("k8s_platform")
|
|
19
|
+
client_id: PropertyRef = PropertyRef("client_id")
|
|
20
|
+
status: PropertyRef = PropertyRef("status")
|
|
21
|
+
name: PropertyRef = PropertyRef("name")
|
|
22
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class KubernetesOIDCProviderToClusterRelProperties(CartographyRelProperties):
|
|
27
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True)
|
|
31
|
+
class KubernetesOIDCProviderToClusterRel(CartographyRelSchema):
|
|
32
|
+
target_node_label: str = "KubernetesCluster"
|
|
33
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
34
|
+
{"id": PropertyRef("CLUSTER_ID", set_in_kwargs=True)}
|
|
35
|
+
)
|
|
36
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
37
|
+
rel_label: str = "TRUSTS"
|
|
38
|
+
properties: KubernetesOIDCProviderToClusterRelProperties = (
|
|
39
|
+
KubernetesOIDCProviderToClusterRelProperties()
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(frozen=True)
|
|
44
|
+
class KubernetesOIDCProviderSchema(CartographyNodeSchema):
|
|
45
|
+
label: str = "KubernetesOIDCProvider"
|
|
46
|
+
properties: KubernetesOIDCProviderNodeProperties = (
|
|
47
|
+
KubernetesOIDCProviderNodeProperties()
|
|
48
|
+
)
|
|
49
|
+
sub_resource_relationship: KubernetesOIDCProviderToClusterRel = (
|
|
50
|
+
KubernetesOIDCProviderToClusterRel()
|
|
51
|
+
)
|
|
@@ -22,6 +22,8 @@ class KubernetesRoleBindingNodeProperties(CartographyNodeProperties):
|
|
|
22
22
|
role_name: PropertyRef = PropertyRef("role_name")
|
|
23
23
|
role_kind: PropertyRef = PropertyRef("role_kind")
|
|
24
24
|
service_account_ids: PropertyRef = PropertyRef("service_account_ids")
|
|
25
|
+
user_ids: PropertyRef = PropertyRef("user_ids")
|
|
26
|
+
group_ids: PropertyRef = PropertyRef("group_ids")
|
|
25
27
|
role_id: PropertyRef = PropertyRef("role_id")
|
|
26
28
|
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
27
29
|
|
|
@@ -83,6 +85,42 @@ class KubernetesRoleBindingToServiceAccountRel(CartographyRelSchema):
|
|
|
83
85
|
)
|
|
84
86
|
|
|
85
87
|
|
|
88
|
+
@dataclass(frozen=True)
|
|
89
|
+
class KubernetesRoleBindingToUserRelProperties(CartographyRelProperties):
|
|
90
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(frozen=True)
|
|
94
|
+
class KubernetesRoleBindingToUserRel(CartographyRelSchema):
|
|
95
|
+
target_node_label: str = "KubernetesUser"
|
|
96
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
97
|
+
{"id": PropertyRef("user_ids", one_to_many=True)}
|
|
98
|
+
)
|
|
99
|
+
direction: LinkDirection = LinkDirection.OUTWARD
|
|
100
|
+
rel_label: str = "SUBJECT"
|
|
101
|
+
properties: KubernetesRoleBindingToUserRelProperties = (
|
|
102
|
+
KubernetesRoleBindingToUserRelProperties()
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@dataclass(frozen=True)
|
|
107
|
+
class KubernetesRoleBindingToGroupRelProperties(CartographyRelProperties):
|
|
108
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@dataclass(frozen=True)
|
|
112
|
+
class KubernetesRoleBindingToGroupRel(CartographyRelSchema):
|
|
113
|
+
target_node_label: str = "KubernetesGroup"
|
|
114
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
115
|
+
{"id": PropertyRef("group_ids", one_to_many=True)}
|
|
116
|
+
)
|
|
117
|
+
direction: LinkDirection = LinkDirection.OUTWARD
|
|
118
|
+
rel_label: str = "SUBJECT"
|
|
119
|
+
properties: KubernetesRoleBindingToGroupRelProperties = (
|
|
120
|
+
KubernetesRoleBindingToGroupRelProperties()
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
86
124
|
@dataclass(frozen=True)
|
|
87
125
|
class KubernetesRoleBindingToRoleRelProperties(CartographyRelProperties):
|
|
88
126
|
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
@@ -114,6 +152,8 @@ class KubernetesRoleBindingSchema(CartographyNodeSchema):
|
|
|
114
152
|
[
|
|
115
153
|
KubernetesRoleBindingToNamespaceRel(),
|
|
116
154
|
KubernetesRoleBindingToServiceAccountRel(),
|
|
155
|
+
KubernetesRoleBindingToUserRel(),
|
|
156
|
+
KubernetesRoleBindingToGroupRel(),
|
|
117
157
|
KubernetesRoleBindingToRoleRel(),
|
|
118
158
|
]
|
|
119
159
|
)
|
|
@@ -0,0 +1,105 @@
|
|
|
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 KubernetesUserNodeProperties(CartographyNodeProperties):
|
|
16
|
+
id: PropertyRef = PropertyRef("id")
|
|
17
|
+
name: PropertyRef = PropertyRef("name")
|
|
18
|
+
cluster_name: PropertyRef = PropertyRef("cluster_name")
|
|
19
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class KubernetesUserToClusterRelProperties(CartographyRelProperties):
|
|
24
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class KubernetesUserToClusterRel(CartographyRelSchema):
|
|
29
|
+
target_node_label: str = "KubernetesCluster"
|
|
30
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
31
|
+
{"id": PropertyRef("CLUSTER_ID", set_in_kwargs=True)}
|
|
32
|
+
)
|
|
33
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
34
|
+
rel_label: str = "RESOURCE"
|
|
35
|
+
properties: KubernetesUserToClusterRelProperties = (
|
|
36
|
+
KubernetesUserToClusterRelProperties()
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class KubernetesUserToOktaUserRelProperties(CartographyRelProperties):
|
|
42
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(frozen=True)
|
|
46
|
+
class KubernetesUserToAWSRoleRelProperties(CartographyRelProperties):
|
|
47
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
class KubernetesUserToAWSUserRelProperties(CartographyRelProperties):
|
|
52
|
+
lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass(frozen=True)
|
|
56
|
+
class KubernetesUserToOktaUserRel(CartographyRelSchema):
|
|
57
|
+
target_node_label: str = "OktaUser"
|
|
58
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
59
|
+
{"email": PropertyRef("name")}
|
|
60
|
+
)
|
|
61
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
62
|
+
rel_label: str = "MAPS_TO"
|
|
63
|
+
properties: KubernetesUserToOktaUserRelProperties = (
|
|
64
|
+
KubernetesUserToOktaUserRelProperties()
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass(frozen=True)
|
|
69
|
+
class KubernetesUserToAWSRoleRel(CartographyRelSchema):
|
|
70
|
+
target_node_label: str = "AWSRole"
|
|
71
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
72
|
+
{"arn": PropertyRef("aws_role_arn")}
|
|
73
|
+
)
|
|
74
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
75
|
+
rel_label: str = "MAPS_TO"
|
|
76
|
+
properties: KubernetesUserToAWSRoleRelProperties = (
|
|
77
|
+
KubernetesUserToAWSRoleRelProperties()
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass(frozen=True)
|
|
82
|
+
class KubernetesUserToAWSUserRel(CartographyRelSchema):
|
|
83
|
+
target_node_label: str = "AWSUser"
|
|
84
|
+
target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
|
|
85
|
+
{"arn": PropertyRef("aws_user_arn")}
|
|
86
|
+
)
|
|
87
|
+
direction: LinkDirection = LinkDirection.INWARD
|
|
88
|
+
rel_label: str = "MAPS_TO"
|
|
89
|
+
properties: KubernetesUserToAWSUserRelProperties = (
|
|
90
|
+
KubernetesUserToAWSUserRelProperties()
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@dataclass(frozen=True)
|
|
95
|
+
class KubernetesUserSchema(CartographyNodeSchema):
|
|
96
|
+
label: str = "KubernetesUser"
|
|
97
|
+
properties: KubernetesUserNodeProperties = KubernetesUserNodeProperties()
|
|
98
|
+
sub_resource_relationship: KubernetesUserToClusterRel = KubernetesUserToClusterRel()
|
|
99
|
+
other_relationships: OtherRelationships = OtherRelationships(
|
|
100
|
+
[
|
|
101
|
+
KubernetesUserToOktaUserRel(),
|
|
102
|
+
KubernetesUserToAWSRoleRel(),
|
|
103
|
+
KubernetesUserToAWSUserRel(),
|
|
104
|
+
]
|
|
105
|
+
)
|