Skip to content

migrate stealthwatch_v610#609

Open
haggit-eliyahu wants to merge 4 commits intomainfrom
migrate-stealthwatch_v610-integration
Open

migrate stealthwatch_v610#609
haggit-eliyahu wants to merge 4 commits intomainfrom
migrate-stealthwatch_v610-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 16:22
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

stealthwatch_v610

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 delivers a new integration for Cisco Stealthwatch V6.10, designed to enhance security operations by providing automated access to network visibility and security analytics. It includes a robust manager for API interactions and specific actions to test connectivity, search for security events, and analyze network flows. The integration is developed with Python 3.11, ensuring compatibility with current standards, and its public release on GitHub fosters collaborative development.

Highlights

  • New Integration: Introduced a new integration for Cisco Stealthwatch V6.10, providing enhanced network security monitoring capabilities.
  • Core Functionality: Implemented key actions including Ping for connectivity testing, Search Events for security event retrieval, and Search Flows for network flow analysis.
  • Python 3.11 Support: The integration is built to run on Python 3.11, aligning with modern Python environments.
  • Open Source Availability: The source code for this integration is now publicly available on GitHub, promoting transparency and community contributions.

🧠 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/stealthwatch_v610/.python-version
    • Added Python version specification.
  • content/response_integrations/google/stealthwatch_v610/init.py
    • Added package initialization file.
  • content/response_integrations/google/stealthwatch_v610/actions/Ping.py
    • Added Python script for the Ping action.
  • content/response_integrations/google/stealthwatch_v610/actions/Ping.yaml
    • Added YAML definition for the Ping action.
  • content/response_integrations/google/stealthwatch_v610/actions/SearchEvents.py
    • Added Python script for the Search Events action.
  • content/response_integrations/google/stealthwatch_v610/actions/SearchEvents.yaml
    • Added YAML definition for the Search Events action.
  • content/response_integrations/google/stealthwatch_v610/actions/SearchFlows.py
    • Added Python script for the Search Flows action.
  • content/response_integrations/google/stealthwatch_v610/actions/SearchFlows.yaml
    • Added YAML definition for the Search Flows action.
  • content/response_integrations/google/stealthwatch_v610/actions/init.py
    • Added package initialization file for actions.
  • content/response_integrations/google/stealthwatch_v610/core/Stealthwatch610Manager.py
    • Added core manager class for Stealthwatch API interactions.
  • content/response_integrations/google/stealthwatch_v610/core/init.py
    • Added package initialization file for core.
  • content/response_integrations/google/stealthwatch_v610/definition.yaml
    • Added integration definition file.
  • content/response_integrations/google/stealthwatch_v610/pyproject.toml
    • Added project configuration for Python dependencies.
  • content/response_integrations/google/stealthwatch_v610/release_notes.yaml
    • Added release notes for the integration.
  • content/response_integrations/google/stealthwatch_v610/resources/logo.svg
    • Added SVG logo for the integration.
  • content/response_integrations/google/stealthwatch_v610/tests/init.py
    • Added package initialization file for tests.
  • content/response_integrations/google/stealthwatch_v610/tests/common.py
    • Added common utilities for tests.
  • content/response_integrations/google/stealthwatch_v610/tests/config.json
    • Added configuration file for tests.
  • content/response_integrations/google/stealthwatch_v610/tests/conftest.py
    • Added pytest configuration file.
  • content/response_integrations/google/stealthwatch_v610/tests/test_defaults/init.py
    • Added package initialization file for default tests.
  • content/response_integrations/google/stealthwatch_v610/tests/test_defaults/test_imports.py
    • Added import test for the integration.
Activity
  • No human activity has been recorded on 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 Stealthwatch v6.10 integration. During the security audit, a medium-severity vulnerability was identified: insecure SSL verification by default and a potential path traversal vulnerability in URL construction within the StealthwatchManager class. Please address these issues to ensure the security and integrity of the integration. Additionally, the pull request is missing comprehensive unit tests, has multiple violations of the repository style guide, is missing JSON example files, and has opportunities to improve code clarity and efficiency.

Comment on lines +22 to +23
def test_imports() -> None:
import_all_integration_modules(common.INTEGRATION_PATH)
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 repository style guide strictly requires that new integrations include comprehensive unit tests for all actions and manager logic. This test file only checks for module imports. Please add meaningful unit tests for the Ping, SearchEvents, and SearchFlows actions, as well as the Stealthwatch610Manager. The tests should mock network calls and validate the logic of each component.

