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,116 @@
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 KeycloakOrganizationNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name")
18
+ alias: PropertyRef = PropertyRef("alias")
19
+ enabled: PropertyRef = PropertyRef("enabled")
20
+ description: PropertyRef = PropertyRef("description")
21
+ redirect_url: PropertyRef = PropertyRef("redirectUrl")
22
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class KeycloakOrganizationToRealmRelProperties(CartographyRelProperties):
27
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ # (:KeycloakOrganization)<-[:RESOURCE]-(:KeycloakRealm)
32
+ class KeycloakOrganizationToRealmRel(CartographyRelSchema):
33
+ target_node_label: str = "KeycloakRealm"
34
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
35
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
36
+ )
37
+ direction: LinkDirection = LinkDirection.INWARD
38
+ rel_label: str = "RESOURCE"
39
+ properties: KeycloakOrganizationToRealmRelProperties = (
40
+ KeycloakOrganizationToRealmRelProperties()
41
+ )
42
+
43
+
44
+ @dataclass(frozen=True)
45
+ class KeycloakOrganizationToManagedUserRelProperties(CartographyRelProperties):
46
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ # (:KeycloakOrganization)<-[:MANAGED_MEMBER_OF]-(:KeycloakUser)
51
+ class KeycloakOrganizationToManagedUserRel(CartographyRelSchema):
52
+ target_node_label: str = "KeycloakUser"
53
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
54
+ {"id": PropertyRef("_managed_members", one_to_many=True)},
55
+ )
56
+ direction: LinkDirection = LinkDirection.INWARD
57
+ rel_label: str = "MANAGED_MEMBER_OF"
58
+ properties: KeycloakOrganizationToManagedUserRelProperties = (
59
+ KeycloakOrganizationToManagedUserRelProperties()
60
+ )
61
+
62
+
63
+ @dataclass(frozen=True)
64
+ class KeycloakOrganizationToUnmanagedUserRelProperties(CartographyRelProperties):
65
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
66
+
67
+
68
+ @dataclass(frozen=True)
69
+ # (:KeycloakOrganization)<-[:UNMANAGED_MEMBER_OF]-(:KeycloakUser)
70
+ class KeycloakOrganizationToUnmanagedUserRel(CartographyRelSchema):
71
+ target_node_label: str = "KeycloakUser"
72
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
73
+ {"id": PropertyRef("_unmanaged_members", one_to_many=True)},
74
+ )
75
+ direction: LinkDirection = LinkDirection.INWARD
76
+ rel_label: str = "UNMANAGED_MEMBER_OF"
77
+ properties: KeycloakOrganizationToUnmanagedUserRelProperties = (
78
+ KeycloakOrganizationToUnmanagedUserRelProperties()
79
+ )
80
+
81
+
82
+ @dataclass(frozen=True)
83
+ class KeycloakOrganizationToIdentityProviderRelProperties(CartographyRelProperties):
84
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
85
+
86
+
87
+ @dataclass(frozen=True)
88
+ # (:KeycloakOrganization)-[:ENFORCES]->(:KeycloakIdentityProvider)
89
+ class KeycloakOrganizationToIdentityProviderRel(CartographyRelSchema):
90
+ target_node_label: str = "KeycloakIdentityProvider"
91
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
92
+ {"id": PropertyRef("_idp_ids", one_to_many=True)},
93
+ )
94
+ direction: LinkDirection = LinkDirection.OUTWARD
95
+ rel_label: str = "ENFORCES"
96
+ properties: KeycloakOrganizationToIdentityProviderRelProperties = (
97
+ KeycloakOrganizationToIdentityProviderRelProperties()
98
+ )
99
+
100
+
101
+ @dataclass(frozen=True)
102
+ class KeycloakOrganizationSchema(CartographyNodeSchema):
103
+ label: str = "KeycloakOrganization"
104
+ properties: KeycloakOrganizationNodeProperties = (
105
+ KeycloakOrganizationNodeProperties()
106
+ )
107
+ sub_resource_relationship: KeycloakOrganizationToRealmRel = (
108
+ KeycloakOrganizationToRealmRel()
109
+ )
110
+ other_relationships: OtherRelationships = OtherRelationships(
111
+ [
112
+ KeycloakOrganizationToManagedUserRel(),
113
+ KeycloakOrganizationToUnmanagedUserRel(),
114
+ KeycloakOrganizationToIdentityProviderRel(),
115
+ ]
116
+ )
@@ -0,0 +1,73 @@
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 KeycloakOrganizationDomainNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name", extra_index=True)
18
+ verified: PropertyRef = PropertyRef("verified")
19
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class KeycloakOrganizationDomainToRealmRelProperties(CartographyRelProperties):
24
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ # (:KeycloakOrganizationDomain)<-[:RESOURCE]-(:KeycloakRealm)
29
+ class KeycloakOrganizationDomainToRealmRel(CartographyRelSchema):
30
+ target_node_label: str = "KeycloakRealm"
31
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
32
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
33
+ )
34
+ direction: LinkDirection = LinkDirection.INWARD
35
+ rel_label: str = "RESOURCE"
36
+ properties: KeycloakOrganizationDomainToRealmRelProperties = (
37
+ KeycloakOrganizationDomainToRealmRelProperties()
38
+ )
39
+
40
+
41
+ @dataclass(frozen=True)
42
+ class KeycloakOrganizationDomainToOrganizationRelProperties(CartographyRelProperties):
43
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
44
+
45
+
46
+ @dataclass(frozen=True)
47
+ # (:KeycloakOrganizationDomain)-[:BELONGS_TO]->(:KeycloakOrganization)
48
+ class KeycloakOrganizationDomainToOrganizationRel(CartographyRelSchema):
49
+ target_node_label: str = "KeycloakOrganization"
50
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
51
+ {"id": PropertyRef("organization_id")},
52
+ )
53
+ direction: LinkDirection = LinkDirection.OUTWARD
54
+ rel_label: str = "BELONGS_TO"
55
+ properties: KeycloakOrganizationDomainToOrganizationRelProperties = (
56
+ KeycloakOrganizationDomainToOrganizationRelProperties()
57
+ )
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ class KeycloakOrganizationDomainSchema(CartographyNodeSchema):
62
+ label: str = "KeycloakOrganizationDomain"
63
+ properties: KeycloakOrganizationDomainNodeProperties = (
64
+ KeycloakOrganizationDomainNodeProperties()
65
+ )
66
+ sub_resource_relationship: KeycloakOrganizationDomainToRealmRel = (
67
+ KeycloakOrganizationDomainToRealmRel()
68
+ )
69
+ other_relationships: OtherRelationships = OtherRelationships(
70
+ [
71
+ KeycloakOrganizationDomainToOrganizationRel(),
72
+ ]
73
+ )
@@ -0,0 +1,173 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class KeycloakRealmNodeProperties(CartographyNodeProperties):
10
+ id: PropertyRef = PropertyRef("id")
11
+ # We need to index realm name as Keycloak use this slug instead of ID in all queries
12
+ name: PropertyRef = PropertyRef("realm", extra_index=True)
13
+ display_name: PropertyRef = PropertyRef("displayName")
14
+ enabled: PropertyRef = PropertyRef("enabled")
15
+ not_before: PropertyRef = PropertyRef("notBefore")
16
+ default_signature_algorithm: PropertyRef = PropertyRef("defaultSignatureAlgorithm")
17
+ revoke_refresh_token: PropertyRef = PropertyRef("revokeRefreshToken")
18
+ refresh_token_max_reuse: PropertyRef = PropertyRef("refreshTokenMaxReuse")
19
+ access_token_lifespan: PropertyRef = PropertyRef("accessTokenLifespan")
20
+ access_token_lifespan_for_implicit_flow: PropertyRef = PropertyRef(
21
+ "accessTokenLifespanForImplicitFlow"
22
+ )
23
+ sso_session_idle_timeout: PropertyRef = PropertyRef("ssoSessionIdleTimeout")
24
+ sso_session_max_lifespan: PropertyRef = PropertyRef("ssoSessionMaxLifespan")
25
+ sso_session_idle_timeout_remember_me: PropertyRef = PropertyRef(
26
+ "ssoSessionIdleTimeoutRememberMe"
27
+ )
28
+ sso_session_max_lifespan_remember_me: PropertyRef = PropertyRef(
29
+ "ssoSessionMaxLifespanRememberMe"
30
+ )
31
+ offline_session_idle_timeout: PropertyRef = PropertyRef("offlineSessionIdleTimeout")
32
+ offline_session_max_lifespan_enabled: PropertyRef = PropertyRef(
33
+ "offlineSessionMaxLifespanEnabled"
34
+ )
35
+ offline_session_max_lifespan: PropertyRef = PropertyRef("offlineSessionMaxLifespan")
36
+ client_session_idle_timeout: PropertyRef = PropertyRef("clientSessionIdleTimeout")
37
+ client_session_max_lifespan: PropertyRef = PropertyRef("clientSessionMaxLifespan")
38
+ client_offline_session_idle_timeout: PropertyRef = PropertyRef(
39
+ "clientOfflineSessionIdleTimeout"
40
+ )
41
+ client_offline_session_max_lifespan: PropertyRef = PropertyRef(
42
+ "clientOfflineSessionMaxLifespan"
43
+ )
44
+ access_code_lifespan: PropertyRef = PropertyRef("accessCodeLifespan")
45
+ access_code_lifespan_user_action: PropertyRef = PropertyRef(
46
+ "accessCodeLifespanUserAction"
47
+ )
48
+ access_code_lifespan_login: PropertyRef = PropertyRef("accessCodeLifespanLogin")
49
+ action_token_generated_by_admin_lifespan: PropertyRef = PropertyRef(
50
+ "actionTokenGeneratedByAdminLifespan"
51
+ )
52
+ action_token_generated_by_user_lifespan: PropertyRef = PropertyRef(
53
+ "actionTokenGeneratedByUserLifespan"
54
+ )
55
+ oauth2_device_code_lifespan: PropertyRef = PropertyRef("oauth2DeviceCodeLifespan")
56
+ oauth2_device_polling_interval: PropertyRef = PropertyRef(
57
+ "oauth2DevicePollingInterval"
58
+ )
59
+ ssl_required: PropertyRef = PropertyRef("sslRequired")
60
+ password_credential_grant_allowed: PropertyRef = PropertyRef(
61
+ "passwordCredentialGrantAllowed"
62
+ )
63
+ registration_allowed: PropertyRef = PropertyRef("registrationAllowed")
64
+ registration_email_as_username: PropertyRef = PropertyRef(
65
+ "registrationEmailAsUsername"
66
+ )
67
+ remember_me: PropertyRef = PropertyRef("rememberMe")
68
+ verify_email: PropertyRef = PropertyRef("verifyEmail")
69
+ login_with_email_allowed: PropertyRef = PropertyRef("loginWithEmailAllowed")
70
+ duplicate_emails_allowed: PropertyRef = PropertyRef("duplicateEmailsAllowed")
71
+ reset_password_allowed: PropertyRef = PropertyRef("resetPasswordAllowed")
72
+ edit_username_allowed: PropertyRef = PropertyRef("editUsernameAllowed")
73
+ user_cache_enabled: PropertyRef = PropertyRef("userCacheEnabled")
74
+ realm_cache_enabled: PropertyRef = PropertyRef("realmCacheEnabled")
75
+ brute_force_protected: PropertyRef = PropertyRef("bruteForceProtected")
76
+ permanent_lockout: PropertyRef = PropertyRef("permanentLockout")
77
+ max_temporary_lockouts: PropertyRef = PropertyRef("maxTemporaryLockouts")
78
+ max_failure_wait_seconds: PropertyRef = PropertyRef("maxFailureWaitSeconds")
79
+ minimum_quick_login_wait_seconds: PropertyRef = PropertyRef(
80
+ "minimumQuickLoginWaitSeconds"
81
+ )
82
+ wait_increment_seconds: PropertyRef = PropertyRef("waitIncrementSeconds")
83
+ quick_login_check_milli_seconds: PropertyRef = PropertyRef(
84
+ "quickLoginCheckMilliSeconds"
85
+ )
86
+ max_delta_time_seconds: PropertyRef = PropertyRef("maxDeltaTimeSeconds")
87
+ failure_factor: PropertyRef = PropertyRef("failureFactor")
88
+ events_enabled: PropertyRef = PropertyRef("eventsEnabled")
89
+ events_expiration: PropertyRef = PropertyRef("eventsExpiration")
90
+ admin_events_enabled: PropertyRef = PropertyRef("adminEventsEnabled")
91
+ admin_events_details_enabled: PropertyRef = PropertyRef("adminEventsDetailsEnabled")
92
+ internationalization_enabled: PropertyRef = PropertyRef(
93
+ "internationalizationEnabled"
94
+ )
95
+ default_locale: PropertyRef = PropertyRef("defaultLocale")
96
+ password_policy: PropertyRef = PropertyRef("passwordPolicy")
97
+ otp_policy_type: PropertyRef = PropertyRef("otpPolicyType")
98
+ otp_policy_algorithm: PropertyRef = PropertyRef("otpPolicyAlgorithm")
99
+ otp_policy_initial_counter: PropertyRef = PropertyRef("otpPolicyInitialCounter")
100
+ otp_policy_digits: PropertyRef = PropertyRef("otpPolicyDigits")
101
+ otp_policy_look_ahead_window: PropertyRef = PropertyRef("otpPolicyLookAheadWindow")
102
+ otp_policy_period: PropertyRef = PropertyRef("otpPolicyPeriod")
103
+ otp_policy_code_reusable: PropertyRef = PropertyRef("otpPolicyCodeReusable")
104
+ web_authn_policy_rp_entity_name: PropertyRef = PropertyRef(
105
+ "webAuthnPolicyRpEntityName"
106
+ )
107
+ web_authn_policy_rp_id: PropertyRef = PropertyRef("webAuthnPolicyRpId")
108
+ web_authn_policy_attestation_conveyance_preference: PropertyRef = PropertyRef(
109
+ "webAuthnPolicyAttestationConveyancePreference"
110
+ )
111
+ web_authn_policy_authenticator_attachment: PropertyRef = PropertyRef(
112
+ "webAuthnPolicyAuthenticatorAttachment"
113
+ )
114
+ web_authn_policy_require_resident_key: PropertyRef = PropertyRef(
115
+ "webAuthnPolicyRequireResidentKey"
116
+ )
117
+ web_authn_policy_user_verification_requirement: PropertyRef = PropertyRef(
118
+ "webAuthnPolicyUserVerificationRequirement"
119
+ )
120
+ web_authn_policy_create_timeout: PropertyRef = PropertyRef(
121
+ "webAuthnPolicyCreateTimeout"
122
+ )
123
+ web_authn_policy_avoid_same_authenticator_register: PropertyRef = PropertyRef(
124
+ "webAuthnPolicyAvoidSameAuthenticatorRegister"
125
+ )
126
+ web_authn_policy_passwordless_rp_entity_name: PropertyRef = PropertyRef(
127
+ "webAuthnPolicyPasswordlessRpEntityName"
128
+ )
129
+ web_authn_policy_passwordless_rp_id: PropertyRef = PropertyRef(
130
+ "webAuthnPolicyPasswordlessRpId"
131
+ )
132
+ web_authn_policy_passwordless_attestation_conveyance_preference: PropertyRef = (
133
+ PropertyRef("webAuthnPolicyPasswordlessAttestationConveyancePreference")
134
+ )
135
+ web_authn_policy_passwordless_authenticator_attachment: PropertyRef = PropertyRef(
136
+ "webAuthnPolicyPasswordlessAuthenticatorAttachment"
137
+ )
138
+ web_authn_policy_passwordless_require_resident_key: PropertyRef = PropertyRef(
139
+ "webAuthnPolicyPasswordlessRequireResidentKey"
140
+ )
141
+ web_authn_policy_passwordless_user_verification_requirement: PropertyRef = (
142
+ PropertyRef("webAuthnPolicyPasswordlessUserVerificationRequirement")
143
+ )
144
+ web_authn_policy_passwordless_create_timeout: PropertyRef = PropertyRef(
145
+ "webAuthnPolicyPasswordlessCreateTimeout"
146
+ )
147
+ web_authn_policy_passwordless_avoid_same_authenticator_register: PropertyRef = (
148
+ PropertyRef("webAuthnPolicyPasswordlessAvoidSameAuthenticatorRegister")
149
+ )
150
+ keycloak_version: PropertyRef = PropertyRef("keycloakVersion")
151
+ user_managed_access_allowed: PropertyRef = PropertyRef("userManagedAccessAllowed")
152
+ organizations_enabled: PropertyRef = PropertyRef("organizationsEnabled")
153
+ verifiable_credentials_enabled: PropertyRef = PropertyRef(
154
+ "verifiableCredentialsEnabled"
155
+ )
156
+ admin_permissions_enabled: PropertyRef = PropertyRef("adminPermissionsEnabled")
157
+ social: PropertyRef = PropertyRef("social")
158
+ update_profile_on_initial_social_login: PropertyRef = PropertyRef(
159
+ "updateProfileOnInitialSocialLogin"
160
+ )
161
+ o_auth2_device_code_lifespan: PropertyRef = PropertyRef("oAuth2DeviceCodeLifespan")
162
+ o_auth2_device_polling_interval: PropertyRef = PropertyRef(
163
+ "oAuth2DevicePollingInterval"
164
+ )
165
+ bruteForceStrategy: PropertyRef = PropertyRef("bruteForceStrategy")
166
+ default_role_id: PropertyRef = PropertyRef("defaultRole.id")
167
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
168
+
169
+
170
+ @dataclass(frozen=True)
171
+ class KeycloakRealmSchema(CartographyNodeSchema):
172
+ label: str = "KeycloakRealm"
173
+ properties: KeycloakRealmNodeProperties = KeycloakRealmNodeProperties()
@@ -0,0 +1,126 @@
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 KeycloakRoleNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name", extra_index=True)
18
+ description: PropertyRef = PropertyRef("description")
19
+ scope_param_required: PropertyRef = PropertyRef("scopeParamRequired")
20
+ composite: PropertyRef = PropertyRef("composite")
21
+ client_role: PropertyRef = PropertyRef("clientRole")
22
+ container_id: PropertyRef = PropertyRef("containerId")
23
+ # We need to store the realm name because role are often referenced by name
24
+ # and not by id, so we need to be able to find the role by name (that is not unique across realms)
25
+ realm: PropertyRef = PropertyRef("REALM", set_in_kwargs=True, extra_index=True)
26
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class KeycloakRoleToRealmRelProperties(CartographyRelProperties):
31
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ # (:KeycloakRole)<-[:RESOURCE]-(:KeycloakRealm)
36
+ class KeycloakRoleToRealmRel(CartographyRelSchema):
37
+ target_node_label: str = "KeycloakRealm"
38
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
39
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
40
+ )
41
+ direction: LinkDirection = LinkDirection.INWARD
42
+ rel_label: str = "RESOURCE"
43
+ properties: KeycloakRoleToRealmRelProperties = KeycloakRoleToRealmRelProperties()
44
+
45
+
46
+ @dataclass(frozen=True)
47
+ class KeycloakRoleToClientRelProperties(CartographyRelProperties):
48
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
49
+
50
+
51
+ @dataclass(frozen=True)
52
+ # (:KeycloakRole)<-[:DEFINES]->(:KeycloakClient)
53
+ class KeycloakRoleToClientRel(CartographyRelSchema):
54
+ target_node_label: str = "KeycloakClient"
55
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
56
+ {"id": PropertyRef("containerId")},
57
+ )
58
+ direction: LinkDirection = LinkDirection.INWARD
59
+ rel_label: str = "DEFINES"
60
+ properties: KeycloakRoleToClientRelProperties = KeycloakRoleToClientRelProperties()
61
+
62
+
63
+ @dataclass(frozen=True)
64
+ class KeycloakRoleToRoleRelProperties(CartographyRelProperties):
65
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
66
+
67
+
68
+ @dataclass(frozen=True)
69
+ # (:KeycloakRole)-[:INCLUDES]->(:KeycloakRole)
70
+ class KeycloakRoleToRoleRel(CartographyRelSchema):
71
+ target_node_label: str = "KeycloakRole"
72
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
73
+ {"id": PropertyRef("_composite_roles", one_to_many=True)},
74
+ )
75
+ direction: LinkDirection = LinkDirection.OUTWARD
76
+ rel_label: str = "INCLUDES"
77
+ properties: KeycloakRoleToRoleRelProperties = KeycloakRoleToRoleRelProperties()
78
+
79
+
80
+ @dataclass(frozen=True)
81
+ class KeycloakRoleToScopeRelProperties(CartographyRelProperties):
82
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
83
+
84
+
85
+ @dataclass(frozen=True)
86
+ # (:KeycloakRole)-[:GRANTS]->(:KeycloakScope)
87
+ class KeycloakRoleToScopeRel(CartographyRelSchema):
88
+ target_node_label: str = "KeycloakScope"
89
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
90
+ {"id": PropertyRef("_scope_ids", one_to_many=True)},
91
+ )
92
+ direction: LinkDirection = LinkDirection.OUTWARD
93
+ rel_label: str = "GRANTS"
94
+ properties: KeycloakRoleToScopeRelProperties = KeycloakRoleToScopeRelProperties()
95
+
96
+
97
+ @dataclass(frozen=True)
98
+ class KeycloakRoleToUserRelProperties(CartographyRelProperties):
99
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
100
+
101
+
102
+ @dataclass(frozen=True)
103
+ # (:KeycloakRole)<-[:ASSUME_ROLE]-(:KeycloakUser)
104
+ class KeycloakRoleToUserRel(CartographyRelSchema):
105
+ target_node_label: str = "KeycloakUser"
106
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
107
+ {"id": PropertyRef("_direct_members", one_to_many=True)},
108
+ )
109
+ direction: LinkDirection = LinkDirection.INWARD
110
+ rel_label: str = "ASSUME_ROLE"
111
+ properties: KeycloakRoleToUserRelProperties = KeycloakRoleToUserRelProperties()
112
+
113
+
114
+ @dataclass(frozen=True)
115
+ class KeycloakRoleSchema(CartographyNodeSchema):
116
+ label: str = "KeycloakRole"
117
+ properties: KeycloakRoleNodeProperties = KeycloakRoleNodeProperties()
118
+ sub_resource_relationship: KeycloakRoleToRealmRel = KeycloakRoleToRealmRel()
119
+ other_relationships: OtherRelationships = OtherRelationships(
120
+ [
121
+ KeycloakRoleToClientRel(),
122
+ KeycloakRoleToRoleRel(),
123
+ KeycloakRoleToScopeRel(),
124
+ KeycloakRoleToUserRel(),
125
+ ],
126
+ )
@@ -0,0 +1,73 @@
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 KeycloakScopeNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("id")
17
+ name: PropertyRef = PropertyRef("name", extra_index=True)
18
+ description: PropertyRef = PropertyRef("description")
19
+ protocol: PropertyRef = PropertyRef("protocol")
20
+ include_in_token_scope: PropertyRef = PropertyRef(
21
+ "attributes.include.in.token.scope",
22
+ )
23
+ display_on_consent_screen: PropertyRef = PropertyRef(
24
+ "attributes.display.on.consent.screen",
25
+ )
26
+ # We need to store the realm name because scope are often referenced by name
27
+ # and not by id, so we need to be able to find the scope by name (that is not unique across realms)
28
+ realm: PropertyRef = PropertyRef("REALM", set_in_kwargs=True, extra_index=True)
29
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class KeycloakScopeToRealmRelProperties(CartographyRelProperties):
34
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
35
+
36
+
37
+ @dataclass(frozen=True)
38
+ # (:KeycloakScope)<-[:RESOURCE]-(:KeycloakRealm)
39
+ class KeycloakScopeToRealmRel(CartographyRelSchema):
40
+ target_node_label: str = "KeycloakRealm"
41
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
42
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
43
+ )
44
+ direction: LinkDirection = LinkDirection.INWARD
45
+ rel_label: str = "RESOURCE"
46
+ properties: KeycloakScopeToRealmRelProperties = KeycloakScopeToRealmRelProperties()
47
+
48
+
49
+ @dataclass(frozen=True)
50
+ class KeycloakScopeToRoleRelProperties(CartographyRelProperties):
51
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
52
+
53
+
54
+ @dataclass(frozen=True)
55
+ # (:KeycloakScope)<-[:GRANTS]-(:KeycloakRole)
56
+ class KeycloakScopeToRoleRel(CartographyRelSchema):
57
+ target_node_label: str = "KeycloakRole"
58
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
59
+ {"id": PropertyRef("_role_ids", one_to_many=True)},
60
+ )
61
+ direction: LinkDirection = LinkDirection.INWARD
62
+ rel_label: str = "GRANTS"
63
+ properties: KeycloakScopeToRoleRelProperties = KeycloakScopeToRoleRelProperties()
64
+
65
+
66
+ @dataclass(frozen=True)
67
+ class KeycloakScopeSchema(CartographyNodeSchema):
68
+ label: str = "KeycloakScope"
69
+ properties: KeycloakScopeNodeProperties = KeycloakScopeNodeProperties()
70
+ sub_resource_relationship: KeycloakScopeToRealmRel = KeycloakScopeToRealmRel()
71
+ other_relationships: OtherRelationships = OtherRelationships(
72
+ [KeycloakScopeToRoleRel()],
73
+ )
@@ -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 KeycloakUserNodeProperties(CartographyNodeProperties):
15
+ id: PropertyRef = PropertyRef("id")
16
+ username: PropertyRef = PropertyRef("username")
17
+ first_name: PropertyRef = PropertyRef("firstName")
18
+ last_name: PropertyRef = PropertyRef("lastName")
19
+ email: PropertyRef = PropertyRef("email")
20
+ email_verified: PropertyRef = PropertyRef("emailVerified")
21
+ origin: PropertyRef = PropertyRef("origin")
22
+ created_timestamp: PropertyRef = PropertyRef("createdTimestamp")
23
+ enabled: PropertyRef = PropertyRef("enabled")
24
+ totp: PropertyRef = PropertyRef("totp")
25
+ service_account_client_id: PropertyRef = PropertyRef("serviceAccountClientId")
26
+ not_before: PropertyRef = PropertyRef("notBefore")
27
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class KeycloakUserToRealmRelProperties(CartographyRelProperties):
32
+ lastupdated: PropertyRef = PropertyRef("LASTUPDATED", set_in_kwargs=True)
33
+
34
+
35
+ @dataclass(frozen=True)
36
+ # (:KeycloakUser)<-[:RESOURCE]-(:KeycloakRealm)
37
+ class KeycloakUserToRealmRel(CartographyRelSchema):
38
+ target_node_label: str = "KeycloakRealm"
39
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
40
+ {"name": PropertyRef("REALM", set_in_kwargs=True)},
41
+ )
42
+ direction: LinkDirection = LinkDirection.INWARD
43
+ rel_label: str = "RESOURCE"
44
+ properties: KeycloakUserToRealmRelProperties = KeycloakUserToRealmRelProperties()
45
+
46
+
47
+ @dataclass(frozen=True)
48
+ class KeycloakUserSchema(CartographyNodeSchema):
49
+ label: str = "KeycloakUser"
50
+ properties: KeycloakUserNodeProperties = KeycloakUserNodeProperties()
51
+ sub_resource_relationship: KeycloakUserToRealmRel = KeycloakUserToRealmRel()
@@ -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
  )