Skip to content

Commit

Permalink
Throw error on invalid OS selection. Closes #1188.
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcodes committed Dec 11, 2024
1 parent cfde05a commit eaf227b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions samples/sensor_download/download_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
from tabulate import tabulate
try:
from falconpy import APIHarness
from falconpy import APIHarnessV2
except ImportError as no_falconpy:
raise SystemExit(
"The CrowdStrike SDK must be installed in order to use this utility.\n"
Expand Down Expand Up @@ -176,7 +176,14 @@ def create_constants():
os_filter = ""
if os_name:
os_filter = f"os:'{str(os_name)}'"

else:
if args.os:
allowed = ["rhel", "centos", "oracle", "rhel/centos/oracle", "mac", "macos", "apple",
"amzn", "az", "amazon", "amazon linux", "ubuntu", "kali", "deb", "debian",
"sles", "suse", "win", "windows", "microsoft", "container", "docker",
"kubernetes", "idp", "identity", "identity protection"
]
raise SystemExit(f"Invalid operating system specified.\nAllowed values: {', '.join(allowed)}")
return cmd, args.key, args.secret, os_filter, args.filename, args.table_format, args.all, \
args.osver, args.nminus, args.debug, args.base_url

Expand All @@ -189,11 +196,11 @@ def create_constants():
logging.basicConfig(level=logging.DEBUG)

# Login to the Falcon API and retrieve our list of sensors
falcon = APIHarness(client_id=CLIENTID,
client_secret=CLIENTSECRET,
debug=ENABLE_DEBUG,
base_url=BASE_URL
)
falcon = APIHarnessV2(client_id=CLIENTID,
client_secret=CLIENTSECRET,
debug=ENABLE_DEBUG,
base_url=BASE_URL
)
sensors = falcon.command(action="GetCombinedSensorInstallersByQuery",
filter=OS_FILTER,
sort="version.desc"
Expand Down

0 comments on commit eaf227b

Please sign in to comment.