Skip to content

migrate juniper_vsrx#604

Open
haggit-eliyahu wants to merge 5 commits intomainfrom
migrate-juniper_vsrx-integration
Open

migrate juniper_vsrx#604
haggit-eliyahu wants to merge 5 commits intomainfrom
migrate-juniper_vsrx-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 12:30
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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 Juniper vSRX firewalls, enabling automated management of IP addresses within security policies. It provides essential actions for adding and removing IPs from address sets, alongside a connectivity check, significantly enhancing the ability to respond to security incidents and maintain network access controls. The integration is designed for Python 3.11 and includes all necessary configuration and testing infrastructure.

Highlights

  • New Integration: A new integration for Juniper vSRX has been added, providing capabilities to manage network security policies.
  • Key Actions: The integration includes actions to add and remove IP addresses from address sets, as well as a connectivity test (Ping).
  • Python 3.11 Support: The integration is configured to run with Python 3.11, aligning with modern Python environments.
  • Dependency Management: Project dependencies, including 'junos-eznc' and 'ncclient', are defined in pyproject.toml for consistent environment setup.

🧠 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/juniper_vsrx/.python-version
    • Added Python version specification for the integration.
  • content/response_integrations/google/juniper_vsrx/init.py
    • Added an empty initialization file for the package.
  • content/response_integrations/google/juniper_vsrx/actions/AddIPToAddressSet.py
    • Added the Python script for the 'Add IP To Address Set' action.
  • content/response_integrations/google/juniper_vsrx/actions/AddIPToAddressSet.yaml
    • Added the YAML definition for the 'Add IP To Address Set' action.
  • content/response_integrations/google/juniper_vsrx/actions/Ping.py
    • Added the Python script for the 'Ping' action.
  • content/response_integrations/google/juniper_vsrx/actions/Ping.yaml
    • Added the YAML definition for the 'Ping' action.
  • content/response_integrations/google/juniper_vsrx/actions/RemoveIPFromAddressSet.py
    • Added the Python script for the 'Remove IP From Address Set' action.
  • content/response_integrations/google/juniper_vsrx/actions/RemoveIPFromAddressSet.yaml
    • Added the YAML definition for the 'Remove IP From Address Set' action.
  • content/response_integrations/google/juniper_vsrx/actions/init.py
    • Added an empty initialization file for the actions package.
  • content/response_integrations/google/juniper_vsrx/core/JuniperVSRXManager.py
    • Added the core manager class for interacting with Juniper vSRX devices.
  • content/response_integrations/google/juniper_vsrx/core/init.py
    • Added an empty initialization file for the core package.
  • content/response_integrations/google/juniper_vsrx/definition.yaml
    • Added the main YAML definition for the JuniperVSRX integration.
  • content/response_integrations/google/juniper_vsrx/pyproject.toml
    • Added project configuration and dependencies for the integration.
  • content/response_integrations/google/juniper_vsrx/release_notes.yaml
    • Added release notes history for the JuniperVSRX integration.
  • content/response_integrations/google/juniper_vsrx/resources/logo.svg
    • Added the SVG logo for the integration.
  • content/response_integrations/google/juniper_vsrx/tests/init.py
    • Added an empty initialization file for the tests package.
  • content/response_integrations/google/juniper_vsrx/tests/common.py
    • Added common utilities for integration tests.
  • content/response_integrations/google/juniper_vsrx/tests/config.json
    • Added a configuration file for integration tests.
  • content/response_integrations/google/juniper_vsrx/tests/conftest.py
    • Added pytest configuration for integration tests.
  • content/response_integrations/google/juniper_vsrx/tests/test_defaults/init.py
    • Added an empty initialization file for default tests.
  • content/response_integrations/google/juniper_vsrx/tests/test_defaults/test_imports.py
    • Added a test to verify module imports within the integration.
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 introduces a new JuniperVSRX integration, including actions to add and remove IP addresses from address sets, and a ping action for connectivity testing. The core logic for interacting with Juniper VSRX devices is implemented in JuniperVSRXManager.py, which handles configuration, session management, and IP record operations. The review highlights a critical bug in JuniperVSRXManager.py where an incorrect slash is used in an f-string for IP mask formatting, leading to functional issues. Additionally, several medium-severity improvements are suggested across the codebase, including updating outdated header comments, ensuring robust configuration parameter access using config.get() to prevent KeyError, catching more specific exceptions instead of a generic Exception, and updating docstrings and type annotations to adhere to Google Style and Python type hinting standards for better readability and maintainability. A minor style issue regarding a missing newline at the end of tests/common.py is also noted.

Note: Security Review did not run due to the size of the PR.

)
if address_book:
addresses = address_book[0]
address_with_mask = f"{ip_address}'\'{DEFAULT_ADDRESS_MASK}"
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 f-string for address_with_mask uses a backslash \ instead of a forward slash / to separate the IP address and the mask. This will result in an incorrect IP prefix string, leading to functional issues.

            address_with_mask = f"{ip_address}/{DEFAULT_ADDRESS_MASK}"
References
  1. Verify code functionality and ensure alignment between function descriptions and implementations.

Comment on lines +15 to +20
# ==============================================================================
# title :JuniperVSRXManager.py
# description :Juniper VSRX integration logic.
# author :victor@siemplify.co
# date :28-10-18
# 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

The header comments contain outdated information such as python_version: 2.7 and specific author/date details. These should be removed to maintain accuracy and adhere to the principle of "Readability & Maintainability".

