Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcodes committed May 31, 2024
1 parent ecca16c commit e59a053
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions samples/hosts/stale_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
Batch the call to hide_hosts to avoid API error
"""
import csv
import os
import re
from argparse import ArgumentParser, RawTextHelpFormatter
from datetime import datetime, timedelta, timezone
Expand All @@ -39,10 +38,6 @@
"CrowdStrike FalconPy must be installed in order to use this application.\n"
"Please execute `python3 -m pip install crowdstrike-falconpy` and try again."
) from no_falconpy
# from dotenv import load_dotenv
# load_dotenv()
# clientId = os.getenv('clientid')
# clientSecret = os.getenv('secret')

def parse_command_line() -> object:
"""Parse command-line arguments and return them back as an ArgumentParser object."""
Expand All @@ -54,15 +49,13 @@ def parse_command_line() -> object:
'-k',
'--client_id',
help='CrowdStrike Falcon API key ID',
required=True,
# default=clientId
required=True
)
parser.add_argument(
'-s',
'--client_secret',
help='CrowdStrike Falcon API key secret',
required=True,
# default=clientSecret
required=True
)
parser.add_argument(
'-m',
Expand Down Expand Up @@ -233,16 +226,14 @@ def hide_hosts(id_list: list) -> dict:
# List to hold our identified hosts
stale = []
# For each stale host identified
if args.hostfilter == r".*":
pattern = args.hostfilter
else:
pattern = re.escape(args.hostfilter)
print(f"Pattern is: {pattern}")
pattern = args.hostfilter
if args.hostfilter != r".*":
print(f"Pattern is: {re.escape(pattern)}")

for host in get_host_details(get_hosts(STALE_DATE, args.tag, args.osfilter)):
# Retrieve host detail
if 'hostname' in host:
if re.findall(pattern, host['hostname']):
print(f"{host['hostname']} matches expected pattern...")
stale = parse_host_detail(host, stale)

# If we produced stale host results
Expand Down Expand Up @@ -280,4 +271,4 @@ def hide_hosts(id_list: list) -> dict:
for deleted in remove_result["body"]["errors"]:
print(f"[{deleted['code']}] {deleted['message']}")
else:
print("No stale hosts identified for the range specified.")
print("No stale hosts identified for the range specified.")

0 comments on commit e59a053

Please sign in to comment.