Use the windows_firewall_rule Chef InSpec audit resource to test if a firewall rule is correctly configured on a Windows system.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
A windows_firewall_rule resource block specifies which rule to validate:
describe windows_firewall_rule('name') do
it { should be_enabled }
end
where
('name') must specify the name of a firewall rule, which is not the firewall rule’s display namebe_enabled is a valid matcher for this resourceThe following example shows how to use this Chef InSpec audit resource.
describe windows_firewall_rule('HTTPS Out') do
it { should be_enabled }
it { should be_allowed }
it { should be_outbound }
it { should be_tcp }
its('remote_port') { should eq 443 }
end
The resource compiles the following list of firewall rule properties:
descriptiondisplaynamegrouplocal_addresslocal_portremote_addressremote_portdirectionprotocolicmp_typeactionprofileprogramserviceinterface_typeEach of these properties can be used in two distinct ways:
its('remote_address') { should cmp '192.0.2.42' }
or via matcher:
it { should have_remote_address '192.0.2.42' }
For a full list of available matchers, please visit our matchers page.
The be_enabled matcher tests if the rule does exist:
it { should exist }
The be_enabled matcher tests if the rule is enabled:
it { should be_enabled }
The be_allowed matcher tests if the rule is allowing traffic:
it { should be_allowed }
The be_inbound matcher tests if the rule is an inbound rule:
it { should be_inbound }
The be_outbound matcher tests if the rule is an outbound rule:
it { should be_outbound }
The be_tcp matcher tests if the rule is for the TCP protocol:
it { should be_tcp }
The be_ucp matcher tests if the rule is for the DCP protocol:
it { should be_dcp }
The be_icmp matcher tests if the rule is for any ICMP protocol:
it { should be_icmp }
The be_icmpv4 matcher tests if the rule is for the ICMPv4 protocol:
it { should be_icmpv4 }
The be_icmpv6 matcher tests if the rule is for any ICMPv6 protocol:
it { should be_icmpv6 }
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/windows_firewall_rule/