References
  1. The style guide mandates that all new features, bug fixes, or integrations added to content/response_integrations/** must include corresponding unit tests to ensure production stability. If tests are missing or incomplete, they should be added. (link)

Comment on lines +36 to +39
end_time = utc_now().strftime("%Y-%m-%dT%H:%M:00z")
start_time = (utc_now() - datetime.timedelta(hours=time_delta)).strftime(
"%Y-%m-%dT%H:%M:00z"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

utc_now() is called twice to calculate end_time and start_time. This is slightly inefficient and can introduce a small time skew between the two timestamps. It's better to call it once and store the result in a variable.

Suggested change
end_time = utc_now().strftime("%Y-%m-%dT%H:%M:00z")
start_time = (utc_now() - datetime.timedelta(hours=time_delta)).strftime(
"%Y-%m-%dT%H:%M:00z"
)
now = utc_now()
end_time = now.strftime("%Y-%m-%dT%H:%M:00z")
start_time = (now - datetime.timedelta(hours=time_delta)).strftime(
"%Y-%m-%dT%H:%M:00z"
)



@output_handler
def main():
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 main function is missing type hints and a docstring. The repository style guide requires all functions to be fully annotated (line 80) and have a Google Style docstring (line 88).

Suggested change
def main():
def main() -> None:
"""
Action to test connectivity to the Stealthwatch API.
"""

Comment on lines +36 to +39
end_time = utc_now().strftime("%Y-%m-%dT%H:%M:00Z")
start_time = (utc_now() - datetime.timedelta(hours=time_delta)).strftime(
"%Y-%m-%dT%H:%M:00Z"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

utc_now() is called twice to calculate end_time and start_time. This is slightly inefficient and can introduce a small time skew between the two timestamps. It's better to call it once and store the result in a variable.

Suggested change
end_time = utc_now().strftime("%Y-%m-%dT%H:%M:00Z")
start_time = (utc_now() - datetime.timedelta(hours=time_delta)).strftime(
"%Y-%m-%dT%H:%M:00Z"
)
now = utc_now()
end_time = now.strftime("%Y-%m-%dT%H:%M:00Z")
start_time = (now - datetime.timedelta(hours=time_delta)).strftime(
"%Y-%m-%dT%H:%M:00Z"
)

Comment on lines +54 to +74
search_id = stealthwatch_manager.search_events(
domain_id, start_time, end_time, src_ip=entity.identifier
)
siemplify.LOGGER.info(f"Search id for source ip: {search_id}")

if search_id:
results = stealthwatch_manager.get_events_search_results(
domain_id, search_id
)
search_id = stealthwatch_manager.search_events(
domain_id, start_time, end_time, dst_ip=entity.identifier
)

siemplify.LOGGER.info(f"Search id for dest ip: {search_id}")

if search_id:
results.extend(
stealthwatch_manager.get_events_search_results(
domain_id, search_id
)
)
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 search_id variable is reused for two different searches (source IP and destination IP). This makes the code harder to read and debug. It's better to use distinct variable names for each search ID.

                src_search_id = stealthwatch_manager.search_events(
                    domain_id, start_time, end_time, src_ip=entity.identifier
                )
                siemplify.LOGGER.info(f"Search id for source ip: {src_search_id}")

                if src_search_id:
                    results.extend(
                        stealthwatch_manager.get_events_search_results(
                            domain_id, src_search_id
                        )
                    )

                dst_search_id = stealthwatch_manager.search_events(
                    domain_id, start_time, end_time, dst_ip=entity.identifier
                )

                siemplify.LOGGER.info(f"Search id for dest ip: {dst_search_id}")

                if dst_search_id:
                    results.extend(
                        stealthwatch_manager.get_events_search_results(
                            domain_id, dst_search_id
                        )
                    )

Comment on lines +15 to +24
# ============================================================================#
# title :StealthwatchManager.py
# description :This Module contain all Protectwise operations functionality
# author :avital@siemplify.co
# date :22-02-2018
# python_version :2.7
# libreries :
# requirments :
# product_version :1.0
# ============================================================================#
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 appears to be from an old Python 2.7 version of this file. Since this integration is now targeting Python 3.11, this header is outdated and should be removed to avoid confusion.

Comment on lines +84 to +86
self.session.headers["Cookie"] = (
f"stealthwatch.jwt={self.session.cookies.get_dict().get('stealthwatch.jwt')}"
)
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 Cookie header is being set manually from the session's cookie jar. The requests.Session object is designed to manage cookies automatically across requests. This manual step is unnecessary and can be brittle if the authentication process changes or sets other important cookies. You can rely on the session to handle this, as the authenticate method already populates self.session.cookies.

while not self.is_search_completed(url, search_id):
if self.is_search_error(url, search_id):
raise StealthwatchManagerError(f"Search {search_id} has failed.")
time.sleep(1)
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 while loop uses time.sleep(1) for polling, which is a blocking call. The repository style guide (lines 73-74) recommends using non-blocking patterns like asyncio.sleep() in asynchronous code. While this manager is not currently async, using blocking sleeps can still impact performance. Consider implementing a timeout and exponential backoff for polling to make it more robust.

- name: Api Root
default_value: https://x.x.x.x
type: ip_or_host
description: ''
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 descriptions for the integration parameters are empty. Providing clear descriptions helps users configure the integration correctly. Please add descriptive text for each parameter. For example, for Api Root: "The base URL of the Stealthwatch API (e.g., https://192.168.1.10)". This applies to Username and Password as well.

# If the domain ID was not found by the search above, try a direct
# search. Once a domain with the ip was found - return its ID
for domain in domains:
url = f"{self.server_address}/smc/rest/domains/{domain['id']}/hosts/{ip}"
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 get_domain_id_by_ip method constructs a URL by directly concatenating the ip parameter, which originates from untrusted entity identifiers. An attacker could provide a malicious identifier containing path traversal sequences (e.g., ../../) to cause the integration to make requests to unintended API endpoints on the Stealthwatch server. It is recommended to validate that the ip parameter is a valid IP address before using it in URL construction, or use proper URL encoding.

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

stealthwatch_v610

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

stealthwatch_v610

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

stealthwatch_v610

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-stealthwatch_v610-integration branch from c77a246 to 221a113 Compare March 22, 2026 09:49
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

stealthwatch_v610

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

stealthwatch_v610

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-stealthwatch_v610-integration branch from 221a113 to 6082083 Compare March 22, 2026 15:09
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

stealthwatch_v610

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

stealthwatch_v610

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

stealthwatch_v610

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

stealthwatch_v610

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

stealthwatch_v610

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