Skip to content

Feature/literal support copilot#229

Open
marksull wants to merge 10 commits intomasterfrom
feature/literal-support-copilot
Open

Feature/literal support copilot#229
marksull wants to merge 10 commits intomasterfrom
feature/literal-support-copilot

Conversation

@marksull
Copy link
Copy Markdown
Owner

@marksull marksull commented Mar 7, 2026

No description provided.

marksull and others added 3 commits March 7, 2026 18:40
- 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>
Copy link
Copy Markdown

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 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 accept literal + protocol and serialize them into the API payload.
  • Add validate_port_literal() and get_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.

marksull and others added 2 commits March 7, 2026 19:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented Mar 7, 2026

@marksull I've opened a new pull request, #230, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits March 7, 2026 09:41
Co-authored-by: marksull <1705633+marksull@users.noreply.github.com>
Fix falsy literal values being mishandled in AccessRules port/network/SGT methods
Copy link
Copy Markdown

Copilot AI commented Mar 7, 2026

@marksull I've opened a new pull request, #231, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 7, 2026 09:50
Co-authored-by: marksull <1705633+marksull@users.noreply.github.com>
Hoist protocol_map to module-level constant PROTOCOL_MAP
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.

3 participants