brokensound77 / toruk

Crowdstrike Falcon Host script for iterating through instances to get alert and other relevant data
MIT License
13 stars 4 forks source link

Update for proper packaging and installation #17

Closed ryandub closed 7 years ago

ryandub commented 7 years ago

This allows toruk to be easily install via pip:

(toruk) ➜  toruk git:(packaging) ls -la
total 48
drwxr-xr-x   9 rwalker  staff    306 Aug 30 10:57 .
drwxr-xr-x   3 rwalker  staff    102 Aug 30 10:27 ..
drwxr-xr-x  14 rwalker  staff    476 Aug 30 10:57 .git
-rw-r--r--   1 rwalker  staff    565 Aug 30 10:57 .gitignore
-rw-r--r--   1 rwalker  staff   1070 Aug 30 10:27 LICENSE
-rw-r--r--   1 rwalker  staff  10111 Aug 30 10:27 README.md
-rw-r--r--   1 rwalker  staff    727 Aug 30 10:57 setup.py
drwxr-xr-x   7 rwalker  staff    238 Aug 30 10:57 toruk
drwxr-xr-x   8 rwalker  staff    272 Aug 30 10:50 toruk.egg-info

(toruk) ➜  toruk git:(packaging) pip install .
Processing /Users/rwalker/projects/csoc/toruk
Collecting colorama>=0.3.9 (from toruk==0.0.1)
  Using cached colorama-0.3.9-py2.py3-none-any.whl
Collecting requests>=2.18.4 (from toruk==0.0.1)
  Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.18.4->toruk==0.0.1)
  Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.18.4->toruk==0.0.1)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests>=2.18.4->toruk==0.0.1)
  Using cached idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests>=2.18.4->toruk==0.0.1)
  Using cached urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: colorama, certifi, chardet, idna, urllib3, requests, toruk
  Running setup.py install for toruk ... done
Successfully installed certifi-2017.7.27.1 chardet-3.0.4 colorama-0.3.9 idna-2.6 requests-2.18.4 toruk-0.0.1 urllib3-1.22

(toruk) ➜  toruk git:(packaging) toruk --help
usage: toruk [-h] [-a] [-s] [-i INSTANCE] [-o OUTFILE] [-c CONFIG_FILE]
             [-l {1,2,3,4,5,6,7,8,9,10,11,12}] [-f FREQUENCY] [-q]

optional arguments:
  -h, --help            show this help message and exit
  -a, --alerts          retrieves new alerts
  -s, --systems         retrieves systems information; ss for FULL details in
                        JSON (NOISY!)
  -i INSTANCE, --instance INSTANCE
                        cid for specific customer instance
  -o OUTFILE, --outfile OUTFILE
                        write output to the selected file, rather than to
                        stdout
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        select a config file with user credentials
  -l {1,2,3,4,5,6,7,8,9,10,11,12}, --loop {1,2,3,4,5,6,7,8,9,10,11,12}
                        runs toruk in a loop, for the number of hours passed
  -f FREQUENCY, --frequency FREQUENCY
                        frequency (in minutes) for the loop to resume
  -q, --quiet           suppresses errors from alert retrieval failures

This will also allow toruk to be easily distributed via PyPI if desired: pip install toruk. PyPI publishing can come as a separate PR if you would like.

brokensound77 commented 7 years ago

All of the changes are great improvements. I am going to merge and then correct the issues which we discussed around moving the code under:

if __name__ == '__main__'

to within the main function, so that it is not passed over as a result of the entry point