Class FirewallRule

java.lang.Object
software.amazon.awssdk.services.networkfirewall.model.FirewallRule
All Implemented Interfaces:
Serializable, SdkPojo, ToCopyableBuilder<FirewallRule.Builder,FirewallRule>

@Generated("software.amazon.awssdk:codegen") public final class FirewallRule extends Object implements SdkPojo, Serializable, ToCopyableBuilder<FirewallRule.Builder,FirewallRule>

A single structured firewall engine rule, for use in a firewall engine rule group or as an embedded rule in a Next Generation policy. A firewall rule accepts, drops, or rejects traffic at a connection-state hook. For more information about authoring firewall engine rules, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

See Also:
  • Method Details

    • action

      public final FirewallRuleAction action()

      The action that the firewall engine takes on traffic that matches the rule. The firewall engine supports the following actions:

      • ACCEPT - Allow the traffic.

      • DROP - Block the traffic and discontinue inspection.

      • REJECT - Block the traffic and send a TCP reset packet back to the client.

      • REJECT_DST - Block the traffic and send a TCP reset packet to the destination.

      • REJECT_BOTH - Block the traffic and send a TCP reset packet to both the client and the destination.

      You combine the action with an action scope, for example accept:flow. To send accepted traffic straight to its destination and skip the IPS engine, pair an accept action with the BypassIPSEnabled setting. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

      If the service returns an enum value that is not available in the current SDK version, action will return FirewallRuleAction.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from actionAsString().

      Returns:
      The action that the firewall engine takes on traffic that matches the rule. The firewall engine supports the following actions:

      • ACCEPT - Allow the traffic.

      • DROP - Block the traffic and discontinue inspection.

      • REJECT - Block the traffic and send a TCP reset packet back to the client.

      • REJECT_DST - Block the traffic and send a TCP reset packet to the destination.

      • REJECT_BOTH - Block the traffic and send a TCP reset packet to both the client and the destination.

      You combine the action with an action scope, for example accept:flow. To send accepted traffic straight to its destination and skip the IPS engine, pair an accept action with the BypassIPSEnabled setting. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

      See Also:
    • actionAsString

      public final String actionAsString()

      The action that the firewall engine takes on traffic that matches the rule. The firewall engine supports the following actions:

      • ACCEPT - Allow the traffic.

      • DROP - Block the traffic and discontinue inspection.

      • REJECT - Block the traffic and send a TCP reset packet back to the client.

      • REJECT_DST - Block the traffic and send a TCP reset packet to the destination.

      • REJECT_BOTH - Block the traffic and send a TCP reset packet to both the client and the destination.

      You combine the action with an action scope, for example accept:flow. To send accepted traffic straight to its destination and skip the IPS engine, pair an accept action with the BypassIPSEnabled setting. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

      If the service returns an enum value that is not available in the current SDK version, action will return FirewallRuleAction.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from actionAsString().

      Returns:
      The action that the firewall engine takes on traffic that matches the rule. The firewall engine supports the following actions:

      • ACCEPT - Allow the traffic.

      • DROP - Block the traffic and discontinue inspection.

      • REJECT - Block the traffic and send a TCP reset packet back to the client.

      • REJECT_DST - Block the traffic and send a TCP reset packet to the destination.

      • REJECT_BOTH - Block the traffic and send a TCP reset packet to both the client and the destination.

      You combine the action with an action scope, for example accept:flow. To send accepted traffic straight to its destination and skip the IPS engine, pair an accept action with the BypassIPSEnabled setting. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

      See Also:
    • actionScope

      public final ActionScope actionScope()

      The scope that controls how much of the matched traffic the action applies to. The valid scopes depend on the action: ACCEPT supports all four scopes, and DROP, REJECT, REJECT_DST, and REJECT_BOTH support only PACKET and FLOW.

      • PACKET - The current packet only.

      • HOOK - The current hook only. The firewall engine evaluates the connection again at the next hook.

      • TX - The current transaction. The firewall engine continues to evaluate later transactions on the connection.

      • FLOW - The entire connection. For an accept action, the connection skips the firewall engine's remaining hooks and advances to the IPS engine.

      In a Suricata-compatible rule string, you write the scope in lowercase, for example accept:flow.

      If the service returns an enum value that is not available in the current SDK version, actionScope will return ActionScope.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from actionScopeAsString().

      Returns:
      The scope that controls how much of the matched traffic the action applies to. The valid scopes depend on the action: ACCEPT supports all four scopes, and DROP, REJECT, REJECT_DST, and REJECT_BOTH support only PACKET and FLOW.

      • PACKET - The current packet only.

      • HOOK - The current hook only. The firewall engine evaluates the connection again at the next hook.

      • TX - The current transaction. The firewall engine continues to evaluate later transactions on the connection.

      • FLOW - The entire connection. For an accept action, the connection skips the firewall engine's remaining hooks and advances to the IPS engine.

      In a Suricata-compatible rule string, you write the scope in lowercase, for example accept:flow.

      See Also:
    • actionScopeAsString

      public final String actionScopeAsString()

      The scope that controls how much of the matched traffic the action applies to. The valid scopes depend on the action: ACCEPT supports all four scopes, and DROP, REJECT, REJECT_DST, and REJECT_BOTH support only PACKET and FLOW.

      • PACKET - The current packet only.

      • HOOK - The current hook only. The firewall engine evaluates the connection again at the next hook.

      • TX - The current transaction. The firewall engine continues to evaluate later transactions on the connection.

      • FLOW - The entire connection. For an accept action, the connection skips the firewall engine's remaining hooks and advances to the IPS engine.

      In a Suricata-compatible rule string, you write the scope in lowercase, for example accept:flow.

      If the service returns an enum value that is not available in the current SDK version, actionScope will return ActionScope.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from actionScopeAsString().

      Returns:
      The scope that controls how much of the matched traffic the action applies to. The valid scopes depend on the action: ACCEPT supports all four scopes, and DROP, REJECT, REJECT_DST, and REJECT_BOTH support only PACKET and FLOW.

      • PACKET - The current packet only.

      • HOOK - The current hook only. The firewall engine evaluates the connection again at the next hook.

      • TX - The current transaction. The firewall engine continues to evaluate later transactions on the connection.

      • FLOW - The entire connection. For an accept action, the connection skips the firewall engine's remaining hooks and advances to the IPS engine.

      In a Suricata-compatible rule string, you write the scope in lowercase, for example accept:flow.

      See Also:
    • hook

      public final HookKey hook()

      The connection-state hook at which the firewall engine evaluates the rule. The hook encodes both the protocol and the connection state, for example a TCP hook or a TLS client_hello hook. For the hooks that the firewall engine supports and how they map to the connection lifecycle, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide and the Suricata firewall mode documentation.

      If the service returns an enum value that is not available in the current SDK version, hook will return HookKey.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from hookAsString().

      Returns:
      The connection-state hook at which the firewall engine evaluates the rule. The hook encodes both the protocol and the connection state, for example a TCP hook or a TLS client_hello hook. For the hooks that the firewall engine supports and how they map to the connection lifecycle, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide and the Suricata firewall mode documentation.
      See Also:
    • hookAsString

      public final String hookAsString()

      The connection-state hook at which the firewall engine evaluates the rule. The hook encodes both the protocol and the connection state, for example a TCP hook or a TLS client_hello hook. For the hooks that the firewall engine supports and how they map to the connection lifecycle, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide and the Suricata firewall mode documentation.

      If the service returns an enum value that is not available in the current SDK version, hook will return HookKey.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from hookAsString().

      Returns:
      The connection-state hook at which the firewall engine evaluates the rule. The hook encodes both the protocol and the connection state, for example a TCP hook or a TLS client_hello hook. For the hooks that the firewall engine supports and how they map to the connection lifecycle, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide and the Suricata firewall mode documentation.
      See Also:
    • protocol

      public final FirewallRuleProtocol protocol()

      The protocol of the rule's hook. The protocol is derived from the hook and must match the hook's protocol prefix. Network Firewall rejects a rule whose protocol doesn't match its hook.

      If the service returns an enum value that is not available in the current SDK version, protocol will return FirewallRuleProtocol.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from protocolAsString().

      Returns:
      The protocol of the rule's hook. The protocol is derived from the hook and must match the hook's protocol prefix. Network Firewall rejects a rule whose protocol doesn't match its hook.
      See Also:
    • protocolAsString

      public final String protocolAsString()

      The protocol of the rule's hook. The protocol is derived from the hook and must match the hook's protocol prefix. Network Firewall rejects a rule whose protocol doesn't match its hook.

      If the service returns an enum value that is not available in the current SDK version, protocol will return FirewallRuleProtocol.UNKNOWN_TO_SDK_VERSION. The raw value returned by the service is available from protocolAsString().

      Returns:
      The protocol of the rule's hook. The protocol is derived from the hook and must match the hook's protocol prefix. Network Firewall rejects a rule whose protocol doesn't match its hook.
      See Also:
    • sourceIPs

      public final String sourceIPs()

      The source IP addresses and address ranges to inspect for, in CIDR notation. A firewall rule always compiles to a forward-direction rule, so you express inbound compared to outbound traffic through the source and destination addresses.

      Returns:
      The source IP addresses and address ranges to inspect for, in CIDR notation. A firewall rule always compiles to a forward-direction rule, so you express inbound compared to outbound traffic through the source and destination addresses.
    • destIPs

      public final String destIPs()

      The destination IP addresses and address ranges to inspect for, in CIDR notation. A firewall rule always compiles to a forward-direction rule, so you express inbound compared to outbound traffic through the source and destination addresses.

      Returns:
      The destination IP addresses and address ranges to inspect for, in CIDR notation. A firewall rule always compiles to a forward-direction rule, so you express inbound compared to outbound traffic through the source and destination addresses.
    • sourcePorts

      public final String sourcePorts()

      The source ports to inspect for.

      Returns:
      The source ports to inspect for.
    • destPorts

      public final String destPorts()

      The destination ports to inspect for.

      Returns:
      The destination ports to inspect for.
    • hasRuleOptions

      public final boolean hasRuleOptions()
      For responses, this returns true if the service returned a value for the RuleOptions property. This DOES NOT check that the value is non-empty (for which, you should check the isEmpty() method on the property). This is useful because the SDK will never return a null collection or map, but you may need to differentiate between the service returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true if a value for the property was specified in the request builder, and false if a value was not specified.
    • ruleOptions

      public final List<RuleOption> ruleOptions()

      Additional options for the rule. These are the Suricata RuleOptions settings, such as the signature ID (sid) and match keywords.

      Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.

      This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the hasRuleOptions() method.

      Returns:
      Additional options for the rule. These are the Suricata RuleOptions settings, such as the signature ID (sid) and match keywords.
    • acceptPriorHooks

      public final Boolean acceptPriorHooks()

      Whether Network Firewall automatically accepts the earlier application-layer hooks that a connection must pass to reach this rule's hook. Because the firewall engine is drop by default, accepting prior hooks lets you author a single rule for the hook you care about, instead of also authoring a rule for each earlier hook. This setting accepts the earlier application-layer hooks only; it doesn't accept the TCP layer. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

      Returns:
      Whether Network Firewall automatically accepts the earlier application-layer hooks that a connection must pass to reach this rule's hook. Because the firewall engine is drop by default, accepting prior hooks lets you author a single rule for the hook you care about, instead of also authoring a rule for each earlier hook. This setting accepts the earlier application-layer hooks only; it doesn't accept the TCP layer. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.
    • alertEnabled

      public final Boolean alertEnabled()

      Specifies whether the rule also generates an alert log for the traffic that it matches. Turning on alerting adds a secondary alert action to the rule, so that Network Firewall logs the match in addition to taking the rule's primary action.

      Returns:
      Specifies whether the rule also generates an alert log for the traffic that it matches. Turning on alerting adds a secondary alert action to the rule, so that Network Firewall logs the match in addition to taking the rule's primary action.
    • bypassIPSEnabled

      public final Boolean bypassIPSEnabled()

      Specifies whether an accepted connection bypasses the IPS engine. By default, traffic that the firewall engine accepts advances to the IPS engine for threat inspection. When you turn on this setting for an accept rule, the accepted traffic goes straight to its destination without IPS inspection. You can set the bypass only on accept rules, and it uses the same scope as the rule's accept action; only the flow and packet scopes support a bypass. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.

      Returns:
      Specifies whether an accepted connection bypasses the IPS engine. By default, traffic that the firewall engine accepts advances to the IPS engine for threat inspection. When you turn on this setting for an accept rule, the accepted traffic goes straight to its destination without IPS inspection. You can set the bypass only on accept rules, and it uses the same scope as the rule's accept action; only the flow and packet scopes support a bypass. For more information, see Rule groups for a firewall using a Next Generation policy in the Network Firewall Developer Guide.
    • ruleMetadata

      public final RuleMetadata ruleMetadata()

      Optional metadata for the rule: whether the rule is enabled and a description. Metadata doesn't change how the rule matches or acts on traffic.

      Returns:
      Optional metadata for the rule: whether the rule is enabled and a description. Metadata doesn't change how the rule matches or acts on traffic.
    • toBuilder

      public FirewallRule.Builder toBuilder()
      Description copied from interface: ToCopyableBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToCopyableBuilder<FirewallRule.Builder,FirewallRule>
      Returns:
      a builder for type T
    • builder

      public static FirewallRule.Builder builder()
    • serializableBuilderClass

      public static Class<? extends FirewallRule.Builder> serializableBuilderClass()
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equalsBySdkFields

      public final boolean equalsBySdkFields(Object obj)
      Description copied from interface: SdkPojo
      Indicates whether some other object is "equal to" this one by SDK fields. An SDK field is a modeled, non-inherited field in an SdkPojo class, and is generated based on a service model.

      If an SdkPojo class does not have any inherited fields, equalsBySdkFields and equals are essentially the same.

      Specified by:
      equalsBySdkFields in interface SdkPojo
      Parameters:
      obj - the object to be compared with
      Returns:
      true if the other object equals to this object by sdk fields, false otherwise.
    • toString

      public final String toString()
      Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be redacted from this string using a placeholder value.
      Overrides:
      toString in class Object
    • getValueForField

      public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz)
    • sdkFields

      public final List<SdkField<?>> sdkFields()
      Specified by:
      sdkFields in interface SdkPojo
      Returns:
      List of SdkField in this POJO. May be empty list but should never be null.
    • sdkFieldNameToField

      public final Map<String,SdkField<?>> sdkFieldNameToField()
      Specified by:
      sdkFieldNameToField in interface SdkPojo
      Returns:
      The mapping between the field name and its corresponding field.