From 7e1100b195ed9b6fadf82a5ca220064fabf73bb7 Mon Sep 17 00:00:00 2001 From: Simon Lukasik Date: Wed, 17 Mar 2021 13:40:43 +0000 Subject: [PATCH 1/2] Alternative falcon shell for python lovers Usage: ``` $ python3 -m falconpy.shell ``` --- src/falconpy/shell.py | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/falconpy/shell.py diff --git a/src/falconpy/shell.py b/src/falconpy/shell.py new file mode 100644 index 000000000..3f0a00471 --- /dev/null +++ b/src/falconpy/shell.py @@ -0,0 +1,54 @@ +import os +from . import oauth2 as FalconAuth + +banner = """ +CrowdStrike Cloud Demo Shell | + ____________ __ -+- ____________ +This shell-like wizard allows for quick learning, \\_____ / /_ \\ | \\ _____/ +demoing, and prototyping of cloud operations with \\_____ \\____/ \\____/ _____/ +CrowdStrike Falcon agent. \\_____ _____/ + \\___________ ___________/ +Please issue help() to learn more. /____\\ +""" + + +python_help = help + + +def help(item=None): + text = """ + This is interactive Python shell. Python help is available under python_help() + + If you have FALCON_CLIENT_ID FALCON_CLIENT_SECRET environment variable set. This + shell will authenticate at the start up and token variable will be filled in with + OAuth2 token. + """ + if item is None: + print(text) + elif callable(getattr(item, 'help', None)): + item.help() + else: + print(item.__doc__) + + +def embed(): + from IPython.terminal.embed import InteractiveShellEmbed + ipshell = InteractiveShellEmbed(banner1=banner) + ipshell.confirm_exit = False + ipshell() + + +falcon_client_id = os.getenv("FALCON_CLIENT_ID") +falcon_client_secret = os.getenv("FALCON_CLIENT_SECRET") + +authorization = FalconAuth.OAuth2(creds={ + 'client_id': falcon_client_id, + 'client_secret': falcon_client_secret +}) + +try: + token = authorization.token()["body"]["access_token"] +except: + token = False + +embed() From 53d98cdd976df9a6731c45964838906a04bba5c5 Mon Sep 17 00:00:00 2001 From: jshcodes <74007258+jshcodes@users.noreply.github.com> Date: Wed, 17 Mar 2021 14:18:20 -0400 Subject: [PATCH 2/2] Merge main/shell (#86) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Configure dependabot to focus on python (#77) And hopefully disregard javascript modules, that are only used for docs pipeline. * Requirements.txt updates (#83) * Configure dependabot to focus on python And hopefully disregard javascript modules, that are only used for docs pipeline. * Removed unnecessary upstream requirement references. Co-authored-by: Simon Lukasik * Bump urllib3 from 1.26.2 to 1.26.4 (#82) Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.2 to 1.26.4. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/1.26.4/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/1.26.2...1.26.4) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump requests from 2.25.0 to 2.25.1 (#81) Bumps [requests](https://github.com/psf/requests) from 2.25.0 to 2.25.1. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/master/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.25.0...v2.25.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Šimon Lukašík Co-authored-by: Simon Lukasik Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/dependabot.yml | 8 ++++++++ requirements.txt | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..a81161967 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +--- +version: 2 +updates: + - package-ecosystem: pip + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/requirements.txt b/requirements.txt index 6f7279084..56cad8a53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,8 +4,5 @@ # # pip-compile requirements.in # -certifi==2020.11.8 # via requests -chardet==3.0.4 # via requests -idna==2.10 # via requests -requests==2.25.0 # via -r requirements.in -urllib3==1.26.2 # via -r requirements.in, requests +requests==2.25.1 # via -r requirements.in +urllib3==1.26.4 # via -r requirements.in, requests