Suggested change
# ==============================================================================
# title :JuniperVSRXManager.py
# description :Juniper VSRX integration logic.
# author :victor@siemplify.co
# date :28-10-18
# python_version :2.7
# =====================================
# IMPORTS #
# =====================================
References
  1. Code is read more often than it is written. Use clear, descriptive naming and modular logic.

Comment on lines +103 to +109
def add_ip_to_address_set(self, ip_address, address_set_name, zone=None):
"""
Add an ip address to an address set
:param ip_address: {string} Target IP address.
:param address_set_name: {string} Target group name.
:param zone: {string} Target security zone.
:return: {Bool} True if succeed.
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 add_ip_to_address_set method's docstring uses the old :param and :return syntax and repeats type information. It is also missing type annotations for its parameters and return type. Please update the docstring to Google Style and add type hints.

    def add_ip_to_address_set(self, ip_address: str, address_set_name: str, zone: str | None = None) -> bool:
        """Adds an IP address to an address set.

        Args:
            ip_address: Target IP address.
            address_set_name: Target group name.
            zone: Target security zone.

        Returns:
            True if successful.
        """
References
  1. All function parameters and return types must be annotated. (link)
  2. All modules, classes, and functions must have triple double-quoted Google Style Docstrings. Do not repeat types in the Args or Returns sections. (link)



@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 a docstring and type annotations for its parameters and return type. Please add a Google Style Docstring and type hints as required by the style guide.

Suggested change
def main():
@output_handler
def main() -> None:
"""Main function for Ping action."""
References
  1. All function parameters and return types must be annotated. (link)
  2. All modules, classes, and functions must have triple double-quoted Google Style Docstrings. (link)

Comment on lines +29 to +32
address = config["Address"]
port = config["Port"]
username = config["Username"]
password = config["Password"]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Accessing configuration values directly using config["Key"] can lead to a KeyError if the key is not present, potentially causing a runtime crash. Consider using config.get("Key") with a default value or explicit error handling to make the code more robust and prevent unexpected failures.

Suggested change
address = config["Address"]
port = config["Port"]
username = config["Username"]
password = config["Password"]
address = config.get("Address")
port = config.get("Port")
username = config.get("Username")
password = config.get("Password")
if not all([address, port, username, password]):
raise ValueError("Missing one or more required configuration parameters: Address, Port, Username, Password.")
References
  1. Code must be resilient, implementing defensive programming and proactive error handling.

Comment on lines +30 to +33
address = config["Address"]
port = config["Port"]
username = config["Username"]
password = config["Password"]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Accessing configuration values directly using config["Key"] can lead to a KeyError if the key is not present, potentially causing a runtime crash. Consider using config.get("Key") with a default value or explicit error handling to make the code more robust and prevent unexpected failures.

Suggested change
address = config["Address"]
port = config["Port"]
username = config["Username"]
password = config["Password"]
address = config.get("Address")
port = config.get("Port")
username = config.get("Username")
password = config.get("Password")
if not all([address, port, username, password]):
raise ValueError("Missing one or more required configuration parameters: Address, Port, Username, Password.")
References
  1. Code must be resilient, implementing defensive programming and proactive error handling.

Comment on lines +202 to +205
def commit_config_changes(self):
"""
Commit all changes made at the config.
:return: {Bool} True if success.
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 commit_config_changes method's docstring uses the old :return syntax and is missing type annotations for its parameters and return type. Please update the docstring to Google Style and add type hints.

    def commit_config_changes(self) -> bool:
        """Commits all changes made to the configuration.

        Returns:
            True if successful.
        """
References
  1. All function parameters and return types must be annotated. (link)
  2. All modules, classes, and functions must have triple double-quoted Google Style Docstrings. Do not repeat types in the Args or Returns sections. (link)

Comment on lines +209 to +212

def close_session(self):
"""
Close connection session.
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 close_session method's docstring uses the old :return syntax and is missing type annotations for its parameters and return type. Please update the docstring to Google Style and add type hints.

    def close_session(self) -> bool:
        """Closes the connection session.

        Returns:
            True if successful.
        """
References
  1. All function parameters and return types must be annotated. (link)
  2. All modules, classes, and functions must have triple double-quoted Google Style Docstrings. Do not repeat types in the Args or Returns sections. (link)


from __future__ import annotations
import pathlib
INTEGRATION_PATH: pathlib.Path = pathlib.Path(__file__).parent.parent No newline at end of file
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 file is missing a newline at the end. It's good practice to ensure all Python files end with a newline character for better compatibility with various tools and version control systems.

Suggested change
INTEGRATION_PATH: pathlib.Path = pathlib.Path(__file__).parent.parent
INTEGRATION_PATH: pathlib.Path = pathlib.Path(__file__).parent.parent
References
  1. Code is read more often than it is written. Use clear, descriptive naming and modular logic.

from .. import common


def test_imports() -> None:
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 test_imports function is missing a docstring. Please add a Google Style Docstring as required by the style guide.

Suggested change
def test_imports() -> None:
def test_imports() -> None:
"""Tests that all integration modules can be imported successfully."""
References
  1. All modules, classes, and functions must have triple double-quoted Google Style Docstrings. (link)

@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

4 similar comments
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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-juniper_vsrx-integration branch from 9de8477 to ed5567e Compare March 18, 2026 14:43
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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-juniper_vsrx-integration branch from bd91295 to b1ff7bf Compare March 22, 2026 09:55
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

juniper_vsrx

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

juniper_vsrx

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-juniper_vsrx-integration branch from b1ff7bf to 164d132 Compare March 22, 2026 15:00
@github-actions
Copy link

Marketplace Validation Failed

Click to view the full report

Validation Report

🧩 Integrations
Pre-Build Stage

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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

juniper_vsrx

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