nccgroup / PMapper

A tool for quickly evaluating IAM permissions in AWS.
GNU Affero General Public License v3.0
1.37k stars 169 forks source link

Stack trace on incorrect PMAPPER_STORAGE environment variable #134

Open rdegraaf opened 10 months ago

rdegraaf commented 10 months ago

Describe the bug If a user attempts to re-use pre-gathered data from a custom storage location but gives an incorrect path, the application dumps a stack trace.

To Reproduce Steps to reproduce the behavior, please include information on suspected users/roles that are the source of the issue when possible:

  1. Gather data for some account 1234567899012, storing the data in a custom location (PMAPPER_STORAGE=/tmp/pmapper pmapper graph create, etc.)
  2. Attempt to use that data but give the wrong path (PMAPPER_STORAGE=/tmp/pmapper/123456789012 pmapper analyze)
  3. Stack trace:

    Traceback (most recent call last):
      File "/home/rdegraaf/aws-venv/bin/pmapper", line 8, in <module>
        sys.exit(main())
      File "/home/rdegraaf/aws-venv/lib/python3.8/site-packages/principalmapper/__main__.py", line 157, in main
        return analysis_cli.process_arguments(parsed_args)
      File "/home/rdegraaf/aws-venv/lib/python3.8/site-packages/principalmapper/analysis/cli.py", line 45, in process_arguments
        graph = graph_actions.get_existing_graph(session, parsed_args.account)
      File "/home/rdegraaf/aws-venv/lib/python3.8/site-packages/principalmapper/graphing/graph_actions.py", line 75, in get_existing_graph
        graph = get_graph_from_disk(get_default_graph_path(account))
      File "/home/rdegraaf/aws-venv/lib/python3.8/site-packages/principalmapper/graphing/graph_actions.py", line 65, in get_graph_from_disk
        return Graph.create_graph_from_local_disk(location)
      File "/home/rdegraaf/aws-venv/lib/python3.8/site-packages/principalmapper/common/graphs.py", line 132, in create_graph_from_local_disk
        raise ValueError('Did not find file at: {}'.format(rootpath))
    ValueError: Did not find file at: /tmp/pmapper/123456789012/123456789012

Expected behavior A useful error message with no stack trace.