From 8f193320af284cdbdc12a046a2b224e1e307da82 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 09:37:32 +0000 Subject: [PATCH 1/2] Initial plan From fe9ef5816e09f3bb6c9e39348c5d09c206fe9cff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 09:41:17 +0000 Subject: [PATCH 2/2] Replace if literal truthiness checks with if literal is not None Co-authored-by: marksull <1705633+marksull@users.noreply.github.com> --- .../policy_services/accessrules.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fmcapi/api_objects/policy_services/accessrules.py b/fmcapi/api_objects/policy_services/accessrules.py index 488ef01..3d84645 100644 --- a/fmcapi/api_objects/policy_services/accessrules.py +++ b/fmcapi/api_objects/policy_services/accessrules.py @@ -582,7 +582,7 @@ def source_port(self, action, name="", literal=None, protocol="TCP"): :return: None """ logging.debug("In source_port() for AccessRules class.") - if literal and name != "": + if literal is not None and name != "": raise ValueError( "Only one of literal or name (object name) should be set while creating a source port" ) @@ -591,7 +591,7 @@ def source_port(self, action, name="", literal=None, protocol="TCP"): self.sourcePorts = {"objects": [], "literals": []} if action == "add": - if literal: + if literal is not None: port_literal = validate_port_literal(literal, protocol) if port_literal not in self.sourcePorts["literals"]: self.sourcePorts["literals"].append(port_literal) @@ -668,7 +668,7 @@ def source_port(self, action, name="", literal=None, protocol="TCP"): ) elif action == "remove": if "sourcePorts" in self.__dict__: - if literal: + if literal is not None: try: port_literal = validate_port_literal(literal, protocol) if port_literal in self.sourcePorts["literals"]: @@ -728,7 +728,7 @@ def destination_port(self, action, name="", literal=None, protocol="TCP"): :return: None """ logging.debug("In destination_port() for AccessRules class.") - if literal and name != "": + if literal is not None and name != "": raise ValueError( "Only one of literal or name (object name) should be set while creating a destination port" ) @@ -737,7 +737,7 @@ def destination_port(self, action, name="", literal=None, protocol="TCP"): self.destinationPorts = {"objects": [], "literals": []} if action == "add": - if literal: + if literal is not None: port_literal = validate_port_literal(literal, protocol) if port_literal not in self.destinationPorts["literals"]: self.destinationPorts["literals"].append(port_literal) @@ -814,7 +814,7 @@ def destination_port(self, action, name="", literal=None, protocol="TCP"): ) elif action == "remove": if "destinationPorts" in self.__dict__: - if literal: + if literal is not None: try: port_literal = validate_port_literal(literal, protocol) if port_literal in self.destinationPorts["literals"]: @@ -876,7 +876,7 @@ def source_network(self, action, name="", literal=None): """ # using dict() as default value is dangerous here, any thoughts/workarounds on this? logging.debug("In source_network() for AccessRules class.") - if literal and name != "": + if literal is not None and name != "": raise ValueError( "Only one of literals or name (object name) should be set while creating a source network" ) @@ -885,7 +885,7 @@ def source_network(self, action, name="", literal=None): self.sourceNetworks = {"objects": [], "literals": {}} if action == "add": - if literal: + if literal is not None: type_ = get_networkaddress_type(literal) self.sourceNetworks["literals"][literal] = type_ logging.info( @@ -1005,7 +1005,7 @@ def destination_network(self, action, name="", literal=None): # using dict() as default value is dangerous here, any thoughts/workarounds on this? logging.debug("In destination_network() for ACPRule class.") - if literal and name != "": + if literal is not None and name != "": raise ValueError( "Only one of literals or name (object name) should be set while creating a source network" ) @@ -1014,7 +1014,7 @@ def destination_network(self, action, name="", literal=None): self.destinationNetworks = {"objects": [], "literals": {}} if action == "add": - if literal: + if literal is not None: type_ = get_networkaddress_type(literal) self.destinationNetworks["literals"][literal] = type_ logging.info( @@ -1137,7 +1137,7 @@ def source_sgt(self, action, name="", literal=None): # using dict() as default value is dangerous here, any thoughts/workarounds on this? logging.debug("In source_sgt() for ACPRule class.") - if literal and name != "": + if literal is not None and name != "": raise ValueError( "Only one of literals or name (object name) should be set while creating a source sgt" ) @@ -1146,7 +1146,7 @@ def source_sgt(self, action, name="", literal=None): self.sourceSecurityGroupTags = {"objects": [], "literals": {}} if action == "add": - if literal: + if literal is not None: type_ = "ISESecurityGroupTag" self.sourceSecurityGroupTags["literals"][literal] = type_ logging.info(