Skip to content

Commit

Permalink
Changes to sate isort and black together
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHammond13 committed Sep 12, 2024
1 parent fe0288c commit ee726f9
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 132 deletions.
20 changes: 5 additions & 15 deletions examples/common/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import os
import sys

from functools import wraps
from typing import Dict

Expand All @@ -13,7 +12,6 @@
from caracara import Client
from caracara.common.csdialog import csradiolist_dialog


_config_path = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"config.yml",
Expand All @@ -33,13 +31,11 @@ def _select_profile(config: dict) -> str:

client_id = falcon.get("client_id")
if client_id is None:
print(
f"The falcon stanza in {profile_name} does not contain a client ID; skipping"
)
print(f"The falcon stanza in {profile_name} does not contain a client ID; skipping")
continue

client_id = str(client_id)
profile_text = f"{profile_name} (Client ID: {client_id[0:7]}{"x"*24})"
profile_text = f"{profile_name} (Client ID: {client_id[0:7]}{'x'*24})"
profile_pairs.append((profile_name, profile_text))

profile_name = csradiolist_dialog(
Expand All @@ -65,19 +61,15 @@ def _get_profile() -> Dict:
config = yaml.safe_load(yaml_config_file)

if "profiles" not in config:
raise KeyError(
"You must create a profiles stanza in the configuration YAML file"
)
raise KeyError("You must create a profiles stanza in the configuration YAML file")

profile_names = list(config["profiles"].keys())
# Check to see if the user provided us with a profile name as the first argument
profile_name = None
if len(sys.argv) > 1:
profile_name = sys.argv[1]
if profile_name not in profile_names:
raise KeyError(
f"The profile named {profile_name} does not exist in config.yml"
)
raise KeyError(f"The profile named {profile_name} does not exist in config.yml")
else:
profile_name = _select_profile(config)

Expand Down Expand Up @@ -162,9 +154,7 @@ def wrapped(*args, **kwargs):
falcon_config: Dict = profile["falcon"]

if "client_id" not in falcon_config or "client_secret" not in falcon_config:
raise KeyError(
"You must include, at minimum, a client_id and client_secret"
)
raise KeyError("You must include, at minimum, a client_id and client_secret")

_configure_logging(profile)

Expand Down
1 change: 0 additions & 1 deletion examples/common/timer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""⏰ Caracara Example execution timer."""

import time

from math import ceil


Expand Down
1 change: 0 additions & 1 deletion examples/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import json

from typing import Dict, List, Union


Expand Down
1 change: 0 additions & 1 deletion examples/flight_control/describe_child_cids.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
This example will show all Child CIDs within a Parent Falcon Flight Control / MSSP CID.
"""
from caracara import Client

from examples.common import caracara_example, pretty_print


Expand Down
14 changes: 4 additions & 10 deletions examples/hosts/find_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
The example demonstrates how to use the Hosts API.
"""
import logging

from typing import Dict, List

from caracara import Client

from examples.common import (
NoDevicesFound,
Timer,
caracara_example,
parse_filter_list,
pretty_print,
NoDevicesFound,
Timer,
)


Expand All @@ -46,13 +44,9 @@ def find_devices(**kwargs):
parse_filter_list(filter_list, filters)

if filters.filters:
logger.info(
"Getting a list of hosts that match the FQL string %s", filters.get_fql()
)
logger.info("Getting a list of hosts that match the FQL string %s", filters.get_fql())
else:
logger.info(
"No filter provided; getting a list of all devices within the tenant"
)
logger.info("No filter provided; getting a list of all devices within the tenant")

with client:
response_data = client.hosts.describe_devices(filters)
Expand Down
8 changes: 1 addition & 7 deletions examples/hosts/find_stale_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@
The example demonstrates how to use the Hosts API and a FalconFilter using a date.
"""
import logging

from datetime import datetime, timezone
from typing import Dict

from dateutil import parser as dparser

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/list_all_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import logging

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/list_all_group_member_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import logging

from caracara import Client

from examples.common import (
caracara_example,
NoGroupsFound,
Timer,
)
from examples.common import NoGroupsFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 2 additions & 5 deletions examples/hosts/list_all_group_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
The example demonstrates how to use the Hosts API.
"""
import logging

from caracara import Client
from examples.common import (
caracara_example,
NoGroupsFound,
Timer,
)
from examples.common import NoGroupsFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/list_all_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import logging

from caracara import Client

from examples.common import (
caracara_example,
NoGroupsFound,
Timer,
)
from examples.common import NoGroupsFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/list_device_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import logging

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/list_hidden_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import logging

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
8 changes: 1 addition & 7 deletions examples/hosts/list_login_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@
The example demonstrates how to use the Hosts API.
"""
import logging

from typing import Dict, List

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
8 changes: 1 addition & 7 deletions examples/hosts/list_network_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@
The example demonstrates how to use the Hosts API.
"""
import logging

from typing import Dict, List

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/list_windows_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
import logging

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
7 changes: 1 addition & 6 deletions examples/hosts/show_agent_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
from tabulate import tabulate

from caracara import Client

from examples.common import (
caracara_example,
NoDevicesFound,
Timer,
)
from examples.common import NoDevicesFound, Timer, caracara_example


@caracara_example
Expand Down
1 change: 0 additions & 1 deletion examples/prevention_policies/create_prevention_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
You can use this code sample to customise the policy.
"""
from caracara import Client

from examples.common import caracara_example, pretty_print


Expand Down
6 changes: 1 addition & 5 deletions examples/prevention_policies/describe_prevention_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
the response policies API.
"""
import logging

from typing import List

from caracara import Client, Policy

from examples.common import caracara_example, pretty_print


Expand All @@ -29,9 +27,7 @@ def describe_prevention_policies(**kwargs):

filters = client.FalconFilter(dialect="hosts")
filters.create_new_filter("OS", "Windows")
policies: List[Policy] = client.prevention_policies.describe_policies(
filters=filters
)
policies: List[Policy] = client.prevention_policies.describe_policies(filters=filters)

i = 1
for policy in policies:
Expand Down
1 change: 0 additions & 1 deletion examples/response_policies/create_response_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging

from caracara import Client

from examples.common import caracara_example, pretty_print


Expand Down
2 changes: 0 additions & 2 deletions examples/response_policies/describe_response_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
the response policies API.
"""
import logging

from typing import List

from caracara import Client, Policy

from examples.common import caracara_example, pretty_print


Expand Down
1 change: 0 additions & 1 deletion examples/rtr/clear_queued_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import logging

from caracara import Client

from examples.common import caracara_example


Expand Down
1 change: 0 additions & 1 deletion examples/rtr/describe_put_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging

from caracara import Client

from examples.common import caracara_example, pretty_print


Expand Down
1 change: 0 additions & 1 deletion examples/rtr/describe_queued_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging

from caracara import Client

from examples.common import caracara_example, pretty_print


Expand Down
1 change: 0 additions & 1 deletion examples/rtr/describe_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging

from caracara import Client

from examples.common import caracara_example, pretty_print


Expand Down
Loading

0 comments on commit ee726f9

Please sign in to comment.