Skip to content

[Feat] Allow Firewall Port Ranges#1088

Open
RichardAnderson wants to merge 2 commits into
vitodeploy:4.xfrom
RichardAnderson:feat/firewall-port-range
Open

[Feat] Allow Firewall Port Ranges#1088
RichardAnderson wants to merge 2 commits into
vitodeploy:4.xfrom
RichardAnderson:feat/firewall-port-range

Conversation

@RichardAnderson
Copy link
Copy Markdown
Member

@RichardAnderson RichardAnderson commented May 15, 2026

This pull request introduces support for specifying firewall rule ports as either a single port or an inclusive port range (e.g., "3000:3010") throughout the application. It updates the backend, validation, database schema, API documentation, frontend, and tests to accommodate this new format, ensuring robust validation and clear user guidance.

Port Ranges in Table
CleanShot 2026-05-15 at 14 30 08
Port on Edit/Create
CleanShot 2026-05-15 at 14 32 10

Changes:

Database:

  • Changed the port field in the FirewallRule model and related logic from an integer to a string to allow port ranges.

Port field and validation:

  • Changed FirewallRule.port from integer to string and added the PortOrPortRangeRule validator to support single ports and port ranges, including all related model, logic, and factory updates.
  • Added a migration to alter the firewall_rules table, converting the port column to string and handling rollback for port ranges.

Business logic refactoring:

  • Refactored ManageRule to normalize port input, centralize attribute mapping, and standardize job dispatching, improving maintainability and consistency.

Frontend user experience:

  • Improved the firewall rule form to provide clear instructions and examples for entering ports or ranges, reducing user error.

Testing:

  • Added and expanded tests to verify correct handling of single ports, port ranges, and invalid inputs for both API and web interfaces.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds firewall port range support across the firewall rule stack, updating backend validation/storage, frontend guidance, API docs, and tests.

Changes:

  • Converts firewall rule ports from integer-style handling to string values that can hold single ports or start:end ranges.
  • Adds shared validation and normalization for port/range input.
  • Updates UI help text, OpenAPI docs, factories, defaults, and feature/API tests.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/Actions/FirewallRule/ManageRule.php Normalizes port input, applies new validation rule, and refactors rule attribute/job handling.
app/Models/FirewallRule.php Updates model typing/casts for string ports.
app/Services/Firewall/AbstractFirewall.php Stores default firewall ports as strings.
app/ValidationRules/PortOrPortRangeRule.php Adds validation for single ports and inclusive port ranges.
database/factories/FirewallRuleFactory.php Emits string ports from the factory.
database/migrations/2026_05_15_131942_change_firewall_rules_port_to_string.php Alters firewall_rules.port to string and defines rollback behavior.
public/api-docs/openapi/firewall-rules.yaml Documents port range input for firewall rule creation.
public/api-docs/openapi/schemas/FirewallRule.yaml Documents port range format on firewall rule responses.
resources/js/pages/firewall/components/form.tsx Adds placeholder/help text for port range entry.
resources/js/types/firewall.d.ts Changes frontend firewall rule port type to string.
tests/Feature/API/FirewallTest.php Updates API expectations and adds valid integer/range input coverage.
tests/Feature/FirewallTest.php Adds web feature coverage for ranges and invalid port inputs.

Comment thread app/Actions/FirewallRule/ManageRule.php Outdated
Comment thread public/api-docs/openapi/schemas/FirewallRule.yaml Outdated
Comment thread public/api-docs/openapi/firewall-rules.yaml Outdated
Comment thread tests/Feature/API/FirewallTest.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants