Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
from soar_sdk.SiemplifyUtils import output_handler, convert_dict_to_json_result_dict
from soar_sdk.SiemplifyDataModel import EntityTypes
from soar_sdk.ScriptResult import EXECUTION_STATE_COMPLETED, EXECUTION_STATE_FAILED
from soar_sdk.SiemplifyAction import SiemplifyAction
from TIPCommon import (
extract_configuration_param,
extract_action_param,
flat_dict_to_csv,
)
from ..core.HCLBigFixInventoryManager import HCLBigFixInventoryManager
from ..core.constants import INTEGRATION_NAME, ENRICH_ENTITIES_SCRIPT_NAME, ENRICHMENT_PREFIX
from ..core.UtilsManager import get_entity_original_identifier, convert_comma_separated_to_list


SUPPORTED_ENTITY_TYPES = [EntityTypes.ADDRESS, EntityTypes.HOSTNAME]


@output_handler
def main():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Missing return type annotation for the main function. According to the style guide, all function parameters and return types must be annotated.

Suggested change
def main():
def main() -> None:
References
  1. All function parameters and return types must be annotated. (link)

siemplify = SiemplifyAction()
siemplify.script_name = ENRICH_ENTITIES_SCRIPT_NAME
siemplify.LOGGER.info("----------------- Main - Param Init -----------------")

api_root = extract_configuration_param(
siemplify,
provider_name=INTEGRATION_NAME,
param_name="API Root",
is_mandatory=True,
print_value=True,
)
api_token = extract_configuration_param(
siemplify,
provider_name=INTEGRATION_NAME,
param_name="API Token",
is_mandatory=True,
remove_whitespaces=False,
)
verify_ssl = extract_configuration_param(
siemplify,
provider_name=INTEGRATION_NAME,
param_name="Verify SSL",
is_mandatory=True,
input_type=bool,
print_value=True,
)

custom_fields = extract_action_param(
siemplify, param_name="Custom Fields", print_value=True
)
create_insight = extract_action_param(
siemplify, param_name="Create Insight", print_value=True, input_type=bool
)

suitable_entities = [
entity
for entity in siemplify.target_entities
if entity.entity_type in SUPPORTED_ENTITY_TYPES
]

siemplify.LOGGER.info("----------------- Main - Started -----------------")

result_value = True
status = EXECUTION_STATE_COMPLETED
output_message = ""
successful_entities, failed_entities = [], []
json_result = {}

try:
manager = HCLBigFixInventoryManager(
api_root=api_root,
api_token=api_token,
verify_ssl=verify_ssl,
siemplify_logger=siemplify.LOGGER,
)
manager.test_connectivity()

for entity in suitable_entities:
entity_identifier = get_entity_original_identifier(entity)
try:
siemplify.LOGGER.info(f"Started processing entity: {entity_identifier}")
if entity.entity_type == EntityTypes.ADDRESS:
devices = manager.get_devices(
custom_fields=convert_comma_separated_to_list(custom_fields),
ip=entity_identifier,
)
else:
devices = manager.get_devices(
custom_fields=convert_comma_separated_to_list(custom_fields),
hostname=entity_identifier,
)

if devices:
device = devices[0]
json_result[entity_identifier] = device.to_json()

siemplify.LOGGER.info(f"Enriching entity {entity_identifier}")
entity.additional_properties.update(
device.to_enrichment_data(prefix=ENRICHMENT_PREFIX)
)
entity.is_enriched = True

if create_insight:
siemplify.LOGGER.info(
f"Adding insight for entity {entity_identifier}"
)
siemplify.add_entity_insight(entity, device.to_insight())

siemplify.result.add_entity_table(
entity_identifier, flat_dict_to_csv(device.to_table())
)

successful_entities.append(entity)
else:
failed_entities.append(entity)

siemplify.LOGGER.info(f"Finish processing entity: {entity_identifier}")
except Exception as e:
failed_entities.append(entity)
siemplify.LOGGER.error(
f"An error occurred on entity: {entity_identifier}."
)
siemplify.LOGGER.exception(e)

if successful_entities:
output_message += (
f"Successfully enriched the following entities using information from "
f"{INTEGRATION_NAME}: "
f"{', '.join([get_entity_original_identifier(entity) for entity in successful_entities])}\n\n"
)
siemplify.update_entities(successful_entities)
siemplify.result.add_result_json(
convert_dict_to_json_result_dict(json_result)
)

if failed_entities:
output_message += (
"Action wasn't able to enrich the following entities using "
f"information from {INTEGRATION_NAME}: "
f"{', '.join([get_entity_original_identifier(entity) for entity in failed_entities])}\n"
)
else:
output_message = "None of the provided entities were enriched."
result_value = False

