duo-labs / duo-labs/cloudmapper
Incorrect JSON in config.json causes exception
- Dominant language
- JavaScript
- Stars
- 6.3k
- Forks
- 836
- PR merge metrics
- No merged PRs in 30d
Description
I had a `config.json` with the following:
```
"cidrs": []
```
Running `cloudmapper.py report` then causes this exception:
```
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 263, in report
public_nodes, _ = get_public_nodes(account, config, use_cache=True)
File "/opt/cloudmapper/shared/public.py", line 89, in get_public_nodes
network = build_data_structure(account, config, outputfilter)
File "/opt/cloudmapper/commands/prepare.py", line 542, in build_data_structure
for cidr in get_external_cidrs(account, config):
File "/opt/cloudmapper/commands/prepare.py", line 198, in get_external_cidrs
external_cidrs.append(Cidr(cidr, get_cidr_name(cidr, config)))
File "/opt/cloudmapper/commands/prepare.py", line 203, in get_cidr_name
return config["cidrs"].get(cidr, {}).get("name", None)
AttributeError: 'list' object has no attribute 'get'
```
After a bit of debugging I realised my config is wrong, since `cloudmapper.py` expects a dict for `cidrs`. Could some validation, e.g. JSON schemas, be added to the configuration when it is loaded?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.