Skip to content

migrate mc_afee_nsm#606

Open
haggit-eliyahu wants to merge 6 commits intomainfrom
migrate-mc_afee_nsm-integration
Open

migrate mc_afee_nsm#606
haggit-eliyahu wants to merge 6 commits intomainfrom
migrate-mc_afee_nsm-integration

Conversation

@haggit-eliyahu
Copy link
Contributor

No description provided.

@haggit-eliyahu haggit-eliyahu requested a review from a team as a code owner March 10, 2026 13:19
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

1 similar comment
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive integration for McAfee Network Security Manager (NSM), enabling automated security responses and data retrieval. The new integration provides capabilities to manage network access by blocking, unblocking, and quarantining IP addresses, as well as querying the block status of specific IPs. Additionally, it allows for the retrieval of detailed alert information from NSM, enhancing threat intelligence and incident response workflows. This integration aims to streamline security operations by providing direct programmatic control over McAfee NSM functionalities.

Highlights

  • New Integration: Implemented a new integration for McAfee Network Security Manager (NSM).
  • Core Functionalities: Added core functionalities including IP blocking, unblocking, and quarantining.
  • Action Capabilities: Introduced actions to check IP block status and retrieve detailed alert information.
  • Project Setup: Established the necessary project structure and configuration files for the integration.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • content/response_integrations/google/mc_afee_nsm/.python-version
    • Added Python version specification (3.11).
  • content/response_integrations/google/mc_afee_nsm/init.py
    • Added package initialization file.
  • content/response_integrations/google/mc_afee_nsm/actions/BlockIP.py
    • Added Python script to block IP addresses.
  • content/response_integrations/google/mc_afee_nsm/actions/BlockIP.yaml
    • Added YAML definition for the Block IP action.
  • content/response_integrations/google/mc_afee_nsm/actions/GetAlertInfoData.py
    • Added Python script to retrieve alert information.
  • content/response_integrations/google/mc_afee_nsm/actions/GetAlertInfoData.yaml
    • Added YAML definition for the Get Alert Info Data action.
  • content/response_integrations/google/mc_afee_nsm/actions/IsIPBlocked.py
    • Added Python script to check if an IP is blocked.
  • content/response_integrations/google/mc_afee_nsm/actions/IsIPBlocked.yaml
    • Added YAML definition for the Is IP Blocked action.
  • content/response_integrations/google/mc_afee_nsm/actions/Ping.py
    • Added Python script to test connectivity.
  • content/response_integrations/google/mc_afee_nsm/actions/Ping.yaml
    • Added YAML definition for the Ping action.
  • content/response_integrations/google/mc_afee_nsm/actions/QuarantineIP.py
    • Added Python script to quarantine IP addresses.
  • content/response_integrations/google/mc_afee_nsm/actions/QuarantineIP.yaml
    • Added YAML definition for the Quarantine IP action.
  • content/response_integrations/google/mc_afee_nsm/actions/UnblockIP.py
    • Added Python script to unblock IP addresses.
  • content/response_integrations/google/mc_afee_nsm/actions/UnblockIP.yaml
    • Added YAML definition for the Unblock IP action.
  • content/response_integrations/google/mc_afee_nsm/actions/init.py
    • Added package initialization file for actions.
  • content/response_integrations/google/mc_afee_nsm/core/NSMManager.py
    • Added the core API manager class for McAfee NSM.
  • content/response_integrations/google/mc_afee_nsm/core/init.py
    • Added package initialization file for core module.
  • content/response_integrations/google/mc_afee_nsm/definition.yaml
    • Added the main integration definition.
  • content/response_integrations/google/mc_afee_nsm/pyproject.toml
    • Added Python project configuration and dependencies.
  • content/response_integrations/google/mc_afee_nsm/release_notes.yaml
    • Added release notes for the integration.
  • content/response_integrations/google/mc_afee_nsm/resources/get_alert_info_data_JsonResult_example.json
    • Added an example JSON result for alert information.
  • content/response_integrations/google/mc_afee_nsm/resources/logo.svg
    • Added the SVG logo for the integration.
  • content/response_integrations/google/mc_afee_nsm/tests/init.py
    • Added package initialization file for tests.
  • content/response_integrations/google/mc_afee_nsm/tests/common.py
    • Added common test utilities.
  • content/response_integrations/google/mc_afee_nsm/tests/config.json
    • Added test configuration file.
  • content/response_integrations/google/mc_afee_nsm/tests/conftest.py
    • Added pytest configuration file.
  • content/response_integrations/google/mc_afee_nsm/tests/test_defaults/init.py
    • Added package initialization file for default tests.
  • content/response_integrations/google/mc_afee_nsm/tests/test_defaults/test_imports.py
    • Added default import test script.
  • content/response_integrations/google/mc_afee_nsm/widgets/GetAlertInfoData.html
    • Added HTML widget for displaying alert info data.
  • content/response_integrations/google/mc_afee_nsm/widgets/GetAlertInfoData.yaml
    • Added YAML definition for the Get Alert Info Data widget.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the McAfee NSM integration, introducing new code. While this is a valuable update, a security audit revealed critical vulnerabilities including a Cross-Site Scripting (XSS) flaw in the widget's HTML construction, default disabling of SSL verification in the core manager class, and a lack of proper validation for API request URL parameters, which could lead to path traversal. Additionally, the code requires attention to align with repository standards, specifically regarding the use of modern Python features like type hints and Google-style docstrings, proper error handling in action scripts, and the complete absence of unit tests for new actions and the manager class, which are strictly required by the style guide.

