redcanaryco / surveyor

A cross-platform baselining, threat hunting, and attack surface analysis tool for security teams.
MIT License
170 stars 59 forks source link

[BUG] KeyError when no profile is specified #76

Closed xC0uNt3r7hr34t closed 1 year ago

xC0uNt3r7hr34t commented 1 year ago

A KeyError occurs when no --profile is not specified. Expected behavior is that the "default" profile will be used when no other profile is specified.

Command Line

py .\surveyor.py --query 'SrcProcName containsCIS \"explorer.exe\"' s1 --creds <cred-file>

Cred File

[default]
url=https://usea1-dfir.sentinelone.net
token=<api token>
account_id=<account-id>

Output/Error

Traceback (most recent call last):
  File "C:\run-surveyor\surveyor.py", line 386, in <module>
    cli()
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\run-surveyor\surveyor.py", line 154, in s1
    survey(ctx, 's1')
  File "C:\run-surveyor\surveyor.py", line 232, in survey
    product = get_product_instance(product, **kwargs)
  File "C:\run-surveyor\load.py", line 64, in get_product_instance
    return subclass(**kwargs)
  File "C:\run-surveyor\products\sentinel_one.py", line 74, in __init__
    if 'account_id' in config[profile] and config[profile]['account_id'] not in account_ids:
  File "C:\Users\<redacted user>\AppData\Local\Programs\Python\Python310\lib\configparser.py", line 964, in __getitem__
    raise KeyError(key)
KeyError: None