Skip to content

Commit

Permalink
Fix #689: pass parent job name from RPR sync (#1356)
Browse files Browse the repository at this point in the history
### Summary
> Describe your changes.

Correctly specifies the parent job name to the GraphStatement from the
AWS RPR sync.


### Related issues or links
> Include links to relevant issues or other pages.

- #689


### Checklist

Provide proof that this works (this makes reviews move faster). Please
perform one or more of the following:
- [ ] Update/add unit or integration tests.
- [ ] Include a screenshot showing what the graph looked like before and
after your changes.
- [x] Include console log trace showing what happened before and after
your changes.


Before
```
INFO:cartography.intel.aws.permission_relationships:Syncing Permission Relationships for account 'XXX'.
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_READ' for node label 'S3Bucket'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_READ' for node label 'S3Bucket'
INFO:cartography.graph.statement:Completed None statement #None
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_WRITE' for node label 'S3Bucket'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_WRITE' for node label 'S3Bucket'
INFO:cartography.graph.statement:Completed None statement #None
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_QUERY' for node label 'DynamoDBTable'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_QUERY' for node label 'DynamoDBTable'
INFO:cartography.graph.statement:Completed None statement #None
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_ADMINISTER' for node label 'RedshiftCluster'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_ADMINISTER' for node label 'RedshiftCluster'
INFO:cartography.graph.statement:Completed None statement #None
```


After
```
INFO:cartography.intel.aws.permission_relationships:Syncing Permission Relationships for account 'XXX'.
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_READ' for node label 'S3Bucket'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_READ' for node label 'S3Bucket'
INFO:cartography.graph.statement:Completed CAN_READ:S3Bucket statement #1
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_WRITE' for node label 'S3Bucket'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_WRITE' for node label 'S3Bucket'
INFO:cartography.graph.statement:Completed CAN_WRITE:S3Bucket statement #1
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_QUERY' for node label 'DynamoDBTable'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_QUERY' for node label 'DynamoDBTable'
INFO:cartography.graph.statement:Completed CAN_QUERY:DynamoDBTable statement #1
INFO:cartography.intel.aws.permission_relationships:Syncing relationship 'CAN_ADMINISTER' for node label 'RedshiftCluster'
INFO:cartography.intel.aws.permission_relationships:Cleaning up relationship 'CAN_ADMINISTER' for node label 'RedshiftCluster'
INFO:cartography.graph.statement:Completed CAN_ADMINISTER:RedshiftCluster statement #1
```
  • Loading branch information
achantavy authored Sep 23, 2024
1 parent c9500db commit cb667ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cartography/intel/aws/permission_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ def cleanup_rpr(
)

statement = GraphStatement(
cleanup_rpr_query_template, {'UPDATE_TAG': update_tag, 'AWS_ID': current_aws_id},
True, 1000,
cleanup_rpr_query_template,
{'UPDATE_TAG': update_tag, 'AWS_ID': current_aws_id},
True,
1000,
parent_job_name=f"{relationship_name}:{node_label}",
parent_job_sequence_num=1,
)
statement.run(neo4j_session)

Expand Down

0 comments on commit cb667ea

Please sign in to comment.