Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tipcommon/TIPCommon/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "TIPCommon"
version = "2.3.0"
version = "2.3.1"
description = "General Purpose CLI tool for Google SecOps Marketplace"
readme = "README.md"
authors = [
Expand Down
55 changes: 54 additions & 1 deletion packages/tipcommon/TIPCommon/src/TIPCommon/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,63 @@
# limitations under the License.


from typing import Any

import SiemplifyVaultUtils

from .data_models import ConnectorParameter, ConnectorParamTypes
from .types import ChronicleSOAR, SingleJson
from .utils import clean_result
from .validation import ParameterValidator


def _get_vault_settings(siemplify: ChronicleSOAR) -> SingleJson | None:
"""Retrieves vault settings from the siemplify object.

Tries to get vault_settings from siemplify.context first,
then falls back to siemplify.vault_settings.

Args:
siemplify (ChronicleSOAR): The Siemplify object.

Returns:
The vault settings if available, otherwise None.

"""
context: Any | None = getattr(siemplify, "context", None)

if context:
vault_settings: SingleJson | None = getattr(context, "vault_settings", None)
if vault_settings:
return vault_settings

return getattr(siemplify, "vault_settings", None)


def _extract_param_value(
input_dictionary: SingleJson,
param_name: str,
vault_settings: SingleJson | None,
) -> Any | None:
"""Extracts a parameter value, applying vault extraction if available.

Args:
input_dictionary (SingleJson): The input dictionary containing parameters.
param_name (str): The parameter name to extract.
vault_settings (SingleJson | None): The vault settings, or None if not available.

Returns:
The extracted value.

"""
raw_value: Any | None = input_dictionary.get(param_name)

if vault_settings is None:
Comment thread
TalShafir1 marked this conversation as resolved.
return raw_value

return SiemplifyVaultUtils.extract_vault_param(raw_value, vault_settings)


def extract_script_param(
siemplify,
input_dictionary,
Expand Down Expand Up @@ -57,7 +109,8 @@ def extract_script_param(
)

# =========== start validation logic =====================
value = input_dictionary.get(param_name)
vault_settings = _get_vault_settings(siemplify)
value = _extract_param_value(input_dictionary, param_name, vault_settings)

if not value:
if is_mandatory:
Expand Down
Binary file not shown.
Loading