Zeus-Labs / ZeusCloud

Open Source Cloud Security
https://docs.zeuscloud.io
Apache License 2.0
691 stars 44 forks source link

iamspy exception thrown #291

Closed varunjain99 closed 1 year ago

varunjain99 commented 1 year ago

Ran into this using iamspy in cartography

cartography_1  | INFO:iamspy.parse:Parsing policy document: policy_identity_arn:aws:iam::315957380126:user/userMFA_forceMfa
cartography_1  | ERROR:cartography.sync:Unhandled exception during sync stage 'aws'
cartography_1  | Traceback (most recent call last):
cartography_1  |   File "/srv/cartography/cartography/sync.py", line 89, in run
cartography_1  |     stage_func(neo4j_session, config)
cartography_1  |   File "/srv/cartography/cartography/util.py", line 133, in timed
cartography_1  |     return method(*args, **kwargs)
cartography_1  |   File "/srv/cartography/cartography/intel/aws/__init__.py", line 270, in start_aws_ingestion
cartography_1  |     sync_successful = _sync_multiple_accounts(
cartography_1  |   File "/srv/cartography/cartography/intel/aws/__init__.py", line 173, in _sync_multiple_accounts
cartography_1  |     _sync_one_account(
cartography_1  |   File "/srv/cartography/cartography/intel/aws/__init__.py", line 70, in _sync_one_account
cartography_1  |     RESOURCE_FUNCTIONS['permission_relationships'](**sync_args)
cartography_1  |   File "/srv/cartography/cartography/util.py", line 133, in timed
cartography_1  |     return method(*args, **kwargs)
cartography_1  |   File "/srv/cartography/cartography/intel/aws/permission_relationships.py", line 1243, in sync
cartography_1  |     sync_iamspy_relationships(
cartography_1  |   File "/srv/cartography/cartography/intel/aws/permission_relationships.py", line 1221, in sync_iamspy_relationships
cartography_1  |     model.load_gaad_json(gaad)
cartography_1  |   File "/usr/local/lib/python3.8/dist-packages/zeuscloud_iamspy/model.py", line 55, in load_gaad_json
cartography_1  |     conditions = parse.generate_model(auth_details)
cartography_1  |   File "/usr/local/lib/python3.8/dist-packages/zeuscloud_iamspy/parse.py", line 358, in generate_model
cartography_1  |     model.extend(_parse_user(data, user))
cartography_1  |   File "/usr/local/lib/python3.8/dist-packages/zeuscloud_iamspy/parse.py", line 281, in _parse_user
cartography_1  |     model.extend(_parse_document(inline_policy.PolicyDocument, identifier))
cartography_1  |   File "/usr/local/lib/python3.8/dist-packages/zeuscloud_iamspy/parse.py", line 173, in _parse_document
cartography_1  |     parsed = _parse_statement(stmt)
cartography_1  |   File "/usr/local/lib/python3.8/dist-packages/zeuscloud_iamspy/parse.py", line 151, in _parse_statement
cartography_1  |     conditions = _parse_condition(statement.Condition)
cartography_1  |   File "/usr/local/lib/python3.8/dist-packages/zeuscloud_iamspy/parse.py", line 70, in _parse_condition
cartography_1  |     test = test.removesuffix("IfExists")
cartography_1  | AttributeError: 'str' object has no attribute 'removesuffix'

quick temporary fix would be catch iamspy exceptions and proceed

varunjain99 commented 1 year ago

updated iamspy version and also we should catch any iamspy issue