cartography 0.110.0rc1__py3-none-any.whl → 0.111.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 (87) hide show
  1. cartography/_version.py +16 -3
  2. cartography/cli.py +46 -8
  3. cartography/config.py +16 -9
  4. cartography/data/indexes.cypher +0 -2
  5. cartography/data/jobs/analysis/aws_ec2_keypair_analysis.json +2 -2
  6. cartography/data/jobs/analysis/keycloak_inheritance.json +30 -0
  7. cartography/graph/querybuilder.py +70 -0
  8. cartography/intel/aws/apigateway.py +113 -4
  9. cartography/intel/aws/cognito.py +201 -0
  10. cartography/intel/aws/ec2/vpc.py +140 -124
  11. cartography/intel/aws/ecs.py +7 -1
  12. cartography/intel/aws/eventbridge.py +73 -0
  13. cartography/intel/aws/glue.py +64 -0
  14. cartography/intel/aws/kms.py +13 -1
  15. cartography/intel/aws/rds.py +105 -0
  16. cartography/intel/aws/resources.py +2 -0
  17. cartography/intel/aws/route53.py +3 -1
  18. cartography/intel/aws/s3.py +104 -0
  19. cartography/intel/entra/__init__.py +41 -43
  20. cartography/intel/entra/applications.py +2 -1
  21. cartography/intel/entra/ou.py +1 -1
  22. cartography/intel/github/__init__.py +21 -25
  23. cartography/intel/github/repos.py +32 -48
  24. cartography/intel/github/util.py +12 -0
  25. cartography/intel/keycloak/__init__.py +153 -0
  26. cartography/intel/keycloak/authenticationexecutions.py +322 -0
  27. cartography/intel/keycloak/authenticationflows.py +77 -0
  28. cartography/intel/keycloak/clients.py +187 -0
  29. cartography/intel/keycloak/groups.py +126 -0
  30. cartography/intel/keycloak/identityproviders.py +94 -0
  31. cartography/intel/keycloak/organizations.py +163 -0
  32. cartography/intel/keycloak/realms.py +61 -0
  33. cartography/intel/keycloak/roles.py +202 -0
  34. cartography/intel/keycloak/scopes.py +73 -0
  35. cartography/intel/keycloak/users.py +70 -0
  36. cartography/intel/keycloak/util.py +47 -0
  37. cartography/intel/kubernetes/__init__.py +4 -0
  38. cartography/intel/kubernetes/rbac.py +464 -0
  39. cartography/intel/kubernetes/util.py +17 -0
  40. cartography/models/aws/apigateway/apigatewaydeployment.py +74 -0
  41. cartography/models/aws/cognito/__init__.py +0 -0
  42. cartography/models/aws/cognito/identity_pool.py +70 -0
  43. cartography/models/aws/cognito/user_pool.py +47 -0
  44. cartography/models/aws/ec2/security_groups.py +1 -1
  45. cartography/models/aws/ec2/vpc.py +46 -0
  46. cartography/models/aws/ec2/vpc_cidr.py +102 -0
  47. cartography/models/aws/ecs/services.py +17 -0
  48. cartography/models/aws/ecs/tasks.py +1 -0
  49. cartography/models/aws/eventbridge/target.py +71 -0
  50. cartography/models/aws/glue/job.py +69 -0
  51. cartography/models/aws/rds/event_subscription.py +146 -0
  52. cartography/models/aws/route53/dnsrecord.py +21 -0
  53. cartography/models/github/dependencies.py +1 -2
  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 +98 -0
  67. cartography/models/kubernetes/clusterroles.py +52 -0
  68. cartography/models/kubernetes/rolebindings.py +119 -0
  69. cartography/models/kubernetes/roles.py +76 -0
  70. cartography/models/kubernetes/serviceaccounts.py +77 -0
  71. cartography/models/tailscale/device.py +1 -0
  72. cartography/sync.py +2 -0
  73. cartography/util.py +8 -0
  74. {cartography-0.110.0rc1.dist-info → cartography-0.111.0.dist-info}/METADATA +4 -3
  75. {cartography-0.110.0rc1.dist-info → cartography-0.111.0.dist-info}/RECORD +85 -46
  76. cartography/data/jobs/cleanup/aws_import_vpc_cleanup.json +0 -23
  77. cartography/intel/entra/resources.py +0 -20
  78. /cartography/data/jobs/{analysis → scoped_analysis}/aws_s3acl_analysis.json +0 -0
  79. /cartography/models/aws/{__init__.py → apigateway/__init__.py} +0 -0
  80. /cartography/models/aws/{apigateway.py → apigateway/apigateway.py} +0 -0
  81. /cartography/models/aws/{apigatewaycertificate.py → apigateway/apigatewaycertificate.py} +0 -0
  82. /cartography/models/aws/{apigatewayresource.py → apigateway/apigatewayresource.py} +0 -0
  83. /cartography/models/aws/{apigatewaystage.py → apigateway/apigatewaystage.py} +0 -0
  84. {cartography-0.110.0rc1.dist-info → cartography-0.111.0.dist-info}/WHEEL +0 -0
  85. {cartography-0.110.0rc1.dist-info → cartography-0.111.0.dist-info}/entry_points.txt +0 -0
  86. {cartography-0.110.0rc1.dist-info → cartography-0.111.0.dist-info}/licenses/LICENSE +0 -0
  87. {cartography-0.110.0rc1.dist-info → cartography-0.111.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,160 @@
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_source_node_matcher
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 SourceNodeMatcher
13
+ from cartography.models.core.relationships import TargetNodeMatcher
14
+
15
+
16
+ @dataclass(frozen=True)
17
+ class KeycloakAuthenticationExecutionNodeProperties(CartographyNodeProperties):
18
+ id: PropertyRef = PropertyRef("id")
19
+ display_name: PropertyRef = PropertyRef("displayName")
20
+ requirement: PropertyRef = PropertyRef("requirement")
21
+ description: PropertyRef = PropertyRef("description")
22
+ configurable: PropertyRef = PropertyRef("configurable")
23
+ authentication_flow: PropertyRef = PropertyRef("authenticationFlow")
24
+ provider_id: PropertyRef = PropertyRef("providerId")
25
+ flow_id: PropertyRef = PropertyRef("flowId")
26
+ level: PropertyRef = PropertyRef("level")
27
+ index: PropertyRef = PropertyRef("index")
28
+ priority: PropertyRef = PropertyRef("priority")
29
+ is_terminal_step: PropertyRef = PropertyRef("is_terminal_step")
30
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class KeycloakAuthenticationExecutionToRealmRelProperties(CartographyRelProperties):
35
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
36
+
37
+
38
+ @dataclass(frozen=True)
39
+ # (:KeycloakAuthenticationExecution)<-[:RESOURCE]-(:KeycloakRealm)
40
+ class KeycloakAuthenticationExecutionToRealmRel(CartographyRelSchema):
41
+ target_node_label: str = "KeycloakRealm"
42
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
43
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
44
+ )
45
+ direction: LinkDirection = LinkDirection.INWARD
46
+ rel_label: str = "RESOURCE"
47
+ properties: KeycloakAuthenticationExecutionToRealmRelProperties = (
48
+ KeycloakAuthenticationExecutionToRealmRelProperties()
49
+ )
50
+
51
+
52
+ @dataclass(frozen=True)
53
+ class ExecutionToFlowRelProperties(CartographyRelProperties):
54
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
55
+
56
+
57
+ @dataclass(frozen=True)
58
+ # (:KeycloakAuthenticationExecution)<-[:HAS_STEP]-(:KeycloakAuthenticationFlow)
59
+ class ExecutionToFlowRel(CartographyRelSchema):
60
+ target_node_label: str = "KeycloakAuthenticationFlow"
61
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
62
+ {
63
+ "alias": PropertyRef("_parent_flow"),
64
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
65
+ },
66
+ )
67
+ direction: LinkDirection = LinkDirection.INWARD
68
+ rel_label: str = "HAS_STEP"
69
+ properties: ExecutionToFlowRelProperties = ExecutionToFlowRelProperties()
70
+
71
+
72
+ @dataclass(frozen=True)
73
+ class ExecutionToExecutionRelProperties(CartographyRelProperties):
74
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
75
+
76
+
77
+ @dataclass(frozen=True)
78
+ # (:KeycloakAuthenticationExecution)<-[:HAS_STEP]-(:KeycloakAuthenticationExecution)
79
+ class ExecutionToExecutionRel(CartographyRelSchema):
80
+ target_node_label: str = "KeycloakAuthenticationExecution"
81
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
82
+ {"id": PropertyRef("_parent_subflow")},
83
+ )
84
+ direction: LinkDirection = LinkDirection.INWARD
85
+ rel_label: str = "HAS_STEP"
86
+ properties: ExecutionToExecutionRelProperties = ExecutionToExecutionRelProperties()
87
+
88
+
89
+ @dataclass(frozen=True)
90
+ class KeycloakAuthenticationExecutionSchema(CartographyNodeSchema):
91
+ label: str = "KeycloakAuthenticationExecution"
92
+ properties: KeycloakAuthenticationExecutionNodeProperties = (
93
+ KeycloakAuthenticationExecutionNodeProperties()
94
+ )
95
+ sub_resource_relationship: KeycloakAuthenticationExecutionToRealmRel = (
96
+ KeycloakAuthenticationExecutionToRealmRel()
97
+ )
98
+ other_relationships: OtherRelationships = OtherRelationships(
99
+ [ExecutionToFlowRel(), ExecutionToExecutionRel()]
100
+ )
101
+
102
+
103
+ # The following relationships are MatchLinks, they are used to modelize all the possible flows
104
+ @dataclass(frozen=True)
105
+ class ExecutionToExecutionStepRelProperties(CartographyRelProperties):
106
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
107
+ # Mandatory fields for MatchLinks
108
+ _sub_resource_label: PropertyRef = PropertyRef(
109
+ "_sub_resource_label", set_in_kwargs=True
110
+ )
111
+ _sub_resource_id: PropertyRef = PropertyRef("_sub_resource_id", set_in_kwargs=True)
112
+
113
+
114
+ @dataclass(frozen=True)
115
+ # (:KeycloakAuthenticationExecution)-[:NEXT_STEP]->(:KeycloakAuthenticationExecution)
116
+ class ExecutionToExecutionMatchLink(CartographyRelSchema):
117
+ source_node_label: str = "KeycloakAuthenticationExecution"
118
+ source_node_matcher: SourceNodeMatcher = make_source_node_matcher(
119
+ {"id": PropertyRef("source")},
120
+ )
121
+ target_node_label: str = "KeycloakAuthenticationExecution"
122
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
123
+ {"id": PropertyRef("target")},
124
+ )
125
+ direction: LinkDirection = LinkDirection.OUTWARD
126
+ rel_label: str = "NEXT_STEP"
127
+ properties: ExecutionToExecutionStepRelProperties = (
128
+ ExecutionToExecutionStepRelProperties()
129
+ )
130
+
131
+
132
+ @dataclass(frozen=True)
133
+ class ExecutionToFlowStepRelProperties(CartographyRelProperties):
134
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
135
+ # Mandatory fields for MatchLinks
136
+ _sub_resource_label: PropertyRef = PropertyRef(
137
+ "_sub_resource_label", set_in_kwargs=True
138
+ )
139
+ _sub_resource_id: PropertyRef = PropertyRef("_sub_resource_id", set_in_kwargs=True)
140
+
141
+
142
+ @dataclass(frozen=True)
143
+ # (:KeycloakAuthenticationFlow)-[:NEXT_STEP]->(:KeycloakAuthenticationExecution)
144
+ class ExecutionToFlowMatchLink(CartographyRelSchema):
145
+ source_node_label: str = "KeycloakAuthenticationExecution"
146
+ source_node_matcher: SourceNodeMatcher = make_source_node_matcher(
147
+ {"id": PropertyRef("execution_id")},
148
+ )
149
+ target_node_label: str = "KeycloakAuthenticationFlow"
150
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
151
+ {
152
+ "alias": PropertyRef("flow_name"),
153
+ "realm": PropertyRef(
154
+ "realm"
155
+ ), # We need to pass the realm to match the flow correctly as aliases can be shared across realms
156
+ },
157
+ )
158
+ direction: LinkDirection = LinkDirection.INWARD
159
+ rel_label: str = "NEXT_STEP"
160
+ properties: ExecutionToFlowStepRelProperties = ExecutionToFlowStepRelProperties()
@@ -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.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 KeycloakAuthenticationFlowNodeProperties(CartographyNodeProperties):
15
+ id: PropertyRef = PropertyRef("id")
16
+ alias: PropertyRef = PropertyRef("alias", extra_index=True)
17
+ description: PropertyRef = PropertyRef("description")
18
+ provider_id: PropertyRef = PropertyRef("providerId")
19
+ top_level: PropertyRef = PropertyRef("topLevel")
20
+ built_in: PropertyRef = PropertyRef("builtIn")
21
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
22
+ # We need to store the realm name because authentication flows are often referenced by name
23
+ # and not by id, so we need to be able to find the authentication flows by name (that is not unique across realms)
24
+ realm: PropertyRef = PropertyRef("REALM", set_in_kwargs=True, extra_index=True)
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ class KeycloakAuthenticationFlowToRealmRelProperties(CartographyRelProperties):
29
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ # (:KeycloakAuthenticationFlow)<-[:RESOURCE]-(:KeycloakRealm)
34
+ class KeycloakAuthenticationFlowToRealmRel(CartographyRelSchema):
35
+ target_node_label: str = "KeycloakRealm"
36
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
37
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
38
+ )
39
+ direction: LinkDirection = LinkDirection.INWARD
40
+ rel_label: str = "RESOURCE"
41
+ properties: KeycloakAuthenticationFlowToRealmRelProperties = (
42
+ KeycloakAuthenticationFlowToRealmRelProperties()
43
+ )
44
+
45
+
46
+ @dataclass(frozen=True)
47
+ class KeycloakAuthenticationFlowSchema(CartographyNodeSchema):
48
+ label: str = "KeycloakAuthenticationFlow"
49
+ properties: KeycloakAuthenticationFlowNodeProperties = (
50
+ KeycloakAuthenticationFlowNodeProperties()
51
+ )
52
+ sub_resource_relationship: KeycloakAuthenticationFlowToRealmRel = (
53
+ KeycloakAuthenticationFlowToRealmRel()
54
+ )
@@ -0,0 +1,177 @@
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_source_node_matcher
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 SourceNodeMatcher
13
+ from cartography.models.core.relationships import TargetNodeMatcher
14
+
15
+
16
+ @dataclass(frozen=True)
17
+ class KeycloakClientNodeProperties(CartographyNodeProperties):
18
+ id: PropertyRef = PropertyRef("id")
19
+ client_id: PropertyRef = PropertyRef("clientId")
20
+ name: PropertyRef = PropertyRef("name")
21
+ description: PropertyRef = PropertyRef("description")
22
+ type: PropertyRef = PropertyRef("type")
23
+ root_url: PropertyRef = PropertyRef("rootUrl")
24
+ admin_url: PropertyRef = PropertyRef("adminUrl")
25
+ base_url: PropertyRef = PropertyRef("baseUrl")
26
+ surrogate_auth_required: PropertyRef = PropertyRef("surrogateAuthRequired")
27
+ enabled: PropertyRef = PropertyRef("enabled")
28
+ always_display_in_console: PropertyRef = PropertyRef("alwaysDisplayInConsole")
29
+ client_authenticator_type: PropertyRef = PropertyRef("clientAuthenticatorType")
30
+ registration_access_token: PropertyRef = PropertyRef("registrationAccessToken")
31
+ not_before: PropertyRef = PropertyRef("notBefore")
32
+ bearer_only: PropertyRef = PropertyRef("bearerOnly")
33
+ consent_required: PropertyRef = PropertyRef("consentRequired")
34
+ standard_flow_enabled: PropertyRef = PropertyRef("standardFlowEnabled")
35
+ implicit_flow_enabled: PropertyRef = PropertyRef("implicitFlowEnabled")
36
+ direct_access_grants_enabled: PropertyRef = PropertyRef("directAccessGrantsEnabled")
37
+ service_accounts_enabled: PropertyRef = PropertyRef("serviceAccountsEnabled")
38
+ authorization_services_enabled: PropertyRef = PropertyRef(
39
+ "authorizationServicesEnabled"
40
+ )
41
+ direct_grants_only: PropertyRef = PropertyRef("directGrantsOnly")
42
+ public_client: PropertyRef = PropertyRef("publicClient")
43
+ frontchannel_logout: PropertyRef = PropertyRef("frontchannelLogout")
44
+ protocol: PropertyRef = PropertyRef("protocol")
45
+ full_scope_allowed: PropertyRef = PropertyRef("fullScopeAllowed")
46
+ node_re_registration_timeout: PropertyRef = PropertyRef("nodeReRegistrationTimeout")
47
+ client_template: PropertyRef = PropertyRef("clientTemplate")
48
+ use_template_config: PropertyRef = PropertyRef("useTemplateConfig")
49
+ use_template_scope: PropertyRef = PropertyRef("useTemplateScope")
50
+ use_template_mappers: PropertyRef = PropertyRef("useTemplateMappers")
51
+ origin: PropertyRef = PropertyRef("origin")
52
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class KeycloakClientToRealmRelProperties(CartographyRelProperties):
57
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ # (:KeycloakClient)<-[:RESOURCE]-(:KeycloakRealm)
62
+ class KeycloakClientToRealmRel(CartographyRelSchema):
63
+ target_node_label: str = "KeycloakRealm"
64
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
65
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
66
+ )
67
+ direction: LinkDirection = LinkDirection.INWARD
68
+ rel_label: str = "RESOURCE"
69
+ properties: KeycloakClientToRealmRelProperties = (
70
+ KeycloakClientToRealmRelProperties()
71
+ )
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class KeycloakClientToDefaultScopeRelProperties(CartographyRelProperties):
76
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
77
+
78
+
79
+ @dataclass(frozen=True)
80
+ # (:KeycloakClient)-[:HAS_DEFAULT_SCOPE]->(:KeycloakScope)
81
+ class KeycloakClientToDefaultScopeRel(CartographyRelSchema):
82
+ target_node_label: str = "KeycloakScope"
83
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
84
+ {
85
+ "name": PropertyRef("defaultClientScopes", one_to_many=True),
86
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
87
+ },
88
+ )
89
+ direction: LinkDirection = LinkDirection.OUTWARD
90
+ rel_label: str = "HAS_DEFAULT_SCOPE"
91
+ properties: KeycloakClientToDefaultScopeRelProperties = (
92
+ KeycloakClientToDefaultScopeRelProperties()
93
+ )
94
+
95
+
96
+ @dataclass(frozen=True)
97
+ class KeycloakClientToOptionalScopeRelProperties(CartographyRelProperties):
98
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
99
+
100
+
101
+ @dataclass(frozen=True)
102
+ # (:KeycloakClient)-[:HAS_OPTIONAL_SCOPE]->(:KeycloakScope)
103
+ class KeycloakClientToOptionalScopeRel(CartographyRelSchema):
104
+ target_node_label: str = "KeycloakScope"
105
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
106
+ {
107
+ "name": PropertyRef("optionalClientScopes", one_to_many=True),
108
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
109
+ },
110
+ )
111
+ direction: LinkDirection = LinkDirection.OUTWARD
112
+ rel_label: str = "HAS_OPTIONAL_SCOPE"
113
+ properties: KeycloakClientToOptionalScopeRelProperties = (
114
+ KeycloakClientToOptionalScopeRelProperties()
115
+ )
116
+
117
+
118
+ @dataclass(frozen=True)
119
+ class KeycloakClientToServiceAccountRelProperties(CartographyRelProperties):
120
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
121
+
122
+
123
+ @dataclass(frozen=True)
124
+ # (:KeycloakClient)-[:HAS_SERVICE_ACCOUNT]->(:KeycloakUser)
125
+ class KeycloakClientToServiceAccountRel(CartographyRelSchema):
126
+ target_node_label: str = "KeycloakUser"
127
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
128
+ {"id": PropertyRef("_service_account_user_id")},
129
+ )
130
+ direction: LinkDirection = LinkDirection.OUTWARD
131
+ rel_label: str = "HAS_SERVICE_ACCOUNT"
132
+ properties: KeycloakClientToServiceAccountRelProperties = (
133
+ KeycloakClientToServiceAccountRelProperties()
134
+ )
135
+
136
+
137
+ @dataclass(frozen=True)
138
+ class KeycloakClientSchema(CartographyNodeSchema):
139
+ label: str = "KeycloakClient"
140
+ properties: KeycloakClientNodeProperties = KeycloakClientNodeProperties()
141
+ sub_resource_relationship: KeycloakClientToRealmRel = KeycloakClientToRealmRel()
142
+ other_relationships: OtherRelationships = OtherRelationships(
143
+ [
144
+ KeycloakClientToDefaultScopeRel(),
145
+ KeycloakClientToOptionalScopeRel(),
146
+ KeycloakClientToServiceAccountRel(),
147
+ ]
148
+ )
149
+
150
+
151
+ # The following relationships are MatchLinks to enable batch loading with rel properties
152
+ @dataclass(frozen=True)
153
+ class KeycloakClientToFlowRelProperties(CartographyRelProperties):
154
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
155
+ flow_name: PropertyRef = PropertyRef("flow_name")
156
+ default_flow: PropertyRef = PropertyRef("default_flow")
157
+ # Mandatory fields for MatchLinks
158
+ _sub_resource_label: PropertyRef = PropertyRef(
159
+ "_sub_resource_label", set_in_kwargs=True
160
+ )
161
+ _sub_resource_id: PropertyRef = PropertyRef("_sub_resource_id", set_in_kwargs=True)
162
+
163
+
164
+ @dataclass(frozen=True)
165
+ # (:KeycloakClient)-[:USES]->(:KeycloakAuthenticationFlow)
166
+ class KeycloakClientToFlowMatchLink(CartographyRelSchema):
167
+ source_node_label: str = "KeycloakClient"
168
+ source_node_matcher: SourceNodeMatcher = make_source_node_matcher(
169
+ {"id": PropertyRef("client_id")},
170
+ )
171
+ target_node_label: str = "KeycloakAuthenticationFlow"
172
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
173
+ {"id": PropertyRef("flow_id")},
174
+ )
175
+ direction: LinkDirection = LinkDirection.OUTWARD
176
+ rel_label: str = "USES"
177
+ properties: KeycloakClientToFlowRelProperties = KeycloakClientToFlowRelProperties()
@@ -0,0 +1,101 @@
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 KeycloakGroupNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name")
18
+ description: PropertyRef = PropertyRef("description")
19
+ path: PropertyRef = PropertyRef("path")
20
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class KeycloakGroupToRealmRelProperties(CartographyRelProperties):
25
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ # (:KeycloakGroup)<-[:RESOURCE]-(:KeycloakRealm)
30
+ class KeycloakGroupToRealmRel(CartographyRelSchema):
31
+ target_node_label: str = "KeycloakRealm"
32
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
33
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
34
+ )
35
+ direction: LinkDirection = LinkDirection.INWARD
36
+ rel_label: str = "RESOURCE"
37
+ properties: KeycloakGroupToRealmRelProperties = KeycloakGroupToRealmRelProperties()
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class KeycloakGroupToGroupRelProperties(CartographyRelProperties):
42
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ # (:KeycloakGroup)-[:SUBGROUP_OF]->(:KeycloakGroup)
47
+ class KeycloakGroupToGroupRel(CartographyRelSchema):
48
+ target_node_label: str = "KeycloakGroup"
49
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
50
+ {"id": PropertyRef("parentId")},
51
+ )
52
+ direction: LinkDirection = LinkDirection.OUTWARD
53
+ rel_label: str = "SUBGROUP_OF"
54
+ properties: KeycloakGroupToGroupRelProperties = KeycloakGroupToGroupRelProperties()
55
+
56
+
57
+ @dataclass(frozen=True)
58
+ class KeycloakGroupToUserRelProperties(CartographyRelProperties):
59
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
60
+
61
+
62
+ @dataclass(frozen=True)
63
+ # (:KeycloakGroup)<-[:MEMBER_OF]-(:KeycloakUser)
64
+ class KeycloakGroupToUserRel(CartographyRelSchema):
65
+ target_node_label: str = "KeycloakUser"
66
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
67
+ {"id": PropertyRef("_member_ids", one_to_many=True)},
68
+ )
69
+ direction: LinkDirection = LinkDirection.INWARD
70
+ rel_label: str = "MEMBER_OF"
71
+ properties: KeycloakGroupToUserRelProperties = KeycloakGroupToUserRelProperties()
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class KeycloakGroupToRoleRelProperties(CartographyRelProperties):
76
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
77
+
78
+
79
+ @dataclass(frozen=True)
80
+ # (:KeycloakGroup)-[:GRANTS]->(:KeycloakRole)
81
+ class KeycloakGroupToRoleRel(CartographyRelSchema):
82
+ target_node_label: str = "KeycloakRole"
83
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
84
+ {
85
+ "name": PropertyRef("_roles", one_to_many=True),
86
+ "realm": PropertyRef("REALM", set_in_kwargs=True),
87
+ },
88
+ )
89
+ direction: LinkDirection = LinkDirection.OUTWARD
90
+ rel_label: str = "GRANTS"
91
+ properties: KeycloakGroupToRoleRelProperties = KeycloakGroupToRoleRelProperties()
92
+
93
+
94
+ @dataclass(frozen=True)
95
+ class KeycloakGroupSchema(CartographyNodeSchema):
96
+ label: str = "KeycloakGroup"
97
+ properties: KeycloakGroupNodeProperties = KeycloakGroupNodeProperties()
98
+ sub_resource_relationship: KeycloakGroupToRealmRel = KeycloakGroupToRealmRel()
99
+ other_relationships: OtherRelationships = OtherRelationships(
100
+ [KeycloakGroupToGroupRel(), KeycloakGroupToUserRel(), KeycloakGroupToRoleRel()]
101
+ )
@@ -0,0 +1,89 @@
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 KeycloakIdentityProviderNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("internalId")
17
+ alias: PropertyRef = PropertyRef("alias", extra_index=True)
18
+ display_name: PropertyRef = PropertyRef("displayName")
19
+ provider_id: PropertyRef = PropertyRef("providerId")
20
+ enabled: PropertyRef = PropertyRef("enabled")
21
+ update_profile_first_login_mode: PropertyRef = PropertyRef(
22
+ "updateProfileFirstLoginMode"
23
+ )
24
+ trust_email: PropertyRef = PropertyRef("trustEmail")
25
+ store_token: PropertyRef = PropertyRef("storeToken")
26
+ add_read_token_role_on_create: PropertyRef = PropertyRef("addReadTokenRoleOnCreate")
27
+ authenticate_by_default: PropertyRef = PropertyRef("authenticateByDefault")
28
+ link_only: PropertyRef = PropertyRef("linkOnly")
29
+ hide_on_login: PropertyRef = PropertyRef("hideOnLogin")
30
+ first_broker_login_flow_alias: PropertyRef = PropertyRef(
31
+ "firstBrokerLoginFlowAlias"
32
+ )
33
+ post_broker_login_flow_alias: PropertyRef = PropertyRef("postBrokerLoginFlowAlias")
34
+ organization_id: PropertyRef = PropertyRef("organizationId")
35
+ update_profile_first_login: PropertyRef = PropertyRef("updateProfileFirstLogin")
36
+ config_sync_mode: PropertyRef = PropertyRef("config.syncMode")
37
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
38
+
39
+
40
+ @dataclass(frozen=True)
41
+ class KeycloakIdentityProviderToRealmRelProperties(CartographyRelProperties):
42
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ # (:KeycloakIdentityProvider)<-[:RESOURCE]-(:KeycloakRealm)
47
+ class KeycloakIdentityProviderToRealmRel(CartographyRelSchema):
48
+ target_node_label: str = "KeycloakRealm"
49
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
50
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
51
+ )
52
+ direction: LinkDirection = LinkDirection.INWARD
53
+ rel_label: str = "RESOURCE"
54
+ properties: KeycloakIdentityProviderToRealmRelProperties = (
55
+ KeycloakIdentityProviderToRealmRelProperties()
56
+ )
57
+
58
+
59
+ @dataclass(frozen=True)
60
+ class KeycloakIdentityProviderToUserRelProperties(CartographyRelProperties):
61
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
62
+
63
+
64
+ @dataclass(frozen=True)
65
+ # (:KeycloakIdentityProvider)<-[:HAS_IDENTITY]-(:KeycloakUser)
66
+ class KeycloakIdentityProviderToUserRel(CartographyRelSchema):
67
+ target_node_label: str = "KeycloakUser"
68
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
69
+ {"id": PropertyRef("_member_ids", one_to_many=True)},
70
+ )
71
+ direction: LinkDirection = LinkDirection.INWARD
72
+ rel_label: str = "HAS_IDENTITY"
73
+ properties: KeycloakIdentityProviderToUserRelProperties = (
74
+ KeycloakIdentityProviderToUserRelProperties()
75
+ )
76
+
77
+
78
+ @dataclass(frozen=True)
79
+ class KeycloakIdentityProviderSchema(CartographyNodeSchema):
80
+ label: str = "KeycloakIdentityProvider"
81
+ properties: KeycloakIdentityProviderNodeProperties = (
82
+ KeycloakIdentityProviderNodeProperties()
83
+ )
84
+ sub_resource_relationship: KeycloakIdentityProviderToRealmRel = (
85
+ KeycloakIdentityProviderToRealmRel()
86
+ )
87
+ other_relationships: OtherRelationships = OtherRelationships(
88
+ [KeycloakIdentityProviderToUserRel()],
89
+ )