soar_ops 模块
TIPCommon.soar_ops.create_slo_message
TIPCommon.soar_ops.create_slo_message(slo: int, interval_days: Iterable[int], existing_comments: Iterable[str])
根据时间间隔和现有注释获取 SLO 警告消息。
对于 interval_days=[0, 1, 7, 14]
参数,该函数会发送一条消息,警告 SLO 将在下一次安排后被违反:
- 距离到期时间还有 7-14 天。
- 距离到期时间还有 1-7 天。
- 违反 SLO 的时间。
如果当前违规时间间隔内已发送评论,则不会返回新评论(返回 None
)。
参数 | |
---|---|
slo |
int 以 Unix 微秒为单位的 SLO 违规日期(例如,1_673_774_674_567) |
interval_days |
Iterable[int] 一个可迭代对象,包含应发送时间违规警告的天数(例如,[0, 1, 3, 7, 14]) |
existing_comments |
Iterable[int] 用于检查评论是否已发送的现有评论。 |
可能引发的错误
ValueError
- 当某个时间区间为负数时。
返回值
如果适用,则返回评论。否则,返回 None
。
TIPCommon.soar_ops.get_clean_comment_body
TIPCommon.soar_ops.get_clean_comment_body(comment: str | CaseComment, prefix: str)
从评论字符串或评论对象中移除前缀。
参数 | |
---|---|
comment |
str | CaseComment 要移除前缀的注释字符串或注释对象。 |
prefix |
str 要移除的前缀。 |
可能引发的错误
TypeError
- 当评论类型既不是 str
也不是 CaseComment
时。
返回值
不带前缀的注释。
返回类型
str
TIPCommon.soar_ops.get_file
TIPCommon.soar_ops.get_file(chronicle_soar: SiemplifyAction | SiemplifyConnectorExecution | SiemplifyJob, identifier: str)→ bytes | None
以字节为单位返回文件内容。
参数
参数 | |
---|---|
chronicle_soar |
ChronicleSOAR Google Security Operations SOAR SDK 对象。 |
identifier |
str 文件名标识符以及完整路径。 |
返回值
所提供标识符的字节数据。
返回类型
bytes | None
TIPCommon.soar_ops.get_secops_mode
TIPCommon.soar_ops.get_secops_mode()→ str | None
返回 SECOPS_MODE
环境变量。
返回值
SECOPS_MODE
环境变量。
返回类型
str | None
TIPCommon.soar_ops.get_soar_case_comments
TIPCommon.soar_ops.get_soar_case_comments(chronicle_soar: SiemplifyAction | SiemplifyJob, case_id: str | int)
使用支持请求的 ID 返回相应支持请求中的评论对象列表。
参数 | |
---|---|
chronicle_soar |
SiemplifyAction | SiemplifyJob SDK 对象。 |
case_id |
str | int 要提取评论的支持请求的 ID。 |
返回值
评论对象列表。
返回类型
list[base.action.CaseComment]
TIPCommon.soar_ops.get_user_by_id
TIPCommon.soar_ops.get_user_by_id(chronicle_soar: SiemplifyAction | SiemplifyConnectorExecution | SiemplifyJob, user_id: str)→ UserProfileCard | None
根据用户 ID 获取 UserProfileCard 对象。
参数
参数 | |
---|---|
chronicle_soar |
ChronicleSOAR Google Security Operations SOAR SDK 对象。 |
user_id |
str 用户 ID,例如 |
返回值
如果找到用户对象,则返回该对象;否则,返回 None
。
返回类型
UserProfileCard | None
TIPCommon.soar_ops.get_users_profile_cards_with_pagination
TIPCommon.soar_ops.get_users_profile_cards_with_pagination(chronicle_soar: SiemplifyAction | SiemplifyConnectorExecution | SiemplifyJob, search_term: str = '', page_size: int = 20, filter_by_role: bool = False, filter_disabled_users: bool = False, filter_support_users: bool = False, fetch_only_support_users: bool = False, filter_permission_types: list[int] | None = None)→ list[UserProfileCard]
使用分页功能获取所有用户个人资料卡片。网页大小用作每次迭代中用户数量的上限。
参数
参数 | |
---|---|
chronicle_soar |
ChronicleSOAR Google Security Operations SOAR SDK 对象。 |
search_term |
str 搜索字词。 默认值为 |
page_size |
int 要返回的用户数量。 默认值为 |
filter_by_role |
bool 定义是否按角色过滤。 默认值为 |
filter_disabled_users |
bool 定义是否过滤已停用的用户。 默认值为 |
filter_support_users |
bool 定义是否过滤支持用户。 默认值为 |
fetch_only_support_users |
bool 定义是否仅返回支持用户。 默认值为 |
filter_permission_types |
list[int] | None 过滤条件权限类型列表(例如 默认值为 |
返回值
所有用户的列表。
返回类型
list[UserProfileCard]
TIPCommon.soar_ops.is_slo_comment
TIPCommon.soar_ops.is_slo_comment(comment: str)
检查评论是否为 SLO 警告评论。
SLO 注释可以是 SLO 警告(“SLO 将在 {int} 天内被违反”),也可以是 SLO 违反消息(“SLO 已被违反”)。
参数 | |
---|---|
comment |
str 要检查的评论。 |
返回值
如果评论是 SLO 评论,则为 True
。否则,返回 False
。
返回类型
bool
TIPCommon.soar_ops.remove_prefix_from_comments
TIPCommon.soar_ops.remove_prefix_from_comments(comments: list[str], prefix: str)
从评论列表中移除前缀(如果存在)。
参数 | |
---|---|
comments |
list[str] 要从中移除前缀的注释。 |
prefix |
str 要移除的前缀。 |
返回值
移除了前缀的所有评论的列表
返回类型
list[str]
TIPCommon.soar_ops.save_file
TIPCommon.soar_ops.save_file(chronicle_soar: SiemplifyAction | SiemplifyConnectorExecution | SiemplifyJob, path: str, name: str, content: bytes)→ bytes | None
将文件保存到 Google Cloud 存储桶或本地路径。
参数
参数 | |
---|---|
chronicle_soar |
ChronicleSOAR Google Security Operations SOAR SDK 对象。 |
path |
str 应保存文件的文件夹的路径。 |
name |
str 要保存的文件名。 |
content |
bytes 文件内容(字节格式)。 |
返回值
下载文件的路径。
返回类型
str | None
需要更多帮助?从社区成员和 Google SecOps 专业人士那里获得解答。