Comment on lines +30 to +37
nsm_manager = NsmManager(
conf["API Root"],
conf["Username"],
conf["Password"],
conf["Domain ID"],
conf["Siemplify Policy Name"],
conf["Sensors Names List Comma Separated"],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The instantiation of NsmManager can fail if there are connectivity issues, as it attempts to get a token in its constructor. This will crash the action. Please wrap this block in a try...except to handle potential exceptions gracefully.

References
  1. Code must be resilient. Implement defensive programming, proactive error handling, and structured logging. (link)

} else if (/\.(png|jpg|jpeg|gif|bmp|webp)$/.test(lowerCaseValue)) {
const icon = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="1" y="1" width="14" height="14" fill="white" stroke="#35424F" stroke-width="2" stroke-linejoin="round"/><path d="M12.6284 11.4587L10.0829 5.94357C10.0201 5.80781 9.89075 5.71533 9.74227 5.69963C9.59209 5.68393 9.44827 5.74714 9.35833 5.86678L7.06745 8.92129L5.70989 7.90312C5.60892 7.82761 5.47995 7.80046 5.35777 7.8293C5.23517 7.85815 5.13208 7.94003 5.07565 8.05245L3.3787 11.4464C3.31295 11.5779 3.32016 11.734 3.39737 11.8591C3.47458 11.9843 3.61119 12.0607 3.7584 12.0607H12.2432C12.3878 12.0607 12.5227 11.9868 12.6004 11.8651C12.6784 11.7433 12.689 11.5902 12.6284 11.4587Z" fill="#35424F"/><path d="M6.30396 6.1216C7.00686 6.1216 7.57668 5.55179 7.57668 4.84889C7.57668 4.14599 7.00686 3.57617 6.30396 3.57617C5.60106 3.57617 5.03125 4.14599 5.03125 4.84889C5.03125 5.55179 5.60106 6.1216 6.30396 6.1216Z" fill="#35424F"/></svg>`;
spanValue.classList.add("list-item-specific-value");
spanValue.innerHTML = `<button class="list-item-screenshot tag tag-item" data-modal="${value}" data-modal-button="item" data-modal-img="true">${icon} <span class="list-item-screenshot-text text-ellipsis">Screenshot</span></button>`;
Copy link
Contributor

Choose a reason for hiding this comment

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

security-high high

The widget constructs HTML by embedding the value variable directly into a template string and setting it as innerHTML. Since value contains data retrieved from the McAfee NSM API, which is considered untrusted, an attacker could potentially inject malicious HTML or script tags that will be executed in the context of the user's browser. To remediate this, use textContent or innerText to set the text of elements, or properly escape the value before inserting it into the HTML string. For example, use setAttribute to set the data-modal attribute safely.

if block_status:
blocked_entities.append(entity)
result_value = True
except Exception as err:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Catching a generic Exception is too broad and can hide unexpected errors. It's better to catch more specific exceptions, such as NSMManagerException which is defined in the manager, or requests.HTTPError for network issues. This makes error handling more robust and predictable.

References
  1. Code must be resilient. Implement defensive programming, proactive error handling, and structured logging. (link)

alert_id = siemplify.parameters.get("Alert ID")
sensor_name = siemplify.parameters.get("Sensor Name")

alert_data = nsm_manager.get_alert_info_by_id(alert_id, sensor_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The call to nsm_manager.get_alert_info_by_id is not wrapped in a try...except block. If this API call fails, the action will crash. Please add error handling to gracefully manage potential exceptions, as per the style guide's emphasis on resilient code.

References
  1. Code must be resilient. Implement defensive programming, proactive error handling, and structured logging. (link)

# CONSTS #
# =====================================
RULE_NAME_TIME_FORMAT = "%Y-%m-%d %H_%M_%S.%f" # c#: "yyyy-MM-dd HH_mm_ss.ff"
RULE_OBJEST_NAME_PREFIX = "Siemplify_Block"
Copy link
Contributor

Choose a reason for hiding this comment

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

high

There is a typo in this constant name. OBJEST should be OBJECT. This typo is used in several places in the code (e.g., lines 244, 303, 330) and should be corrected throughout.

Suggested change
RULE_OBJEST_NAME_PREFIX = "Siemplify_Block"
RULE_OBJECT_NAME_PREFIX = "Siemplify_Block"

siemplify.LOGGER.info(
f"Error blocking ip {entity.identifier}, ERROR: {err}"
)
siemplify.LOGGER._log.exception(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using the private member _log is not best practice as it might change in future library versions. Please use the public API for logging exceptions, which is likely siemplify.LOGGER.exception(err).

Suggested change
siemplify.LOGGER._log.exception(err)
siemplify.LOGGER.exception(err)

@output_handler
def main():
# Define Variables.
blocked_entitites = []
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is a typo in the variable name blocked_entitites. It should be blocked_entities. This typo appears in multiple places in this file (lines 30, 55, 66).

Suggested change
blocked_entitites = []
blocked_entities = []

Comment on lines +66 to +67
f"Blocked Entities: {','.join(map(str, blocked_entitites))} \n Unblocked"
f" Entities: {','.join(map(str, unblocked_entities))}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The output message is constructed by calling str() on entity objects via map. It's more explicit and safer to use the entity's identifier. A list comprehension is also often more readable than map. Note that this suggestion assumes the blocked_entitites typo has been fixed to blocked_entities.

Suggested change
f"Blocked Entities: {','.join(map(str, blocked_entitites))} \n Unblocked"
f" Entities: {','.join(map(str, unblocked_entities))}"
f"Blocked Entities: {','.join([e.identifier for e in blocked_entities])} \n Unblocked"
f" Entities: {','.join([e.identifier for e in unblocked_entities])}"

siemplify_policy_name,
sensors_names_string_list,
siemplify_rules_description="",
ignore_ssl=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The NsmManager class defaults ignore_ssl to True, which disables SSL certificate verification for all API requests. This makes the integration vulnerable to Man-in-the-Middle (MitM) attacks, allowing an attacker to intercept or modify sensitive data transmitted between the integration and the McAfee NSM API. It is highly recommended to set ignore_ssl to False by default to ensure secure communication. Additionally, ensure type hints are consistently applied to parameters as required by the style guide.

Suggested change
ignore_ssl=True,
ignore_ssl: bool = False,

# description :This Module contain all NSM API functionality
# author :itaih@siemplify.co
# date :2-1-2018
# python_version :2.7
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This file header comment indicates Python 2.7, but the integration now targets Python 3.11. Please update this comment to reflect the correct Python version to avoid confusion for future maintainers.

Suggested change
# python_version :2.7
# python_version :3.11

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

2 similar comments
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@haggit-eliyahu haggit-eliyahu force-pushed the migrate-mc_afee_nsm-integration branch from fb819cd to 55622a5 Compare March 18, 2026 15:19
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

3 similar comments
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@haggit-eliyahu haggit-eliyahu force-pushed the migrate-mc_afee_nsm-integration branch from 7aa2459 to f25d1af Compare March 18, 2026 17:17
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

3 similar comments
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@haggit-eliyahu haggit-eliyahu force-pushed the migrate-mc_afee_nsm-integration branch from 717cd43 to 4d86b23 Compare March 22, 2026 14:58
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

1 similar comment
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

mc_afee_nsm

Validation Name Details
⚠️ Integration Version Bump New integration project.toml and release_note.yaml version must be initialize to 1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants