Skip to content

Fix falsy literal values being mishandled in AccessRules port/network/SGT methods#230

Merged
marksull merged 2 commits intofeature/literal-support-copilotfrom
copilot/sub-pr-229
Mar 7, 2026
Merged

Fix falsy literal values being mishandled in AccessRules port/network/SGT methods#230
marksull merged 2 commits intofeature/literal-support-copilotfrom
copilot/sub-pr-229

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 7, 2026

Truthiness checks on literal parameters caused valid falsy values (e.g., port 0 as int) to fall through to the object-name lookup path instead of being treated as literals.

Changes

  • All five literal-accepting methods (source_port, destination_port, source_network, destination_network, source_sgt): replaced if literal / if literal and name != "" with if literal is not None / if literal is not None and name != "" — 12 occurrences total.

Example

# Before: port 0 (falsy int) silently fell through to object-name lookup
rule.source_port("add", literal=0, protocol="TCP")  # BUG: treated as no literal

# After: correctly routes to literal handling path
rule.source_port("add", literal=0, protocol="TCP")  # OK

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: marksull <1705633+marksull@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on literal support feature Fix falsy literal values being mishandled in AccessRules port/network/SGT methods Mar 7, 2026
@marksull marksull marked this pull request as ready for review March 7, 2026 09:46
@marksull marksull merged commit 2e21235 into feature/literal-support-copilot Mar 7, 2026
@marksull marksull deleted the copilot/sub-pr-229 branch March 7, 2026 09:46
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