cartography 0.106.0rc1__py3-none-any.whl → 0.107.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 (101) hide show
  1. cartography/_version.py +2 -2
  2. cartography/cli.py +131 -2
  3. cartography/client/core/tx.py +62 -0
  4. cartography/config.py +42 -0
  5. cartography/driftdetect/cli.py +3 -2
  6. cartography/graph/cleanupbuilder.py +47 -0
  7. cartography/graph/job.py +42 -0
  8. cartography/graph/querybuilder.py +136 -2
  9. cartography/graph/statement.py +1 -1
  10. cartography/intel/airbyte/__init__.py +105 -0
  11. cartography/intel/airbyte/connections.py +120 -0
  12. cartography/intel/airbyte/destinations.py +81 -0
  13. cartography/intel/airbyte/organizations.py +59 -0
  14. cartography/intel/airbyte/sources.py +78 -0
  15. cartography/intel/airbyte/tags.py +64 -0
  16. cartography/intel/airbyte/users.py +106 -0
  17. cartography/intel/airbyte/util.py +122 -0
  18. cartography/intel/airbyte/workspaces.py +63 -0
  19. cartography/intel/aws/__init__.py +1 -0
  20. cartography/intel/aws/cloudtrail_management_events.py +364 -0
  21. cartography/intel/aws/cloudwatch.py +77 -0
  22. cartography/intel/aws/codebuild.py +132 -0
  23. cartography/intel/aws/ec2/subnets.py +1 -1
  24. cartography/intel/aws/ecs.py +17 -0
  25. cartography/intel/aws/efs.py +80 -0
  26. cartography/intel/aws/inspector.py +80 -61
  27. cartography/intel/aws/resources.py +4 -0
  28. cartography/intel/aws/sns.py +62 -2
  29. cartography/intel/entra/users.py +84 -42
  30. cartography/intel/scaleway/__init__.py +127 -0
  31. cartography/intel/scaleway/iam/__init__.py +0 -0
  32. cartography/intel/scaleway/iam/apikeys.py +71 -0
  33. cartography/intel/scaleway/iam/applications.py +71 -0
  34. cartography/intel/scaleway/iam/groups.py +71 -0
  35. cartography/intel/scaleway/iam/users.py +71 -0
  36. cartography/intel/scaleway/instances/__init__.py +0 -0
  37. cartography/intel/scaleway/instances/flexibleips.py +86 -0
  38. cartography/intel/scaleway/instances/instances.py +92 -0
  39. cartography/intel/scaleway/projects.py +79 -0
  40. cartography/intel/scaleway/storage/__init__.py +0 -0
  41. cartography/intel/scaleway/storage/snapshots.py +86 -0
  42. cartography/intel/scaleway/storage/volumes.py +84 -0
  43. cartography/intel/scaleway/utils.py +37 -0
  44. cartography/intel/sentinelone/__init__.py +69 -0
  45. cartography/intel/sentinelone/account.py +140 -0
  46. cartography/intel/sentinelone/agent.py +139 -0
  47. cartography/intel/sentinelone/api.py +113 -0
  48. cartography/intel/sentinelone/application.py +248 -0
  49. cartography/intel/sentinelone/utils.py +28 -0
  50. cartography/models/airbyte/__init__.py +0 -0
  51. cartography/models/airbyte/connection.py +138 -0
  52. cartography/models/airbyte/destination.py +75 -0
  53. cartography/models/airbyte/organization.py +19 -0
  54. cartography/models/airbyte/source.py +75 -0
  55. cartography/models/airbyte/stream.py +74 -0
  56. cartography/models/airbyte/tag.py +69 -0
  57. cartography/models/airbyte/user.py +111 -0
  58. cartography/models/airbyte/workspace.py +46 -0
  59. cartography/models/aws/cloudtrail/management_events.py +64 -0
  60. cartography/models/aws/cloudwatch/log_metric_filter.py +79 -0
  61. cartography/models/aws/codebuild/__init__.py +0 -0
  62. cartography/models/aws/codebuild/project.py +49 -0
  63. cartography/models/aws/ec2/networkinterfaces.py +2 -0
  64. cartography/models/aws/ec2/subnet_instance.py +2 -0
  65. cartography/models/aws/ec2/subnet_networkinterface.py +2 -0
  66. cartography/models/aws/ecs/containers.py +19 -0
  67. cartography/models/aws/ecs/task_definitions.py +38 -0
  68. cartography/models/aws/ecs/tasks.py +24 -1
  69. cartography/models/aws/efs/access_point.py +77 -0
  70. cartography/models/aws/inspector/findings.py +37 -0
  71. cartography/models/aws/inspector/packages.py +1 -31
  72. cartography/models/aws/sns/topic_subscription.py +74 -0
  73. cartography/models/core/common.py +1 -0
  74. cartography/models/core/relationships.py +44 -0
  75. cartography/models/entra/user.py +17 -51
  76. cartography/models/scaleway/__init__.py +0 -0
  77. cartography/models/scaleway/iam/__init__.py +0 -0
  78. cartography/models/scaleway/iam/apikey.py +96 -0
  79. cartography/models/scaleway/iam/application.py +52 -0
  80. cartography/models/scaleway/iam/group.py +95 -0
  81. cartography/models/scaleway/iam/user.py +60 -0
  82. cartography/models/scaleway/instance/__init__.py +0 -0
  83. cartography/models/scaleway/instance/flexibleip.py +52 -0
  84. cartography/models/scaleway/instance/instance.py +118 -0
  85. cartography/models/scaleway/organization.py +19 -0
  86. cartography/models/scaleway/project.py +48 -0
  87. cartography/models/scaleway/storage/__init__.py +0 -0
  88. cartography/models/scaleway/storage/snapshot.py +78 -0
  89. cartography/models/scaleway/storage/volume.py +51 -0
  90. cartography/models/sentinelone/__init__.py +1 -0
  91. cartography/models/sentinelone/account.py +40 -0
  92. cartography/models/sentinelone/agent.py +50 -0
  93. cartography/models/sentinelone/application.py +44 -0
  94. cartography/models/sentinelone/application_version.py +96 -0
  95. cartography/sync.py +11 -4
  96. {cartography-0.106.0rc1.dist-info → cartography-0.107.0.dist-info}/METADATA +20 -16
  97. {cartography-0.106.0rc1.dist-info → cartography-0.107.0.dist-info}/RECORD +101 -36
  98. {cartography-0.106.0rc1.dist-info → cartography-0.107.0.dist-info}/WHEEL +0 -0
  99. {cartography-0.106.0rc1.dist-info → cartography-0.107.0.dist-info}/entry_points.txt +0 -0
  100. {cartography-0.106.0rc1.dist-info → cartography-0.107.0.dist-info}/licenses/LICENSE +0 -0
  101. {cartography-0.106.0rc1.dist-info → cartography-0.107.0.dist-info}/top_level.txt +0 -0
@@ -44,7 +44,9 @@ class EC2NetworkInterfaceNodeProperties(CartographyNodeProperties):
44
44
  requester_id: PropertyRef = PropertyRef("RequesterId", extra_index=True)
45
45
  requester_managed: PropertyRef = PropertyRef("RequesterManaged")
46
46
  source_dest_check: PropertyRef = PropertyRef("SourceDestCheck")
47
+ # TODO: remove subnetid once we have migrated to subnet_id
47
48
  subnetid: PropertyRef = PropertyRef("SubnetId", extra_index=True)
49
+ subnet_id: PropertyRef = PropertyRef("SubnetId", extra_index=True)
48
50
 
49
51
 
50
52
  @dataclass(frozen=True)
@@ -15,7 +15,9 @@ from cartography.models.core.relationships import TargetNodeMatcher
15
15
  class EC2SubnetInstanceNodeProperties(CartographyNodeProperties):
16
16
  # arn: PropertyRef = PropertyRef('Arn', extra_index=True) TODO use arn; issue #1024
17
17
  id: PropertyRef = PropertyRef("SubnetId")
18
+ # TODO: remove subnetid once we have migrated to subnet_id
18
19
  subnetid: PropertyRef = PropertyRef("SubnetId", extra_index=True)
20
+ subnet_id: PropertyRef = PropertyRef("SubnetId", extra_index=True)
19
21
  region: PropertyRef = PropertyRef("Region", set_in_kwargs=True)
20
22
  lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
21
23
 
@@ -16,6 +16,8 @@ from cartography.models.core.relationships import TargetNodeMatcher
16
16
  @dataclass(frozen=True)
17
17
  class EC2SubnetNetworkInterfaceNodeProperties(CartographyNodeProperties):
18
18
  id: PropertyRef = PropertyRef("SubnetId")
19
+ # TODO: remove subnetid once we have migrated to subnet_id
20
+ subnetid: PropertyRef = PropertyRef("SubnetId", extra_index=True)
19
21
  subnet_id: PropertyRef = PropertyRef("SubnetId", extra_index=True)
20
22
  region: PropertyRef = PropertyRef("Region", set_in_kwargs=True)
21
23
  lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
@@ -66,6 +66,24 @@ class ECSContainerToTaskRel(CartographyRelSchema):
66
66
  properties: ECSContainerToTaskRelProperties = ECSContainerToTaskRelProperties()
67
67
 
68
68
 
69
+ @dataclass(frozen=True)
70
+ class ECSContainerToECRImageRelProperties(CartographyRelProperties):
71
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class ECSContainerToECRImageRel(CartographyRelSchema):
76
+ target_node_label: str = "ECRImage"
77
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
78
+ {"digest": PropertyRef("imageDigest")}
79
+ )
80
+ direction: LinkDirection = LinkDirection.OUTWARD
81
+ rel_label: str = "HAS_IMAGE"
82
+ properties: ECSContainerToECRImageRelProperties = (
83
+ ECSContainerToECRImageRelProperties()
84
+ )
85
+
86
+
69
87
  @dataclass(frozen=True)
70
88
  class ECSContainerSchema(CartographyNodeSchema):
71
89
  label: str = "ECSContainer"
@@ -76,5 +94,6 @@ class ECSContainerSchema(CartographyNodeSchema):
76
94
  other_relationships: OtherRelationships = OtherRelationships(
77
95
  [
78
96
  ECSContainerToTaskRel(),
97
+ ECSContainerToECRImageRel(),
79
98
  ]
80
99
  )
@@ -83,6 +83,42 @@ class ECSTaskDefinitionToECSTaskRel(CartographyRelSchema):
83
83
  )
84
84
 
85
85
 
86
+ @dataclass(frozen=True)
87
+ class ECSTaskDefinitionToTaskRoleRelProperties(CartographyRelProperties):
88
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
89
+
90
+
91
+ @dataclass(frozen=True)
92
+ class ECSTaskDefinitionToTaskRoleRel(CartographyRelSchema):
93
+ target_node_label: str = "AWSRole"
94
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
95
+ {"arn": PropertyRef("taskRoleArn")}
96
+ )
97
+ direction: LinkDirection = LinkDirection.OUTWARD
98
+ rel_label: str = "HAS_TASK_ROLE"
99
+ properties: ECSTaskDefinitionToTaskRoleRelProperties = (
100
+ ECSTaskDefinitionToTaskRoleRelProperties()
101
+ )
102
+
103
+
104
+ @dataclass(frozen=True)
105
+ class ECSTaskDefinitionToExecutionRoleRelProperties(CartographyRelProperties):
106
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
107
+
108
+
109
+ @dataclass(frozen=True)
110
+ class ECSTaskDefinitionToExecutionRoleRel(CartographyRelSchema):
111
+ target_node_label: str = "AWSRole"
112
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
113
+ {"arn": PropertyRef("executionRoleArn")}
114
+ )
115
+ direction: LinkDirection = LinkDirection.OUTWARD
116
+ rel_label: str = "HAS_EXECUTION_ROLE"
117
+ properties: ECSTaskDefinitionToExecutionRoleRelProperties = (
118
+ ECSTaskDefinitionToExecutionRoleRelProperties()
119
+ )
120
+
121
+
86
122
  @dataclass(frozen=True)
87
123
  class ECSTaskDefinitionSchema(CartographyNodeSchema):
88
124
  label: str = "ECSTaskDefinition"
@@ -93,5 +129,7 @@ class ECSTaskDefinitionSchema(CartographyNodeSchema):
93
129
  other_relationships: OtherRelationships = OtherRelationships(
94
130
  [
95
131
  ECSTaskDefinitionToECSTaskRel(),
132
+ ECSTaskDefinitionToTaskRoleRel(),
133
+ ECSTaskDefinitionToExecutionRoleRel(),
96
134
  ]
97
135
  )
@@ -46,6 +46,7 @@ class ECSTaskNodeProperties(CartographyNodeProperties):
46
46
  ephemeral_storage_size_in_gib: PropertyRef = PropertyRef(
47
47
  "ephemeralStorage.sizeInGiB"
48
48
  )
49
+ network_interface_id: PropertyRef = PropertyRef("networkInterfaceId")
49
50
  region: PropertyRef = PropertyRef("Region", set_in_kwargs=True)
50
51
  lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
51
52
 
@@ -100,11 +101,33 @@ class ECSTaskToAWSAccountRel(CartographyRelSchema):
100
101
  properties: ECSTaskToAWSAccountRelProperties = ECSTaskToAWSAccountRelProperties()
101
102
 
102
103
 
104
+ @dataclass(frozen=True)
105
+ class ECSTaskToNetworkInterfaceRelProperties(CartographyRelProperties):
106
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
107
+
108
+
109
+ @dataclass(frozen=True)
110
+ class ECSTaskToNetworkInterfaceRel(CartographyRelSchema):
111
+ target_node_label: str = "NetworkInterface"
112
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
113
+ {"id": PropertyRef("networkInterfaceId")}
114
+ )
115
+ direction: LinkDirection = LinkDirection.OUTWARD
116
+ rel_label: str = "NETWORK_INTERFACE"
117
+ properties: ECSTaskToNetworkInterfaceRelProperties = (
118
+ ECSTaskToNetworkInterfaceRelProperties()
119
+ )
120
+
121
+
103
122
  @dataclass(frozen=True)
104
123
  class ECSTaskSchema(CartographyNodeSchema):
105
124
  label: str = "ECSTask"
106
125
  properties: ECSTaskNodeProperties = ECSTaskNodeProperties()
107
126
  sub_resource_relationship: ECSTaskToAWSAccountRel = ECSTaskToAWSAccountRel()
108
127
  other_relationships: OtherRelationships = OtherRelationships(
109
- [ECSTaskToContainerInstanceRel(), ECSTaskToECSClusterRel()]
128
+ [
129
+ ECSTaskToContainerInstanceRel(),
130
+ ECSTaskToECSClusterRel(),
131
+ ECSTaskToNetworkInterfaceRel(),
132
+ ]
110
133
  )
@@ -0,0 +1,77 @@
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 EfsAccessPointNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("AccessPointArn")
17
+ arn: PropertyRef = PropertyRef("AccessPointArn", extra_index=True)
18
+ region: PropertyRef = PropertyRef("Region", set_in_kwargs=True)
19
+ access_point_id: PropertyRef = PropertyRef("AccessPointId")
20
+ file_system_id: PropertyRef = PropertyRef("FileSystemId")
21
+ lifecycle_state: PropertyRef = PropertyRef("LifeCycleState")
22
+ name: PropertyRef = PropertyRef("Name")
23
+ owner_id: PropertyRef = PropertyRef("OwnerId")
24
+ posix_gid: PropertyRef = PropertyRef("Gid")
25
+ posix_uid: PropertyRef = PropertyRef("Uid")
26
+ root_directory_path: PropertyRef = PropertyRef("RootDirectoryPath")
27
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class EfsAccessPointToAwsAccountRelProperties(CartographyRelProperties):
32
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
33
+
34
+
35
+ @dataclass(frozen=True)
36
+ class EfsAccessPointToAWSAccountRel(CartographyRelSchema):
37
+ target_node_label: str = "AWSAccount"
38
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
39
+ {"id": PropertyRef("AWS_ID", set_in_kwargs=True)},
40
+ )
41
+ direction: LinkDirection = LinkDirection.INWARD
42
+ rel_label: str = "RESOURCE"
43
+ properties: EfsAccessPointToAwsAccountRelProperties = (
44
+ EfsAccessPointToAwsAccountRelProperties()
45
+ )
46
+
47
+
48
+ @dataclass(frozen=True)
49
+ class EfsAccessPointToEfsFileSystemRelProperties(CartographyRelProperties):
50
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
51
+
52
+
53
+ @dataclass(frozen=True)
54
+ class EfsAccessPointToEfsFileSystemRel(CartographyRelSchema):
55
+ target_node_label: str = "EfsFileSystem"
56
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
57
+ {"id": PropertyRef("FileSystemId")},
58
+ )
59
+ direction: LinkDirection = LinkDirection.OUTWARD
60
+ rel_label: str = "ACCESS_POINT_OF"
61
+ properties: EfsAccessPointToEfsFileSystemRelProperties = (
62
+ EfsAccessPointToEfsFileSystemRelProperties()
63
+ )
64
+
65
+
66
+ @dataclass(frozen=True)
67
+ class EfsAccessPointSchema(CartographyNodeSchema):
68
+ label: str = "EfsAccessPoint"
69
+ properties: EfsAccessPointNodeProperties = EfsAccessPointNodeProperties()
70
+ sub_resource_relationship: EfsAccessPointToAWSAccountRel = (
71
+ EfsAccessPointToAWSAccountRel()
72
+ )
73
+ other_relationships: OtherRelationships = OtherRelationships(
74
+ [
75
+ EfsAccessPointToEfsFileSystemRel(),
76
+ ]
77
+ )
@@ -7,8 +7,10 @@ from cartography.models.core.nodes import ExtraNodeLabels
7
7
  from cartography.models.core.relationships import CartographyRelProperties
8
8
  from cartography.models.core.relationships import CartographyRelSchema
9
9
  from cartography.models.core.relationships import LinkDirection
10
+ from cartography.models.core.relationships import make_source_node_matcher
10
11
  from cartography.models.core.relationships import make_target_node_matcher
11
12
  from cartography.models.core.relationships import OtherRelationships
13
+ from cartography.models.core.relationships import SourceNodeMatcher
12
14
  from cartography.models.core.relationships import TargetNodeMatcher
13
15
 
14
16
 
@@ -135,6 +137,40 @@ class InspectorFindingToECRImageRel(CartographyRelSchema):
135
137
  )
136
138
 
137
139
 
140
+ @dataclass(frozen=True)
141
+ class InspectorFindingToPackageRelRelProperties(CartographyRelProperties):
142
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
143
+ _sub_resource_label: PropertyRef = PropertyRef(
144
+ "_sub_resource_label", set_in_kwargs=True
145
+ )
146
+ _sub_resource_id: PropertyRef = PropertyRef("_sub_resource_id", set_in_kwargs=True)
147
+ # The following properties live in vulnerablePackages from AWS API
148
+ # Adding them here to avoid multiple repetion of packages
149
+ filepath: PropertyRef = PropertyRef("filePath")
150
+ fixedinversion: PropertyRef = PropertyRef("fixedInVersion")
151
+ remediation: PropertyRef = PropertyRef("remediation")
152
+ sourcelayerhash: PropertyRef = PropertyRef("sourceLayerHash")
153
+ sourcelambdalayerarn: PropertyRef = PropertyRef("sourceLambdaLayerArn")
154
+
155
+
156
+ @dataclass(frozen=True)
157
+ # (:AWSInspectorFinding)-[:HAS]->(:AWSInspectorPackage)
158
+ class InspectorFindingToPackageMatchLink(CartographyRelSchema):
159
+ target_node_label: str = "AWSInspectorPackage"
160
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
161
+ {"id": PropertyRef("packageid")},
162
+ )
163
+ source_node_label: str = "AWSInspectorFinding"
164
+ source_node_matcher: SourceNodeMatcher = make_source_node_matcher(
165
+ {"id": PropertyRef("findingarn")},
166
+ )
167
+ properties: InspectorFindingToPackageRelRelProperties = (
168
+ InspectorFindingToPackageRelRelProperties()
169
+ )
170
+ direction: LinkDirection = LinkDirection.OUTWARD
171
+ rel_label: str = "HAS"
172
+
173
+
138
174
  @dataclass(frozen=True)
139
175
  class AWSInspectorFindingSchema(CartographyNodeSchema):
140
176
  label: str = "AWSInspectorFinding"
@@ -146,6 +182,7 @@ class AWSInspectorFindingSchema(CartographyNodeSchema):
146
182
  other_relationships: OtherRelationships = OtherRelationships(
147
183
  [
148
184
  InspectorFindingToEC2InstanceRel(),
185
+ # TODO: Fix ECRRepository and ECRImage relationships
149
186
  InspectorFindingToECRRepositoryRel(),
150
187
  InspectorFindingToECRImageRel(),
151
188
  InspectorFindingToAWSAccountRelDelegateRel(),
@@ -7,25 +7,18 @@ from cartography.models.core.relationships import CartographyRelProperties
7
7
  from cartography.models.core.relationships import CartographyRelSchema
8
8
  from cartography.models.core.relationships import LinkDirection
9
9
  from cartography.models.core.relationships import make_target_node_matcher
10
- from cartography.models.core.relationships import OtherRelationships
11
10
  from cartography.models.core.relationships import TargetNodeMatcher
12
11
 
13
12
 
14
13
  @dataclass(frozen=True)
15
14
  class AWSInspectorPackageNodeProperties(CartographyNodeProperties):
16
15
  id: PropertyRef = PropertyRef("id")
17
- region: PropertyRef = PropertyRef("Region", set_in_kwargs=True)
18
- awsaccount: PropertyRef = PropertyRef("AWS_ID", set_in_kwargs=True)
19
- findingarn: PropertyRef = PropertyRef("findingarn", extra_index=True)
20
16
  name: PropertyRef = PropertyRef("name", extra_index=True)
21
- arch: PropertyRef = PropertyRef("arch")
22
17
  version: PropertyRef = PropertyRef("version", extra_index=True)
23
18
  release: PropertyRef = PropertyRef("release", extra_index=True)
19
+ arch: PropertyRef = PropertyRef("arch")
24
20
  epoch: PropertyRef = PropertyRef("epoch")
25
21
  manager: PropertyRef = PropertyRef("packageManager")
26
- filepath: PropertyRef = PropertyRef("filePath")
27
- fixedinversion: PropertyRef = PropertyRef("fixedInVersion")
28
- sourcelayerhash: PropertyRef = PropertyRef("sourceLayerHash")
29
22
  lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
30
23
 
31
24
 
@@ -47,24 +40,6 @@ class InspectorPackageToAWSAccountRel(CartographyRelSchema):
47
40
  )
48
41
 
49
42
 
50
- @dataclass(frozen=True)
51
- class InspectorPackageToFindingRelRelProperties(CartographyRelProperties):
52
- lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
53
-
54
-
55
- @dataclass(frozen=True)
56
- class InspectorPackageToFindingRel(CartographyRelSchema):
57
- target_node_label: str = "AWSInspectorFinding"
58
- target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
59
- {"id": PropertyRef("findingarn")},
60
- )
61
- direction: LinkDirection = LinkDirection.INWARD
62
- rel_label: str = "HAS"
63
- properties: InspectorPackageToFindingRelRelProperties = (
64
- InspectorPackageToFindingRelRelProperties()
65
- )
66
-
67
-
68
43
  @dataclass(frozen=True)
69
44
  class AWSInspectorPackageSchema(CartographyNodeSchema):
70
45
  label: str = "AWSInspectorPackage"
@@ -72,8 +47,3 @@ class AWSInspectorPackageSchema(CartographyNodeSchema):
72
47
  sub_resource_relationship: InspectorPackageToAWSAccountRel = (
73
48
  InspectorPackageToAWSAccountRel()
74
49
  )
75
- other_relationships: OtherRelationships = OtherRelationships(
76
- [
77
- InspectorPackageToFindingRel(),
78
- ],
79
- )
@@ -0,0 +1,74 @@
1
+ from dataclasses import dataclass
2
+
3
+ from cartography.models.core.common import PropertyRef
4
+ from cartography.models.core.nodes import CartographyNodeProperties
5
+ from cartography.models.core.nodes import CartographyNodeSchema
6
+ from cartography.models.core.relationships import CartographyRelProperties
7
+ from cartography.models.core.relationships import CartographyRelSchema
8
+ from cartography.models.core.relationships import LinkDirection
9
+ from cartography.models.core.relationships import make_target_node_matcher
10
+ from cartography.models.core.relationships import OtherRelationships
11
+ from cartography.models.core.relationships import TargetNodeMatcher
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class SNSTopicSubscriptionNodeProperties(CartographyNodeProperties):
16
+ id: PropertyRef = PropertyRef("SubscriptionArn")
17
+ arn: PropertyRef = PropertyRef("SubscriptionArn", extra_index=True)
18
+ topic_arn: PropertyRef = PropertyRef("TopicArn")
19
+ endpoint: PropertyRef = PropertyRef("Endpoint")
20
+ owner: PropertyRef = PropertyRef("Owner")
21
+ protocol: PropertyRef = PropertyRef("Protocol")
22
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class SNSTopicSubscriptionToAwsAccountRelProperties(CartographyRelProperties):
27
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class SNSTopicSubscriptionToAWSAccountRel(CartographyRelSchema):
32
+ target_node_label: str = "AWSAccount"
33
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
34
+ {"id": PropertyRef("AWS_ID", set_in_kwargs=True)},
35
+ )
36
+ direction: LinkDirection = LinkDirection.INWARD
37
+ rel_label: str = "RESOURCE"
38
+ properties: SNSTopicSubscriptionToAwsAccountRelProperties = (
39
+ SNSTopicSubscriptionToAwsAccountRelProperties()
40
+ )
41
+
42
+
43
+ @dataclass(frozen=True)
44
+ class SNSTopicSubscriptionToSNSTopicRelProperties(CartographyRelProperties):
45
+ lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
46
+
47
+
48
+ @dataclass(frozen=True)
49
+ class SNSTopicSubscriptionToSNSTopicRel(CartographyRelSchema):
50
+ target_node_label: str = "SNSTopic"
51
+ target_node_matcher: TargetNodeMatcher = make_target_node_matcher(
52
+ {"id": PropertyRef("TopicArn")},
53
+ )
54
+ direction: LinkDirection = LinkDirection.OUTWARD
55
+ rel_label: str = "HAS_SUBSCRIPTION"
56
+ properties: SNSTopicSubscriptionToSNSTopicRelProperties = (
57
+ SNSTopicSubscriptionToSNSTopicRelProperties()
58
+ )
59
+
60
+
61
+ @dataclass(frozen=True)
62
+ class SNSTopicSubscriptionSchema(CartographyNodeSchema):
63
+ label: str = "SNSTopicSubscription"
64
+ properties: SNSTopicSubscriptionNodeProperties = (
65
+ SNSTopicSubscriptionNodeProperties()
66
+ )
67
+ sub_resource_relationship: SNSTopicSubscriptionToAWSAccountRel = (
68
+ SNSTopicSubscriptionToAWSAccountRel()
69
+ )
70
+ other_relationships: OtherRelationships = OtherRelationships(
71
+ [
72
+ SNSTopicSubscriptionToSNSTopicRel(),
73
+ ]
74
+ )
@@ -63,6 +63,7 @@ class PropertyRef:
63
63
  ```
64
64
  This means that as we create AWSInstanceProfile nodes, we will search for AWSRoles to attach to, and we do
65
65
  this by checking if each role's `arn` field is in the `Roles` list of the data dict.
66
+ Note that one_to_many has no effect on matchlinks.
66
67
  """
67
68
  self.name = name
68
69
  self.set_in_kwargs = set_in_kwargs
@@ -42,6 +42,11 @@ class CartographyRelProperties(abc.ABC):
42
42
  Abstract class that represents the properties on a CartographyRelSchema. This is intended to enforce that all
43
43
  subclasses will have a lastupdated field defined on their resulting relationships. These fields are assigned to the
44
44
  relationship in the `SET` clause.
45
+
46
+ If the CartographyRelSchema is used as a MatchLink, the following properties are required to be defined here:
47
+ - lastupdated: A PropertyRef to the update tag of the relationship.
48
+ - _sub_resource_label: A PropertyRef to the label of the sub-resource that the relationship is associated with.
49
+ - _sub_resource_id: A PropertyRef to the id of the sub-resource that the relationship is associated with.
45
50
  """
46
51
 
47
52
  lastupdated: PropertyRef = field(init=False)
@@ -90,6 +95,29 @@ def make_target_node_matcher(key_ref_dict: Dict[str, PropertyRef]) -> TargetNode
90
95
  return make_dataclass(TargetNodeMatcher.__name__, fields, frozen=True)()
91
96
 
92
97
 
98
+ @dataclass(frozen=True)
99
+ class SourceNodeMatcher:
100
+ """
101
+ Same as TargetNodeMatcher, but for the source node; see `make_source_node_matcher()`.
102
+ This object is used only for load_matchlinks() where we match on and connect existing nodes.
103
+ This has no effect on CartographyRelSchema objects that are included in CartographyNodeSchema.
104
+ """
105
+
106
+ pass
107
+
108
+
109
+ def make_source_node_matcher(key_ref_dict: Dict[str, PropertyRef]) -> SourceNodeMatcher:
110
+ """
111
+ :param key_ref_dict: A Dict mapping keys present on the node to PropertyRef objects.
112
+ :return: A SourceNodeMatcher used for CartographyRelSchema to match with other nodes.
113
+ """
114
+ fields = [
115
+ (key, PropertyRef, field(default=prop_ref))
116
+ for key, prop_ref in key_ref_dict.items()
117
+ ]
118
+ return make_dataclass(SourceNodeMatcher.__name__, fields, frozen=True)()
119
+
120
+
93
121
  @dataclass(frozen=True)
94
122
  class CartographyRelSchema(abc.ABC):
95
123
  """
@@ -139,6 +167,22 @@ class CartographyRelSchema(abc.ABC):
139
167
  """
140
168
  pass
141
169
 
170
+ @property
171
+ def source_node_label(self) -> str | None:
172
+ """
173
+ :return: Optional. Only used for load_matchlinks(). The source node label to use for the relationship.
174
+ This does not affect CartographyRelSchema that are included in CartographyNodeSchema objects.
175
+ """
176
+ return None
177
+
178
+ @property
179
+ def source_node_matcher(self) -> SourceNodeMatcher | None:
180
+ """
181
+ :return: Optional. Only used for load_matchlinks(). A SourceNodeMatcher object used to find what node(s) to attach the relationship to.
182
+ This does not affect CartographyRelSchema that are included in CartographyNodeSchema objects.
183
+ """
184
+ return None
185
+
142
186
 
143
187
  @dataclass(frozen=True)
144
188
  class OtherRelationships:
@@ -9,6 +9,10 @@ from cartography.models.core.relationships import LinkDirection
9
9
  from cartography.models.core.relationships import make_target_node_matcher
10
10
  from cartography.models.core.relationships import TargetNodeMatcher
11
11
 
12
+ # The user resource in Microsoft Graph exposes hundreds of properties but, in
13
+ # practice, only a small subset is populated in most tenants. We deliberately
14
+ # model *just* the commonly-used attributes to keep the graph lean.
15
+
12
16
 
13
17
  @dataclass(frozen=True)
14
18
  class EntraUserNodeProperties(CartographyNodeProperties):
@@ -17,61 +21,23 @@ class EntraUserNodeProperties(CartographyNodeProperties):
17
21
  display_name: PropertyRef = PropertyRef("display_name")
18
22
  given_name: PropertyRef = PropertyRef("given_name")
19
23
  surname: PropertyRef = PropertyRef("surname")
20
- # The underlying datatype calls this 'mail' but everything else in cartography uses 'email'
24
+ # The SDK calls this `mail`; we surface it as `email` like the rest of Cartography
21
25
  email: PropertyRef = PropertyRef("mail", extra_index=True)
22
- other_mails: PropertyRef = PropertyRef("other_mails")
23
- preferred_language: PropertyRef = PropertyRef("preferred_language")
24
- preferred_name: PropertyRef = PropertyRef("preferred_name")
25
- state: PropertyRef = PropertyRef("state")
26
- usage_location: PropertyRef = PropertyRef("usage_location")
27
- user_type: PropertyRef = PropertyRef("user_type")
28
- show_in_address_list: PropertyRef = PropertyRef("show_in_address_list")
29
- sign_in_sessions_valid_from_date_time: PropertyRef = PropertyRef(
30
- "sign_in_sessions_valid_from_date_time"
31
- )
32
- security_identifier: PropertyRef = PropertyRef("security_identifier")
33
- account_enabled: PropertyRef = PropertyRef("account_enabled")
34
- city: PropertyRef = PropertyRef("city")
35
- company_name: PropertyRef = PropertyRef("company_name")
36
- consent_provided_for_minor: PropertyRef = PropertyRef("consent_provided_for_minor")
37
- country: PropertyRef = PropertyRef("country")
38
- created_date_time: PropertyRef = PropertyRef("created_date_time")
39
- creation_type: PropertyRef = PropertyRef("creation_type")
40
- deleted_date_time: PropertyRef = PropertyRef("deleted_date_time")
26
+ mobile_phone: PropertyRef = PropertyRef("mobile_phone")
27
+ business_phones: PropertyRef = PropertyRef("business_phones")
28
+ job_title: PropertyRef = PropertyRef("job_title")
41
29
  department: PropertyRef = PropertyRef("department")
30
+ company_name: PropertyRef = PropertyRef("company_name")
31
+ office_location: PropertyRef = PropertyRef("office_location")
42
32
  employee_id: PropertyRef = PropertyRef("employee_id")
43
33
  employee_type: PropertyRef = PropertyRef("employee_type")
44
- external_user_state: PropertyRef = PropertyRef("external_user_state")
45
- external_user_state_change_date_time: PropertyRef = PropertyRef(
46
- "external_user_state_change_date_time"
47
- )
48
- hire_date: PropertyRef = PropertyRef("hire_date")
49
- is_management_restricted: PropertyRef = PropertyRef("is_management_restricted")
50
- is_resource_account: PropertyRef = PropertyRef("is_resource_account")
51
- job_title: PropertyRef = PropertyRef("job_title")
52
- last_password_change_date_time: PropertyRef = PropertyRef(
53
- "last_password_change_date_time"
54
- )
55
- mail_nickname: PropertyRef = PropertyRef("mail_nickname")
56
- office_location: PropertyRef = PropertyRef("office_location")
57
- on_premises_distinguished_name: PropertyRef = PropertyRef(
58
- "on_premises_distinguished_name"
59
- )
60
- on_premises_domain_name: PropertyRef = PropertyRef("on_premises_domain_name")
61
- on_premises_immutable_id: PropertyRef = PropertyRef("on_premises_immutable_id")
62
- on_premises_last_sync_date_time: PropertyRef = PropertyRef(
63
- "on_premises_last_sync_date_time"
64
- )
65
- on_premises_sam_account_name: PropertyRef = PropertyRef(
66
- "on_premises_sam_account_name"
67
- )
68
- on_premises_security_identifier: PropertyRef = PropertyRef(
69
- "on_premises_security_identifier"
70
- )
71
- on_premises_sync_enabled: PropertyRef = PropertyRef("on_premises_sync_enabled")
72
- on_premises_user_principal_name: PropertyRef = PropertyRef(
73
- "on_premises_user_principal_name"
74
- )
34
+ city: PropertyRef = PropertyRef("city")
35
+ state: PropertyRef = PropertyRef("state")
36
+ country: PropertyRef = PropertyRef("country")
37
+ preferred_language: PropertyRef = PropertyRef("preferred_language")
38
+ account_enabled: PropertyRef = PropertyRef("account_enabled")
39
+ age_group: PropertyRef = PropertyRef("age_group")
40
+ manager_id: PropertyRef = PropertyRef("manager_id")
75
41
  lastupdated: PropertyRef = PropertyRef("lastupdated", set_in_kwargs=True)
76
42
 
77
43
 
File without changes
File without changes