Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging harness, dependabot updates from main. #87

Merged
merged 2 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
54 changes: 54 additions & 0 deletions src/falconpy/shell.py
Original file line number Diff line number Diff line change
@@ -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()