-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug: Return empty access_keys object when access keys do not exist #1309
Merged
achantavy
merged 2 commits into
cartography-cncf:master
from
austincomstockzoom:fix-access-keys-return
Jun 17, 2024
Merged
Fix bug: Return empty access_keys object when access keys do not exist #1309
achantavy
merged 2 commits into
cartography-cncf:master
from
austincomstockzoom:fix-access-keys-return
Jun 17, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LGTM |
Hi @austincomstockzoom, thank you for the fix! Can you please sign the CLA? |
Check again, thanks |
achantavy
approved these changes
Jun 17, 2024
chandanchowdhury
pushed a commit
to juju4/cartography
that referenced
this pull request
Jun 26, 2024
cartography-cncf#1309) While running the AWS sync in Cartography, the following error occurs, causing the sync process to fail: ``` ERROR:cartography.sync:Unhandled exception during sync stage 'aws' Traceback (most recent call last): File "/home/REDACTED/cartography/cartography/sync.py", line 113, in run stage_func(neo4j_session, config) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 298, in start_aws_ingestion sync_successful = _sync_multiple_accounts( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 169, in _sync_multiple_accounts _sync_one_account( File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 64, in _sync_one_account RESOURCE_FUNCTIONS[func_name](**sync_args) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 819, in sync sync_user_access_keys(neo4j_session, boto3_session, current_aws_account_id, update_tag, common_job_parameters) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 795, in sync_user_access_keys access_keys = get_account_access_key_data(boto3_session, user["name"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 230, in get_account_access_key_data for access_key in access_keys['AccessKeyMetadata']: ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ KeyError: 'AccessKeyMetadata' ERROR:__main__:Error in AWS account sync REDACTED: 'AccessKeyMetadata' ``` The fix involves returning the access_keys object directly from the get_account_access_key_data function. This ensures that the function returns the correct data structure, even if the AccessKeyMetadata key is missing. The function was tested with various AWS accounts to ensure it correctly handles cases where the AccessKeyMetadata key is present and when it is missing. Verified that the sync process was completed successfully without any errors. Co-authored-by: Alex Chantavy <[email protected]>
SecPrez
pushed a commit
to SecPrez/cartography
that referenced
this pull request
Nov 10, 2024
cartography-cncf#1309) While running the AWS sync in Cartography, the following error occurs, causing the sync process to fail: ``` ERROR:cartography.sync:Unhandled exception during sync stage 'aws' Traceback (most recent call last): File "/home/REDACTED/cartography/cartography/sync.py", line 113, in run stage_func(neo4j_session, config) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 298, in start_aws_ingestion sync_successful = _sync_multiple_accounts( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 169, in _sync_multiple_accounts _sync_one_account( File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 64, in _sync_one_account RESOURCE_FUNCTIONS[func_name](**sync_args) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 819, in sync sync_user_access_keys(neo4j_session, boto3_session, current_aws_account_id, update_tag, common_job_parameters) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 795, in sync_user_access_keys access_keys = get_account_access_key_data(boto3_session, user["name"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 230, in get_account_access_key_data for access_key in access_keys['AccessKeyMetadata']: ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ KeyError: 'AccessKeyMetadata' ERROR:__main__:Error in AWS account sync REDACTED: 'AccessKeyMetadata' ``` The fix involves returning the access_keys object directly from the get_account_access_key_data function. This ensures that the function returns the correct data structure, even if the AccessKeyMetadata key is missing. The function was tested with various AWS accounts to ensure it correctly handles cases where the AccessKeyMetadata key is present and when it is missing. Verified that the sync process was completed successfully without any errors. Co-authored-by: Alex Chantavy <[email protected]>
chandanchowdhury
pushed a commit
to chandanchowdhury/cartography
that referenced
this pull request
Nov 27, 2024
cartography-cncf#1309) While running the AWS sync in Cartography, the following error occurs, causing the sync process to fail: ``` ERROR:cartography.sync:Unhandled exception during sync stage 'aws' Traceback (most recent call last): File "/home/REDACTED/cartography/cartography/sync.py", line 113, in run stage_func(neo4j_session, config) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 298, in start_aws_ingestion sync_successful = _sync_multiple_accounts( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 169, in _sync_multiple_accounts _sync_one_account( File "/home/REDACTED/cartography/cartography/intel/aws/__init__.py", line 64, in _sync_one_account RESOURCE_FUNCTIONS[func_name](**sync_args) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 819, in sync sync_user_access_keys(neo4j_session, boto3_session, current_aws_account_id, update_tag, common_job_parameters) File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 795, in sync_user_access_keys access_keys = get_account_access_key_data(boto3_session, user["name"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/util.py", line 197, in timed return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/REDACTED/cartography/cartography/intel/aws/iam.py", line 230, in get_account_access_key_data for access_key in access_keys['AccessKeyMetadata']: ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ KeyError: 'AccessKeyMetadata' ERROR:__main__:Error in AWS account sync REDACTED: 'AccessKeyMetadata' ``` The fix involves returning the access_keys object directly from the get_account_access_key_data function. This ensures that the function returns the correct data structure, even if the AccessKeyMetadata key is missing. The function was tested with various AWS accounts to ensure it correctly handles cases where the AccessKeyMetadata key is present and when it is missing. Verified that the sync process was completed successfully without any errors. Co-authored-by: Alex Chantavy <[email protected]> Signed-off-by: chandanchowdhury <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While running the AWS sync in Cartography, the following error occurs, causing the sync process to fail:
The fix involves returning the access_keys object directly from the get_account_access_key_data function. This ensures that the function returns the correct data structure, even if the AccessKeyMetadata key is missing.
The function was tested with various AWS accounts to ensure it correctly handles cases where the AccessKeyMetadata key is present and when it is missing.
Verified that the sync process was completed successfully without any errors.