Skip to content

Commit e65ea67

Browse files
Chronicle Teamcopybara-github
authored andcommitted
Add check for operation ID to Detect v1 list_results sample
PiperOrigin-RevId: 373458576
1 parent ac7ead1 commit e65ea67

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

detect/v1/list_results.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
import re
2424
from typing import Any, Mapping, Optional, Sequence, Tuple
2525

26-
from common import chronicle_auth
2726
from google.auth.transport import requests
2827

28+
from common import chronicle_auth
29+
2930
CHRONICLE_API_BASE_URL = "https://backstory.googleapis.com"
3031

3132
OPERATION_ID_PATTERN = re.compile(
@@ -79,6 +80,10 @@ def list_results(
7980
except binascii.Error:
8081
raise ValueError(f"Invalid page token: '{page_token}'.")
8182

83+
if not OPERATION_ID_PATTERN.fullmatch(operation_id):
84+
raise ValueError(f"Invalid detection operation ID: '{operation_id}' != " +
85+
"'rulejob_jo_<UUID>'.")
86+
8287
url = (f"{CHRONICLE_API_BASE_URL}/v1/rules_results?name=operations/" +
8388
operation_id)
8489
if page_size > 0:

0 commit comments

Comments
 (0)