Skip to content

Commit 913dadf

Browse files
committed
chore: minor refactoring and formatting
1 parent 73bcf71 commit 913dadf

4 files changed

Lines changed: 79 additions & 10 deletions

File tree

src/secops/chronicle/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
list_retrohunts as _list_retrohunts,
289289
)
290290
from secops.chronicle.rule_set import (
291-
batch_update_curated_rule_set_deployments as _batch_update_curated_rule_set_deployments, #pylint: disable=line-too-long
291+
batch_update_curated_rule_set_deployments as _batch_update_curated_rule_set_deployments, # pylint: disable=line-too-long
292292
)
293293
from secops.chronicle.rule_set import get_curated_rule as _get_curated_rule
294294
from secops.chronicle.rule_set import (
@@ -304,7 +304,7 @@
304304
get_curated_rule_set_deployment as _get_curated_rule_set_deployment,
305305
)
306306
from secops.chronicle.rule_set import (
307-
get_curated_rule_set_deployment_by_name as _get_curated_rule_set_deployment_by_name, #pylint: disable=line-too-long
307+
get_curated_rule_set_deployment_by_name as _get_curated_rule_set_deployment_by_name, # pylint: disable=line-too-long
308308
)
309309
from secops.chronicle.rule_set import (
310310
list_curated_rule_set_categories as _list_curated_rule_set_categories,

src/secops/chronicle/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class IntegrationType(str, Enum):
105105
RESPONSE = "RESPONSE"
106106
EXTENSION = "EXTENSION"
107107

108+
108109
class IntegrationParamType(str, Enum):
109110
"""Parameter types for Chronicle SOAR integration functions."""
110111

@@ -127,6 +128,7 @@ class IntegrationParamType(str, Enum):
127128
FILTER_LIST = "FILTER_LIST"
128129
NUMERICAL_VALUES = "NUMERICAL_VALUES"
129130

131+
130132
@dataclass
131133
class IntegrationParam:
132134
"""A parameter definition for a Chronicle SOAR integration.

src/secops/chronicle/soar/integration/integrations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,14 @@ def update_integration(
599599
"""
600600
body, params = build_patch_body(
601601
field_map=[
602-
("displayName", "display_name", display_name),
602+
("display_name", "displayName", display_name),
603603
("description", "description", description),
604-
("imageBase64", "image_base64", image_base64),
605-
("svgIcon", "svg_icon", svg_icon),
606-
("pythonVersion", "python_version", python_version),
604+
("image_base64", "imageBase64", image_base64),
605+
("svg_icon", "svgIcon", svg_icon),
606+
("python_version", "pythonVersion", python_version),
607607
("parameters", "parameters", parameters),
608608
("categories", "categories", categories),
609-
("integrationType", "integration_type", integration_type),
609+
("integration_type", "integrationType", integration_type),
610610
("staging", "staging", staging),
611611
],
612612
update_mask=update_mask,

src/secops/cli/commands/integration/integration.py

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#
1515
"""Google SecOps CLI integration commands"""
1616

17+
import json
1718
import sys
1819

1920
from secops.chronicle.models import (
@@ -127,6 +128,18 @@ def setup_integrations_command(subparsers):
127128
help="Integration type",
128129
dest="integration_type",
129130
)
131+
create_parser.add_argument(
132+
"--parameters",
133+
type=str,
134+
help="JSON string representing a list of integration parameters",
135+
dest="parameters",
136+
)
137+
create_parser.add_argument(
138+
"--categories",
139+
type=str,
140+
help="Comma-separated list of categories for the integration",
141+
dest="categories",
142+
)
130143
create_parser.set_defaults(func=handle_integration_create_command)
131144

132145
# download command
@@ -412,6 +425,18 @@ def setup_integrations_command(subparsers):
412425
help="Integration type",
413426
dest="integration_type",
414427
)
428+
update_parser.add_argument(
429+
"--parameters",
430+
type=str,
431+
help="JSON string representing a list of integration parameters",
432+
dest="parameters",
433+
)
434+
update_parser.add_argument(
435+
"--categories",
436+
type=str,
437+
help="Comma-separated list of categories for the integration",
438+
dest="categories",
439+
)
415440
update_parser.add_argument(
416441
"--staging",
417442
action="store_true",
@@ -489,6 +514,18 @@ def setup_integrations_command(subparsers):
489514
help="Integration type",
490515
dest="integration_type",
491516
)
517+
update_custom_parser.add_argument(
518+
"--parameters",
519+
type=str,
520+
help="JSON string representing a list of integration parameters",
521+
dest="parameters",
522+
)
523+
update_custom_parser.add_argument(
524+
"--categories",
525+
type=str,
526+
help="Comma-separated list of categories for the integration",
527+
dest="categories",
528+
)
492529
update_custom_parser.add_argument(
493530
"--staging",
494531
action="store_true",
@@ -580,6 +617,16 @@ def handle_integration_create_command(args, chronicle):
580617
if args.integration_type
581618
else None
582619
),
620+
parameters=(
621+
json.loads(args.parameters)
622+
if getattr(args, "parameters", None)
623+
else None
624+
),
625+
categories=(
626+
[c.strip() for c in args.categories.split(",")]
627+
if getattr(args, "categories", None)
628+
else None
629+
),
583630
)
584631
output_formatter(out, getattr(args, "output", "json"))
585632
except Exception as e: # pylint: disable=broad-exception-caught
@@ -590,7 +637,7 @@ def handle_integration_create_command(args, chronicle):
590637
def handle_integration_download_command(args, chronicle):
591638
"""Handle download integration command"""
592639
try:
593-
zip_bytes = chronicle.download_integration(
640+
zip_bytes = chronicle.soar.download_integration(
594641
integration_name=args.integration_id,
595642
)
596643
with open(args.output_file, "wb") as f:
@@ -622,7 +669,7 @@ def handle_download_integration_dependency_command(args, chronicle):
622669
def handle_export_integration_items_command(args, chronicle):
623670
"""Handle export integration items command"""
624671
try:
625-
zip_bytes = chronicle.export_integration_items(
672+
zip_bytes = chronicle.soar.export_integration_items(
626673
integration_name=args.integration_id,
627674
actions=args.actions,
628675
jobs=args.jobs,
@@ -736,7 +783,17 @@ def handle_update_integration_command(args, chronicle):
736783
if args.integration_type
737784
else None
738785
),
739-
staging=args.staging or None,
786+
parameters=(
787+
json.loads(args.parameters)
788+
if getattr(args, "parameters", None)
789+
else None
790+
),
791+
categories=(
792+
[c.strip() for c in args.categories.split(",")]
793+
if getattr(args, "categories", None)
794+
else None
795+
),
796+
staging=args.staging if "staging" in vars(args) else None,
740797
dependencies_to_remove=args.dependencies_to_remove,
741798
update_mask=args.update_mask,
742799
)
@@ -765,6 +822,16 @@ def handle_updated_custom_integration_command(args, chronicle):
765822
if args.integration_type
766823
else None
767824
),
825+
parameters=(
826+
json.loads(args.parameters)
827+
if getattr(args, "parameters", None)
828+
else None
829+
),
830+
categories=(
831+
[c.strip() for c in args.categories.split(",")]
832+
if getattr(args, "categories", None)
833+
else None
834+
),
768835
staging=args.staging or None,
769836
dependencies_to_remove=args.dependencies_to_remove,
770837
update_mask=args.update_mask,

0 commit comments

Comments
 (0)