Skip to content

Commit 1d95a08

Browse files
committed
linting
1 parent e1f79a0 commit 1d95a08

File tree

9 files changed

+87
-78
lines changed

9 files changed

+87
-78
lines changed

detect/v1alpha/batch_update_curated_rule_set_deployments.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,17 @@ def batch_update_curated_rule_set_deployments(
8080
"""
8181
base_url_with_region = regions.url_always_prepend_region(
8282
CHRONICLE_API_BASE_URL, proj_region)
83+
# pylint: disable-next=line-too-long
8384
parent = f"projects/{proj_id}/locations/{proj_region}/instances/{proj_instance}"
8485

8586
# We use "-" in the URL because we provide category and rule_set IDs
8687
# in the request data
88+
# pylint: disable-next=line-too-long
8789
url = f"{base_url_with_region}/v1alpha/{parent}/curatedRuleSetCategories/-/curatedRuleSets/-/curatedRuleSetDeployments:batchUpdate"
8890

8991
def make_deployment_name(category: str, rule_set: str, precision: str) -> str:
9092
"""Helper function to create a deployment name."""
93+
# pylint: disable-next=line-too-long
9194
return f"{parent}/curatedRuleSetCategories/{category}/curatedRuleSets/{rule_set}/curatedRuleSetDeployments/{precision}"
9295

9396
# Example deployment configurations - update these with actual IDs

detect/v1alpha/enable_rule.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def enable_rule(
7575
"""
7676
base_url_with_region = regions.url_always_prepend_region(
7777
CHRONICLE_API_BASE_URL, proj_region)
78+
# pylint: disable-next=line-too-long
7879
parent = f"projects/{proj_id}/locations/{proj_region}/instances/{proj_instance}"
7980
url = f"{base_url_with_region}/v1alpha/{parent}/rules/{rule_id}/deployment"
8081

detect/v1alpha/get_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_rule(
6969
"""
7070
base_url_with_region = regions.url_always_prepend_region(
7171
CHRONICLE_API_BASE_URL, proj_region)
72-
# pylint: disable=line-too-long-next
72+
# pylint: disable-next=line-too-long
7373
parent = f"projects/{proj_id}/locations/{proj_region}/instances/{proj_instance}"
7474
url = f"{base_url_with_region}/v1alpha/{parent}/rules/{rule_id}"
7575

iocs/v1alpha/batch_get_iocs.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,32 @@ def batch_get_iocs(
3333
) -> Mapping[str, Any]:
3434
"""Get multiple IoCs by their values from Chronicle.
3535
36-
Args:
37-
http_session: Authorized session for HTTP requests.
38-
proj_id: GCP project id or number to which the target instance belongs.
39-
proj_instance: Customer ID (uuid with dashes) for the instance.
40-
proj_region: region in which the target project is located.
41-
ioc_values: List of IoC values to retrieve.
42-
ioc_type: Type of IoCs being requested. One of:
43-
IOC_TYPE_UNSPECIFIED
44-
DOMAIN
45-
IP
46-
FILE_HASH
47-
URL
48-
USER_EMAIL
49-
MUTEX
50-
FILE_HASH_MD5
51-
FILE_HASH_SHA1
52-
FILE_HASH_SHA256
53-
IOC_TYPE_RESOURCE
36+
Args:
37+
http_session: Authorized session for HTTP requests.
38+
proj_id: GCP project id or number to which the target instance belongs.
39+
proj_instance: Customer ID (uuid with dashes) for the instance.
40+
proj_region: region in which the target project is located.
41+
ioc_values: List of IoC values to retrieve.
42+
ioc_type: Type of IoCs being requested. One of:
43+
IOC_TYPE_UNSPECIFIED
44+
DOMAIN
45+
IP
46+
FILE_HASH
47+
URL
48+
USER_EMAIL
49+
MUTEX
50+
FILE_HASH_MD5
51+
FILE_HASH_SHA1
52+
FILE_HASH_SHA256
53+
IOC_TYPE_RESOURCE
5454
55-
Returns:
56-
Dict containing the requested IoCs.
55+
Returns:
56+
Dict containing the requested IoCs.
5757
58-
Raises:
59-
requests.exceptions.HTTPError: HTTP request resulted in an error
60-
(response.status_code >= 400).
61-
"""
58+
Raises:
59+
requests.exceptions.HTTPError: HTTP request resulted in an error
60+
(response.status_code >= 400).
61+
"""
6262
base_url_with_region = regions.url_always_prepend_region(
6363
CHRONICLE_API_BASE_URL, proj_region)
6464
instance = f"projects/{proj_id}/locations/{proj_region}/instances/{proj_instance}"

iocs/v1alpha/get_ioc_state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
# limitations under the License.
1616
"""Get the state of an IoC from Chronicle."""
1717

18+
from typing import Any, Mapping
19+
1820
from common import regions
1921
from google.auth.transport import requests
20-
from typing import Any, Mapping
2122

2223
CHRONICLE_API_BASE_URL = "https://chronicle.googleapis.com"
2324

sdk/commands/detect.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ def update_alert_cmd(credentials_file, project_id, project_instance, region,
122122
@alerts.command("bulk-update")
123123
@add_common_options
124124
@click.option(
125-
"--filter",
125+
"--a_filter",
126126
required=True,
127-
help="Filter to select alerts to update.",
127+
help="a_filter to select alerts to update.",
128128
)
129129
@click.option(
130130
"--update-mask",
@@ -137,7 +137,7 @@ def update_alert_cmd(credentials_file, project_id, project_instance, region,
137137
help="JSON string containing the update data.",
138138
)
139139
def bulk_update_alerts_cmd(credentials_file, project_id, project_instance,
140-
region, filter, update_mask, json_body):
140+
region, a_filter, update_mask, json_body):
141141
"""Bulk update alerts matching a filter."""
142142
auth_session = chronicle_auth.initialize_http_session(
143143
credentials_file,
@@ -148,7 +148,7 @@ def bulk_update_alerts_cmd(credentials_file, project_id, project_instance,
148148
project_id,
149149
project_instance,
150150
region,
151-
filter,
151+
a_filter,
152152
update_mask,
153153
json_body,
154154
)
@@ -195,8 +195,8 @@ def get_detection_cmd(credentials_file, project_id, project_instance, region,
195195
@detections.command("list")
196196
@add_common_options
197197
@click.option(
198-
"--filter",
199-
help="Filter string for the list request.",
198+
"--a_filter",
199+
help="a_filter string for the list request.",
200200
)
201201
@click.option(
202202
"--page-size",
@@ -208,7 +208,7 @@ def get_detection_cmd(credentials_file, project_id, project_instance, region,
208208
help="Page token from previous response.",
209209
)
210210
def list_detections_cmd(credentials_file, project_id, project_instance, region,
211-
filter, page_size, page_token):
211+
a_filter, page_size, page_token):
212212
"""List detections."""
213213
auth_session = chronicle_auth.initialize_http_session(
214214
credentials_file,
@@ -219,7 +219,7 @@ def list_detections_cmd(credentials_file, project_id, project_instance, region,
219219
region,
220220
project_id,
221221
project_instance,
222-
filter,
222+
a_filter,
223223
page_size,
224224
page_token,
225225
)
@@ -331,8 +331,8 @@ def enable_rule_cmd(credentials_file, project_id, project_instance, region,
331331
@rules.command("list")
332332
@add_common_options
333333
@click.option(
334-
"--filter",
335-
help="Filter string for the list request.",
334+
"--a_filter",
335+
help="a_filter string for the list request.",
336336
)
337337
@click.option(
338338
"--page-size",
@@ -344,7 +344,7 @@ def enable_rule_cmd(credentials_file, project_id, project_instance, region,
344344
help="Page token from previous response.",
345345
)
346346
def list_rules_cmd(credentials_file, project_id, project_instance, region,
347-
filter, page_size, page_token):
347+
a_filter, page_size, page_token):
348348
"""List rules."""
349349
auth_session = chronicle_auth.initialize_http_session(
350350
credentials_file,
@@ -355,7 +355,7 @@ def list_rules_cmd(credentials_file, project_id, project_instance, region,
355355
project_id,
356356
project_instance,
357357
region,
358-
filter,
358+
a_filter,
359359
page_size,
360360
page_token,
361361
)
@@ -427,8 +427,8 @@ def errors():
427427
@errors.command("list")
428428
@add_common_options
429429
@click.option(
430-
"--filter",
431-
help="Filter string for the list request.",
430+
"--a_filter",
431+
help="a_filter string for the list request.",
432432
)
433433
@click.option(
434434
"--page-size",
@@ -440,7 +440,7 @@ def errors():
440440
help="Page token from previous response.",
441441
)
442442
def list_errors_cmd(credentials_file, project_id, project_instance, region,
443-
filter, page_size, page_token):
443+
a_filter, page_size, page_token):
444444
"""List errors."""
445445
auth_session = chronicle_auth.initialize_http_session(
446446
credentials_file,
@@ -451,7 +451,7 @@ def list_errors_cmd(credentials_file, project_id, project_instance, region,
451451
project_id,
452452
project_instance,
453453
region,
454-
filter,
454+
a_filter,
455455
page_size,
456456
page_token,
457457
)
@@ -479,6 +479,7 @@ def batch_update_rule_sets_cmd(credentials_file, project_id, project_instance,
479479
credentials_file,
480480
SCOPES,
481481
)
482+
# pylint: disable-next=line-too-long
482483
result = batch_update_curated_rule_set_deployments.batch_update_curated_rule_set_deployments(
483484
auth_session,
484485
project_id,

search/v1alpha/raw_logs_find.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,33 @@ def find_raw_logs(http_session: requests.AuthorizedSession,
5050
regex_search: bool = False,
5151
case_sensitive: bool = False,
5252
max_response_size: Optional[int] = None) -> None:
53+
# pylint: disable=line-too-long
5354
"""Find raw logs in Chronicle using the Legacy Find Raw Logs API.
5455
55-
Args:
56-
http_session: Authorized session for HTTP requests.
57-
proj_id: GCP project id or number to which the target instance belongs.
58-
proj_instance: Customer ID (uuid with dashes) for the Chronicle instance.
59-
proj_region: region in which the target project is located.
60-
query: Required search parameters that expand or restrict the search.
61-
batch_tokens: Optional list of tokens that should be downloaded.
62-
log_ids: Optional list of raw log ids that should be downloaded.
63-
If both batch_tokens and log_ids are provided, batch_tokens will be discarded.
64-
regex_search: Optional boolean to treat query as regex. Default is False.
65-
case_sensitive: Optional boolean for case-sensitive search. Default is False.
66-
max_response_size: Optional maximum response size in bytes. Default is 50MiB.
67-
68-
Raises:
69-
requests.exceptions.HTTPError: HTTP request resulted in an error
70-
(response.status_code >= 400).
71-
72-
Requires the following IAM permission on the instance resource:
73-
chronicle.legacies.legacyFindRawLogs
74-
"""
56+
Args:
57+
http_session: Authorized session for HTTP requests.
58+
proj_id: GCP project id or number to which the target instance belongs.
59+
proj_instance: Customer ID (uuid with dashes) for the Chronicle instance.
60+
proj_region: region in which the target project is located.
61+
query: Required search parameters that expand or restrict the search.
62+
batch_tokens: Optional list of tokens that should be downloaded.
63+
log_ids: Optional list of raw log ids that should be downloaded.
64+
If both batch_tokens and log_ids are provided, batch_tokens will be discarded.
65+
regex_search: Optional boolean to treat query as regex. Default is False.
66+
case_sensitive: Optional boolean for case-sensitive search. Default is False.
67+
max_response_size: Optional maximum response size in bytes. Default is 50MiB.
68+
69+
Raises:
70+
requests.exceptions.HTTPError: HTTP request resulted in an error
71+
(response.status_code >= 400).
72+
73+
Requires the following IAM permission on the instance resource:
74+
chronicle.legacies.legacyFindRawLogs
75+
"""
76+
# pylint: enable=line-too-long
7577
base_url_with_region = regions.url_always_prepend_region(
7678
CHRONICLE_API_BASE_URL, proj_region)
79+
# pylint: disable-next=line-too-long
7780
instance = f"projects/{proj_id}/locations/{proj_region}/instances/{proj_instance}"
7881
url = f"{base_url_with_region}/v1alpha/{instance}/legacy:legacyFindRawLogs"
7982

@@ -123,7 +126,8 @@ def find_raw_logs(http_session: requests.AuthorizedSession,
123126
"--batch_tokens",
124127
type=str,
125128
help=
126-
'JSON string containing a list of batch tokens (e.g., \'["token1", "token2"]\')'
129+
'JSON string containing a list of batch tokens '
130+
' (e.g., \'["token1", "token2"]\')'
127131
)
128132
parser.add_argument(
129133
"--log_ids",

search/v1alpha/search_query_get.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ def get_search_query(http_session: requests.AuthorizedSession, proj_id: str,
4141
query_id: str) -> None:
4242
"""Get a search query by ID from Chronicle.
4343
44-
Args:
45-
http_session: Authorized session for HTTP requests.
46-
proj_id: GCP project id or number to which the target instance belongs.
47-
proj_instance: Customer ID (uuid with dashes) for the instance.
48-
proj_region: region in which the target project is located.
49-
user_id: ID of the user who owns the search query.
50-
query_id: ID of the search query to retrieve.
44+
Args:
45+
http_session: Authorized session for HTTP requests.
46+
proj_id: GCP project id or number to which the target instance belongs.
47+
proj_instance: Customer ID (uuid with dashes) for the instance.
48+
proj_region: region in which the target project is located.
49+
user_id: ID of the user who owns the search query.
50+
query_id: ID of the search query to retrieve.
5151
52-
Raises:
53-
requests.exceptions.HTTPError: HTTP request resulted in an error
54-
(response.status_code >= 400).
52+
Raises:
53+
requests.exceptions.HTTPError: HTTP request resulted in an error
54+
(response.status_code >= 400).
5555
56-
Requires the following IAM permission on the instance resource:
57-
chronicle.searchQueries.get
58-
"""
56+
Requires the following IAM permission on the instance resource:
57+
chronicle.searchQueries.get
58+
"""
5959
base_url_with_region = regions.url_always_prepend_region(
6060
CHRONICLE_API_BASE_URL, proj_region)
6161
# pylint: disable=line-too-long

search/v1alpha/udm_events_find.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def find_udm_events(http_session: requests.AuthorizedSession,
5959
tokens: Optional[List[str]] = None,
6060
event_ids: Optional[List[str]] = None,
6161
return_unenriched_data: bool = False,
62-
return_all_events_for_log: bool = False
63-
) -> None:
62+
return_all_events_for_log: bool = False) -> None:
6463
# pylint: disable=line-too-long
6564
"""Find UDM events in Chronicle using the Legacy Find UDM Events API.
6665

0 commit comments

Comments
 (0)