nccgroup / Scout2

Security auditing tool for AWS environments
http://nccgroup.github.io/Scout2/
GNU General Public License v2.0
1.73k stars 300 forks source link

Scout2 trying to open IP address files with wrong path #232

Closed nathan-v closed 6 years ago

nathan-v commented 6 years ago
Traceback (most recent call last):
  File "/home/ubuntu/Scout2/Scout2.py", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/Scout2/AWSScout2/__main__.py", line 95, in main
    finding_rules = Ruleset(profile_name, filename = args.ruleset, ip_ranges = args.ip_ranges, aws_account_id = aws_config['aws_account_id'])
  File "/home/ubuntu/Scout2/AWSScout2/rules/ruleset.py", line 39, in __init__
    self.shared_init(ruleset_generator, rules_dir, aws_account_id, ip_ranges)
  File "/home/ubuntu/Scout2/AWSScout2/rules/ruleset.py", line 58, in shared_init
    self.prepare_rules(ip_ranges = ip_ranges, params = params)
  File "/home/ubuntu/Scout2/AWSScout2/rules/ruleset.py", line 109, in prepare_rules
    rule.set_definition(self.rule_definitions, attributes, ip_ranges, params)
  File "/home/ubuntu/Scout2/AWSScout2/rules/rule.py", line 107, in set_definition
    condition[2] = read_ip_ranges(filename, local_file = local_file, ip_only = True, conditions = conditions)
  File "/home/ubuntu/.pyenv/versions/3.6.3/lib/python3.6/site-packages/opinel/utils/fs.py", line 71, in read_ip_ranges
    data = load_data(filename, local_file = local_file)
  File "/home/ubuntu/.pyenv/versions/3.6.3/lib/python3.6/site-packages/opinel/utils/fs.py", line 45, in load_data
    with open(src_file) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/AWSScout2/rules/data/ip-ranges/aws-in-us.json'
Done.
$ ll ./Scout2/AWSScout2/rules/data/ip-ranges/aws-in-us.json 
-rw-rw-r-- 1 ubuntu ubuntu 116 Dec 21 19:19 ./Scout2/AWSScout2/rules/data/ip-ranges/aws-in-us.json

For some reason it's dropping the Scout2 directory along the way and when the file read is called the path is incorrect.

nathan-v commented 6 years ago

I haven't found the spot in the code yet but it looks to be caused if you run Scout2.py from another directory; If I run ./Scout2/Scou2.py instead of running ./Scout2.py from the root directory where it's cloned to the failure above is seen. It does not happen if you run it from it's own directory.

l01cd3v commented 6 years ago

Merged PR, should be fixed now.