Open
Conversation
- Add source_port() and destination_port() literal parameter support - Implement port literal validation with protocol mapping (TCP=6, UDP=17, etc.) - Support single ports (0-65535) and port ranges (e.g., 80-443) - Mirror existing network literals implementation for consistency - Include comprehensive IANA protocol support - Add parse_kwargs() handling for port literals in AccessRules - Update format_data() to serialize port literals to JSON - Maintain full backward compatibility with existing port object code - Add helper functions: get_protocol_number() and validate_port_literal() This resolves Issue #96 by allowing users to specify port numbers directly without creating port objects in FMC, reducing duplicate port objects. Example usage: rule.source_port(action='add', literal='80', protocol='TCP') rule.destination_port(action='add', literal='443', protocol='TCP') rule.destination_port(action='add', literal='1024-65535', protocol='TCP') Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add example usage of the new port literals feature to the existing ACPRule test file. Demonstrates: - Source port literal with TCP range (1024-65535) - Destination port literals for HTTP (80), HTTPS (443) - Destination port literal for DNS UDP (53) This shows how to use the new literal parameter with protocol specification as an alternative to creating port objects in FMC. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds support for specifying source/destination port literals (e.g., 80, 443, 1024-65535) in Access Policy access rules, including validation and an integration-style unit test that exercises the new capability.
Changes:
- Extend
AccessRules.source_port()/destination_port()to acceptliteral+protocoland serialize them into the API payload. - Add
validate_port_literal()andget_protocol_number()helper utilities. - Update ACP rule unit test to post an access rule containing literal source/destination ports.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
unit_tests/acprule.py |
Adds coverage to create an access rule using literal ports/protocols. |
fmcapi/api_objects/policy_services/accessrules.py |
Implements literal port support in access rule port setters + JSON formatting/parsing. |
fmcapi/api_objects/helper_functions.py |
Introduces protocol-number mapping and port-literal validation helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: marksull <1705633+marksull@users.noreply.github.com>
Fix falsy literal values being mishandled in AccessRules port/network/SGT methods
Co-authored-by: marksull <1705633+marksull@users.noreply.github.com>
Hoist protocol_map to module-level constant PROTOCOL_MAP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.