cartography 0.108.0rc1__py3-none-any.whl → 0.108.0rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cartography might be problematic. Click here for more details.

cartography/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.108.0rc1'
21
- __version_tuple__ = version_tuple = (0, 108, 0, 'rc1')
20
+ __version__ = version = '0.108.0rc2'
21
+ __version_tuple__ = version_tuple = (0, 108, 0, 'rc2')
@@ -26,13 +26,25 @@ def get_cloudtrail_trails(
26
26
  )
27
27
 
28
28
  trails = client.describe_trails()["trailList"]
29
-
30
- # CloudTrail multi-region trails are shown in list_trails,
31
- # but the get_trail call only works in the home region
32
29
  trails_filtered = [trail for trail in trails if trail.get("HomeRegion") == region]
30
+
33
31
  return trails_filtered
34
32
 
35
33
 
34
+ def transform_cloudtrail_trails(
35
+ trails: List[Dict[str, Any]], region: str
36
+ ) -> List[Dict[str, Any]]:
37
+ """
38
+ Transform CloudTrail trail data for ingestion
39
+ """
40
+ for trail in trails:
41
+ arn = trail.get("CloudWatchLogsLogGroupArn")
42
+ if arn:
43
+ trail["CloudWatchLogsLogGroupArn"] = arn.split(":*")[0]
44
+
45
+ return trails
46
+
47
+
36
48
  @timeit
37
49
  def load_cloudtrail_trails(
38
50
  neo4j_session: neo4j.Session,
@@ -79,7 +91,8 @@ def sync(
79
91
  logger.info(
80
92
  f"Syncing CloudTrail for region '{region}' in account '{current_aws_account_id}'.",
81
93
  )
82
- trails = get_cloudtrail_trails(boto3_session, region)
94
+ trails_filtered = get_cloudtrail_trails(boto3_session, region)
95
+ trails = transform_cloudtrail_trails(trails_filtered, region)
83
96
 
84
97
  load_cloudtrail_trails(
85
98
  neo4j_session,