duo-labs / duo-labs/cloudmapper
Regions data not found when account ID starts with a zero
- Dominant language
- JavaScript
- Stars
- 6.3k
- Forks
- 836
- PR merge metrics
- No merged PRs in 30d
Description
Using the Docker container, when running `cloudmapper.py report`, with multiple accounts, I get the following error:
```
Traceback (most recent call last):
File "./cloudmapper.py", line 72, in
main()
File "./cloudmapper.py", line 66, in main
commands[command].run(arguments)
File "/opt/cloudmapper/commands/report.py", line 471, in run
report(accounts, config, args)
File "/opt/cloudmapper/commands/report.py", line 91, in report
"collection_date": get_collection_date(account)[:10],
File "/opt/cloudmapper/shared/common.py", line 332, in get_collection_date
account_struct, "iam-get-credential-report", get_us_east_1(account_struct)
File "/opt/cloudmapper/shared/common.py", line 306, in get_us_east_1
for region_json in get_regions(account):
File "/opt/cloudmapper/shared/common.py", line 162, in get_regions
regions = pyjq.all(".Regions[]{}".format(region_filter), region_data)
File "/usr/local/lib/python3.7/site-packages/pyjq.py", line 49, in all
return compile(script, vars, library_paths).all(_get_value(value, url, opener))
File "_pyjq.pyx", line 209, in _pyjq.Script.all (_pyjq.c:2561)
_pyjq.ScriptRuntimeError: Cannot iterate over null (null)
```
After some debugging I saw the account data involved did have a `describe-regions.json` and it contained data in the right format. However, the account ID started with a zero. Doing this:
```
cd account-data
ln -s 012345678 12345678 # replace with real account IDs
```
...fixed it. Very nasty hack that may mess up other parts of my audit though! This should be fixed - clearly Python is doing a silent type conversion to a number somewhere and stripping the zero.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with shared/common.py around get_regions and get_us_east_1, then trace the account data used by commands/report.py. Reproduce the report command with an account ID beginning with zero and its describe-regions.json; done means regions are found without the symlink workaround and the report no longer raises the null-iteration error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, python
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100