except Exception as e:
result_value = False
status = EXECUTION_STATE_FAILED
output_message = (
f"Error executing action {ENRICH_ENTITIES_SCRIPT_NAME}. Reason: {e}"
)
siemplify.LOGGER.error(output_message)
siemplify.LOGGER.exception(e)

siemplify.LOGGER.info("----------------- Main - Finished -----------------")
siemplify.LOGGER.info(
f"\n status: {status}\n "
f"is_success: {result_value}\n "
f"output_message: {output_message}"
)
siemplify.end(output_message, result_value, status)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Enrich Entities
description: 'Enrich entities using information from HCL BigFix Inventory. Supported
entities: Hostname, IP Address.'
integration_identifier: HCLBigFixInventory
parameters:
- name: Custom Fields
default_value: ''
type: string
description: Specify a comma-separated list of fields that needs to be returned
in addition to the ones that are returned by default.
is_mandatory: false
- name: Create Insight
default_value: true
type: boolean
description: If enabled, action will create an insight containing all of the retrieved
information about the entity.
is_mandatory: false
dynamic_results_metadata:
- result_example_path: resources/enrich_entities_JsonResult_example.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The result_example_path should point to a file named according to the action filename convention: EnrichEntities_JsonResult_example.json.

-   result_example_path: resources/EnrichEntities_JsonResult_example.json
References
  1. The example file must match the action's filename: action_name.py requires resources/action_name_JsonResult_example.json. (link)

result_name: JsonResult
show_result: true
creator: admin
simulation_data_json: '{"Entities": ["HOSTNAME", "ADDRESS"]}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
from soar_sdk.SiemplifyUtils import output_handler
from soar_sdk.ScriptResult import EXECUTION_STATE_COMPLETED, EXECUTION_STATE_FAILED
from soar_sdk.SiemplifyAction import SiemplifyAction
from TIPCommon import extract_configuration_param
from ..core.HCLBigFixInventoryManager import HCLBigFixInventoryManager
from ..core.constants import INTEGRATION_NAME, INTEGRATION_DISPLAY_NAME, PING_SCRIPT_NAME


@output_handler
def main():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Missing return type annotation for the main function. All function parameters and return types must be annotated per the style guide.

Suggested change
def main():
def main() -> None:
References
  1. All function parameters and return types must be annotated. (link)

siemplify = SiemplifyAction()
siemplify.script_name = PING_SCRIPT_NAME
siemplify.LOGGER.info("----------------- Main - Param Init -----------------")

api_root = extract_configuration_param(
siemplify,
provider_name=INTEGRATION_NAME,
param_name="API Root",
is_mandatory=True,
print_value=True,
)
api_token = extract_configuration_param(
siemplify,
provider_name=INTEGRATION_NAME,
param_name="API Token",
is_mandatory=True,
remove_whitespaces=False,
)
verify_ssl = extract_configuration_param(
siemplify,
provider_name=INTEGRATION_NAME,
param_name="Verify SSL",
is_mandatory=True,
input_type=bool,
print_value=True,
)

siemplify.LOGGER.info("----------------- Main - Started -----------------")

try:
manager = HCLBigFixInventoryManager(
api_root=api_root,
api_token=api_token,
verify_ssl=verify_ssl,
siemplify_logger=siemplify.LOGGER,
)
manager.test_connectivity()
result = True
status = EXECUTION_STATE_COMPLETED
output_message = (
f"Successfully connected to the {INTEGRATION_DISPLAY_NAME} server with the "
f"provided connection parameters!"
)

except Exception as e:
siemplify.LOGGER.error(f"General error performing action {PING_SCRIPT_NAME}")
siemplify.LOGGER.exception(e)
result = False
status = EXECUTION_STATE_FAILED
output_message = (
f"Failed to connect to the {INTEGRATION_DISPLAY_NAME} server! Error is {e}"
)

siemplify.LOGGER.info("----------------- Main - Finished -----------------")
siemplify.LOGGER.info(f"Status: {status}")
siemplify.LOGGER.info(f"Result: {result}")
siemplify.LOGGER.info(f"Output Message: {output_message}")

siemplify.end(output_message, result, status)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Ping
description: Test connectivity to the HCL BigFix Inventory with parameters provided
at the integration configuration page on the Marketplace tab.
integration_identifier: HCLBigFixInventory
parameters: []
dynamic_results_metadata: []
creator: admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
class HCLBigFixInventoryException(Exception):
"""
General exception for HCL BigFix Inventory
"""
Loading
Loading